You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
5 years ago
|
import { KEYS } from "../keys";
|
||
5 years ago
|
import { register } from "./register";
|
||
5 years ago
|
import { selectGroupsForSelectedElements } from "../groups";
|
||
3 years ago
|
import { getNonDeletedElements, isTextElement } from "../element";
|
||
3 years ago
|
import { ExcalidrawElement } from "../element/types";
|
||
3 years ago
|
import { isLinearElement } from "../element/typeChecks";
|
||
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
||
2 years ago
|
import { excludeElementsInFramesFromSelection } from "../scene/selection";
|
||
5 years ago
|
|
||
5 years ago
|
export const actionSelectAll = register({
|
||
5 years ago
|
name: "selectAll",
|
||
3 years ago
|
trackEvent: { category: "canvas" },
|
||
3 years ago
|
perform: (elements, appState, value, app) => {
|
||
5 years ago
|
if (appState.editingLinearElement) {
|
||
|
return false;
|
||
|
}
|
||
2 years ago
|
|
||
|
const selectedElementIds = excludeElementsInFramesFromSelection(
|
||
|
elements.filter(
|
||
|
(element) =>
|
||
3 years ago
|
!element.isDeleted &&
|
||
|
!(isTextElement(element) && element.containerId) &&
|
||
2 years ago
|
!element.locked,
|
||
|
),
|
||
|
).reduce((map: Record<ExcalidrawElement["id"], true>, element) => {
|
||
|
map[element.id] = true;
|
||
|
return map;
|
||
|
}, {});
|
||
3 years ago
|
|
||
5 years ago
|
return {
|
||
2 years ago
|
appState: {
|
||
|
...appState,
|
||
|
...selectGroupsForSelectedElements(
|
||
|
{
|
||
|
editingGroupId: null,
|
||
|
selectedElementIds,
|
||
|
},
|
||
|
getNonDeletedElements(elements),
|
||
|
appState,
|
||
|
app,
|
||
|
),
|
||
|
selectedLinearElement:
|
||
|
// single linear element selected
|
||
|
Object.keys(selectedElementIds).length === 1 &&
|
||
|
isLinearElement(elements[0])
|
||
|
? new LinearElementEditor(elements[0], app.scene)
|
||
|
: null,
|
||
|
},
|
||
5 years ago
|
commitToHistory: true,
|
||
5 years ago
|
};
|
||
|
},
|
||
5 years ago
|
contextItemLabel: "labels.selectAll",
|
||
4 years ago
|
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === KEYS.A,
|
||
5 years ago
|
});
|