437595fa65
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
24 lines
628 B
TypeScript
24 lines
628 B
TypeScript
import { CaptureUpdateAction } from "@excalidraw/element";
|
|
|
|
import { register } from "./register";
|
|
|
|
export const actionToggleMidpointSnapping = register({
|
|
name: "midpointSnapping",
|
|
label: "labels.midpointSnapping",
|
|
viewMode: false,
|
|
trackEvent: {
|
|
category: "canvas",
|
|
predicate: (appState) => !appState.isMidpointSnappingEnabled,
|
|
},
|
|
perform(elements, appState) {
|
|
return {
|
|
appState: {
|
|
...appState,
|
|
isMidpointSnappingEnabled: !this.checked!(appState),
|
|
},
|
|
captureUpdate: CaptureUpdateAction.NEVER,
|
|
};
|
|
},
|
|
checked: (appState) => appState.isMidpointSnappingEnabled,
|
|
});
|