fix: wire export shortcut, text tool canvas integration, and undo rendering

1. Export dialog (Ctrl+Shift+S): replaced react-hotkeys-hook handler with
   a capture-phase keydown listener on window so the browser's native
   "Save Page As" dialog is intercepted before it can fire.

2. Text tool: created useTextTool hook that spawns an inline textarea
   overlay on canvas click, commits the text as a Konva Text object on
   blur/Enter, and wired it into the useActiveToolHandlers dispatcher.

3. Undo (Ctrl+Z): removed the 500ms debounce from zundo's handleSet.
   The debounce caused a race where calling undo before the timer fired
   would discard the future-states stack, making undo appear to do
   nothing.  The equality function (keyed on _historyVersion) already
   prevents intermediate states from being recorded, so the debounce
   was redundant.
This commit is contained in:
SnapOtter
2026-05-07 20:21:46 +08:00
parent 79897fcdb0
commit a633eff788
4 changed files with 209 additions and 17 deletions
+5 -8
View File
@@ -732,14 +732,11 @@ export const useEditorStore = create<EditorState>()(
equality: (a, b) =>
(a as { _historyVersion: number })._historyVersion ===
(b as { _historyVersion: number })._historyVersion,
// Issue #1: Forward all arguments from zundo's internal _handleSet
handleSet: (handleSet) => {
let timeout: ReturnType<typeof setTimeout>;
return (...args: Parameters<typeof handleSet>) => {
clearTimeout(timeout);
timeout = setTimeout(() => handleSet(...args), 500);
};
},
// Issue #1: Forward all arguments from zundo's internal _handleSet.
// No debounce -- the equality function (based on _historyVersion) already
// prevents intermediate states from being recorded. Debouncing caused
// undo/redo to race with the delayed recording and silently discard the
// future-states stack.
},
),
);