adds undo, redo shortcuts

This commit is contained in:
bhushan6
2023-08-15 04:24:09 +05:30
parent fd7470ff66
commit 0ad3cbeb0f
2 changed files with 19 additions and 0 deletions
+3
View File
@@ -4,6 +4,7 @@ import { TrashIcon, ResetIcon } from "@radix-ui/react-icons";
import "./styles.css"; import "./styles.css";
import { useStore } from "../../../store"; import { useStore } from "../../../store";
import { PopoverPeopleList } from "../PeopleList"; import { PopoverPeopleList } from "../PeopleList";
import { useUndoRedoShortcut } from "../../../utils";
// import { EDIT_MODE } from "../../../utils"; // import { EDIT_MODE } from "../../../utils";
export const BottomBar = () => { export const BottomBar = () => {
@@ -51,6 +52,8 @@ export const BottomBar = () => {
setSelection({}); setSelection({});
}; };
useUndoRedoShortcut(undo, redo);
return ( return (
<div className="BottomBar"> <div className="BottomBar">
<button className="Button violet" onClick={undo}> <button className="Button violet" onClick={undo}>
+16
View File
@@ -78,3 +78,19 @@ export const useDeleteShortcut = (selected, setBricks, onDelete) => {
return null; return null;
}; };
export const useUndoRedoShortcut = (undo, redo) => {
useKeyboardShortcut(["Control", "Z"], undo, {
overrideSystem: true,
ignoreInputFields: false,
repeatOnHold: false,
});
useKeyboardShortcut(["Control", "R"], redo, {
overrideSystem: true,
ignoreInputFields: false,
repeatOnHold: false,
});
return null;
};