excalidraw/src/actions/actionFinalize.tsx
Gasim Gasimzada 08d80fb4fe
Add points to multi arrows in real time (#697)
* Add points to multi arrows in real time

* Fix linter issues

* Clear unecessary values from local storage
2020-02-04 14:39:08 +01:00

35 lines
1000 B
TypeScript

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();
}
if (appState.multiElement) {
appState.multiElement.points = appState.multiElement.points.slice(
0,
appState.multiElement.points.length - 1,
);
appState.multiElement.shape = null;
}
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),
};