@mocanvas/mocanvas 4.0.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui/ui-dialogs.tsx","../src/ui/icons.tsx","../src/ui/ui-icon.tsx","../src/ui/ui-button.tsx","../src/ui/overlays.tsx","../src/ui/ui-floating.tsx","../src/ui/ui-dropdown-menu.tsx","../src/ui/ui-kbd.tsx","../src/ui/ui-actions.ts","../src/ui/ui-events.tsx","../src/ui/ui-translation.tsx","../src/ui/ui-menu.tsx","../src/ui/useKeyboardShortcuts.ts","../src/ui/useToolShortcuts.ts","../src/ui/useActionShortcuts.ts","../src/ui/panel-shortcuts.tsx"],"names":["jsx","jsxs","Fragment","useRef","useState","useCallback","useEffect","createContext","useContext","useMemo","useLayoutEffect","FOCUSABLE","EditorPortal","useEditor","useValue","isEditable","useTools","useActions"],"mappings":";;;;;;AA6CA,IAAM,cAAA,GAAiB,cAA6C,IAAI,CAAA;AAExE,IAAM,OAA+B,EAAE,SAAA,EAAW,MAAM,EAAA,EAAI,cAAc,MAAM;AAAC,CAAA,EAAG,cAAc,MAAM;AAAC,CAAA,EAAG,OAAA,EAAS,EAAC,EAAE;AAMxH,IAAI,YAAA,GAAe,CAAA;AAGZ,SAAS,uBAAA,CAAwB,EAAE,QAAA,EAAS,EAA6B;AAC9E,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,QAAA,CAAuB,EAAE,CAAA;AAEvD,EAAA,MAAM,YAAA,GAAe,WAAA,CAAY,CAAC,EAAA,KAAe;AAC/C,IAAA,UAAA,CAAW,CAAC,OAAA,KAAY;AACtB,MAAA,OAAA,CAAQ,KAAK,CAAC,MAAA,KAAW,OAAO,EAAA,KAAO,EAAE,GAAG,OAAA,IAAU;AACtD,MAAA,OAAO,QAAQ,MAAA,CAAO,CAAC,MAAA,KAAW,MAAA,CAAO,OAAO,EAAE,CAA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;AAClF,EAAA,uBAAOA,IAAC,8BAAA,EAAA,EAA+B,CAAA;AACzC","file":"chunk-YMUR46N6.js","sourcesContent":["import { EditorPortal } from \"@mocanvas/editor\"\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ComponentType,\n type ReactNode,\n} from \"react\"\n\n/**\n * Modal dialogs, and the stack that owns them.\n *\n * Opening a dialog is a *data* operation — `addDialog({ component })` — rather\n * than rendering one in place, because the code that opens a dialog is almost\n * always a menu item that unmounts on the same click.\n */\n\n/** What a dialog component is rendered with. */\nexport interface TLUiDialogProps {\n /** Close this dialog. Also called when the backdrop or Escape closes it. */\n onClose(): void\n}\n\n/** One entry on the dialog stack. */\nexport interface TLUiDialog {\n id: string\n /** Rendered inside the modal frame. */\n component: ComponentType<TLUiDialogProps>\n /** Called after the dialog is removed, however it was closed. */\n onClose?(): void\n /** Let a click on the backdrop close it. Defaults to `true`. */\n preventBackdropClose?: boolean\n}\n\nexport interface TLUiDialogsContextType {\n addDialog(dialog: Omit<TLUiDialog, \"id\"> & { id?: string }): string\n removeDialog(id: string): void\n clearDialogs(): void\n dialogs: TLUiDialog[]\n}\n\nconst DialogsContext = createContext<TLUiDialogsContextType | null>(null)\n\nconst NOOP: TLUiDialogsContextType = { addDialog: () => \"\", removeDialog: () => {}, clearDialogs: () => {}, dialogs: [] }\n\nexport interface TLUiDialogsProviderProps {\n children?: ReactNode\n}\n\nlet nextDialogId = 0\n\n/** Holds the dialog stack. Render {@link DefaultDialogs} inside it. */\nexport function TldrawUiDialogsProvider({ children }: TLUiDialogsProviderProps) {\n const [dialogs, setDialogs] = useState<TLUiDialog[]>([])\n\n const removeDialog = useCallback((id: string) => {\n setDialogs((current) => {\n current.find((dialog) => dialog.id === id)?.onClose?.()\n return current.filter((dialog) => dialog.id !== id)\n })\n }, [])\n\n const addDialog = useCallback((dialog: Omit<TLUiDialog, \"id\"> & { id?: string }) => {\n const id = dialog.id ?? `dialog:${nextDialogId++}`\n setDialogs((current) => [...current.filter((d) => d.id !== id), { ...dialog, id }])\n return id\n }, [])\n\n const clearDialogs = useCallback(() => {\n setDialogs((current) => {\n for (const dialog of current) dialog.onClose?.()\n return []\n })\n }, [])\n\n const value = useMemo<TLUiDialogsContextType>(\n () => ({ addDialog, removeDialog, clearDialogs, dialogs }),\n [addDialog, removeDialog, clearDialogs, dialogs],\n )\n return <DialogsContext.Provider value={value}>{children}</DialogsContext.Provider>\n}\n\n/** The dialog stack. Inert outside a provider. */\nexport function useDialogs(): TLUiDialogsContextType {\n return useContext(DialogsContext) ?? NOOP\n}\n\n/** Everything inside a dialog that the keyboard can reach. */\nconst FOCUSABLE =\n 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])'\n\n/**\n * The modal frame: backdrop, focus trap, Escape.\n *\n * The trap is the part a dialog cannot do without. Without it, Tab walks out\n * of the dialog and onto the canvas behind it, which is both wrong and\n * invisible — the focus ring is under the backdrop.\n */\nfunction DialogFrame({ dialog, onClose }: { dialog: TLUiDialog; onClose: () => void }) {\n const ref = useRef<HTMLDivElement>(null)\n const returnFocusTo = useRef<Element | null>(null)\n\n useEffect(() => {\n returnFocusTo.current = ref.current?.ownerDocument.activeElement ?? null\n const first = ref.current?.querySelector<HTMLElement>(FOCUSABLE)\n ;(first ?? ref.current)?.focus()\n return () => {\n const previous = returnFocusTo.current\n if (previous instanceof HTMLElement) previous.focus()\n }\n }, [])\n\n const onKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.stopPropagation()\n onClose()\n return\n }\n if (event.key !== \"Tab\") return\n const items = Array.from(ref.current?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? [])\n if (items.length === 0) return\n const first = items[0]!\n const last = items[items.length - 1]!\n const active = ref.current?.ownerDocument.activeElement\n if (event.shiftKey && active === first) {\n event.preventDefault()\n last.focus()\n } else if (!event.shiftKey && active === last) {\n event.preventDefault()\n first.focus()\n }\n }\n\n const Component = dialog.component\n return (\n <div\n className=\"mocanvas-dialog-backdrop\"\n onPointerDown={(event) => {\n if (event.target === event.currentTarget && !dialog.preventBackdropClose) onClose()\n }}\n >\n <div ref={ref} className=\"mocanvas-dialog mocanvas-panel\" role=\"dialog\" aria-modal=\"true\" tabIndex={-1} onKeyDown={onKeyDown}>\n <Component onClose={onClose} />\n </div>\n </div>\n )\n}\n\n/** Renders the dialog stack into the editor's container. */\nexport function DefaultDialogs() {\n const { dialogs, removeDialog } = useDialogs()\n if (dialogs.length === 0) return null\n return (\n <EditorPortal>\n {dialogs.map((dialog) => (\n <DialogFrame key={dialog.id} dialog={dialog} onClose={() => removeDialog(dialog.id)} />\n ))}\n </EditorPortal>\n )\n}\n\n// ---------------------------------------------------------------------------\n// The pieces a dialog is built from\n// ---------------------------------------------------------------------------\n\nexport interface TLUiDialogHeaderProps {\n className?: string\n children?: ReactNode\n}\n\n/** A dialog's title bar. */\nexport function TldrawUiDialogHeader({ className, children }: TLUiDialogHeaderProps) {\n return <div className={className ? `mocanvas-dialog-header ${className}` : \"mocanvas-dialog-header\"}>{children}</div>\n}\n\nexport interface TLUiDialogTitleProps {\n className?: string\n children?: ReactNode\n}\n\n/**\n * A dialog's title. Rendered as an `<h2>` so the dialog has a heading in the\n * document outline, not just a bold line.\n */\nexport function TldrawUiDialogTitle({ className, children }: TLUiDialogTitleProps) {\n return <h2 className={className ? `mocanvas-dialog-title ${className}` : \"mocanvas-dialog-title\"}>{children}</h2>\n}\n\n/** The dialog's close affordance. Reads `onClose` from the enclosing dialog. */\nexport function TldrawUiDialogCloseButton() {\n const { dialogs, removeDialog } = useDialogs()\n const top = dialogs[dialogs.length - 1]\n return (\n <button\n type=\"button\"\n className=\"mocanvas-btn mocanvas-dialog-close\"\n aria-label=\"Close\"\n onClick={() => {\n if (top) removeDialog(top.id)\n }}\n >\n ×\n </button>\n )\n}\n\nexport interface TLUiDialogBodyProps {\n className?: string\n style?: React.CSSProperties\n children?: ReactNode\n}\n\n/** A dialog's scrollable middle. */\nexport function TldrawUiDialogBody({ className, style, children }: TLUiDialogBodyProps) {\n return (\n <div className={className ? `mocanvas-dialog-body ${className}` : \"mocanvas-dialog-body\"} style={style}>\n {children}\n </div>\n )\n}\n\nexport interface TLUiDialogFooterProps {\n className?: string\n children?: ReactNode\n}\n\n/** A dialog's button row. */\nexport function TldrawUiDialogFooter({ className, children }: TLUiDialogFooterProps) {\n return <div className={className ? `mocanvas-dialog-footer ${className}` : \"mocanvas-dialog-footer\"}>{children}</div>\n}\n\nexport interface ExampleDialogProps extends TLUiDialogProps {\n title?: string\n body?: ReactNode\n confirmLabel?: string\n cancelLabel?: string\n displayDontShowAgain?: boolean\n onCancel?(): void\n onContinue?(): void\n}\n\n/**\n * A confirm/cancel dialog, complete.\n *\n * Exists so an app that only needs \"are you sure?\" does not have to assemble\n * one out of the five pieces above — and so the pieces have a worked example\n * to copy when it needs something else.\n */\nexport function ExampleDialog({\n title = \"Title\",\n body = \"Description\",\n confirmLabel = \"Continue\",\n cancelLabel = \"Cancel\",\n displayDontShowAgain = false,\n onCancel,\n onContinue,\n onClose,\n}: ExampleDialogProps) {\n const [dontShowAgain, setDontShowAgain] = useState(false)\n return (\n <>\n <TldrawUiDialogHeader>\n <TldrawUiDialogTitle>{title}</TldrawUiDialogTitle>\n <TldrawUiDialogCloseButton />\n </TldrawUiDialogHeader>\n <TldrawUiDialogBody>{body}</TldrawUiDialogBody>\n <TldrawUiDialogFooter>\n {displayDontShowAgain ? (\n <label className=\"mocanvas-dialog-checkbox\">\n <input type=\"checkbox\" checked={dontShowAgain} onChange={(event) => setDontShowAgain(event.target.checked)} />\n Don&rsquo;t show again\n </label>\n ) : null}\n <button\n type=\"button\"\n className=\"mocanvas-btn mocanvas-btn--wide\"\n onClick={() => {\n onCancel?.()\n onClose()\n }}\n >\n {cancelLabel}\n </button>\n <button\n type=\"button\"\n className=\"mocanvas-btn mocanvas-btn--wide\"\n onClick={() => {\n onContinue?.()\n onClose()\n }}\n >\n {confirmLabel}\n </button>\n </TldrawUiDialogFooter>\n </>\n )\n}\n","/**\n * The default UI icon set: original artwork drawn on a 24×24 grid with a\n * 1.75px stroke, round caps and joins, painted with `currentColor` so buttons\n * control their own colour.\n *\n * Grid rules, enforced by `icons.test.tsx` where they are checkable statically\n * and by the gallery pass otherwise:\n *\n * - the artwork lives on a 24×24 viewBox; ink (stroke included) stays inside it\n * - ink is optically centred on (12, 12) and spans about 17.75 units at its\n * widest, so no icon reads heavier than its neighbour in the same row\n * - stroke is 1.75 with round caps and joins; only texture marks (hatching,\n * dotted rules, the mono rails) deviate, and they say so at the call site\n * - deliberate asymmetry is allowed only when it carries meaning, e.g. the\n * vertical-align icons sit high or low on purpose\n *\n * Geo icons are generated from the same geometry the canvas draws, so a toolbar\n * button matches the shape it creates.\n */\nimport { GEO_SHAPE_KINDS, type GeoShapeKind } from \"@mocanvas/editor\"\nimport type { ReactElement } from \"react\"\nimport { getGeoGeometry } from \"../shapes/geo-helpers\"\nimport { pathWordsToSvgD } from \"../shapes/svg-path\"\n\n/** Side of the drawing grid. */\nexport const ICON_GRID = 24\n/** Longest side of the box a geo outline is fitted into, centred in the grid. */\nexport const GEO_BOX = 16\n\nconst solid = { fill: \"currentColor\", stroke: \"none\" } as const\n\n// ---------------------------------------------------------------------------\n// Tools\n// ---------------------------------------------------------------------------\n\nconst TOOL_ICONS = {\n select: <path d=\"M6.65 4.05v13.95l3.54-3.35 2.41 5.3 2.33-1.02-2.42-5.21 4.84-.19z\" />,\n hand: (\n <path d=\"M8.35 14.6V9.5a1.3 1.3 0 0 1 2.6 0V5.3a1.3 1.3 0 0 1 2.6 0v.5a1.3 1.3 0 0 1 2.6 0v1.9a1.3 1.3 0 0 1 2.6 0v6.75c0 3.15-2.55 5.7-5.7 5.7h-.6c-1.9 0-3.68-.96-4.72-2.55l-1.75-2.65a1.3 1.3 0 0 1 2.17-1.42z\" />\n ),\n draw: (\n <>\n <path d=\"M4.4 19.6l1.05-3.8L15.5 5.75a2 2 0 0 1 2.83 2.83L8.2 18.55z\" />\n <path d=\"M13.55 7.7l2.83 2.83\" />\n </>\n ),\n eraser: (\n <>\n <g transform=\"translate(12 10.5) rotate(-45)\">\n <rect x=\"-5.75\" y=\"-3.5\" width=\"11.5\" height=\"7\" rx=\"1.6\" />\n <path d=\"M0 -3.5V3.5\" />\n </g>\n <path d=\"M7 19.4h10.5\" />\n </>\n ),\n highlight: (\n <>\n {/* A chisel tip over the wet band it has just laid down. */}\n <path d=\"M9.15 14.9L6.1 11.85l7.15-6.4a2.15 2.15 0 0 1 3.05 3.05z\" />\n <path d=\"M8.6 15.7l-2.9.6.5-2.95\" />\n <path d=\"M5.2 20.05h13.6\" strokeWidth={2.8} />\n </>\n ),\n laser: (\n <>\n <circle cx=\"12\" cy=\"12\" r=\"2.55\" />\n <path d=\"M12 3.1v3.15M12 17.75v3.15M3.1 12h3.15M17.75 12h3.15\" />\n <path d=\"M5.7 5.7l2.2 2.2M16.1 16.1l2.2 2.2M18.3 5.7l-2.2 2.2M7.9 16.1l-2.2 2.2\" />\n </>\n ),\n text: (\n <>\n <path d=\"M5 6.25V4.5h14v1.75\" />\n <path d=\"M12 4.5v15\" />\n <path d=\"M8.75 19.5h6.5\" />\n </>\n ),\n note: (\n <>\n <path d=\"M4.5 5.75A1.75 1.75 0 0 1 6.25 4h11.5a1.75 1.75 0 0 1 1.75 1.75v8L13.5 20H6.25A1.75 1.75 0 0 1 4.5 18.25z\" />\n <path d=\"M19.5 13.75h-4.25a1.75 1.75 0 0 0-1.75 1.75V20\" />\n </>\n ),\n frame: (\n <>\n <path d=\"M8 4.5v15M16 4.5v15\" />\n <path d=\"M4.5 8h15M4.5 16h15\" />\n </>\n ),\n arrow: (\n <>\n <path d=\"M5.15 18.85L18.85 5.15\" />\n <path d=\"M12 5.15h6.85V12\" />\n </>\n ),\n line: (\n <>\n <path d=\"M7.6 16.4L16.4 7.6\" />\n <circle cx=\"5.85\" cy=\"18.15\" r=\"1.85\" />\n <circle cx=\"18.15\" cy=\"5.85\" r=\"1.85\" />\n </>\n ),\n image: (\n <>\n <rect x=\"3.9\" y=\"5.25\" width=\"16.2\" height=\"13.5\" rx=\"2.25\" />\n <circle cx=\"8.9\" cy=\"10\" r=\"1.55\" />\n <path d=\"M4 16.2l4.75-4.2 3.75 3.25 3-2.5 4.6 4.05\" />\n </>\n ),\n} as const\n\n// ---------------------------------------------------------------------------\n// View, history and object actions\n// ---------------------------------------------------------------------------\n\nconst ACTION_ICONS = {\n \"zoom-in\": (\n <>\n <circle cx=\"10.75\" cy=\"10.75\" r=\"6.25\" />\n <path d=\"M15.4 15.4l5.1 5.1\" />\n <path d=\"M8 10.75h5.5M10.75 8v5.5\" />\n </>\n ),\n \"zoom-out\": (\n <>\n <circle cx=\"10.75\" cy=\"10.75\" r=\"6.25\" />\n <path d=\"M15.4 15.4l5.1 5.1\" />\n <path d=\"M8 10.75h5.5\" />\n </>\n ),\n \"zoom-fit\": (\n <path d=\"M4 9V5.5A1.5 1.5 0 0 1 5.5 4H9M15 4h3.5A1.5 1.5 0 0 1 20 5.5V9M20 15v3.5a1.5 1.5 0 0 1-1.5 1.5H15M9 20H5.5A1.5 1.5 0 0 1 4 18.5V15\" />\n ),\n undo: (\n <>\n <path d=\"M4.25 8.75h10.25a5.25 5.25 0 0 1 0 10.5H10\" />\n <path d=\"M8.25 4.75L4.25 8.75l4 4\" />\n </>\n ),\n redo: (\n <>\n <path d=\"M19.75 8.75H9.5a5.25 5.25 0 0 0 0 10.5H14\" />\n <path d=\"M15.75 4.75l4 4-4 4\" />\n </>\n ),\n lock: (\n <>\n <rect x=\"4.75\" y=\"10.5\" width=\"14.5\" height=\"9.5\" rx=\"2.25\" />\n <path d=\"M8.25 10.5V7.75a3.75 3.75 0 0 1 7.5 0v2.75\" />\n </>\n ),\n unlock: (\n <>\n <rect x=\"4.75\" y=\"10.5\" width=\"14.5\" height=\"9.5\" rx=\"2.25\" />\n <path d=\"M8.25 10.5V7.75a3.75 3.75 0 0 1 7.15-1.5\" />\n </>\n ),\n duplicate: (\n <>\n <rect x=\"8.5\" y=\"8.5\" width=\"11.5\" height=\"11.5\" rx=\"2.25\" />\n <path d=\"M15.5 4H6.25A2.25 2.25 0 0 0 4 6.25V15.5\" />\n </>\n ),\n trash: (\n <>\n <path d=\"M4.5 7h15\" />\n <path d=\"M9.5 7V5.75A1.5 1.5 0 0 1 11 4.25h2a1.5 1.5 0 0 1 1.5 1.5V7\" />\n <path d=\"M6.75 7l.75 11.5A1.5 1.5 0 0 0 9 20h6a1.5 1.5 0 0 0 1.5-1.5L17.25 7\" />\n <path d=\"M10.25 10.5v6M13.75 10.5v6\" />\n </>\n ),\n group: (\n <>\n <rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"2\" strokeDasharray=\"3 3\" />\n <rect x=\"7\" y=\"7\" width=\"4.5\" height=\"4.5\" rx=\"1\" />\n <rect x=\"12.5\" y=\"12.5\" width=\"4.5\" height=\"4.5\" rx=\"1\" />\n </>\n ),\n ungroup: (\n <>\n <path d=\"M4 8V5.25A1.25 1.25 0 0 1 5.25 4H8M16 4h2.75A1.25 1.25 0 0 1 20 5.25V8M20 16v2.75A1.25 1.25 0 0 1 18.75 20H16M8 20H5.25A1.25 1.25 0 0 1 4 18.75V16\" />\n <rect x=\"7\" y=\"7\" width=\"4.5\" height=\"4.5\" rx=\"1\" />\n <rect x=\"12.5\" y=\"12.5\" width=\"4.5\" height=\"4.5\" rx=\"1\" />\n </>\n ),\n \"bring-forward\": (\n <>\n <rect x=\"4.75\" y=\"11.25\" width=\"14.5\" height=\"8.75\" rx=\"2.25\" />\n <path d=\"M12 9V4M8.75 7.25L12 4l3.25 3.25\" />\n </>\n ),\n \"send-backward\": (\n <>\n <rect x=\"4.75\" y=\"4\" width=\"14.5\" height=\"8.75\" rx=\"2.25\" />\n <path d=\"M12 15v5M8.75 16.75L12 20l3.25-3.25\" />\n </>\n ),\n \"chevron-down\": <path d=\"M6.75 9.75L12 15l5.25-5.25\" />,\n \"chevron-up\": <path d=\"M6.75 14.25L12 9l5.25 5.25\" />,\n check: <path d=\"M5 12.5l4.9 4.9L19 6.75\" />,\n close: <path d=\"M6.5 6.5l11 11M17.5 6.5l-11 11\" />,\n mixed: <circle cx=\"12\" cy=\"12\" r=\"7.25\" strokeDasharray=\"2.6 2.8\" />,\n} as const\n\n// ---------------------------------------------------------------------------\n// Style properties\n// ---------------------------------------------------------------------------\n\nconst FILL_BOX = { x: 4.25, y: 4.25, width: 15.5, height: 15.5, rx: 3 } as const\n\nconst STYLE_ICONS = {\n \"fill-none\": <rect {...FILL_BOX} />,\n \"fill-semi\": (\n <>\n <rect {...FILL_BOX} fill=\"currentColor\" fillOpacity={0.22} />\n </>\n ),\n \"fill-solid\": <rect {...FILL_BOX} fill=\"currentColor\" />,\n // Hatching is texture, not outline: a lighter stroke keeps the block's weight\n // level with the other three fill icons.\n \"fill-pattern\": (\n <>\n <rect {...FILL_BOX} />\n <path d=\"M6.2 12.6l6.4-6.4M6.2 17.1l10.9-10.9M9.4 18.3l8.9-8.9M14.6 18.4l3.7-3.7\" strokeWidth={1.25} />\n </>\n ),\n \"dash-draw\": <path d=\"M4 14.9c1.6-3.4 3.2-4.9 4.9-4.4 1.7.4 2.4 4 4.2 4.4 1.9.4 3.9-1.9 6.9-5.9\" />,\n \"dash-solid\": <path d=\"M4.25 12h15.5\" />,\n \"dash-dashed\": <path d=\"M4.5 12h15\" strokeDasharray=\"3.1 2.8\" />,\n // Round caps on a zero-length dash draw the dots; the wider stroke is the dot.\n \"dash-dotted\": <path d=\"M5 12h14\" strokeDasharray=\"0.01 4.35\" strokeWidth={2.6} />,\n \"size-s\": <circle cx=\"12\" cy=\"12\" r=\"2\" {...solid} />,\n \"size-m\": <circle cx=\"12\" cy=\"12\" r=\"3.4\" {...solid} />,\n \"size-l\": <circle cx=\"12\" cy=\"12\" r=\"4.9\" {...solid} />,\n \"size-xl\": <circle cx=\"12\" cy=\"12\" r=\"6.6\" {...solid} />,\n \"align-left\": <path d=\"M4.5 6.5h15M4.5 12h7.5M4.5 17.5h11.5\" />,\n \"align-center\": <path d=\"M4.5 6.5h15M8.25 12h7.5M6.25 17.5h11.5\" />,\n \"align-right\": <path d=\"M4.5 6.5h15M12 12h7.5M8 17.5h11.5\" />,\n \"valign-top\": (\n <>\n <path d=\"M4.5 4.5h15\" />\n <rect x=\"7.5\" y=\"7.75\" width=\"9\" height=\"6.25\" rx=\"1.5\" />\n </>\n ),\n \"valign-middle\": (\n <>\n <path d=\"M4.5 12h15\" />\n <rect x=\"7.5\" y=\"8.9\" width=\"9\" height=\"6.25\" rx=\"1.5\" />\n </>\n ),\n \"valign-bottom\": (\n <>\n <path d=\"M4.5 19.5h15\" />\n <rect x=\"7.5\" y=\"10\" width=\"9\" height=\"6.25\" rx=\"1.5\" />\n </>\n ),\n // A single-storey script \"a\": the other three fonts share the capital-A\n // silhouette, so the handwriting option needs a different letter to stay\n // legible at 20px.\n \"font-draw\": (\n <>\n <circle cx=\"10.6\" cy=\"12.6\" r=\"4.4\" />\n <path d=\"M15 6.3v8.9c0 1.5 1 2.5 2.5 2.5\" />\n </>\n ),\n \"font-sans\": (\n <>\n <path d=\"M5.5 19L12 5l6.5 14\" />\n <path d=\"M8 14.5h8\" />\n </>\n ),\n \"font-serif\": (\n <>\n <path d=\"M6.75 19L12 5l5.25 14\" />\n <path d=\"M8.7 14.5h6.6\" />\n <path d=\"M4.9 19h3.6M15.5 19h3.6\" />\n </>\n ),\n \"font-mono\": (\n <>\n <path d=\"M8 19l4-13 4 13\" />\n <path d=\"M9.6 14.9h4.8\" />\n {/* The rails are a frame, not a letter stroke: keep them lighter. */}\n <path d=\"M4.75 5.75v12.5M19.25 5.75v12.5\" strokeWidth={1.4} />\n </>\n ),\n} as const\n\n// ---------------------------------------------------------------------------\n// Geo kinds, derived from the canvas geometry\n// ---------------------------------------------------------------------------\n\n/**\n * Box each geo outline is fitted into. Square by default; kinds whose name\n * implies a proportion get one, so that e.g. \"oval\" does not draw the same\n * circle as \"ellipse\". The longest side is always `GEO_BOX`, which keeps every\n * geo icon at the same optical weight as the rest of the set.\n */\nconst GEO_ICON_BOX: Partial<Record<GeoShapeKind, readonly [number, number]>> = {\n rectangle: [GEO_BOX, 12],\n oval: [GEO_BOX, 10.5],\n \"arrow-left\": [GEO_BOX, 13],\n \"arrow-right\": [GEO_BOX, 13],\n \"arrow-up\": [13, GEO_BOX],\n \"arrow-down\": [13, GEO_BOX],\n}\n\n/** The box a geo icon's outline is fitted into, in grid units. */\nexport function getGeoIconBox(kind: GeoShapeKind): readonly [number, number] {\n return GEO_ICON_BOX[kind] ?? [GEO_BOX, GEO_BOX]\n}\n\n/** `d` attribute for each geo kind, fitted to its icon box. */\nexport const GEO_ICON_PATHS: Record<GeoShapeKind, string> = Object.fromEntries(\n GEO_SHAPE_KINDS.map((kind) => {\n const [w, h] = getGeoIconBox(kind)\n return [kind, pathWordsToSvgD(getGeoGeometry(kind, w, h, false).toPathWords())]\n }),\n) as Record<GeoShapeKind, string>\n\ntype GeoIconName = `geo-${GeoShapeKind}`\n\nconst GEO_ICONS = Object.fromEntries(\n GEO_SHAPE_KINDS.map((kind) => {\n const [w, h] = getGeoIconBox(kind)\n return [\n `geo-${kind}`,\n <g transform={`translate(${(ICON_GRID - w) / 2} ${(ICON_GRID - h) / 2})`}>\n <path d={GEO_ICON_PATHS[kind]} />\n </g>,\n ]\n }),\n) as Record<GeoIconName, ReactElement>\n\n/** Every icon in the set, keyed by name. */\nexport const ICONS = { ...TOOL_ICONS, ...ACTION_ICONS, ...STYLE_ICONS, ...GEO_ICONS }\n\nexport type IconName = keyof typeof ICONS\n\n/** All icon names, sorted — handy for tests and galleries. */\nexport const ICON_NAMES = Object.keys(ICONS).sort() as IconName[]\n\nexport interface IconProps {\n name: IconName\n /** Rendered size in px; the artwork is scaled from the 24×24 grid. */\n size?: number\n className?: string\n}\n\n/** Renders one icon from the set. Decorative by default: label the button instead. */\nexport function Icon({ name, size = 20, className }: IconProps) {\n return (\n <svg\n className={className ? `mocanvas-icon ${className}` : \"mocanvas-icon\"}\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.75}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n {ICONS[name]}\n </svg>\n )\n}\n","import type { CSSProperties } from \"react\"\nimport { Icon, ICONS, type IconName } from \"./icons\"\n\n/**\n * The icon element the UI primitives use.\n *\n * Distinct from {@link Icon}, which takes a name the set is known to have.\n * This one takes an arbitrary string, because a `TLUiActionItem.icon` comes\n * from an app's override and may name artwork mocanvas does not ship: an\n * unknown name falls back to the label's initial rather than rendering an\n * empty box, so a custom item is still a legible button.\n */\nexport interface TLUiIconProps {\n /** Icon name, or an image URL when it contains a `/` or `.`. */\n icon: string\n /** Read out when the icon is the button's only content. */\n label?: string\n /** Draw at the smaller size used inside dense rows. */\n small?: boolean\n /** Mirror horizontally, for a direction icon in a right-to-left locale. */\n invertIcon?: boolean\n className?: string\n style?: CSSProperties\n color?: string\n}\n\n/** Whether `icon` looks like a URL rather than a name in the built-in set. */\nfunction isUrl(icon: string): boolean {\n return icon.includes(\"/\") || icon.includes(\".\")\n}\n\n/**\n * An icon, from the built-in set, from a URL, or as a fallback initial.\n *\n * `aria-hidden` unless it was given a label: an icon inside a labelled button\n * is decoration, and announcing it would make a screen reader say the name\n * twice.\n */\nexport function TldrawUiIcon({ icon, label, small, invertIcon, className, style, color }: TLUiIconProps) {\n const classes = [\"mocanvas-icon\", small ? \"mocanvas-icon--small\" : null, className].filter(Boolean).join(\" \")\n const transform = invertIcon ? \"scaleX(-1)\" : undefined\n const size = small ? 16 : 20\n\n if (Object.prototype.hasOwnProperty.call(ICONS, icon)) {\n return (\n <span className={classes} style={{ ...style, color, transform, display: \"inline-flex\" }} {...(label ? { role: \"img\", \"aria-label\": label } : { \"aria-hidden\": true })}>\n <Icon name={icon as IconName} size={size} />\n </span>\n )\n }\n\n if (isUrl(icon)) {\n return (\n <img\n className={classes}\n src={icon}\n alt={label ?? \"\"}\n width={size}\n height={size}\n style={{ ...style, transform }}\n {...(label ? {} : { \"aria-hidden\": true })}\n />\n )\n }\n\n return (\n <span\n className={`${classes} mocanvas-icon--fallback`}\n style={{ ...style, color, transform, width: size, height: size, display: \"inline-flex\", alignItems: \"center\", justifyContent: \"center\", fontWeight: 600 }}\n {...(label ? { role: \"img\", \"aria-label\": label } : { \"aria-hidden\": true })}\n >\n {(label ?? icon).slice(0, 1).toUpperCase()}\n </span>\n )\n}\n","import type { CSSProperties, MouseEvent, PointerEvent, ReactNode, Ref } from \"react\"\nimport { TldrawUiIcon } from \"./ui-icon\"\n\n/**\n * The button every piece of chrome is made of, and the three things that go\n * inside it.\n *\n * Split into four components rather than one with an `icon` and a `label`\n * prop, because the arrangement varies: a toolbar button is icon-only, a menu\n * item is icon-then-label, a checkbox item is label-then-check. Composing\n * covers all three without a prop that means \"which layout\".\n */\n\n/** How a button reads: its size, its emphasis, and whether it is a menu row. */\nexport type TLUiButtonType = \"normal\" | \"primary\" | \"danger\" | \"low\" | \"icon\" | \"menu\" | \"tool\" | \"help\"\n\nexport interface TLUiButtonProps {\n type?: TLUiButtonType\n /** Rendered as `aria-pressed`: a two-state button, not a link. */\n isChecked?: boolean\n /** Marks the active item in a set. Rendered as `aria-current`. */\n isActive?: boolean\n disabled?: boolean\n /** Accessible name. Required when the button's content is an icon alone. */\n title?: string\n /** Explicit accessible name, when it differs from the visible label. */\n \"aria-label\"?: string\n className?: string\n style?: CSSProperties\n id?: string\n tabIndex?: number\n role?: string\n ref?: Ref<HTMLButtonElement>\n onClick?(event: MouseEvent<HTMLButtonElement>): void\n onPointerDown?(event: PointerEvent<HTMLButtonElement>): void\n onPointerUp?(event: PointerEvent<HTMLButtonElement>): void\n onKeyDown?(event: React.KeyboardEvent<HTMLButtonElement>): void\n onFocus?(event: React.FocusEvent<HTMLButtonElement>): void\n onBlur?(event: React.FocusEvent<HTMLButtonElement>): void\n children?: ReactNode\n}\n\n/**\n * A button.\n *\n * `type=\"submit\"` is never what chrome wants — a button inside a form that\n * defaults to submitting is a bug waiting for someone to press Enter — so this\n * always renders `type=\"button\"`.\n */\nexport function TldrawUiButton({\n type = \"normal\",\n isChecked,\n isActive,\n disabled,\n title,\n className,\n style,\n id,\n tabIndex,\n role,\n ref,\n onClick,\n onPointerDown,\n onPointerUp,\n onKeyDown,\n onFocus,\n onBlur,\n children,\n ...rest\n}: TLUiButtonProps) {\n const label = rest[\"aria-label\"] ?? title\n return (\n <button\n ref={ref}\n type=\"button\"\n id={id}\n role={role}\n tabIndex={tabIndex}\n className={[\"mocanvas-btn\", `mocanvas-btn--${type}`, className].filter(Boolean).join(\" \")}\n style={style}\n disabled={disabled}\n {...(label ? { \"aria-label\": label, \"data-tooltip\": title ?? label } : {})}\n {...(isChecked === undefined ? {} : { \"aria-pressed\": isChecked })}\n {...(isActive ? { \"aria-current\": true as const } : {})}\n onClick={onClick}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n >\n {children}\n </button>\n )\n}\n\nexport interface TLUiButtonIconProps {\n icon: string\n small?: boolean\n invertIcon?: boolean\n className?: string\n}\n\n/** The icon slot inside a {@link TldrawUiButton}. Decorative: never labelled. */\nexport function TldrawUiButtonIcon({ icon, small, invertIcon, className }: TLUiButtonIconProps) {\n return <TldrawUiIcon icon={icon} {...(small ? { small } : {})} {...(invertIcon ? { invertIcon } : {})} className={[\"mocanvas-btn-icon\", className].filter(Boolean).join(\" \")} />\n}\n\nexport interface TLUiButtonLabelProps {\n className?: string\n children?: ReactNode\n}\n\n/** The text slot inside a {@link TldrawUiButton}. */\nexport function TldrawUiButtonLabel({ className, children }: TLUiButtonLabelProps) {\n return <span className={[\"mocanvas-btn-label\", className].filter(Boolean).join(\" \")}>{children}</span>\n}\n\nexport interface TLUiButtonCheckProps {\n checked: boolean\n className?: string\n}\n\n/**\n * The tick at the end of a checkbox menu row.\n *\n * Always rendered, invisible when unchecked, so the row's label does not shift\n * sideways as it is toggled. `aria-hidden` because the row itself already\n * carries `aria-checked`.\n */\nexport function TldrawUiButtonCheck({ checked, className }: TLUiButtonCheckProps) {\n return (\n <span\n className={[\"mocanvas-btn-check\", className].filter(Boolean).join(\" \")}\n data-checked={checked}\n aria-hidden=\"true\"\n style={{ visibility: checked ? \"visible\" : \"hidden\", display: \"inline-flex\" }}\n >\n <TldrawUiIcon icon=\"check\" small />\n </span>\n )\n}\n","/**\n * Floating layers shared by the default UI: the tooltip and the popover.\n *\n * Both are `position: fixed` and clamped to the viewport. Absolutely positioned\n * versions cannot do either job: a tooltip on the leftmost zoom button runs off\n * the left edge of the window, and anything anchored inside the style panel is\n * clipped by that panel's own scroll container.\n */\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState, type ReactNode, type RefObject } from \"react\"\n\n/** Gap between an anchor and the layer floating beside it. */\nconst GAP = 8\n/** Smallest distance a floating layer keeps from the viewport edge. */\nconst EDGE = 8\n\nexport interface Placement {\n left: number\n top: number\n}\n\n/**\n * Centre `box` on `anchor`, on the preferred side if it fits there and on the\n * other side if it does not, then clamp the result inside the viewport.\n */\nexport function placeNear(anchor: DOMRect, box: { width: number; height: number }, prefer: \"above\" | \"below\", vw: number, vh: number): Placement {\n const above = anchor.top - box.height - GAP\n const below = anchor.bottom + GAP\n let top = prefer === \"above\" ? above : below\n if (prefer === \"above\" && above < EDGE && below + box.height <= vh - EDGE) top = below\n if (prefer === \"below\" && below + box.height > vh - EDGE && above >= EDGE) top = above\n top = Math.min(Math.max(top, EDGE), Math.max(EDGE, vh - box.height - EDGE))\n let left = anchor.left + anchor.width / 2 - box.width / 2\n left = Math.min(Math.max(left, EDGE), Math.max(EDGE, vw - box.width - EDGE))\n return { left, top }\n}\n\nfunction useClamped(getAnchor: () => DOMRect | null, prefer: \"above\" | \"below\", deps: unknown[]): [RefObject<HTMLDivElement | null>, Placement | null] {\n const ref = useRef<HTMLDivElement>(null)\n const [pos, setPos] = useState<Placement | null>(null)\n useLayoutEffect(() => {\n const el = ref.current\n const anchor = getAnchor()\n if (!el || !anchor) {\n setPos(null)\n return\n }\n const box = el.getBoundingClientRect()\n setPos(placeNear(anchor, box, prefer, window.innerWidth, window.innerHeight))\n // getAnchor is recreated per render on purpose; the caller's deps drive this.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps)\n return [ref, pos]\n}\n\n// ---------------------------------------------------------------------------\n// Tooltip\n// ---------------------------------------------------------------------------\n\ninterface TipState {\n label: string\n shortcut: string | null\n anchor: DOMRect\n}\n\n/** How long the pointer must rest on a control before its tooltip appears. */\nconst HOVER_DELAY = 500\n\n/**\n * The single tooltip for the whole UI. Mount it once; it labels any element\n * carrying `data-tooltip` (and, optionally, `data-shortcut`) by delegation, so\n * buttons stay plain buttons.\n */\nexport function UiTooltip() {\n const [tip, setTip] = useState<TipState | null>(null)\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n\n const clear = useCallback(() => {\n clearTimeout(timer.current)\n setTip(null)\n }, [])\n\n useEffect(() => {\n const read = (el: HTMLElement): TipState | null => {\n const label = el.dataset[\"tooltip\"]\n if (!label) return null\n return { label, shortcut: el.dataset[\"shortcut\"] ?? null, anchor: el.getBoundingClientRect() }\n }\n const target = (e: Event): HTMLElement | null => {\n const el = (e.target as HTMLElement | null)?.closest?.<HTMLElement>(\"[data-tooltip]\")\n if (!el || el.matches(\":disabled\") || el.getAttribute(\"aria-disabled\") === \"true\") return null\n return el\n }\n const onOver = (e: PointerEvent) => {\n const el = target(e)\n clearTimeout(timer.current)\n if (!el) {\n setTip(null)\n return\n }\n timer.current = setTimeout(() => setTip(read(el)), HOVER_DELAY)\n }\n // Keyboard focus is deliberate, so it skips the hover delay.\n const onFocus = (e: FocusEvent) => {\n const el = target(e)\n clearTimeout(timer.current)\n setTip(el && el.matches(\":focus-visible\") ? read(el) : null)\n }\n document.addEventListener(\"pointerover\", onOver, true)\n document.addEventListener(\"pointerdown\", clear, true)\n document.addEventListener(\"focusin\", onFocus, true)\n document.addEventListener(\"focusout\", clear, true)\n window.addEventListener(\"scroll\", clear, true)\n return () => {\n clearTimeout(timer.current)\n document.removeEventListener(\"pointerover\", onOver, true)\n document.removeEventListener(\"pointerdown\", clear, true)\n document.removeEventListener(\"focusin\", onFocus, true)\n document.removeEventListener(\"focusout\", clear, true)\n window.removeEventListener(\"scroll\", clear, true)\n }\n }, [clear])\n\n // Above the control by default, so the tooltip never covers what it names.\n const [ref, pos] = useClamped(() => tip?.anchor ?? null, \"above\", [tip])\n if (!tip) return null\n return (\n <div\n ref={ref}\n className=\"mocanvas-tooltip mocanvas-layer\"\n role=\"tooltip\"\n style={pos ? { left: pos.left, top: pos.top } : { left: 0, top: 0, visibility: \"hidden\" }}\n >\n {tip.label}\n {tip.shortcut ? <kbd>{tip.shortcut}</kbd> : null}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Popover\n// ---------------------------------------------------------------------------\n\nexport interface PopoverProps {\n /** The control the popover belongs to; also the click target that keeps it open. */\n anchorRef: RefObject<HTMLElement | null>\n open: boolean\n onClose: () => void\n label: string\n /** Columns in the popover grid. */\n cols?: number\n prefer?: \"above\" | \"below\"\n children: ReactNode\n}\n\n/** A dismissable floating grid anchored to a button. */\nexport function Popover({ anchorRef, open, onClose, label, cols = 5, prefer = \"above\", children }: PopoverProps) {\n const [ref, pos] = useClamped(() => anchorRef.current?.getBoundingClientRect() ?? null, prefer, [open, anchorRef])\n\n useEffect(() => {\n if (!open) return\n const onDown = (e: PointerEvent) => {\n const t = e.target as Node\n if (ref.current?.contains(t) || anchorRef.current?.contains(t)) return\n onClose()\n }\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.stopPropagation()\n onClose()\n anchorRef.current?.focus()\n }\n }\n document.addEventListener(\"pointerdown\", onDown, true)\n document.addEventListener(\"keydown\", onKey, true)\n return () => {\n document.removeEventListener(\"pointerdown\", onDown, true)\n document.removeEventListener(\"keydown\", onKey, true)\n }\n }, [open, onClose, anchorRef, ref])\n\n if (!open) return null\n return (\n <div\n ref={ref}\n className=\"mocanvas-popover mocanvas-layer\"\n role=\"menu\"\n aria-label={label}\n style={{\n [\"--mocanvas-popover-cols\" as string]: cols,\n ...(pos ? { left: pos.left, top: pos.top } : { left: 0, top: 0, visibility: \"hidden\" as const }),\n }}\n onPointerDown={(e) => e.stopPropagation()}\n >\n {children}\n </div>\n )\n}\n","import { EditorPortal } from \"@mocanvas/editor\"\nimport { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from \"react\"\nimport { placeNear, type Placement } from \"./overlays\"\n\n/**\n * The mechanics every floating layer in the chrome shares: position beside an\n * anchor, stay inside the viewport, close on Escape or an outside click, and\n * hand focus back to the anchor when it closes.\n *\n * Factored out because getting any one of those wrong is invisible in the\n * common case and infuriating in the uncommon one — a menu that opens off the\n * bottom of a short window, or that drops focus into the void when dismissed.\n */\n\nexport type Side = \"above\" | \"below\"\n\n/**\n * How a layer learns about the layers opened from inside it.\n *\n * Every floating layer is portalled to the same place, so a submenu is a\n * *sibling* of the menu that opened it, not a descendant. A dismiss check\n * written as \"did the press land inside me?\" therefore answers no for a press\n * on the submenu's own rows — and closes the whole menu on pointer-down,\n * before the click that would have chosen the row ever happens. Every submenu\n * item in the chrome was unreachable for exactly this reason.\n *\n * A layer registers its element with the layer it was opened from (and, up\n * the chain, with that layer's own parent), so \"inside me\" can mean \"inside\n * me or anything I opened\".\n */\nexport interface TLUiLayerNesting {\n /** Register a nested layer's element. Returns the un-register. */\n register(node: HTMLElement): () => void\n /** Whether `target` is inside a layer opened from this one. */\n containsNested(target: Node): boolean\n}\n\nconst LayerNestingContext = createContext<TLUiLayerNesting | null>(null)\n\n/** The nesting handle a layer publishes to whatever it renders inside it. */\nfunction useLayerNesting(): TLUiLayerNesting {\n const parent = useContext(LayerNestingContext)\n const nested = useRef<Set<HTMLElement>>(new Set())\n return useMemo<TLUiLayerNesting>(\n () => ({\n register(node) {\n nested.current.add(node)\n // Forward upwards, so a press two submenus deep still counts as\n // inside the menu at the top.\n const releaseParent = parent?.register(node)\n return () => {\n nested.current.delete(node)\n releaseParent?.()\n }\n },\n containsNested(target) {\n for (const node of nested.current) if (node.contains(target)) return true\n return false\n },\n }),\n [parent],\n )\n}\n\n/** Position an element beside `anchor` once it has been measured. */\nexport function useAnchoredPosition(\n anchorRef: RefObject<HTMLElement | null>,\n open: boolean,\n prefer: Side,\n): [RefObject<HTMLDivElement | null>, Placement | null] {\n const ref = useRef<HTMLDivElement>(null)\n const [pos, setPos] = useState<Placement | null>(null)\n useLayoutEffect(() => {\n const el = ref.current\n const anchor = anchorRef.current?.getBoundingClientRect() ?? null\n if (!open || !el || !anchor) {\n setPos(null)\n return\n }\n const box = el.getBoundingClientRect()\n setPos(placeNear(anchor, box, prefer, window.innerWidth, window.innerHeight))\n }, [open, prefer, anchorRef])\n return [ref, pos]\n}\n\n/**\n * Close on Escape or on a pointer press outside both the layer and its anchor.\n *\n * Listens in the capture phase so it wins against a canvas handler that would\n * otherwise start a gesture on the same press.\n */\nexport function useDismissable(\n open: boolean,\n layerRef: RefObject<HTMLElement | null>,\n anchorRef: RefObject<HTMLElement | null>,\n onClose: () => void,\n /** Also treat these as \"inside\": the layers this one opened. */\n containsNested?: (target: Node) => boolean,\n): void {\n useEffect(() => {\n if (!open) return\n const onDown = (event: PointerEvent) => {\n const target = event.target as Node\n if (layerRef.current?.contains(target) || anchorRef.current?.contains(target)) return\n if (containsNested?.(target)) return\n onClose()\n }\n const onKey = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\") return\n // Escape inside a field reverts the field. The layer only closes once\n // there is nothing left in it that owns the key.\n if (isTypingTarget(event.target)) return\n // Escape closes the innermost layer only: one press should back out of\n // a submenu, not out of the menu it lives in.\n if (containsNested?.(event.target as Node)) return\n event.stopPropagation()\n onClose()\n anchorRef.current?.focus()\n }\n document.addEventListener(\"pointerdown\", onDown, true)\n document.addEventListener(\"keydown\", onKey, true)\n return () => {\n document.removeEventListener(\"pointerdown\", onDown, true)\n document.removeEventListener(\"keydown\", onKey, true)\n }\n }, [open, layerRef, anchorRef, onClose, containsNested])\n}\n\n/** Everything inside a floating layer that the keyboard can reach. */\nconst FOCUSABLE = '[role=\"menuitem\"],[role=\"menuitemcheckbox\"],[role=\"menuitemradio\"],[role=\"option\"],button:not([disabled]),a[href],input:not([disabled])'\n\n/**\n * Whether a key press is being typed into a field.\n *\n * A menu that holds a text field — the page menu's rename row — has to stop\n * being a menu for as long as the caret is in it: Home, End and the arrows\n * belong to the text, and Escape means \"undo this edit\" rather than \"close\n * everything\". Without this the field is unusable inside the layer that\n * contains it.\n */\nfunction isTypingTarget(target: EventTarget | null): boolean {\n const el = target as HTMLElement | null\n if (!el || typeof el.tagName !== \"string\") return false\n return el.tagName === \"INPUT\" || el.tagName === \"TEXTAREA\" || el.isContentEditable === true\n}\n\n/**\n * Roving focus inside a menu: Up/Down move, Home/End jump, and focus lands on\n * the first item when the menu opens.\n *\n * A menu whose items cannot be reached with the arrow keys is not a menu — it\n * is a set of buttons that happen to be in a box — so this is wired into every\n * floating layer rather than left to each one.\n */\nexport function useMenuKeyboard(open: boolean, layerRef: RefObject<HTMLElement | null>): void {\n useEffect(() => {\n if (!open) return\n const layer = layerRef.current\n if (!layer) return\n const items = () => Array.from(layer.querySelectorAll<HTMLElement>(FOCUSABLE))\n const first = items()[0]\n first?.focus()\n const onKey = (event: KeyboardEvent) => {\n if (isTypingTarget(event.target)) return\n const list = items()\n if (list.length === 0) return\n const index = list.indexOf(layer.ownerDocument.activeElement as HTMLElement)\n if (event.key === \"ArrowDown\" || event.key === \"ArrowRight\") {\n event.preventDefault()\n list[(index + 1) % list.length]?.focus()\n } else if (event.key === \"ArrowUp\" || event.key === \"ArrowLeft\") {\n event.preventDefault()\n list[(index - 1 + list.length) % list.length]?.focus()\n } else if (event.key === \"Home\") {\n event.preventDefault()\n list[0]?.focus()\n } else if (event.key === \"End\") {\n event.preventDefault()\n list[list.length - 1]?.focus()\n }\n }\n layer.addEventListener(\"keydown\", onKey)\n return () => layer.removeEventListener(\"keydown\", onKey)\n }, [open, layerRef])\n}\n\nexport interface FloatingLayerProps {\n anchorRef: RefObject<HTMLElement | null>\n open: boolean\n onClose(): void\n prefer?: Side\n role?: string\n label?: string\n className?: string\n /** Wire up arrow-key navigation. Off for a layer that is not a menu. */\n keyboardNav?: boolean\n children?: ReactNode\n}\n\n/**\n * A positioned, dismissable layer portalled into the editor's container.\n *\n * Portalled rather than rendered in place so it escapes the `overflow: hidden`\n * of whatever panel opened it, while staying inside the container that carries\n * the theme's CSS custom properties.\n */\nexport function FloatingLayer({\n anchorRef,\n open,\n onClose,\n prefer = \"below\",\n role = \"menu\",\n label,\n className,\n keyboardNav = true,\n children,\n}: FloatingLayerProps) {\n const [ref, pos] = useAnchoredPosition(anchorRef, open, prefer)\n const parent = useContext(LayerNestingContext)\n const nesting = useLayerNesting()\n useDismissable(open, ref, anchorRef, onClose, nesting.containsNested)\n useMenuKeyboard(keyboardNav && open, ref)\n // Tell the layer we were opened from that we exist, so a press on our rows\n // does not read to it as a press outside itself.\n useEffect(() => {\n const node = ref.current\n if (!open || !node || !parent) return\n return parent.register(node)\n }, [open, parent, ref])\n if (!open) return null\n return (\n <EditorPortal>\n <div\n ref={ref}\n className={[\"mocanvas-layer\", className].filter(Boolean).join(\" \")}\n role={role}\n {...(label ? { \"aria-label\": label } : {})}\n style={pos ? { position: \"fixed\", left: pos.left, top: pos.top } : { position: \"fixed\", left: 0, top: 0, visibility: \"hidden\" }}\n onPointerDown={(event) => event.stopPropagation()}\n >\n <LayerNestingContext.Provider value={nesting}>{children}</LayerNestingContext.Provider>\n </div>\n </EditorPortal>\n )\n}\n","import { createContext, useCallback, useContext, useId, useMemo, useRef, useState, type ReactNode, type RefObject } from \"react\"\nimport { FloatingLayer } from \"./ui-floating\"\nimport { TldrawUiButtonCheck } from \"./ui-button\"\nimport { TldrawUiIcon } from \"./ui-icon\"\n\n/**\n * The dropdown menu: root, trigger, content, and the rows that go in it.\n *\n * Ten components because a menu is genuinely ten things — a checkbox row is\n * not a link row is not a submenu trigger, and each has a different ARIA role.\n * Collapsing them into one `<MenuItem type=\"checkbox\">` would move that\n * distinction into a prop and make it easy to get wrong.\n */\n\ninterface MenuContextValue {\n id: string\n open: boolean\n setOpen(open: boolean): void\n anchorRef: RefObject<HTMLElement | null>\n}\n\nconst DropdownContext = createContext<MenuContextValue | null>(null)\n\nfunction useDropdown(component: string): MenuContextValue {\n const value = useContext(DropdownContext)\n if (!value) throw new Error(`${component}: render inside <TldrawUiDropdownMenuRoot>.`)\n return value\n}\n\nexport interface TLUiDropdownMenuRootProps {\n id?: string\n open?: boolean\n onOpenChange?(open: boolean): void\n /** Sets `modal` on the content: a modal menu traps focus until dismissed. */\n modal?: boolean\n children?: ReactNode\n}\n\n/** The pair's root. Owns the open state unless the caller controls it. */\nexport function TldrawUiDropdownMenuRoot({ id, open: controlled, onOpenChange, children }: TLUiDropdownMenuRootProps) {\n const generated = useId()\n const [uncontrolled, setUncontrolled] = useState(false)\n const anchorRef = useRef<HTMLElement | null>(null)\n const open = controlled ?? uncontrolled\n const setOpen = useCallback(\n (next: boolean) => {\n if (controlled === undefined) setUncontrolled(next)\n onOpenChange?.(next)\n },\n [controlled, onOpenChange],\n )\n const value = useMemo<MenuContextValue>(() => ({ id: id ?? generated, open, setOpen, anchorRef }), [id, generated, open, setOpen])\n return <DropdownContext.Provider value={value}>{children}</DropdownContext.Provider>\n}\n\nexport interface TLUiDropdownMenuTriggerProps {\n className?: string\n /** Accessible name, when the trigger's content is an icon alone. */\n label?: string\n children?: ReactNode\n}\n\n/** The control that opens the menu. */\nexport function TldrawUiDropdownMenuTrigger({ className, label, children }: TLUiDropdownMenuTriggerProps) {\n const { id, open, setOpen, anchorRef } = useDropdown(\"TldrawUiDropdownMenuTrigger\")\n return (\n <button\n ref={(node) => {\n anchorRef.current = node\n }}\n type=\"button\"\n className={[\"mocanvas-btn\", className].filter(Boolean).join(\" \")}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-controls={`${id}-content`}\n {...(label ? { \"aria-label\": label, \"data-tooltip\": label } : {})}\n onClick={() => setOpen(!open)}\n onKeyDown={(event) => {\n if (event.key === \"ArrowDown\" && !open) {\n event.preventDefault()\n setOpen(true)\n }\n }}\n >\n {children}\n </button>\n )\n}\n\nexport interface TLUiDropdownMenuContentProps {\n label?: string\n className?: string\n side?: \"above\" | \"below\"\n /** Alignment against the trigger. Kept for API parity; layers are centred. */\n align?: \"start\" | \"center\" | \"end\"\n /** Distance from the trigger, in px. Kept for API parity. */\n sideOffset?: number\n alignOffset?: number\n children?: ReactNode\n}\n\n/** The menu panel. */\nexport function TldrawUiDropdownMenuContent({ label, className, side = \"below\", children }: TLUiDropdownMenuContentProps) {\n const ctx = useDropdown(\"TldrawUiDropdownMenuContent\")\n const close = useCallback(() => ctx.setOpen(false), [ctx])\n return (\n <FloatingLayer\n anchorRef={ctx.anchorRef}\n open={ctx.open}\n onClose={close}\n prefer={side}\n role=\"menu\"\n className={[\"mocanvas-menu\", className].filter(Boolean).join(\" \")}\n {...(label ? { label } : {})}\n >\n <div id={`${ctx.id}-content`} className=\"mocanvas-menu-list\">\n {children}\n </div>\n </FloatingLayer>\n )\n}\n\nexport interface TLUiDropdownMenuGroupProps {\n label?: string\n className?: string\n children?: ReactNode\n}\n\n/**\n * A run of related rows.\n *\n * `role=\"group\"` with a label, so a screen reader says which section it is in\n * rather than reading twenty undifferentiated rows.\n */\nexport function TldrawUiDropdownMenuGroup({ label, className, children }: TLUiDropdownMenuGroupProps) {\n return (\n <div className={[\"mocanvas-menu-group\", className].filter(Boolean).join(\" \")} role=\"group\" {...(label ? { \"aria-label\": label } : {})}>\n {children}\n </div>\n )\n}\n\nexport interface TLUiDropdownMenuItemProps {\n /** Close the menu after selecting. Defaults to `true`. */\n closeOnSelect?: boolean\n disabled?: boolean\n className?: string\n onSelect?(): void\n children?: ReactNode\n}\n\n/** A plain row. */\nexport function TldrawUiDropdownMenuItem({ closeOnSelect = true, disabled, className, onSelect, children }: TLUiDropdownMenuItemProps) {\n const ctx = useContext(DropdownContext)\n return (\n <button\n type=\"button\"\n role=\"menuitem\"\n className={[\"mocanvas-menu-item\", className].filter(Boolean).join(\" \")}\n disabled={disabled}\n onClick={() => {\n onSelect?.()\n if (closeOnSelect) ctx?.setOpen(false)\n }}\n >\n {children}\n </button>\n )\n}\n\nexport interface TLUiDropdownMenuCheckboxItemProps {\n checked: boolean\n disabled?: boolean\n title?: string\n className?: string\n onSelect?(): void\n children?: ReactNode\n}\n\n/** A row that toggles. Stays open on select, because toggles come in runs. */\nexport function TldrawUiDropdownMenuCheckboxItem({ checked, disabled, title, className, onSelect, children }: TLUiDropdownMenuCheckboxItemProps) {\n return (\n <button\n type=\"button\"\n role=\"menuitemcheckbox\"\n aria-checked={checked}\n className={[\"mocanvas-menu-item\", className].filter(Boolean).join(\" \")}\n disabled={disabled}\n {...(title ? { \"data-tooltip\": title } : {})}\n onClick={() => onSelect?.()}\n >\n {children}\n <TldrawUiButtonCheck checked={checked} />\n </button>\n )\n}\n\n/** The dot marking the chosen entry in a radio group. */\nexport function TldrawUiDropdownMenuIndicator() {\n return <span className=\"mocanvas-menu-indicator\" aria-hidden=\"true\" />\n}\n\nconst SubContext = createContext<MenuContextValue | null>(null)\n\nexport interface TLUiDropdownMenuSubProps {\n id?: string\n open?: boolean\n onOpenChange?(open: boolean): void\n children?: ReactNode\n}\n\n/** A nested menu's root. */\nexport function TldrawUiDropdownMenuSub({ id, open: controlled, onOpenChange, children }: TLUiDropdownMenuSubProps) {\n const generated = useId()\n const [uncontrolled, setUncontrolled] = useState(false)\n const anchorRef = useRef<HTMLElement | null>(null)\n const open = controlled ?? uncontrolled\n const setOpen = useCallback(\n (next: boolean) => {\n if (controlled === undefined) setUncontrolled(next)\n onOpenChange?.(next)\n },\n [controlled, onOpenChange],\n )\n const value = useMemo<MenuContextValue>(() => ({ id: id ?? generated, open, setOpen, anchorRef }), [id, generated, open, setOpen])\n return <SubContext.Provider value={value}>{children}</SubContext.Provider>\n}\n\nexport interface TLUiDropdownMenuSubTriggerProps {\n label: string\n /** Marks the submenu as containing the active choice. */\n \"data-testid\"?: string\n disabled?: boolean\n className?: string\n children?: ReactNode\n}\n\n/**\n * The row that opens a nested menu.\n *\n * Right arrow opens it and left arrow closes it, which is the convention every\n * platform menu follows — an arrow key that does nothing here reads as the\n * submenu being unreachable.\n */\nexport function TldrawUiDropdownMenuSubTrigger({ label, disabled, className, children }: TLUiDropdownMenuSubTriggerProps) {\n const ctx = useContext(SubContext)\n return (\n <button\n ref={(node) => {\n if (ctx) ctx.anchorRef.current = node\n }}\n type=\"button\"\n role=\"menuitem\"\n aria-haspopup=\"menu\"\n aria-expanded={ctx?.open ?? false}\n className={[\"mocanvas-menu-item\", \"mocanvas-menu-item--sub\", className].filter(Boolean).join(\" \")}\n disabled={disabled}\n onClick={() => ctx?.setOpen(!ctx.open)}\n onKeyDown={(event) => {\n if (event.key === \"ArrowRight\") {\n event.preventDefault()\n event.stopPropagation()\n ctx?.setOpen(true)\n } else if (event.key === \"ArrowLeft\" && ctx?.open) {\n event.preventDefault()\n event.stopPropagation()\n ctx.setOpen(false)\n }\n }}\n >\n {children ?? label}\n <TldrawUiIcon icon=\"chevron-down\" small />\n </button>\n )\n}\n\nexport interface TLUiDropdownMenuSubContentProps {\n label?: string\n className?: string\n alignOffset?: number\n sideOffset?: number\n children?: ReactNode\n}\n\n/** A nested menu's panel. */\nexport function TldrawUiDropdownMenuSubContent({ label, className, children }: TLUiDropdownMenuSubContentProps) {\n const ctx = useContext(SubContext)\n const close = useCallback(() => ctx?.setOpen(false), [ctx])\n if (!ctx) return null\n return (\n <FloatingLayer\n anchorRef={ctx.anchorRef}\n open={ctx.open}\n onClose={close}\n prefer=\"below\"\n role=\"menu\"\n className={[\"mocanvas-menu\", \"mocanvas-menu--sub\", className].filter(Boolean).join(\" \")}\n {...(label ? { label } : {})}\n >\n <div id={`${ctx.id}-content`} className=\"mocanvas-menu-list\">\n {children}\n </div>\n </FloatingLayer>\n )\n}\n","import type { ReactNode } from \"react\"\n\n/**\n * A keyboard shortcut, rendered.\n *\n * Takes the shortcut in the same `\"mod+shift+z\"` notation the tool and action\n * items carry, so a menu row can pass an item's `kbd` straight through instead\n * of every call site formatting it.\n */\nexport interface TLUiKbdProps {\n /** `\"mod+z\"`, `\"shift+r\"`, `\"?\"`. Comma-separated alternatives: only the first is shown. */\n children?: ReactNode\n /** Force Apple-style glyphs. Detected from the platform when omitted. */\n isApple?: boolean\n className?: string\n}\n\nconst APPLE = {\n mod: \"⌘\",\n cmd: \"⌘\",\n alt: \"⌥\",\n opt: \"⌥\",\n shift: \"⇧\",\n ctrl: \"⌃\",\n enter: \"↵\",\n backspace: \"⌫\",\n del: \"⌦\",\n esc: \"⎋\",\n tab: \"⇥\",\n up: \"↑\",\n down: \"↓\",\n left: \"←\",\n right: \"→\",\n} as const\n\nconst OTHER = {\n mod: \"Ctrl\",\n cmd: \"Ctrl\",\n alt: \"Alt\",\n opt: \"Alt\",\n shift: \"Shift\",\n ctrl: \"Ctrl\",\n enter: \"Enter\",\n backspace: \"Backspace\",\n del: \"Delete\",\n esc: \"Esc\",\n tab: \"Tab\",\n up: \"↑\",\n down: \"↓\",\n left: \"←\",\n right: \"→\",\n} as const\n\nfunction isApplePlatform(): boolean {\n if (typeof navigator === \"undefined\") return false\n return /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || \"\")\n}\n\n/**\n * Split a shortcut into the keys to draw.\n *\n * Only the first comma-separated alternative is shown: a tool bound to\n * `\"d,p,b\"` has one shortcut as far as the user is concerned, and printing\n * three would suggest a chord.\n */\nexport function kbdToKeys(kbd: string, isApple = isApplePlatform()): string[] {\n const table: Record<string, string> = isApple ? APPLE : OTHER\n const first = (kbd.split(\",\")[0] ?? \"\").trim()\n if (first === \"\") return []\n return first\n .split(\"+\")\n .map((part) => part.trim())\n .filter(Boolean)\n .map((part) => table[part.toLowerCase()] ?? (part.length === 1 ? part.toUpperCase() : part))\n}\n\n/**\n * A shortcut as a row of `<kbd>` elements.\n *\n * `aria-hidden`: the shortcut is already on the control it belongs to, via\n * `aria-keyshortcuts`, and reading the glyphs out as text (\"command shift Z\"\n * rendered as three separate symbols) is noise.\n */\nexport function TldrawUiKbd({ children, isApple, className }: TLUiKbdProps) {\n const raw = typeof children === \"string\" ? children : String(children ?? \"\")\n const keys = kbdToKeys(raw, isApple ?? isApplePlatform())\n if (keys.length === 0) return null\n return (\n <span className={[\"mocanvas-kbd\", className].filter(Boolean).join(\" \")} aria-hidden=\"true\">\n {keys.map((key, i) => (\n <kbd key={`${key}-${i}`}>{key}</kbd>\n ))}\n </span>\n )\n}\n","import { useEditor, useValue, type SharedStyleMap } from \"@mocanvas/editor\"\n\n/**\n * The reactive predicates the chrome branches on.\n *\n * Each one is a thin `useValue` over the editor. They exist as named hooks\n * rather than inline reads so a menu item's enabled/disabled rule is written\n * once — `useCanApplySelectionAction()` is the same question in twelve places,\n * and twelve slightly different inline versions of it is how a menu ends up\n * with one row that greys out on a locked shape and eleven that do not.\n */\n\n/** Whether there is anything to undo. */\nexport function useCanUndo(): boolean {\n const editor = useEditor()\n return useValue(\"canUndo\", () => editor.getCanUndo(), [editor])\n}\n\n/** Whether there is anything to redo. */\nexport function useCanRedo(): boolean {\n const editor = useEditor()\n return useValue(\"canRedo\", () => editor.getCanRedo(), [editor])\n}\n\n/** Whether the editor refuses document edits. */\nexport function useReadonly(): boolean {\n const editor = useEditor()\n return useValue(\"isReadonly\", () => editor.getIsReadonly(), [editor])\n}\n\n/** How many of the selected shapes can actually be changed. */\nexport function useUnlockedSelectedShapesCount(min = 1): boolean {\n const editor = useEditor()\n return useValue(\"unlockedSelectedShapes\", () => editor.getSelectedShapes().filter((shape) => !shape.isLocked).length >= min, [editor, min])\n}\n\n/**\n * Whether an action that edits the selection can run: the editor is writable\n * and at least one selected shape is unlocked.\n *\n * The two halves are checked together because either alone is misleading — a\n * writable editor with a locked selection, or an unlocked selection in a\n * read-only editor, both mean \"no\".\n */\nexport function useCanApplySelectionAction(): boolean {\n const readonly = useReadonly()\n const hasUnlocked = useUnlockedSelectedShapesCount(1)\n return !readonly && hasUnlocked\n}\n\n/** Whether the current page has any locked shapes to unlock. */\nexport function useHasLockedShapes(): boolean {\n const editor = useEditor()\n return useValue(\"hasLockedShapes\", () => editor.getCurrentPageShapes().some((shape) => shape.isLocked), [editor])\n}\n\n/** Whether the grid is on. */\nexport function useIsGridMode(): boolean {\n const editor = useEditor()\n return useValue(\"isGridMode\", () => editor.getInstanceState().isGridMode, [editor])\n}\n\n/** Whether the editor is in dark mode right now. */\nexport function useIsDarkMode(): boolean {\n const editor = useEditor()\n return useValue(\"isDarkMode\", () => editor.getColorMode() === \"dark\", [editor])\n}\n\n/**\n * The styles the style panel should offer, and their shared values.\n *\n * With a selection this is what the selected shapes have in common; with\n * nothing selected it is what the active tool is about to create. `null` means\n * there is nothing to show — which a panel renders as nothing at all, rather\n * than as an empty frame.\n */\nexport function useRelevantStyles(): SharedStyleMap | null {\n const editor = useEditor()\n return useValue(\n \"relevantStyles\",\n () => {\n const styles = editor.getSharedStyles()\n if (styles.size === 0 && editor.getSelectedShapeIds().length > 0) return null\n return styles.size === 0 ? null : styles\n },\n [editor],\n )\n}\n\n/**\n * Whether an action can run right now, and whether it is on.\n *\n * The action list is built once per editor (see `buildDefaultActionItems`), so\n * an item cannot carry its own availability without freezing it. This is where\n * that question is answered instead: reactively, at the point of render, so a\n * menu row greys out the moment the selection stops supporting it.\n *\n * An action with no rule here is always enabled and never checked, which is\n * the right default for an app's own action: mocanvas knows nothing about when\n * it applies, and guessing \"disabled\" would make a working item look broken.\n */\nexport function useActionState(actionId: string): { disabled: boolean; checked: boolean } {\n const editor = useEditor()\n return useValue(\n \"actionState\",\n () => {\n const readonly = editor.getIsReadonly()\n const shapes = editor.getSelectedShapes()\n const unlocked = shapes.filter((shape) => !shape.isLocked).length\n const instance = editor.getInstanceState()\n const user = editor.user\n\n /** An action that edits the selection. */\n const edits = (min: number) => ({ disabled: readonly || unlocked < min, checked: false })\n\n switch (actionId) {\n case \"undo\":\n return { disabled: !editor.getCanUndo(), checked: false }\n case \"redo\":\n return { disabled: !editor.getCanRedo(), checked: false }\n case \"zoom-to-selection\":\n case \"select-none\":\n return { disabled: shapes.length === 0, checked: false }\n case \"delete\":\n case \"duplicate\":\n case \"toggle-lock\":\n case \"rotate-cw\":\n case \"rotate-ccw\":\n case \"bring-to-front\":\n case \"bring-forward\":\n case \"send-backward\":\n case \"send-to-back\":\n case \"flip-horizontal\":\n case \"flip-vertical\":\n return edits(1)\n case \"group\":\n case \"align-left\":\n case \"align-center-horizontal\":\n case \"align-right\":\n case \"align-top\":\n case \"align-center-vertical\":\n case \"align-bottom\":\n case \"stretch-horizontal\":\n case \"stretch-vertical\":\n return edits(2)\n case \"distribute-horizontal\":\n case \"distribute-vertical\":\n case \"stack-horizontal\":\n case \"stack-vertical\":\n case \"pack\":\n return edits(3)\n case \"ungroup\":\n return { disabled: readonly || !shapes.some((shape) => shape.type === \"group\"), checked: false }\n case \"unlock-all\":\n return { disabled: readonly || !editor.getCurrentPageShapes().some((shape) => shape.isLocked), checked: false }\n case \"delete-page\":\n return { disabled: readonly || editor.getPages().length < 2, checked: false }\n case \"new-page\":\n case \"duplicate-page\":\n return { disabled: readonly, checked: false }\n case \"toggle-grid\":\n return { disabled: false, checked: instance.isGridMode }\n case \"toggle-focus-mode\":\n return { disabled: false, checked: instance.isFocusMode }\n case \"toggle-debug-mode\":\n return { disabled: false, checked: instance.isDebugMode }\n case \"toggle-tool-lock\":\n return { disabled: readonly, checked: instance.isToolLocked }\n // The preference is \"transparent background\", the record is\n // \"paint a background\", so the tick is the negation.\n case \"toggle-transparent\":\n return { disabled: false, checked: !instance.exportBackground }\n case \"toggle-snap-mode\":\n return { disabled: false, checked: user.getIsSnapMode() }\n case \"toggle-wrap-mode\":\n return { disabled: false, checked: user.getIsWrapMode() }\n case \"toggle-dynamic-size-mode\":\n return { disabled: false, checked: user.getIsDynamicSizeMode() }\n case \"toggle-paste-at-cursor\":\n return { disabled: false, checked: user.getIsPasteAtCursorMode() }\n case \"toggle-edge-scrolling\":\n return { disabled: false, checked: user.getEdgeScrollSpeed() !== 0 }\n case \"toggle-reduce-motion\":\n return { disabled: false, checked: user.getAnimationSpeed() === 0 }\n case \"toggle-dark-mode\":\n return { disabled: false, checked: editor.getColorMode() === \"dark\" }\n case \"toggle-keyboard-shortcuts\":\n return { disabled: false, checked: user.getAreKeyboardShortcutsEnabled() }\n default:\n return { disabled: false, checked: false }\n }\n },\n [editor, actionId],\n )\n}\n","import { createContext, useCallback, useContext, type ReactNode } from \"react\"\nimport type { TLUiEventSource } from \"@mocanvas/editor\"\n\n/**\n * The analytics seam: one callback the whole UI reports through.\n *\n * Every piece of chrome that does something on the user's behalf announces it\n * here rather than reaching for an app's telemetry directly, so a host can\n * instrument the editor by supplying one function instead of replacing panels.\n */\n\n/**\n * The events the default chrome reports, and what each one carries beyond the\n * common `{ source }`.\n *\n * Open-ended on purpose: an app's own chrome reports its own names through the\n * same handler, so the map is what mocanvas promises to send, not a limit on\n * what may be sent.\n */\nexport interface TLUiEventMap {\n \"select-tool\": { id: string }\n \"toggle-tool-lock\": null\n \"toggle-grid-mode\": null\n \"toggle-snap-mode\": null\n \"toggle-dark-mode\": null\n \"toggle-focus-mode\": null\n \"toggle-debug-mode\": null\n \"toggle-wrap-mode\": null\n \"toggle-dynamic-size-mode\": null\n \"toggle-paste-at-cursor\": null\n \"toggle-edge-scrolling\": null\n \"toggle-reduce-motion\": null\n \"toggle-transparent\": null\n \"toggle-lock\": null\n \"toggle-auto-size\": null\n \"change-language\": { locale: string }\n \"change-page\": null\n \"change-user-name\": null\n \"delete-page\": null\n \"duplicate-page\": null\n \"move-page\": null\n \"new-page\": null\n \"rename-page\": null\n \"align-shapes\": { operation: string }\n \"distribute-shapes\": { operation: string }\n \"stack-shapes\": { operation: string }\n \"flip-shapes\": { operation: string }\n \"pack-shapes\": null\n \"stretch-shapes\": { operation: string }\n \"reorder-shapes\": { operation: string }\n \"group-shapes\": null\n \"ungroup-shapes\": null\n \"duplicate-shapes\": null\n \"delete-shapes\": null\n \"select-all-shapes\": null\n \"select-none-shapes\": null\n \"rotate-cw\": null\n \"rotate-ccw\": null\n \"edit-link\": null\n \"convert-to-embed\": null\n \"convert-to-bookmark\": null\n \"fit-frame-to-content\": null\n \"remove-frame\": null\n copy: null\n cut: null\n paste: null\n \"copy-as\": { format: string }\n \"export-as\": { format: string }\n print: null\n undo: null\n redo: null\n \"zoom-in\": null\n \"zoom-out\": null\n \"reset-zoom\": null\n \"zoom-to-fit\": null\n \"zoom-to-selection\": null\n \"open-menu\": { id: string }\n \"close-menu\": { id: string }\n \"open-url\": { url: string }\n \"set-style\": { id: string; value: unknown }\n \"insert-media\": null\n \"unlock-all\": null\n \"move-to-page\": null\n \"share-project\": null\n \"a11y-repeat-shape-announce\": null\n}\n\n/** The common half of every reported event: where the user did it. */\nexport interface TLUiEventData {\n source: TLUiEventSource\n [key: string]: unknown\n}\n\n/**\n * What a host supplies as `onUiEvent`. The name is a key of\n * {@link TLUiEventMap} for anything mocanvas reports, and any string for\n * anything an app's own chrome reports.\n */\nexport type TLUiEventHandler = (name: string, data: TLUiEventData) => void\n\nconst EventsContext = createContext<TLUiEventHandler | null>(null)\n\nexport interface EventsProviderProps {\n onEvent?: TLUiEventHandler\n children?: ReactNode\n}\n\n/** Publishes `onEvent` to {@link useUiEvents}. */\nexport function TldrawUiEventsProvider({ onEvent, children }: EventsProviderProps) {\n return <EventsContext.Provider value={onEvent ?? null}>{children}</EventsContext.Provider>\n}\n\n/**\n * Report a UI event.\n *\n * Always returns a function, so a component can call it unconditionally; with\n * no provider the call is a no-op rather than an error, which is what lets a\n * panel be rendered on its own in a test.\n */\nexport function useUiEvents(): TLUiEventHandler {\n const handler = useContext(EventsContext)\n return useCallback(\n (name: string, data: TLUiEventData) => {\n handler?.(name, data)\n },\n [handler],\n )\n}\n\n/**\n * The value {@link useUiEvents} returns — the handler an app passed as\n * `onUiEvent`, or a no-op.\n *\n * Named separately from {@link TLUiEventHandler} because they answer different\n * questions: the handler type is what an app *writes*, this is what a component\n * *reads*. They are the same function today; keeping the two names means the\n * context can gain a second member later without changing every app's handler\n * signature.\n */\nexport type TLUiEventContextType = TLUiEventHandler\n","import { getLocaleChain, resolveUiMessage, useEditor, useValue, type TLUiTranslations } from \"@mocanvas/editor\"\nimport { createContext, useContext, useMemo, type ReactNode } from \"react\"\n\n/**\n * UI strings, and the locale they are resolved in.\n *\n * mocanvas ships no dictionary of its own — its default chrome labels are\n * already display text — so this exists to give an app's chrome one lookup\n * that follows the editor's locale rather than two that disagree.\n */\n\n/** One locale's dictionary: string id to display text. */\nexport interface TLUiTranslation {\n locale: string\n label: string\n dir: \"ltr\" | \"rtl\"\n messages: Readonly<Record<string, string>>\n /**\n * The locales the host supplied a dictionary for, in the order it gave\n * them. Empty when it supplied none — which is the default, because\n * mocanvas ships no catalogues of its own.\n */\n locales?: readonly string[]\n}\n\n/**\n * A UI string id. Open (`string`) rather than a closed union: mocanvas has no\n * fixed key list, and an app registers its own ids freely.\n */\nexport type TLUiTranslationKey = string\n\n/** A language mocanvas knows how to name and lay out. */\nexport interface TLLanguage {\n readonly locale: string\n readonly label: string\n}\n\n/**\n * The languages offered in the language menu.\n *\n * SEMANTICS-ASSUMED: mocanvas ships no message catalogues, so this is a list\n * of locale *tags* an app can offer, not a claim that strings exist for them.\n * Picking one sets `user.locale`, which is what an app's own dictionary is\n * then resolved against.\n */\nexport const LANGUAGES: readonly TLLanguage[] = [\n { locale: \"ar\", label: \"العربية\" },\n { locale: \"cs\", label: \"Čeština\" },\n { locale: \"da\", label: \"Dansk\" },\n { locale: \"de\", label: \"Deutsch\" },\n { locale: \"en\", label: \"English\" },\n { locale: \"es\", label: \"Español\" },\n { locale: \"fa\", label: \"فارسی\" },\n { locale: \"fi\", label: \"Suomi\" },\n { locale: \"fr\", label: \"Français\" },\n { locale: \"he\", label: \"עברית\" },\n { locale: \"hi\", label: \"हिन्दी\" },\n { locale: \"hu\", label: \"Magyar\" },\n { locale: \"it\", label: \"Italiano\" },\n { locale: \"ja\", label: \"日本語\" },\n { locale: \"ko\", label: \"한국어\" },\n { locale: \"nl\", label: \"Nederlands\" },\n { locale: \"no\", label: \"Norsk\" },\n { locale: \"pl\", label: \"Polski\" },\n { locale: \"pt\", label: \"Português\" },\n { locale: \"ru\", label: \"Русский\" },\n { locale: \"sv\", label: \"Svenska\" },\n { locale: \"tr\", label: \"Türkçe\" },\n { locale: \"uk\", label: \"Українська\" },\n { locale: \"vi\", label: \"Tiếng Việt\" },\n { locale: \"zh\", label: \"中文\" },\n]\n\n/** Base languages written right to left. */\nexport const RTL_LANGUAGES: readonly string[] = [\"ar\", \"fa\", \"he\", \"ur\"]\n\n/**\n * The best match for a browser locale among {@link LANGUAGES}, falling back to\n * English. Takes the navigator's list so a browser configured with\n * `[\"cs-CZ\", \"en\"]` gets Czech rather than the first exact match.\n */\nexport function getDefaultTranslationLocale(locales: readonly string[] = typeof navigator === \"undefined\" ? [] : navigator.languages ?? []): string {\n for (const locale of locales) {\n for (const candidate of getLocaleChain(locale)) {\n if (LANGUAGES.some((l) => l.locale === candidate)) return candidate\n }\n }\n return \"en\"\n}\n\n/** Whether a locale is written right to left. */\nexport function isRtlLanguage(locale: string): boolean {\n return RTL_LANGUAGES.includes(locale.split(/[-_]/)[0] ?? locale)\n}\n\nconst TranslationContext = createContext<TLUiTranslation | null>(null)\n\nexport interface TLUiTranslationProviderProps {\n /** Extra dictionaries, keyed by locale then by string id. */\n overrides?: TLUiTranslations\n children?: ReactNode\n}\n\n/**\n * Resolves the editor's current locale into a {@link TLUiTranslation} and\n * publishes it. Re-resolves when the user changes locale, so a language menu\n * takes effect without remounting the chrome.\n */\nexport function TldrawUiTranslationProvider({ overrides, children }: TLUiTranslationProviderProps) {\n const editor = useEditor()\n const locale = useValue(\"ui locale\", () => editor.user.getLocale(), [editor])\n const value = useMemo<TLUiTranslation>(() => {\n const messages = overrides ? Object.assign({}, ...getLocaleChain(locale).reverse().map((l) => overrides[l] ?? {})) : {}\n // A locale counts as available only if it has strings. An empty entry is\n // a placeholder, and offering it in a language menu would promise a\n // translation that does not exist.\n const locales = overrides ? Object.keys(overrides).filter((l) => Object.keys(overrides[l] ?? {}).length > 0) : []\n return {\n locale,\n label: LANGUAGES.find((l) => l.locale === locale)?.label ?? locale,\n dir: isRtlLanguage(locale) ? \"rtl\" : \"ltr\",\n messages,\n locales,\n }\n }, [locale, overrides])\n return <TranslationContext.Provider value={value}>{children}</TranslationContext.Provider>\n}\n\n/**\n * The resolved dictionary. Throws outside a provider — a component that needs\n * the locale as well as the strings has no sensible fallback for \"no locale\".\n */\nexport function useCurrentTranslation(): TLUiTranslation {\n const value = useContext(TranslationContext)\n if (!value) throw new Error(\"useCurrentTranslation: render inside <TldrawUiTranslationProvider>.\")\n return value\n}\n\n/** The resolved dictionary, or `null` outside a provider. */\nexport function useMaybeCurrentTranslation(): TLUiTranslation | null {\n return useContext(TranslationContext)\n}\n\n/**\n * Look a string id up. An id with no entry passes through unchanged, so a\n * component may use a localized literal as its own label and still be safe to\n * render outside a provider.\n */\nexport function useTranslation(): (id: TLUiTranslationKey) => string {\n const translation = useMaybeCurrentTranslation()\n return useMemo(() => {\n if (!translation) return (id: string) => id\n const dict: TLUiTranslations = { [translation.locale]: translation.messages as Record<string, string> }\n return (id: string) => resolveUiMessage(dict, translation.locale, id)\n }, [translation])\n}\n\n/** Alias of {@link useTranslation}, spelled as the value it returns. */\nexport const useMsg = useTranslation\n\n/**\n * The languages this editor can actually be shown in.\n *\n * mocanvas ships no message catalogues — its default labels are English\n * display text — so this is the set the *host* supplied through\n * `overrides.translations`, named where {@link LANGUAGES} knows the name.\n * With no dictionaries it is empty, and a language menu built from it\n * correctly offers nothing rather than twenty-five languages that all render\n * the same English.\n */\nexport function useAvailableTranslationLocales(): readonly TLLanguage[] {\n const translation = useMaybeCurrentTranslation()\n const locales = translation?.locales\n return useMemo(\n () => (locales ?? []).map((locale) => LANGUAGES.find((l) => l.locale === locale) ?? { locale, label: locale }),\n [locales],\n )\n}\n\n/** The writing direction of the current locale; `\"ltr\"` outside a provider. */\nexport function useDirection(): \"ltr\" | \"rtl\" {\n return useMaybeCurrentTranslation()?.dir ?? \"ltr\"\n}\n\n/**\n * The value {@link useCurrentTranslation} returns: the active locale's strings.\n *\n * The name a component annotates a prop with when it is handed the translation\n * rather than reading it from context — a static renderer, say, or a test.\n */\nexport type TLUiTranslationContextType = TLUiTranslation\n","import { useActions, useEditor, useIsToolSelected, useTools, type TLUiEventSource } from \"@mocanvas/editor\"\nimport { createContext, useContext, type ReactNode } from \"react\"\nimport { TldrawUiButtonCheck } from \"./ui-button\"\nimport {\n TldrawUiDropdownMenuCheckboxItem,\n TldrawUiDropdownMenuGroup,\n TldrawUiDropdownMenuItem,\n TldrawUiDropdownMenuSub,\n TldrawUiDropdownMenuSubContent,\n TldrawUiDropdownMenuSubTrigger,\n} from \"./ui-dropdown-menu\"\nimport { TldrawUiIcon } from \"./ui-icon\"\nimport { TldrawUiKbd } from \"./ui-kbd\"\nimport { useActionState } from \"./ui-actions\"\nimport { useUiEvents } from \"./ui-events\"\nimport { useTranslation } from \"./ui-translation\"\n\n/**\n * The menu system: one set of item components that render differently\n * depending on where they are.\n *\n * This is the whole point of it. The same `CutMenuItem` appears in the main\n * menu (a row with a label and a shortcut), in the context menu (the same),\n * in the actions menu (an icon-only button in a grid) and in the shortcuts\n * dialog (a label and a key, with no click behaviour at all). Writing four\n * components for each of seventy items is not an option, so the item asks the\n * context what shape to take.\n */\n\n/** Where a menu item is being rendered. */\nexport type TLUiMenuContextType =\n /** A vertical list of rows: the main menu, the help menu. */\n | \"menu\"\n /** The right-click menu. Same shape as `menu`; kept apart so items can differ. */\n | \"context-menu\"\n /** A grid of icon-only buttons: the actions menu. */\n | \"small-icons\"\n /** A row of icon buttons: the quick actions. */\n | \"icons\"\n /** Read-only rows in the keyboard shortcuts dialog. */\n | \"keyboard-shortcuts\"\n /** The helper buttons above the toolbar. */\n | \"helper-buttons\"\n /** The tool bar. */\n | \"toolbar\"\n /** A panel's own layout, e.g. the style panel. */\n | \"panel\"\n\nconst MenuContext = createContext<{ type: TLUiMenuContextType; sourceId: TLUiEventSource }>({ type: \"menu\", sourceId: \"menu\" })\n\nexport interface TLUiMenuContextProviderProps {\n type: TLUiMenuContextType\n /** Reported to `onSelect` and to the UI event handler. */\n sourceId?: TLUiEventSource\n children?: ReactNode\n}\n\n/** Tells the items inside it what shape to take. */\nexport function TldrawUiMenuContextProvider({ type, sourceId, children }: TLUiMenuContextProviderProps) {\n const resolved: TLUiEventSource = sourceId ?? (type === \"context-menu\" ? \"context-menu\" : type === \"toolbar\" ? \"toolbar\" : \"menu\")\n return <MenuContext.Provider value={{ type, sourceId: resolved }}>{children}</MenuContext.Provider>\n}\n\n/** The menu context an item is in. */\nexport function useTldrawUiMenuContext() {\n return useContext(MenuContext)\n}\n\nexport interface TLUiMenuItemProps {\n id: string\n label?: string\n icon?: string\n kbd?: string\n title?: string\n disabled?: boolean\n /** Marks this item as the active one in a set. */\n isSelected?: boolean\n /** Keep the menu open after selecting. */\n noClose?: boolean\n /** Rendered instead of the label; for an item that needs custom content. */\n children?: ReactNode\n onSelect?(source: TLUiEventSource): void\n}\n\n/**\n * One menu item, in whatever shape its context calls for.\n *\n * `label` is display text, already localized: an id with no dictionary entry\n * resolves to itself, so passing a literal is safe.\n */\nexport function TldrawUiMenuItem({ id, label, icon, kbd, title, disabled, isSelected, noClose, children, onSelect }: TLUiMenuItemProps) {\n const { type, sourceId } = useTldrawUiMenuContext()\n const msg = useTranslation()\n const trackEvent = useUiEvents()\n const text = label === undefined ? undefined : msg(label)\n\n const select = () => {\n onSelect?.(sourceId)\n trackEvent(id, { source: sourceId })\n }\n\n switch (type) {\n case \"keyboard-shortcuts\":\n return (\n <div className=\"mocanvas-shortcut-row\" data-item={id}>\n <span className=\"mocanvas-shortcut-label\">{text ?? id}</span>\n {kbd ? <TldrawUiKbd>{kbd}</TldrawUiKbd> : null}\n </div>\n )\n case \"small-icons\":\n case \"icons\":\n case \"helper-buttons\":\n case \"toolbar\":\n return (\n <button\n type=\"button\"\n className=\"mocanvas-btn\"\n data-item={id}\n disabled={disabled}\n aria-label={text ?? id}\n data-tooltip={title ?? text ?? id}\n {...(kbd ? { \"aria-keyshortcuts\": kbd, \"data-shortcut\": kbd } : {})}\n {...(isSelected === undefined ? {} : { \"aria-pressed\": isSelected })}\n onClick={select}\n >\n {icon ? <TldrawUiIcon icon={icon} label={text ?? id} /> : (children ?? <span>{text ?? id}</span>)}\n </button>\n )\n default:\n return (\n <TldrawUiDropdownMenuItem closeOnSelect={!noClose} {...(disabled ? { disabled } : {})} onSelect={select}>\n {icon ? <TldrawUiIcon icon={icon} /> : null}\n <span className=\"mocanvas-menu-item-label\">{children ?? text ?? id}</span>\n {kbd ? <TldrawUiKbd>{kbd}</TldrawUiKbd> : null}\n </TldrawUiDropdownMenuItem>\n )\n }\n}\n\nexport interface TLUiMenuGroupProps {\n id: string\n label?: string\n className?: string\n children?: ReactNode\n}\n\n/**\n * A run of related items, with a rule between it and the next.\n *\n * Renders nothing when it has no children, so a group whose items all decided\n * not to render does not leave a stray divider behind.\n */\nexport function TldrawUiMenuGroup({ id, label, className, children }: TLUiMenuGroupProps) {\n const { type } = useTldrawUiMenuContext()\n const msg = useTranslation()\n if (type === \"small-icons\" || type === \"icons\" || type === \"toolbar\" || type === \"helper-buttons\") {\n return (\n <div className=\"mocanvas-menu-icon-group\" data-group={id} role=\"group\" {...(label ? { \"aria-label\": msg(label) } : {})}>\n {children}\n </div>\n )\n }\n return (\n <TldrawUiDropdownMenuGroup className={[\"mocanvas-menu-group\", className].filter(Boolean).join(\" \")} {...(label ? { label: msg(label) } : {})}>\n {children}\n </TldrawUiDropdownMenuGroup>\n )\n}\n\nexport interface TLUiMenuSubmenuProps {\n id: string\n label?: string\n disabled?: boolean\n size?: \"tiny\" | \"small\" | \"medium\" | \"wide\"\n children?: ReactNode\n}\n\n/**\n * A nested menu.\n *\n * Flattens into a plain group in the icon-only contexts: a grid of buttons has\n * nowhere to hang a submenu off, and hiding items behind one that cannot open\n * would lose them.\n */\nexport function TldrawUiMenuSubmenu({ id, label, disabled, children }: TLUiMenuSubmenuProps) {\n const { type } = useTldrawUiMenuContext()\n const msg = useTranslation()\n const text = label ? msg(label) : id\n if (type === \"small-icons\" || type === \"icons\" || type === \"toolbar\" || type === \"helper-buttons\" || type === \"keyboard-shortcuts\") {\n return (\n <div className=\"mocanvas-menu-icon-group\" data-group={id} role=\"group\" aria-label={text}>\n {children}\n </div>\n )\n }\n return (\n <TldrawUiDropdownMenuSub id={id}>\n <TldrawUiDropdownMenuSubTrigger label={text} {...(disabled ? { disabled } : {})} />\n <TldrawUiDropdownMenuSubContent label={text}>{children}</TldrawUiDropdownMenuSubContent>\n </TldrawUiDropdownMenuSub>\n )\n}\n\nexport interface TLUiMenuCheckboxItemProps {\n id: string\n label?: string\n icon?: string\n kbd?: string\n title?: string\n checked?: boolean\n disabled?: boolean\n /** Close the menu after toggling. Off by default: toggles come in runs. */\n toggle?: boolean\n onSelect?(source: TLUiEventSource): void\n}\n\n/** A menu item that toggles. */\nexport function TldrawUiMenuCheckboxItem({ id, label, icon, kbd, title, checked = false, disabled, onSelect }: TLUiMenuCheckboxItemProps) {\n const { type, sourceId } = useTldrawUiMenuContext()\n const msg = useTranslation()\n const trackEvent = useUiEvents()\n const text = label ? msg(label) : id\n\n const select = () => {\n onSelect?.(sourceId)\n trackEvent(id, { source: sourceId })\n }\n\n if (type === \"keyboard-shortcuts\") {\n return (\n <div className=\"mocanvas-shortcut-row\" data-item={id}>\n <span className=\"mocanvas-shortcut-label\">{text}</span>\n {kbd ? <TldrawUiKbd>{kbd}</TldrawUiKbd> : null}\n </div>\n )\n }\n if (type === \"small-icons\" || type === \"icons\" || type === \"toolbar\" || type === \"helper-buttons\") {\n return (\n <button\n type=\"button\"\n className=\"mocanvas-btn\"\n data-item={id}\n role=\"checkbox\"\n aria-checked={checked}\n aria-label={text}\n data-tooltip={title ?? text}\n disabled={disabled}\n onClick={select}\n >\n {icon ? <TldrawUiIcon icon={icon} label={text} /> : <span>{text}</span>}\n </button>\n )\n }\n return (\n <TldrawUiDropdownMenuCheckboxItem checked={checked} {...(disabled ? { disabled } : {})} {...(title ? { title } : {})} onSelect={select}>\n {icon ? <TldrawUiIcon icon={icon} /> : null}\n <span className=\"mocanvas-menu-item-label\">{text}</span>\n {kbd ? <TldrawUiKbd>{kbd}</TldrawUiKbd> : null}\n </TldrawUiDropdownMenuCheckboxItem>\n )\n}\n\nexport interface TLUiMenuActionItemProps {\n /** The id of an entry in the action list. */\n actionId: string\n /** Override the item's own label. */\n label?: string\n /** Override the item's own icon. */\n icon?: string\n disabled?: boolean\n noClose?: boolean\n}\n\n/**\n * A menu item driven by the action list.\n *\n * Renders nothing when the action is not registered — the normal state on a\n * trimmed or read-only editor. That is why the concrete items below are all\n * written this way: removing an action through `overrides.actions` removes it\n * from every menu at once, rather than leaving buttons that throw.\n */\nexport function TldrawUiMenuActionItem({ actionId, label, icon, disabled, noClose }: TLUiMenuActionItemProps) {\n const actions = useActions()\n const state = useActionState(actionId)\n const action = actions[actionId]\n if (!action) return null\n return (\n <TldrawUiMenuItem\n id={action.id}\n label={label ?? action.label}\n {...(icon ?? action.icon ? { icon: icon ?? (action.icon as string) } : {})}\n {...(action.kbd ? { kbd: action.kbd } : {})}\n {...((disabled ?? action.disabled ?? state.disabled) ? { disabled: true } : {})}\n {...(noClose ? { noClose } : {})}\n onSelect={(source) => action.onSelect(source)}\n />\n )\n}\n\nexport interface TLUiMenuActionCheckboxItemProps extends TLUiMenuActionItemProps {\n checked?: boolean\n}\n\n/** A checkbox menu item driven by the action list. */\nexport function TldrawUiMenuActionCheckboxItem({ actionId, label, icon, checked, disabled }: TLUiMenuActionCheckboxItemProps) {\n const actions = useActions()\n const state = useActionState(actionId)\n const action = actions[actionId]\n if (!action) return null\n const isChecked = checked ?? (typeof action.meta?.[\"checked\"] === \"boolean\" ? (action.meta[\"checked\"] as boolean) : state.checked)\n return (\n <TldrawUiMenuCheckboxItem\n id={action.id}\n label={label ?? action.label}\n {...(icon ?? action.icon ? { icon: icon ?? (action.icon as string) } : {})}\n {...(action.kbd ? { kbd: action.kbd } : {})}\n checked={isChecked}\n {...((disabled ?? action.disabled ?? state.disabled) ? { disabled: true } : {})}\n onSelect={(source) => action.onSelect(source)}\n />\n )\n}\n\nexport interface TLUiMenuToolItemProps {\n /** The id of an entry in the tool list. */\n toolId: string\n label?: string\n icon?: string\n disabled?: boolean\n}\n\n/**\n * A menu item driven by the tool list, showing whether its tool is active.\n *\n * Renders nothing when the tool is not registered, for the same reason\n * {@link TldrawUiMenuActionItem} does.\n */\nexport function TldrawUiMenuToolItem({ toolId, label, icon, disabled }: TLUiMenuToolItemProps) {\n const tools = useTools()\n const tool = tools[toolId]\n const isSelected = useIsToolSelected(tool)\n if (!tool) return null\n return (\n <TldrawUiMenuItem\n id={tool.id}\n label={label ?? tool.label}\n icon={icon ?? tool.icon}\n {...(tool.kbd ? { kbd: tool.kbd } : {})}\n {...(disabled ?? tool.disabled ? { disabled: true } : {})}\n isSelected={isSelected}\n onSelect={(source) => tool.onSelect(source)}\n />\n )\n}\n\n/** Read for its side effect on the type checker only; keeps `useEditor` imported. */\nexport type TLUiMenuEditorHook = typeof useEditor\n","import { useEffect } from \"react\"\nimport { atom } from \"@mocanvas/state\"\nimport type { Editor } from \"@mocanvas/editor\"\n\n/** Whether the frame-statistics chip is visible. Toggled with ⌥D. */\nexport const debugStatsOpen = atom(\"debugStatsOpen\", false)\n\nfunction isEditable(t: EventTarget | null): boolean {\n return t instanceof HTMLElement && (t.tagName === \"INPUT\" || t.tagName === \"TEXTAREA\" || t.isContentEditable)\n}\n\nlet clipboardFallback = \"\"\n\n/** The sections the shortcuts dialog groups its rows under. */\nexport type TLKeyboardShortcutGroup = \"Edit\" | \"View\" | \"Arrange\" | \"Canvas\"\n\n/** One binding this hook installs. */\nexport interface TLKeyboardShortcut {\n /** Stable id; also what the dialog keys its rows on. */\n id: string\n /** Display text for the dialog. */\n label: string\n /** The binding, in the `\"mod+shift+z\"` notation {@link TldrawUiKbd} renders. */\n kbd: string\n /** Further bindings that do the same thing; not shown. */\n also?: readonly string[]\n group: TLKeyboardShortcutGroup\n /**\n * Do the thing. Returning `false` means \"not handled after all\" — the event\n * keeps its default, which is what lets ⌘C fall through to the browser's own\n * copy when there is no selection to take.\n */\n run(editor: Editor, event: KeyboardEvent): void | false\n}\n\n/**\n * Every shortcut the editor binds, as data.\n *\n * This list *is* the binding: the handler below dispatches through it and the\n * keyboard-shortcuts dialog renders from it, so the sheet cannot describe a\n * key the editor does not answer to, and a key added here appears in the sheet\n * without anyone remembering to write it down. The previous arrangement — a\n * switch statement here and a separate list in the dialog — is exactly the\n * shape that drifts.\n *\n * Tool switches are *not* here. They come from the UI tool list, because that\n * is the list an app's `TLUiOverrides.tools` can rewrite; `useToolShortcuts`\n * binds them and the dialog reads the same list.\n */\nexport const KEYBOARD_SHORTCUTS: readonly TLKeyboardShortcut[] = [\n // ---- edit ---------------------------------------------------------------\n { id: \"undo\", label: \"Undo\", kbd: \"mod+z\", group: \"Edit\", run: (editor) => void editor.undo() },\n { id: \"redo\", label: \"Redo\", kbd: \"mod+shift+z\", also: [\"mod+y\"], group: \"Edit\", run: (editor) => void editor.redo() },\n { id: \"select-all\", label: \"Select all\", kbd: \"mod+a\", group: \"Edit\", run: (editor) => void editor.selectAll() },\n {\n id: \"duplicate\",\n label: \"Duplicate\",\n kbd: \"mod+d\",\n group: \"Edit\",\n run: (editor) => {\n const ids = editor.getSelectedShapeIds()\n if (ids.length === 0) return\n editor.markHistoryStoppingPoint(\"duplicate\")\n editor.setSelectedShapes(editor.duplicateShapes(ids))\n },\n },\n {\n id: \"copy\",\n label: \"Copy\",\n kbd: \"mod+c\",\n group: \"Edit\",\n run: (editor) => (writeSelectionToClipboard(editor) ? undefined : false),\n },\n {\n id: \"cut\",\n label: \"Cut\",\n kbd: \"mod+x\",\n group: \"Edit\",\n run: (editor) => {\n if (!writeSelectionToClipboard(editor)) return false\n editor.markHistoryStoppingPoint(\"cut\")\n editor.deleteShapes(editor.getSelectedShapeIds())\n return undefined\n },\n },\n {\n id: \"paste\",\n label: \"Paste\",\n kbd: \"mod+v\",\n group: \"Edit\",\n run: (editor) => {\n const paste = (text: string) => {\n try {\n const data = JSON.parse(text) as { type?: string; shapes?: unknown[]; bindings?: unknown[] }\n if (data.type !== \"application/mocanvas\" || !Array.isArray(data.shapes)) return\n editor.markHistoryStoppingPoint(\"paste\")\n editor.putContentOntoCurrentPage(data as never, { point: editor.getViewportPageCenter() })\n } catch {\n // not our content\n }\n }\n if (navigator.clipboard?.readText) navigator.clipboard.readText().then(paste, () => clipboardFallback && paste(clipboardFallback))\n else if (clipboardFallback) paste(clipboardFallback)\n },\n },\n\n // ---- arrange ------------------------------------------------------------\n {\n id: \"group\",\n label: \"Group\",\n kbd: \"mod+g\",\n group: \"Arrange\",\n run: (editor) => {\n const ids = editor.getSelectedShapeIds()\n if (ids.length === 0) return\n editor.markHistoryStoppingPoint(\"group\")\n editor.groupShapes(ids)\n },\n },\n {\n id: \"ungroup\",\n label: \"Ungroup\",\n kbd: \"mod+shift+g\",\n group: \"Arrange\",\n run: (editor) => {\n const ids = editor.getSelectedShapeIds()\n if (ids.length === 0) return\n editor.markHistoryStoppingPoint(\"ungroup\")\n editor.ungroupShapes(ids)\n },\n },\n {\n id: \"toggle-lock\",\n label: \"Lock or unlock\",\n kbd: \"mod+shift+l\",\n group: \"Arrange\",\n run: (editor) => {\n editor.markHistoryStoppingPoint(\"lock\")\n editor.toggleLock()\n },\n },\n { id: \"bring-forward\", label: \"Bring forward\", kbd: \"mod+]\", group: \"Arrange\", run: (editor) => void editor.bringForward() },\n { id: \"bring-to-front\", label: \"Bring to front\", kbd: \"mod+alt+]\", group: \"Arrange\", run: (editor) => void editor.bringToFront() },\n { id: \"send-backward\", label: \"Send backward\", kbd: \"mod+[\", group: \"Arrange\", run: (editor) => void editor.sendBackward() },\n { id: \"send-to-back\", label: \"Send to back\", kbd: \"mod+alt+[\", group: \"Arrange\", run: (editor) => void editor.sendToBack() },\n\n // ---- view ---------------------------------------------------------------\n { id: \"zoom-in\", label: \"Zoom in\", kbd: \"mod+=\", also: [\"mod++\", \"mod+shift+=\"], group: \"View\", run: (editor) => void editor.zoomIn() },\n { id: \"zoom-out\", label: \"Zoom out\", kbd: \"mod+-\", group: \"View\", run: (editor) => void editor.zoomOut() },\n { id: \"reset-zoom\", label: \"Reset zoom\", kbd: \"mod+0\", group: \"View\", run: (editor) => void editor.resetZoom() },\n { id: \"zoom-to-fit\", label: \"Zoom to fit\", kbd: \"mod+1\", group: \"View\", run: (editor) => void editor.zoomToFit() },\n { id: \"zoom-to-selection\", label: \"Zoom to selection\", kbd: \"mod+2\", group: \"View\", run: (editor) => void editor.zoomToSelection() },\n {\n id: \"toggle-grid\",\n label: \"Show grid\",\n kbd: \"mod+'\",\n group: \"View\",\n run: (editor) => void editor.updateInstanceState({ isGridMode: !editor.getInstanceState().isGridMode }),\n },\n {\n id: \"toggle-focus-mode\",\n label: \"Focus mode\",\n kbd: \"mod+.\",\n group: \"View\",\n run: (editor) => void editor.updateInstanceState({ isFocusMode: !editor.getInstanceState().isFocusMode }),\n },\n {\n id: \"toggle-debug-stats\",\n label: \"Frame statistics\",\n // Not ⌥D: that belongs to Align right, which the Arrange menu advertises\n // and which is one of a coherent ⌥A/H/D/W/V/S set — breaking the set so\n // one of its members opens a developer overlay is the wrong trade. The\n // overlay takes the accelerator-plus-⌥ spelling instead.\n kbd: \"mod+alt+d\",\n group: \"View\",\n run: () => void debugStatsOpen.set(!debugStatsOpen.get()),\n },\n\n // ---- canvas -------------------------------------------------------------\n {\n id: \"toggle-tool-lock\",\n label: \"Tool lock\",\n kbd: \"q\",\n group: \"Canvas\",\n run: (editor) => void editor.updateInstanceState({ isToolLocked: !editor.getInstanceState().isToolLocked }),\n },\n]\n\n/** Put the selection on the clipboard. `false` when there was nothing to put. */\nfunction writeSelectionToClipboard(editor: Editor): boolean {\n const ids = editor.getSelectedShapeIds()\n if (ids.length === 0) return false\n const content = editor.getContentFromCurrentPage(ids)\n if (!content) return false\n const text = JSON.stringify({ type: \"application/mocanvas\", ...content })\n navigator.clipboard?.writeText(text).catch(() => {})\n clipboardFallback = text\n return true\n}\n\n/**\n * The names a key press can be looked up under.\n *\n * Both `key` and the physical `code` are offered, because on macOS a key held\n * with Alt reports the character it *produces* — ⌥D is `\"∂\"` — and a binding\n * written as `alt+d` would never match it.\n */\nfunction pressedKeyNames(event: KeyboardEvent): string[] {\n const names: string[] = []\n const key = event.key.toLowerCase()\n if (key) names.push(key)\n const code = event.code\n const fromCode = /^Key[A-Z]$/.test(code)\n ? code.slice(3).toLowerCase()\n : /^Digit[0-9]$/.test(code)\n ? code.slice(5)\n : PUNCTUATION_CODES[code]\n if (fromCode && !names.includes(fromCode)) names.push(fromCode)\n return names\n}\n\nconst PUNCTUATION_CODES: Record<string, string> = {\n Equal: \"=\",\n Minus: \"-\",\n BracketLeft: \"[\",\n BracketRight: \"]\",\n Quote: \"'\",\n Period: \".\",\n Comma: \",\",\n Slash: \"/\",\n Semicolon: \";\",\n Backslash: \"\\\\\",\n}\n\n/** `\"mod+alt+shift+key\"`, with the modifiers in a fixed order. */\nfunction bindingString(mod: boolean, alt: boolean, shift: boolean, key: string): string {\n return `${mod ? \"mod+\" : \"\"}${alt ? \"alt+\" : \"\"}${shift ? \"shift+\" : \"\"}${key}`\n}\n\n/** Normalize an authored binding into the same shape {@link bindingString} makes. */\nexport function normalizeKbd(kbd: string): string {\n const parts = kbd\n .split(\"+\")\n .map((part) => part.trim().toLowerCase())\n .filter(Boolean)\n // A trailing \"+\" is the key itself (`mod++`), which the split above ate.\n const key = kbd.trim().endsWith(\"+\") ? \"+\" : (parts.pop() ?? \"\")\n const set = new Set(parts)\n return bindingString(set.has(\"mod\") || set.has(\"cmd\") || set.has(\"ctrl\"), set.has(\"alt\") || set.has(\"opt\"), set.has(\"shift\"), key)\n}\n\n/**\n * Every binding a press could mean, in the same normalized shape\n * {@link normalizeKbd} produces.\n *\n * Exported so the action list's bindings are matched by exactly the same rules\n * as this table's — the mac accelerator split and the `key`/`code` pair are\n * both easy to get subtly wrong a second time.\n */\nexport function pressedBindings(e: KeyboardEvent): string[] {\n const isMac = /Mac|iPhone|iPad/.test(navigator.platform ?? \"\")\n // A press carrying the *other* accelerator is not ours: ⌃C on a Mac belongs\n // to the terminal-ish bindings, not to copy.\n if (isMac ? e.ctrlKey : e.metaKey) return []\n const mod = isMac ? e.metaKey : e.ctrlKey\n return pressedKeyNames(e).map((name) => bindingString(mod, e.altKey, e.shiftKey, name))\n}\n\n/** Every binding in the table, indexed by its normalized form. */\nexport function buildShortcutIndex(shortcuts: readonly TLKeyboardShortcut[] = KEYBOARD_SHORTCUTS): Map<string, TLKeyboardShortcut> {\n const index = new Map<string, TLKeyboardShortcut>()\n for (const shortcut of shortcuts) {\n for (const binding of [shortcut.kbd, ...(shortcut.also ?? [])]) {\n const normalized = normalizeKbd(binding)\n if (!index.has(normalized)) index.set(normalized, shortcut)\n }\n }\n return index\n}\n\nexport interface KeyboardShortcutOptions {\n /**\n * Bind the plain-key tool switches (`v`, `h`, `n`, …). Leave it on for an\n * editor with no chrome; turn it OFF whenever the chrome is mounted, because\n * the UI tool list binds those keys itself — and it is the list an app's\n * `TLUiOverrides.tools` can rewrite, so a binding hard-coded here would\n * survive an override that meant to remove it. Defaults to `true`.\n */\n tools?: boolean\n}\n\n/** The tool switches bound only when the chrome is not doing it. */\nconst TOOL_KEYS: Record<string, { tool: string; geo?: string; optional?: boolean }> = {\n v: { tool: \"select\" },\n h: { tool: \"hand\" },\n r: { tool: \"geo\", geo: \"rectangle\" },\n o: { tool: \"geo\", geo: \"ellipse\" },\n d: { tool: \"draw\" },\n p: { tool: \"draw\" },\n b: { tool: \"draw\" },\n e: { tool: \"eraser\" },\n n: { tool: \"note\" },\n t: { tool: \"text\" },\n a: { tool: \"arrow\", optional: true },\n l: { tool: \"line\", optional: true },\n f: { tool: \"frame\", optional: true },\n}\n\n/** Default keyboard shortcuts: {@link KEYBOARD_SHORTCUTS}, plus tool switching. */\nexport function useKeyboardShortcuts(editor: Editor | null, options: KeyboardShortcutOptions = {}): void {\n const bindTools = options.tools ?? true\n useEffect(() => {\n if (!editor) return\n const isMac = /Mac|iPhone|iPad/.test(navigator.platform ?? \"\")\n const index = buildShortcutIndex()\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (isEditable(e.target)) return\n if (editor.getEditingShapeId()) return\n const mod = isMac ? e.metaKey : e.ctrlKey\n // A press that carries the *other* accelerator is not ours: ⌃C on a Mac\n // belongs to the terminal-ish bindings, not to copy.\n if (isMac ? e.ctrlKey : e.metaKey) return\n\n for (const name of pressedKeyNames(e)) {\n const shortcut = index.get(bindingString(mod, e.altKey, e.shiftKey, name))\n if (!shortcut) continue\n if (shortcut.run(editor, e) !== false) e.preventDefault()\n return\n }\n\n if (mod || e.altKey || !bindTools) return\n const tool = TOOL_KEYS[e.key.toLowerCase()]\n if (!tool) return\n if (tool.optional && !editor.root.children?.[tool.tool]) return\n editor.setCurrentTool(tool.tool, tool.geo ? { geo: tool.geo } : undefined)\n }\n\n window.addEventListener(\"keydown\", onKeyDown)\n return () => window.removeEventListener(\"keydown\", onKeyDown)\n }, [editor, bindTools])\n}\n","import { useEditor, useTools, type TLUiToolsContextType } from \"@mocanvas/editor\"\nimport { useEffect, useRef } from \"react\"\n\n/**\n * Bind the keyboard shortcuts declared by the UI tool list.\n *\n * This is what makes `TLUiOverrides.tools` mean something: a tool's `kbd`\n * lives on its UI item, so an app that rebinds `s` to the note tool, or that\n * registers a tool of its own with a `c`, does it by rewriting that list —\n * not by patching a switch statement inside mocanvas.\n *\n * Only plain single-key bindings are handled here. Anything with a modifier\n * (`mod+z`) belongs to the action shortcuts, which `useKeyboardShortcuts`\n * owns; binding it in both places would fire it twice.\n */\nfunction isEditable(t: EventTarget | null): boolean {\n return t instanceof HTMLElement && (t.tagName === \"INPUT\" || t.tagName === \"TEXTAREA\" || t.isContentEditable)\n}\n\n/** `{ key: toolId }` for every plain single-key binding in the list. */\nexport function toolKeyMap(tools: TLUiToolsContextType, isReadonly: boolean): Map<string, string> {\n const map = new Map<string, string>()\n for (const tool of Object.values(tools)) {\n if (tool.disabled) continue\n if (isReadonly && !tool.readonlyOk) continue\n if (!tool.kbd) continue\n for (const raw of tool.kbd.split(\",\")) {\n const key = raw.trim().toLowerCase()\n if (key === \"\" || key.includes(\"+\")) continue\n // First declaration wins, so a later item cannot silently steal a key\n // an earlier one already answers to.\n if (!map.has(key)) map.set(key, tool.id)\n }\n }\n return map\n}\n\n/** Binds the tool list's shortcuts for as long as the calling component is mounted. */\nexport function useToolShortcuts(): void {\n const editor = useEditor()\n const tools = useTools()\n const toolsRef = useRef(tools)\n toolsRef.current = tools\n\n useEffect(() => {\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.metaKey || e.ctrlKey || e.altKey) return\n // Shift is a modifier here too, but only where it is *only* a modifier.\n // `toolKeyMap` drops any binding containing \"+\", so no tool key is a\n // shifted one, and without this ⇧H reached the map as a plain \"h\" and\n // selected the hand tool out from under an action bound to ⇧H. The\n // alphanumeric test is what keeps that from breaking a key that needs\n // Shift to be typed at all: \"?\" arrives as \"?\" , not as a capital.\n if (e.shiftKey && e.key.length === 1 && /[a-z0-9]/i.test(e.key)) return\n if (isEditable(e.target)) return\n if (editor.getEditingShapeId()) return\n const map = toolKeyMap(toolsRef.current, editor.getInstanceState().isReadonly)\n const id = map.get(e.key.toLowerCase())\n if (id === undefined) return\n const tool = toolsRef.current[id]\n if (!tool) return\n e.preventDefault()\n tool.onSelect(\"kbd\")\n }\n window.addEventListener(\"keydown\", onKeyDown)\n return () => window.removeEventListener(\"keydown\", onKeyDown)\n }, [editor])\n}\n\n/** Component form, so the hook can be mounted from inside the UI provider. */\nexport function ToolShortcuts() {\n useToolShortcuts()\n return null\n}\n","import { useActions, useEditor, type TLUiActionsContextType } from \"@mocanvas/editor\"\nimport { useEffect, useRef } from \"react\"\nimport { buildShortcutIndex, normalizeKbd, pressedBindings } from \"./useKeyboardShortcuts\"\n\n/**\n * Bind the keyboard shortcuts declared by the UI *action* list.\n *\n * The counterpart to `useToolShortcuts`, and it exists for the same reason:\n * an action's `kbd` is what the Arrange and Actions menus print beside it, so\n * whatever prints there had better be what fires. Before this, thirteen of\n * them printed a shortcut nothing listened for — ⇧L on Toggle lock, ⌥A/H/D/W/V/S\n * on the align items, ⌥⇧H/V on distribute, ⇧H/V on flip, and bare ] and [ on\n * bring-to-front and send-to-back. A menu that advertises a key and ignores it\n * is worse than one that advertises nothing.\n *\n * Binding the list rather than a second hard-coded table is what keeps the two\n * from drifting again, and it is what makes `TLUiOverrides.actions` mean\n * something: an app that rebinds an action, or adds one with a `kbd`, gets the\n * binding with it.\n */\nfunction isEditable(t: EventTarget | null): boolean {\n return t instanceof HTMLElement && (t.tagName === \"INPUT\" || t.tagName === \"TEXTAREA\" || t.isContentEditable)\n}\n\n/**\n * `{ normalized binding: actionId }` for every action that declares one.\n *\n * Bindings already owned by {@link KEYBOARD_SHORTCUTS} are skipped rather than\n * overridden: those carry behaviour an action item does not (undo coalescing,\n * clipboard fallbacks), and firing both would run the same operation twice.\n */\nexport function actionKeyMap(actions: TLUiActionsContextType, isReadonly: boolean): Map<string, string> {\n const owned = buildShortcutIndex()\n const map = new Map<string, string>()\n for (const action of Object.values(actions)) {\n if (action.disabled) continue\n if (isReadonly && !action.readonlyOk) continue\n if (!action.kbd) continue\n for (const raw of action.kbd.split(\",\")) {\n const binding = raw.trim()\n if (binding === \"\") continue\n const normalized = normalizeKbd(binding)\n if (owned.has(normalized)) continue\n // First declaration wins, so a later item cannot silently steal a\n // binding an earlier one already answers to.\n if (!map.has(normalized)) map.set(normalized, action.id)\n }\n }\n return map\n}\n\n/** Binds the action list's shortcuts for as long as the calling component is mounted. */\nexport function useActionShortcuts(): void {\n const editor = useEditor()\n const actions = useActions()\n const actionsRef = useRef(actions)\n actionsRef.current = actions\n\n useEffect(() => {\n const onKeyDown = (e: KeyboardEvent) => {\n if (isEditable(e.target)) return\n if (editor.getEditingShapeId()) return\n const map = actionKeyMap(actionsRef.current, editor.getInstanceState().isReadonly)\n for (const binding of pressedBindings(e)) {\n const id = map.get(binding)\n if (id === undefined) continue\n const action = actionsRef.current[id]\n if (!action) continue\n e.preventDefault()\n action.onSelect(\"kbd\")\n return\n }\n }\n window.addEventListener(\"keydown\", onKeyDown)\n return () => window.removeEventListener(\"keydown\", onKeyDown)\n }, [editor])\n}\n\n/** Component form, so the hook can be mounted from inside the UI provider. */\nexport function ActionShortcuts() {\n useActionShortcuts()\n return null\n}\n","import { useActions, useTools } from \"@mocanvas/editor\"\nimport { useMemo, type ReactNode } from \"react\"\nimport { TldrawUiDialogBody, TldrawUiDialogCloseButton, TldrawUiDialogHeader, TldrawUiDialogTitle, type TLUiDialogProps } from \"./ui-dialogs\"\nimport { TldrawUiMenuContextProvider, TldrawUiMenuItem } from \"./ui-menu\"\nimport { useReadonly } from \"./ui-actions\"\nimport { KEYBOARD_SHORTCUTS, type TLKeyboardShortcut, type TLKeyboardShortcutGroup } from \"./useKeyboardShortcuts\"\nimport { toolKeyMap } from \"./useToolShortcuts\"\nimport { actionKeyMap } from \"./useActionShortcuts\"\nimport type { TLUiKeyboardShortcutsDialogProps } from \"./ui-components\"\n\n/**\n * The keyboard shortcuts dialog.\n *\n * Built from the three things that actually install bindings — the\n * {@link KEYBOARD_SHORTCUTS} table that `useKeyboardShortcuts` dispatches\n * through, the UI tool list that `useToolShortcuts` binds, and the UI action\n * list that `useActionShortcuts` binds — rather than from a list written out\n * by hand beside them. A sheet assembled from\n * anything else can drift from the editor it describes, and a shortcut sheet\n * that is wrong is worse than none: the user tries the key, nothing happens,\n * and they stop trusting the rest of the page.\n *\n * It is also why the tool rows come from the *list* and not from the tool's\n * declared `kbd`: an app that rebinds a key through `overrides.tools` gets a\n * correct sheet, and one whose binding lost a fight for the same key does not\n * see a row claiming otherwise.\n */\n\n/** One row: a label and the key that reaches it. */\ninterface ShortcutRow {\n id: string\n label: string\n kbd: string\n}\n\n/** The tools that really answer to a key right now, in tool-list order. */\nexport function useBoundToolShortcuts(): ShortcutRow[] {\n const tools = useTools()\n const readonly = useReadonly()\n return useMemo(() => {\n const bound = toolKeyMap(tools, readonly)\n const keysByTool = new Map<string, string[]>()\n for (const [key, toolId] of bound) {\n const keys = keysByTool.get(toolId)\n if (keys) keys.push(key)\n else keysByTool.set(toolId, [key])\n }\n const rows: ShortcutRow[] = []\n for (const tool of Object.values(tools)) {\n const keys = keysByTool.get(tool.id)\n if (!keys || keys.length === 0) continue\n rows.push({ id: tool.id, label: tool.label, kbd: keys.join(\",\") })\n }\n return rows\n }, [tools, readonly])\n}\n\n/**\n * The actions that really answer to a key right now, in action-list order.\n *\n * `actionKeyMap` drops anything {@link KEYBOARD_SHORTCUTS} already owns, so an\n * action that shares a binding with the table is listed once, by the table,\n * under the table's label — which is the one that runs.\n */\nexport function useBoundActionShortcuts(): ShortcutRow[] {\n const actions = useActions()\n const readonly = useReadonly()\n return useMemo(() => {\n const bound = actionKeyMap(actions, readonly)\n const keysByAction = new Map<string, string[]>()\n for (const [key, actionId] of bound) {\n const keys = keysByAction.get(actionId)\n if (keys) keys.push(key)\n else keysByAction.set(actionId, [key])\n }\n const rows: ShortcutRow[] = []\n for (const action of Object.values(actions)) {\n const keys = keysByAction.get(action.id)\n if (!keys || keys.length === 0) continue\n rows.push({ id: action.id, label: action.label, kbd: keys.join(\",\") })\n }\n return rows\n }, [actions, readonly])\n}\n\nconst GROUP_ORDER: readonly TLKeyboardShortcutGroup[] = [\"Edit\", \"View\", \"Arrange\", \"Canvas\"]\n\n/** The table's rows, in the order the sections are shown. */\nexport function groupKeyboardShortcuts(\n shortcuts: readonly TLKeyboardShortcut[] = KEYBOARD_SHORTCUTS,\n): { group: TLKeyboardShortcutGroup; rows: ShortcutRow[] }[] {\n return GROUP_ORDER.map((group) => ({\n group,\n rows: shortcuts.filter((s) => s.group === group).map((s) => ({ id: s.id, label: s.label, kbd: s.kbd })),\n })).filter((section) => section.rows.length > 0)\n}\n\nfunction Section({ title, rows }: { title: string; rows: readonly ShortcutRow[] }) {\n if (rows.length === 0) return null\n return (\n <section className=\"mocanvas-shortcut-section\" data-section={title}>\n <h3>{title}</h3>\n {rows.map((row) => (\n <TldrawUiMenuItem key={row.id} id={row.id} label={row.label} kbd={row.kbd} />\n ))}\n </section>\n )\n}\n\n/** Every shortcut the editor is listening for, grouped. */\nexport function DefaultKeyboardShortcutsDialogContent() {\n const toolRows = useBoundToolShortcuts()\n const actionRows = useBoundActionShortcuts()\n const sections = groupKeyboardShortcuts()\n return (\n <TldrawUiMenuContextProvider type=\"keyboard-shortcuts\">\n <Section title=\"Tools\" rows={toolRows} />\n {sections.map((section) => (\n <Section key={section.group} title={section.group} rows={section.rows} />\n ))}\n <Section title=\"Actions\" rows={actionRows} />\n </TldrawUiMenuContextProvider>\n )\n}\n\n/**\n * The dialog frame. Replace the contents by passing `children`; replace the\n * whole dialog through the `KeyboardShortcutsDialog` component slot.\n */\nexport function DefaultKeyboardShortcutsDialog({ children }: TLUiKeyboardShortcutsDialogProps) {\n return (\n <>\n <TldrawUiDialogHeader>\n <TldrawUiDialogTitle>Keyboard shortcuts</TldrawUiDialogTitle>\n <TldrawUiDialogCloseButton />\n </TldrawUiDialogHeader>\n <TldrawUiDialogBody className=\"mocanvas-shortcuts\">{children ?? <DefaultKeyboardShortcutsDialogContent />}</TldrawUiDialogBody>\n </>\n )\n}\n\n/**\n * The form the dialog stack wants: a component taking `onClose`.\n *\n * `addDialog({ component: KeyboardShortcutsDialogContents })` is the whole\n * call, which is why this exists separately from the panel above.\n */\nexport function KeyboardShortcutsDialogContents(_props: TLUiDialogProps): ReactNode {\n return <DefaultKeyboardShortcutsDialog />\n}\n"]}
@@ -1,5 +1,5 @@
1
- export { SVG_DARK_BACKGROUND, SVG_EXPORT_DEFAULT_PADDING, SVG_LIGHT_BACKGROUND, copyBlobToClipboard, dashArray, defaultShapeSvgRenderer, downloadBlob, escapeXml, exportToBlob, geometryFallbackSvg, geometryToSvgPaths, getExportBounds, getExportShapes, getSvgString, matrixAttr, registerShapeSvgRenderer, rgbaToHex, shapeSvgRenderers, shapeToBackgroundSvg, shapeToSvg, svgResultToMarkup, textToSvg, wrapTextLines } from './chunk-DMCI6V5Y.js';
2
- import './chunk-OCYJAMXT.js';
1
+ export { SVG_DARK_BACKGROUND, SVG_EXPORT_DEFAULT_PADDING, SVG_LIGHT_BACKGROUND, copyBlobToClipboard, dashArray, defaultShapeSvgRenderer, downloadBlob, escapeXml, exportToBlob, geometryFallbackSvg, geometryToSvgPaths, getExportBounds, getExportShapes, getSvgString, matrixAttr, registerShapeSvgRenderer, rgbaToHex, shapeSvgRenderers, shapeToBackgroundSvg, shapeToSvg, svgResultToMarkup, textToSvg, wrapTextLines } from './chunk-HRUFJLK5.js';
2
+ import './chunk-S7FPGQAA.js';
3
3
  import './chunk-OMUOD53T.js';
4
- //# sourceMappingURL=export-VQGOVONC.js.map
5
- //# sourceMappingURL=export-VQGOVONC.js.map
4
+ //# sourceMappingURL=export-UA6X35ZW.js.map
5
+ //# sourceMappingURL=export-UA6X35ZW.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"export-VQGOVONC.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"export-UA6X35ZW.js"}