feat(history): add undo redo stack

This commit is contained in:
syntaxbullet
2026-07-03 17:30:31 +02:00
parent fedeaffa57
commit 0ffbc4f68b
12 changed files with 139 additions and 7 deletions

12
input/history.ts Normal file
View File

@@ -0,0 +1,12 @@
import { commandIds } from "@commands/ids";
import type { Dispatch } from "@commands/dispatcher";
import type { KeybindEvent } from "./keyboard";
export function handleHistoryKey(options: { event: KeybindEvent; dispatch: Dispatch }): boolean {
if (options.event.altKey) return false;
const modifier = options.event.metaKey || options.event.ctrlKey;
if (!modifier || options.event.key.toLowerCase() !== "z") return false;
options.dispatch(options.event.shiftKey ? commandIds.historyRedo : commandIds.historyUndo, undefined);
return true;
}