Add selection copy paste shortcuts

This commit is contained in:
Mitchell McCaffrey
2021-07-23 15:53:13 +10:00
parent b3fc7f9e1d
commit 23dd67c1a9
2 changed files with 27 additions and 0 deletions
@@ -32,6 +32,8 @@ import { MapState } from "../../types/MapState";
import { isMapState } from "../../validators/MapState";
import { isSelection } from "../../validators/Selection";
import { getRelativePointerPosition } from "../../helpers/konva";
import { useKeyboard } from "../../contexts/KeyboardContext";
import shortcuts from "../../shortcuts";
type SelectionMenuProps = {
isOpen: boolean;
@@ -346,6 +348,19 @@ function SelectionMenu({
}
}
function handleKeyDown(event: KeyboardEvent) {
if (active) {
if (selection && shortcuts.copy(event)) {
handleCopy();
}
if (shortcuts.paste(event)) {
handlePaste();
}
}
}
useKeyboard(handleKeyDown);
return (
<MapMenu
isOpen={isOpen}