change-grid
Panayiotis Lipiridis 4 years ago
parent 3c86b014de
commit 8802ea62ca

@ -1,8 +1,7 @@
import { trackEvent } from "../analytics";
import { CODES, KEYS } from "../keys"; import { CODES, KEYS } from "../keys";
import { register } from "./register";
import { GRID_SIZE } from "../constants";
import { AppState } from "../types"; import { AppState } from "../types";
import { trackEvent } from "../analytics"; import { register } from "./register";
export const actionToggleGridMode = register({ export const actionToggleGridMode = register({
name: "gridMode", name: "gridMode",
@ -11,12 +10,12 @@ export const actionToggleGridMode = register({
return { return {
appState: { appState: {
...appState, ...appState,
gridSize: this.checked!(appState) ? null : GRID_SIZE, showGrid: !appState.showGrid,
}, },
commitToHistory: false, commitToHistory: false,
}; };
}, },
checked: (appState: AppState) => appState.gridSize !== null, checked: (appState: AppState) => appState.showGrid,
contextItemLabel: "labels.gridMode", contextItemLabel: "labels.gridMode",
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.code === CODES.QUOTE, keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.code === CODES.QUOTE,
}); });

@ -1202,9 +1202,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
}; };
toggleGridMode = () => { toggleGridMode = () => {
this.setState({ this.actionManager.executeAction(actionToggleGridMode);
showGrid: !this.state.showGrid,
});
}; };
toggleStats = () => { toggleStats = () => {

Loading…
Cancel
Save