feat: implement document actions for managing artboards, zoom, and history; update UI components to utilize new actions
This commit is contained in:
@@ -2,11 +2,20 @@ 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 {
|
||||
export type HistoryActions = { undo(): void; redo(): void };
|
||||
|
||||
export function handleHistoryKey(options: { event: KeybindEvent; dispatch?: Dispatch; actions?: HistoryActions }): 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);
|
||||
if (options.actions) {
|
||||
if (options.event.shiftKey) options.actions.redo();
|
||||
else options.actions.undo();
|
||||
} else if (options.dispatch) {
|
||||
options.dispatch(options.event.shiftKey ? commandIds.historyRedo : commandIds.historyUndo, undefined);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user