mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
This reverts commit 16263e942b
.
This commit is contained in:
parent
16263e942b
commit
3d2e59bfed
19 changed files with 130 additions and 789 deletions
|
@ -4,10 +4,9 @@ import { KEYS } from "../keys";
|
|||
|
||||
export const actionDeleteSelected: Action = {
|
||||
name: "deleteSelectedElements",
|
||||
perform: (elements, appState) => {
|
||||
perform: elements => {
|
||||
return {
|
||||
elements: deleteSelectedElements(elements),
|
||||
appState: { ...appState, elementType: "selection", multiElement: null },
|
||||
};
|
||||
},
|
||||
contextItemLabel: "labels.delete",
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
import { Action } from "./types";
|
||||
import { KEYS } from "../keys";
|
||||
import { clearSelection } from "../scene";
|
||||
|
||||
export const actionFinalize: Action = {
|
||||
name: "finalize",
|
||||
perform: (elements, appState) => {
|
||||
if (window.document.activeElement instanceof HTMLElement) {
|
||||
window.document.activeElement.blur();
|
||||
}
|
||||
return {
|
||||
elements: clearSelection(elements),
|
||||
appState: {
|
||||
...appState,
|
||||
elementType: "selection",
|
||||
draggingElement: null,
|
||||
multiElement: null,
|
||||
},
|
||||
};
|
||||
},
|
||||
keyTest: (event, appState) =>
|
||||
(event.key === KEYS.ESCAPE &&
|
||||
!appState.draggingElement &&
|
||||
appState.multiElement === null) ||
|
||||
((event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) &&
|
||||
appState.multiElement !== null),
|
||||
};
|
|
@ -23,8 +23,6 @@ export {
|
|||
actionClearCanvas,
|
||||
} from "./actionCanvas";
|
||||
|
||||
export { actionFinalize } from "./actionFinalize";
|
||||
|
||||
export {
|
||||
actionChangeProjectName,
|
||||
actionChangeExportBackground,
|
||||
|
|
|
@ -34,7 +34,7 @@ export class ActionManager implements ActionsManagerInterface {
|
|||
const data = Object.values(this.actions)
|
||||
.sort((a, b) => (b.keyPriority || 0) - (a.keyPriority || 0))
|
||||
.filter(
|
||||
action => action.keyTest && action.keyTest(event, appState, elements),
|
||||
action => action.keyTest && action.keyTest(event, elements, appState),
|
||||
);
|
||||
|
||||
if (data.length === 0) return null;
|
||||
|
|
|
@ -29,8 +29,8 @@ export interface Action {
|
|||
keyPriority?: number;
|
||||
keyTest?: (
|
||||
event: KeyboardEvent,
|
||||
appState: AppState,
|
||||
elements: readonly ExcalidrawElement[],
|
||||
elements?: readonly ExcalidrawElement[],
|
||||
appState?: AppState,
|
||||
) => boolean;
|
||||
contextItemLabel?: string;
|
||||
contextMenuOrder?: number;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue