excalidraw/src/actions/actionSelectAll.ts
2020-04-04 12:27:34 +02:00

23 lines
579 B
TypeScript

import { KEYS } from "../keys";
import { register } from "./register";
export const actionSelectAll = register({
name: "selectAll",
perform: (elements, appState) => {
return {
appState: {
...appState,
selectedElementIds: elements.reduce((map, element) => {
if (!element.isDeleted) {
map[element.id] = true;
}
return map;
}, {} as any),
},
commitToHistory: true,
};
},
contextItemLabel: "labels.selectAll",
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === "a",
});