control z
This commit is contained in:
@@ -18,10 +18,6 @@ export const useKeyboardMovement = () => {
|
|||||||
} = useEditorStore();
|
} = useEditorStore();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (tool !== "select") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleKeyDown = (e: KeyboardEvent) => {
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
const target = e.target as HTMLElement;
|
const target = e.target as HTMLElement;
|
||||||
if (
|
if (
|
||||||
@@ -32,6 +28,26 @@ export const useKeyboardMovement = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((e.metaKey || e.ctrlKey) && (e.key === "z" || e.key === "Z")) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (e.shiftKey) {
|
||||||
|
redoObjects();
|
||||||
|
} else {
|
||||||
|
undoObjects();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((e.metaKey || e.ctrlKey) && (e.key === "y" || e.key === "Y")) {
|
||||||
|
e.preventDefault();
|
||||||
|
redoObjects();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tool !== "select") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle Delete and Backspace keys
|
// Handle Delete and Backspace keys
|
||||||
if (e.key === "Delete" || e.key === "Backspace") {
|
if (e.key === "Delete" || e.key === "Backspace") {
|
||||||
if (selectedObjectIds.length > 0) {
|
if (selectedObjectIds.length > 0) {
|
||||||
@@ -78,22 +94,6 @@ export const useKeyboardMovement = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((e.metaKey || e.ctrlKey) && (e.key === "z" || e.key === "Z")) {
|
|
||||||
e.preventDefault();
|
|
||||||
if (e.shiftKey) {
|
|
||||||
redoObjects();
|
|
||||||
} else {
|
|
||||||
undoObjects();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((e.metaKey || e.ctrlKey) && (e.key === "y" || e.key === "Y")) {
|
|
||||||
e.preventDefault();
|
|
||||||
redoObjects();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedObjectIds.length === 0) {
|
if (selectedObjectIds.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user