handle select all shortcut in whiteboard

This commit is contained in:
Ramón Souza 2023-03-15 11:39:33 -03:00
parent 3e3d18f73b
commit 5d0b1c842f
2 changed files with 12 additions and 3 deletions

View File

@ -550,8 +550,8 @@ export default function Whiteboard(props) {
previousSlide(+curPageId, podId);
};
const switchSlide = (event) => {
const { which } = event;
const handleOnKeyDown = (event) => {
const { which, ctrlKey } = event;
switch (which) {
case KEY_CODES.ARROW_LEFT:
@ -565,6 +565,13 @@ export default function Whiteboard(props) {
case KEY_CODES.ENTER:
fullscreenToggleHandler();
break;
case KEY_CODES.A:
if (ctrlKey) {
event.preventDefault();
event.stopPropagation();
tldrawAPI?.selectAll();
}
break;
default:
}
};
@ -886,7 +893,7 @@ export default function Whiteboard(props) {
if (currentTool && !isPanning) tldrawAPI?.selectTool(currentTool);
const editableWB = (
<Styled.EditableWBWrapper onKeyDown={switchSlide}>
<Styled.EditableWBWrapper onKeyDown={handleOnKeyDown}>
<Tldraw
key={`wb-${isRTL}-${dockPos}`}
document={doc}

View File

@ -8,6 +8,7 @@ export const ARROW_RIGHT = 39;
export const ARROW_LEFT = 37;
export const PAGE_UP = 33;
export const PAGE_DOWN = 34;
export const A = 65;
export default {
SPACE,
@ -20,4 +21,5 @@ export default {
ARROW_LEFT,
PAGE_UP,
PAGE_DOWN,
A,
};