This commit is contained in:
Michael D. Adams 2025-03-26 12:13:37 +07:00 committed by GitHub
commit 818c37c193
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 38 additions and 1 deletions

View file

@ -110,6 +110,7 @@ export const actionClearCanvas = register({
exportEmbedScene: appState.exportEmbedScene,
gridSize: appState.gridSize,
gridStep: appState.gridStep,
showGrid: appState.showGrid,
gridModeEnabled: appState.gridModeEnabled,
stats: appState.stats,
pasteDialog: appState.pasteDialog,

View file

@ -0,0 +1,27 @@
import { CODES, KEYS } from "../keys";
import { register } from "./register";
import type { AppState } from "../types";
import { gridIcon } from "../components/icons";
import { StoreAction } from "../store";
export const actionToggleShowGrid = register({
name: "showGrid",
icon: gridIcon,
keywords: ["snap"],
label: "labels.toggleShowGrid",
viewMode: true,
trackEvent: {
category: "canvas",
predicate: (appState) => appState.showGrid,
},
perform(elements, appState) {
return {
appState: {
...appState,
showGrid: !this.checked!(appState),
},
storeAction: StoreAction.NONE,
};
},
checked: (appState: AppState) => appState.showGrid,
});

View file

@ -77,6 +77,7 @@ export {
copyText,
} from "./actionClipboard";
export { actionToggleShowGrid } from "./actionToggleShowGrid";
export { actionToggleGridMode } from "./actionToggleGridMode";
export { actionToggleZenMode } from "./actionToggleZenMode";
export { actionToggleObjectsSnapMode } from "./actionToggleObjectsSnapMode";

View file

@ -54,6 +54,7 @@ export type ActionName =
| "copyStyles"
| "selectAll"
| "pasteStyles"
| "showGrid"
| "gridMode"
| "zenMode"
| "objectsSnapMode"

View file

@ -64,6 +64,7 @@ export const getDefaultAppState = (): Omit<
fileHandle: null,
gridSize: DEFAULT_GRID_SIZE,
gridStep: DEFAULT_GRID_STEP,
showGrid: false,
gridModeEnabled: false,
isBindingEnabled: true,
defaultSidebarDockedPreference: false,
@ -184,6 +185,7 @@ const APP_STATE_STORAGE_CONF = (<
fileHandle: { browser: false, export: false, server: false },
gridSize: { browser: true, export: true, server: true },
gridStep: { browser: true, export: true, server: true },
showGrid: { browser: true, export: true, server: true },
gridModeEnabled: { browser: true, export: true, server: true },
height: { browser: false, export: false, server: false },
isBindingEnabled: { browser: false, export: false, server: false },

View file

@ -41,6 +41,7 @@ import {
actionSelectAll,
actionSendBackward,
actionSendToBack,
actionToggleShowGrid,
actionToggleGridMode,
actionToggleStats,
actionToggleZenMode,
@ -1738,7 +1739,7 @@ class App extends React.Component<AppProps, AppState> {
renderConfig={{
imageCache: this.imageCache,
isExporting: false,
renderGrid: isGridModeEnabled(this),
renderGrid: this.state.showGrid || isGridModeEnabled(this),
canvasBackgroundColor:
this.state.viewBackgroundColor,
embedsValidationStatus: this.embedsValidationStatus,
@ -10750,6 +10751,7 @@ class App extends React.Component<AppProps, AppState> {
return [
...options,
actionToggleGridMode,
actionToggleShowGrid,
actionToggleZenMode,
actionToggleViewMode,
actionToggleStats,
@ -10767,6 +10769,7 @@ class App extends React.Component<AppProps, AppState> {
actionUnlockAllElements,
CONTEXT_MENU_SEPARATOR,
actionToggleGridMode,
actionToggleShowGrid,
actionToggleObjectsSnapMode,
actionToggleZenMode,
actionToggleViewMode,

View file

@ -95,6 +95,7 @@
"group": "Group selection",
"ungroup": "Ungroup selection",
"collaborators": "Collaborators",
"toggleShowGrid": "Toggle show grid",
"toggleGrid": "Toggle grid",
"addToLibrary": "Add to library",
"removeFromLibrary": "Remove from library",

View file

@ -360,6 +360,7 @@ export interface AppState {
/** grid cell px size */
gridSize: number;
gridStep: number;
showGrid: boolean;
gridModeEnabled: boolean;
viewModeEnabled: boolean;