diff --git a/examples/landing/components/editor/Viewport/Header.tsx b/examples/landing/components/editor/Viewport/Header.tsx index 640e6b5ea..f47b9da63 100644 --- a/examples/landing/components/editor/Viewport/Header.tsx +++ b/examples/landing/components/editor/Viewport/Header.tsx @@ -8,6 +8,7 @@ import Checkmark from '../../../public/icons/check.svg'; import Customize from '../../../public/icons/customize.svg'; import RedoSvg from '../../../public/icons/toolbox/redo.svg'; import UndoSvg from '../../../public/icons/toolbox/undo.svg'; +import { useEffect } from 'react'; const HeaderDiv = styled.div` width: 100%; @@ -57,6 +58,29 @@ export const Header = () => { canUndo: query.history.canUndo(), canRedo: query.history.canRedo(), })); + // ketstroke undo redo + useEffect(() => { + const handleKeyDown = (event: any) => { + if (event.ctrlKey || event.metaKey) { + if (event.key.toLowerCase() === 'z') { + event.preventDefault(); + if (event.shiftKey) { + if (canRedo) { + actions.history.redo(); + } + } else if (canUndo) { + actions.history.undo(); + } + } + } + }; + + window.addEventListener('keydown', handleKeyDown); + + return () => { + window.removeEventListener('keydown', handleKeyDown); + }; + }, [canUndo, canRedo, actions]); return ( diff --git a/packages/core/README.md b/packages/core/README.md index f0aa2b8ab..30576629a 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -248,3 +248,7 @@ Craft.js is released under the [MIT license](https://github.com/prevwong/craft.j + + +# To start the project in local machine +cmd -> yarn run-p dev dev:site \ No newline at end of file