Skip to content

Commit

Permalink
feat: add history forward & back shortcut key (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo authored May 20, 2024
1 parent 8bf53a7 commit df3021f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/designer/src/dnd/use-dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export function useDnd({
'command+v,ctrl+v': () => {
workspace.pasteSelectedNode();
},
'command+z,ctrl+z': () => {
workspace.history.back();
},
'command+shift+z,ctrl+shift+z': () => {
workspace.history.forward();
},
});
}, [workspace]);

Expand All @@ -84,10 +90,10 @@ export function useDnd({
const onMouseMove = (e: React.MouseEvent) => {
const point = sandboxQuery.getRelativePoint({ x: e.clientX, y: e.clientY });
setElementStyle('.SelectionMask', {
width: Math.abs(selectSource.start?.point.x - point.x) + 'px',
height: Math.abs(selectSource.start?.point.y - point.y) + 'px',
left: Math.min(selectSource.start?.point.x, point.x) + 'px',
top: Math.min(selectSource.start?.point.y, point.y) + 'px',
width: `${Math.abs(selectSource.start?.point.x - point.x)}px`,
height: `${Math.abs(selectSource.start?.point.y - point.y)}px`,
left: `${Math.min(selectSource.start?.point.x, point.x)}px`,
top: `${Math.min(selectSource.start?.point.y, point.y)}px`,
});
};

Expand Down

0 comments on commit df3021f

Please sign in to comment.