feat(history): add undo redo stack
This commit is contained in:
12
input/history.ts
Normal file
12
input/history.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user