mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
Co-authored-by: Ryan Di <ryan.weihao.di@gmail.com> Co-authored-by: dwelle <luzar.david@gmail.com>
28 lines
827 B
TypeScript
28 lines
827 B
TypeScript
import { CODES, KEYS } from "../keys";
|
|
import { register } from "./register";
|
|
|
|
export const actionToggleObjectsSnapMode = register({
|
|
name: "objectsSnapMode",
|
|
viewMode: true,
|
|
trackEvent: {
|
|
category: "canvas",
|
|
predicate: (appState) => !appState.objectsSnapModeEnabled,
|
|
},
|
|
perform(elements, appState) {
|
|
return {
|
|
appState: {
|
|
...appState,
|
|
objectsSnapModeEnabled: !this.checked!(appState),
|
|
gridSize: null,
|
|
},
|
|
commitToHistory: false,
|
|
};
|
|
},
|
|
checked: (appState) => appState.objectsSnapModeEnabled,
|
|
predicate: (elements, appState, appProps) => {
|
|
return typeof appProps.objectsSnapModeEnabled === "undefined";
|
|
},
|
|
contextItemLabel: "buttons.objectsSnapMode",
|
|
keyTest: (event) =>
|
|
!event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.S,
|
|
});
|