You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
863 B
TypeScript
30 lines
863 B
TypeScript
4 years ago
|
import { CODES, KEYS } from "../keys";
|
||
|
import { register } from "./register";
|
||
|
import { GRID_SIZE } from "../constants";
|
||
4 years ago
|
import { AppState } from "../types";
|
||
4 years ago
|
|
||
|
export const actionToggleGridMode = register({
|
||
|
name: "gridMode",
|
||
2 years ago
|
viewMode: true,
|
||
3 years ago
|
trackEvent: {
|
||
|
category: "canvas",
|
||
|
predicate: (appState) => !appState.gridSize,
|
||
|
},
|
||
4 years ago
|
perform(elements, appState) {
|
||
|
return {
|
||
|
appState: {
|
||
|
...appState,
|
||
4 years ago
|
gridSize: this.checked!(appState) ? null : GRID_SIZE,
|
||
1 year ago
|
objectsSnapModeEnabled: false,
|
||
4 years ago
|
},
|
||
|
commitToHistory: false,
|
||
|
};
|
||
|
},
|
||
4 years ago
|
checked: (appState: AppState) => appState.gridSize !== null,
|
||
2 years ago
|
predicate: (element, appState, props) => {
|
||
2 years ago
|
return typeof props.gridModeEnabled === "undefined";
|
||
|
},
|
||
4 years ago
|
contextItemLabel: "labels.showGrid",
|
||
4 years ago
|
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.code === CODES.QUOTE,
|
||
|
});
|