2020-01-19 13:21:33 -08:00
|
|
|
import { KEYS } from "../keys";
|
2020-03-07 10:20:38 -05:00
|
|
|
import { register } from "./register";
|
2020-05-26 13:07:46 -07:00
|
|
|
import { selectGroupsForSelectedElements } from "../groups";
|
|
|
|
import { getNonDeletedElements } from "../element";
|
2020-01-12 02:22:03 +04:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionSelectAll = register({
|
2020-01-12 02:22:03 +04:00
|
|
|
name: "selectAll",
|
2020-03-08 10:20:55 -07:00
|
|
|
perform: (elements, appState) => {
|
2020-07-08 17:29:47 +09:00
|
|
|
if (appState.editingLinearElement) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-01-12 02:22:03 +04:00
|
|
|
return {
|
2020-05-26 13:07:46 -07:00
|
|
|
appState: selectGroupsForSelectedElements(
|
|
|
|
{
|
|
|
|
...appState,
|
|
|
|
editingGroupId: null,
|
|
|
|
selectedElementIds: elements.reduce((map, element) => {
|
|
|
|
if (!element.isDeleted) {
|
|
|
|
map[element.id] = true;
|
|
|
|
}
|
|
|
|
return map;
|
|
|
|
}, {} as any),
|
|
|
|
},
|
|
|
|
getNonDeletedElements(elements),
|
|
|
|
),
|
2020-03-19 14:51:05 +01:00
|
|
|
commitToHistory: true,
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-01-21 01:14:10 +02:00
|
|
|
contextItemLabel: "labels.selectAll",
|
2020-03-23 13:05:07 +02:00
|
|
|
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === "a",
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|