2021-01-28 00:41:17 +05:30
|
|
|
import { CODES, KEYS } from "../keys";
|
|
|
|
import { register } from "./register";
|
|
|
|
import { GRID_SIZE } from "../constants";
|
2021-01-29 23:38:37 +05:30
|
|
|
import { AppState } from "../types";
|
2021-01-28 00:41:17 +05:30
|
|
|
|
|
|
|
export const actionToggleGridMode = register({
|
|
|
|
name: "gridMode",
|
2022-03-28 14:46:40 +02:00
|
|
|
trackEvent: {
|
|
|
|
category: "canvas",
|
|
|
|
predicate: (appState) => !appState.gridSize,
|
|
|
|
},
|
2021-01-28 00:41:17 +05:30
|
|
|
perform(elements, appState) {
|
|
|
|
return {
|
|
|
|
appState: {
|
|
|
|
...appState,
|
2021-01-29 23:38:37 +05:30
|
|
|
gridSize: this.checked!(appState) ? null : GRID_SIZE,
|
2021-01-28 00:41:17 +05:30
|
|
|
},
|
|
|
|
commitToHistory: false,
|
|
|
|
};
|
|
|
|
},
|
2021-01-29 23:38:37 +05:30
|
|
|
checked: (appState: AppState) => appState.gridSize !== null,
|
2021-02-06 03:20:53 +05:30
|
|
|
contextItemLabel: "labels.showGrid",
|
2021-01-28 00:41:17 +05:30
|
|
|
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.code === CODES.QUOTE,
|
|
|
|
});
|