// Dock-Panel „Verlauf" ([84]): die Undo-Schritte als Liste, jüngster oben, der aktuelle Stand // markiert, Wiederholen-Schritte (noch nicht gültig) gedimmt darüber. Klick auf einen Eintrag springt // dorthin (`jumpHistory`: ein Kern-Aufruf über mehrere Schritte). Die Beschriftungen liefert der Kern // (`historyEntries`), Anzeigetext über `historyLabelText`. // // Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md). import { useMemo } from "react"; import { t } from "../i18n"; import { useStore } from "../state/appStore"; import { historyLabelText } from "../state/historyLabels"; interface Entry { /** Undo-Tiefe, auf die ein Klick springt (0 = Ausgangsstand). */ depth: number; text: string; future: boolean; } export function HistoryPanel() { const undoDepth = useStore((s) => s.undoDepth); const redoDepth = useStore((s) => s.redoDepth); const project = useStore((s) => s.project); const historyEntries = useStore((s) => s.historyEntries); const jumpHistory = useStore((s) => s.jumpHistory); const entries = useMemo(() => { const { undo, redo } = historyEntries(); const list: Entry[] = [{ depth: 0, text: t("history.start"), future: false }]; undo.forEach((l, i) => list.push({ depth: i + 1, text: historyLabelText(l), future: false })); redo.forEach((l, i) => list.push({ depth: undo.length + i + 1, text: historyLabelText(l), future: true })); return list.reverse(); // `project` ändert sich mit jedem Schritt; die Tiefen fangen Sprünge ab. // eslint-disable-next-line react-hooks/exhaustive-deps }, [historyEntries, undoDepth, redoDepth, project]); if (undoDepth + redoDepth === 0) { return (
{t("history.empty")}
); } return (
); }