mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Some checks failed
Auto release excalidraw next / Auto-release-excalidraw-next (push) Failing after 2m36s
Build Docker image / build-docker (push) Failing after 6s
Cancel previous runs / cancel (push) Failing after 1s
Publish Docker / publish-docker (push) Failing after 31s
New Sentry production release / sentry (push) Failing after 2m3s
33 lines
979 B
TypeScript
33 lines
979 B
TypeScript
import { CODES, KEYS } from "@excalidraw/common";
|
|
|
|
import { magnetIcon } from "../components/icons";
|
|
import { CaptureUpdateAction } from "../store";
|
|
|
|
import { register } from "./register";
|
|
|
|
export const actionToggleObjectsSnapMode = register({
|
|
name: "objectsSnapMode",
|
|
label: "buttons.objectsSnapMode",
|
|
icon: magnetIcon,
|
|
viewMode: false,
|
|
trackEvent: {
|
|
category: "canvas",
|
|
predicate: (appState) => !appState.objectsSnapModeEnabled,
|
|
},
|
|
perform(elements, appState) {
|
|
return {
|
|
appState: {
|
|
...appState,
|
|
objectsSnapModeEnabled: !this.checked!(appState),
|
|
gridModeEnabled: false,
|
|
},
|
|
captureUpdate: CaptureUpdateAction.EVENTUALLY,
|
|
};
|
|
},
|
|
checked: (appState) => appState.objectsSnapModeEnabled,
|
|
predicate: (elements, appState, appProps) => {
|
|
return typeof appProps.objectsSnapModeEnabled === "undefined";
|
|
},
|
|
keyTest: (event) =>
|
|
!event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.S,
|
|
});
|