Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions examples/landing/components/editor/Viewport/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
Expand Down Expand Up @@ -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 (
<HeaderDiv className="header text-white transition w-full">
Expand Down
4 changes: 4 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,7 @@ Craft.js is released under the [MIT license](https://github.com/prevwong/craft.j
<a href="https://opencollective.com/craftjs/contribute" target="_blank">
<img src="https://opencollective.com/craftjs/donate/[email protected]?color=blue" width="260" />
</a>


# To start the project in local machine
cmd -> yarn run-p dev dev:site