Skip to content

Commit c2b164c

Browse files
committed
fix: maxrecursive call issue
1 parent e07f423 commit c2b164c

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Suraj Air",
66
"license": "BSD-3-Clause",
77
"homepage": "https://chaibuilder.com",
8-
"version": "1.2.60",
8+
"version": "1.2.61",
99
"type": "module",
1010
"repository": {
1111
"type": "git",

src/core/components/RootLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const RootLayout: ComponentType = () => {
4141
if (!isDevelopment()) e.preventDefault();
4242
};
4343

44-
useKeyEventWatcher(document);
44+
useKeyEventWatcher();
4545
useExpandTree();
4646
useAutoSave();
4747

src/core/components/canvas/KeyboarHandler.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ import { useFrame } from "../../frame";
44
export const KeyboardHandler = () => {
55
const { document: iframeDoc } = useFrame();
66
useKeyEventWatcher(iframeDoc);
7-
87
return null;
98
};

src/core/hooks/useKeyEventWatcher.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ import { useRemoveBlocks } from "./useRemoveBlocks";
44
import { useDuplicateBlocks } from "./useDuplicateBlocks";
55
import { useUndoManager } from "../history/useUndoManager.ts";
66

7-
export const useKeyEventWatcher = (doc: Document) => {
7+
export const useKeyEventWatcher = (doc?: Document) => {
88
const [ids, setIds] = useSelectedBlockIds();
99
const removeBlocks = useRemoveBlocks();
1010
const duplicateBlocks = useDuplicateBlocks();
1111
const { undo, redo } = useUndoManager();
1212

13-
useHotkeys("esc", () => setIds([]), { document: doc }, [setIds]);
14-
useHotkeys("ctrl+d,command+d", () => duplicateBlocks(ids), { document: doc, preventDefault: true }, [
13+
const options = doc ? { document: doc } : {};
14+
useHotkeys("esc", () => setIds([]), options, [setIds]);
15+
useHotkeys("ctrl+d,command+d", () => duplicateBlocks(ids), { ...options, preventDefault: true }, [
1516
ids,
1617
duplicateBlocks,
1718
]);
18-
useHotkeys("ctrl+z,command+z", () => undo(), { document: doc }, [undo]);
19-
useHotkeys("ctrl+y,command+y", () => redo(), { document: doc }, [redo]);
20-
19+
useHotkeys("ctrl+z,command+z", () => undo(), options, [undo]);
20+
useHotkeys("ctrl+y,command+y", () => redo(), options, [redo]);
2121
useHotkeys(
2222
"del, backspace",
2323
(event: any) => {
2424
event.preventDefault();
2525
removeBlocks(ids);
2626
},
27-
{ document: doc },
27+
options,
2828
[ids, removeBlocks],
2929
);
3030
};

0 commit comments

Comments
 (0)