mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-02-18 13:29:36 +01:00
feat: add "toggle grid" to command palette (#7887)
This commit is contained in:
parent
da2e507298
commit
890ed9f31f
@ -2,10 +2,13 @@ import { CODES, KEYS } from "../keys";
|
|||||||
import { register } from "./register";
|
import { register } from "./register";
|
||||||
import { GRID_SIZE } from "../constants";
|
import { GRID_SIZE } from "../constants";
|
||||||
import { AppState } from "../types";
|
import { AppState } from "../types";
|
||||||
|
import { gridIcon } from "../components/icons";
|
||||||
|
|
||||||
export const actionToggleGridMode = register({
|
export const actionToggleGridMode = register({
|
||||||
name: "gridMode",
|
name: "gridMode",
|
||||||
label: "labels.showGrid",
|
icon: gridIcon,
|
||||||
|
keywords: ["snap"],
|
||||||
|
label: "labels.toggleGrid",
|
||||||
viewMode: true,
|
viewMode: true,
|
||||||
trackEvent: {
|
trackEvent: {
|
||||||
category: "canvas",
|
category: "canvas",
|
||||||
|
@ -309,6 +309,7 @@ function CommandPaletteInner({
|
|||||||
actionManager.actions.zoomToFit,
|
actionManager.actions.zoomToFit,
|
||||||
actionManager.actions.zenMode,
|
actionManager.actions.zenMode,
|
||||||
actionManager.actions.viewMode,
|
actionManager.actions.viewMode,
|
||||||
|
actionManager.actions.gridMode,
|
||||||
actionManager.actions.objectsSnapMode,
|
actionManager.actions.objectsSnapMode,
|
||||||
actionManager.actions.toggleShortcuts,
|
actionManager.actions.toggleShortcuts,
|
||||||
actionManager.actions.selectAll,
|
actionManager.actions.selectAll,
|
||||||
|
@ -273,7 +273,7 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => {
|
|||||||
shortcuts={[getShortcutKey("Alt+S")]}
|
shortcuts={[getShortcutKey("Alt+S")]}
|
||||||
/>
|
/>
|
||||||
<Shortcut
|
<Shortcut
|
||||||
label={t("labels.showGrid")}
|
label={t("labels.toggleGrid")}
|
||||||
shortcuts={[getShortcutKey("CtrlOrCmd+'")]}
|
shortcuts={[getShortcutKey("CtrlOrCmd+'")]}
|
||||||
/>
|
/>
|
||||||
<Shortcut
|
<Shortcut
|
||||||
|
@ -2116,3 +2116,16 @@ export const youtubeIcon = createIcon(
|
|||||||
</g>,
|
</g>,
|
||||||
tablerIconProps,
|
tablerIconProps,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const gridIcon = createIcon(
|
||||||
|
<g strokeWidth={1.5}>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path d="M3 6h18" />
|
||||||
|
<path d="M3 12h18" />
|
||||||
|
<path d="M3 18h18" />
|
||||||
|
<path d="M6 3v18" />
|
||||||
|
<path d="M12 3v18" />
|
||||||
|
<path d="M18 3v18" />
|
||||||
|
</g>,
|
||||||
|
tablerIconProps,
|
||||||
|
);
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
"group": "Group selection",
|
"group": "Group selection",
|
||||||
"ungroup": "Ungroup selection",
|
"ungroup": "Ungroup selection",
|
||||||
"collaborators": "Collaborators",
|
"collaborators": "Collaborators",
|
||||||
"showGrid": "Show grid",
|
"toggleGrid": "Toggle grid",
|
||||||
"addToLibrary": "Add to library",
|
"addToLibrary": "Add to library",
|
||||||
"removeFromLibrary": "Remove from library",
|
"removeFromLibrary": "Remove from library",
|
||||||
"libraryLoadingMessage": "Loading library…",
|
"libraryLoadingMessage": "Loading library…",
|
||||||
|
@ -7870,8 +7870,51 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
|
|||||||
"separator",
|
"separator",
|
||||||
{
|
{
|
||||||
"checked": [Function],
|
"checked": [Function],
|
||||||
|
"icon": <svg
|
||||||
|
aria-hidden="true"
|
||||||
|
className=""
|
||||||
|
fill="none"
|
||||||
|
focusable="false"
|
||||||
|
role="img"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeWidth={2}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<g
|
||||||
|
strokeWidth={1.5}
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M0 0h24v24H0z"
|
||||||
|
fill="none"
|
||||||
|
stroke="none"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M3 6h18"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M3 12h18"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M3 18h18"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M6 3v18"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M12 3v18"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M18 3v18"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
</svg>,
|
||||||
"keyTest": [Function],
|
"keyTest": [Function],
|
||||||
"label": "labels.showGrid",
|
"keywords": [
|
||||||
|
"snap",
|
||||||
|
],
|
||||||
|
"label": "labels.toggleGrid",
|
||||||
"name": "gridMode",
|
"name": "gridMode",
|
||||||
"perform": [Function],
|
"perform": [Function],
|
||||||
"predicate": [Function],
|
"predicate": [Function],
|
||||||
|
@ -101,7 +101,7 @@ describe("<Excalidraw/>", () => {
|
|||||||
clientY: 1,
|
clientY: 1,
|
||||||
});
|
});
|
||||||
const contextMenu = document.querySelector(".context-menu");
|
const contextMenu = document.querySelector(".context-menu");
|
||||||
fireEvent.click(queryByText(contextMenu as HTMLElement, "Show grid")!);
|
fireEvent.click(queryByText(contextMenu as HTMLElement, "Toggle grid")!);
|
||||||
expect(h.state.gridSize).toBe(GRID_SIZE);
|
expect(h.state.gridSize).toBe(GRID_SIZE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user