fix(ui): fix dependency tracking for copy/paste hotkeys

This commit is contained in:
psychedelicious 2024-05-16 21:23:18 +10:00
parent dbfaa07e03
commit c359ab6d9b

View File

@ -193,36 +193,32 @@ export const Flow = memo(() => {
const { copySelection, pasteSelection } = useCopyPaste(); const { copySelection, pasteSelection } = useCopyPaste();
useHotkeys(['Ctrl+c', 'Meta+c'], (e) => { const onCopyHotkey = useCallback(
(e: KeyboardEvent) => {
e.preventDefault(); e.preventDefault();
copySelection(); copySelection();
}); },
[copySelection]
);
useHotkeys(['Ctrl+c', 'Meta+c'], onCopyHotkey);
useHotkeys(['Ctrl+a', 'Meta+a'], (e) => { const onSelectAllHotkey = useCallback(
(e: KeyboardEvent) => {
e.preventDefault(); e.preventDefault();
dispatch(selectedAll()); dispatch(selectedAll());
});
useHotkeys(['Ctrl+v', 'Meta+v'], (e) => {
e.preventDefault();
pasteSelection();
});
useHotkeys(
['meta+z', 'ctrl+z'],
() => {
dispatch(undo());
}, },
[dispatch] [dispatch]
); );
useHotkeys(['Ctrl+a', 'Meta+a'], onSelectAllHotkey);
useHotkeys( const onPasteHotkey = useCallback(
['meta+shift+z', 'ctrl+shift+z'], (e: KeyboardEvent) => {
() => { e.preventDefault();
dispatch(redo()); pasteSelection();
}, },
[dispatch] [pasteSelection]
); );
useHotkeys(['Ctrl+v', 'Meta+v'], onPasteHotkey);
const onUndoHotkey = useCallback(() => { const onUndoHotkey = useCallback(() => {
if (mayUndo) { if (mayUndo) {