@aglyn/besigner-ui 1.15.2 → 1.16.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.
- package/package.json +17 -17
- package/src/lib/components/dnd/draggable-droppable.js +13 -3
- package/src/lib/components/dnd/draggable-droppable.js.map +1 -1
- package/src/lib/components/inline-text-editor.component.js +105 -14
- package/src/lib/components/inline-text-editor.component.js.map +1 -1
- package/src/lib/components/node-context-menu.js +8 -0
- package/src/lib/components/node-context-menu.js.map +1 -1
- package/src/lib/components/table-menu-items.d.ts +38 -0
- package/src/lib/components/table-menu-items.js +132 -0
- package/src/lib/components/table-menu-items.js.map +1 -0
- package/src/lib/utils/canvas-context-menu.d.ts +33 -2
- package/src/lib/utils/canvas-context-menu.js +18 -19
- package/src/lib/utils/canvas-context-menu.js.map +1 -1
- package/src/lib/utils/inline-text-edit.store.d.ts +6 -3
- package/src/lib/utils/inline-text-edit.store.js.map +1 -1
- package/src/lib/utils/sanitize-rich-text.d.ts +2 -0
- package/src/lib/utils/sanitize-rich-text.js +9 -1
- package/src/lib/utils/sanitize-rich-text.js.map +1 -1
- package/src/lib/utils/table-cell-edit.d.ts +44 -0
- package/src/lib/utils/table-cell-edit.js +130 -2
- package/src/lib/utils/table-cell-edit.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/node-context-menu.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { canvas } from '@aglyn/aglyn'\nimport * as Besigner from '@aglyn/besigner'\nimport {\n BesignerPanelTabFlag,\n setBesignerPanels,\n} from '@aglyn/besigner'\nimport {\n ICON_VARIANT_MODIFY_COPY,\n ICON_VARIANT_MODIFY_DELETE,\n ICON_VARIANT_MODIFY_DUPLICATE,\n ICON_VARIANT_MODIFY_MOVE_DOWN,\n ICON_VARIANT_MODIFY_MOVE_IN,\n ICON_VARIANT_MODIFY_MOVE_OUT,\n ICON_VARIANT_MODIFY_MOVE_UP,\n ICON_VARIANT_MODIFY_PASTE,\n ICON_VARIANT_VISIBILITY_HIDDEN,\n ICON_VARIANT_VISIBILITY_SHOWN,\n} from '@aglyn/shared-data-enums'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport {\n Divider,\n ListItemIcon,\n ListItemText,\n MenuItem,\n MenuList,\n Paper,\n type PaperProps,\n Typography,\n} from '@mui/material'\nimport { action } from 'mobx'\nimport { observer } from 'mobx-react-lite'\nimport { ChangeEvent, forwardRef, useCallback, useState } from 'react'\nimport useAglynBesignerFlag from '../hooks/use-aglyn-besigner-flag'\nimport useAddElementDrawerCallback from '../hooks/use-add-element-drawer-callback'\nimport useBesignerAppContext from '../hooks/use-besigner-app-context'\nimport {\n useCopyElementsCallback,\n usePasteElementsCallback,\n} from '../hooks/use-clipboard-callbacks'\nimport useDeleteElementCallback, {\n useDeleteElementsCallback,\n} from '../hooks/use-delete-element-callback'\nimport {\n useMoveNodeInCallback,\n useMoveNodeOutCallback,\n} from '../hooks/use-move-node-callbacks'\nimport {\n isNodeHiddenOnSite,\n nodePropsWithHiddenOnSite,\n} from '../utils/canvas-reveal'\nimport { openSubtreeJson } from './subtree-json-dialog.component'\n\nexport interface NodeContextMenuProps extends PaperProps {\n node: Aglyn.NodeSchema<any>\n /** Invoked when a menu action should dismiss the hosting menu/tooltip. */\n onAction?: () => void\n}\n\nexport const NodeContextMenu = observer(\n forwardRef<any, NodeContextMenuProps>((props, ref) => {\n const { node, onAction, ...rest } = props\n\n const isRootNode = canvas.isRootNode(node)\n // Multi-selection (AGL-11): ambiguous single-target actions hide or\n // disable; Duplicate/Delete apply to the whole selection.\n const multi = Besigner.focus.hasMultipleSelected()\n const app = useBesignerAppContext()\n const handleAddElementClick = useAddElementDrawerCallback()\n const elementRef = Besigner.refs.get(node?.$id)\n const [moreOpen, setMoreOpen] = useState(false)\n const [moreButton, moreButtonRef] = useState<HTMLButtonElement | null>(null)\n\n const closeMore = useCallback(() => setMoreOpen(false), [])\n const openMore = useCallback(() => setMoreOpen(true), [])\n\n const handleDuplicateClick = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n onAction?.()\n const targets = multi ? Besigner.focus.getSelected() : [node]\n for (const target of targets) {\n if (target && !canvas.isRootNode(target)) {\n canvas.duplicateNode(target)\n }\n }\n },\n [node, isRootNode, multi, onAction],\n )\n\n const handleModifyClick = useCallback(\n (e: ChangeEvent<unknown>) => {\n setBesignerPanels(app, {\n panels: (panels) => ({\n ...panels,\n panelRight: {\n ...panels.panelRight,\n toggled: true,\n tab: BesignerPanelTabFlag.ELEMENT_PROPS_FORM,\n },\n }),\n })\n },\n [app],\n )\n const handleMoveUp = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n canvas.reorderNode(node, node?.index - 1)\n },\n [node, isRootNode],\n )\n const handleMoveDown = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n canvas.reorderNode(node, node?.index + 1)\n },\n [node, isRootNode],\n )\n\n /**\n * Reparenting by clicking (AGL-1405). Until these two existed, the only\n * way to move a node into a different container was to drag it — so a\n * node that ended up somewhere it can never render (AGL-1388) could only\n * be rescued by hand-editing the document's JSON.\n *\n * `canMove*` is read through the observer, so the items enable and\n * disable as the selection moves, and both refuse anything the renderer\n * could not draw rather than accepting it and stranding the subtree.\n */\n const moveNodeOut = useMoveNodeOutCallback()\n const moveNodeIn = useMoveNodeInCallback()\n const canMoveOut = !multi && Besigner.canMoveNodeOut(node)\n const canMoveIn = !multi && Besigner.canMoveNodeIn(node)\n\n const handleMoveOut = useCallback(() => {\n onAction?.()\n moveNodeOut(node)\n }, [node, onAction, moveNodeOut])\n\n const handleMoveIn = useCallback(() => {\n onAction?.()\n moveNodeIn(node)\n }, [node, onAction, moveNodeIn])\n\n const handleParentOnClick = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n Besigner.focus.setSelectedNode(node?.parent)\n },\n [node, isRootNode],\n )\n\n const handleParentOnMouseEnter = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n Besigner.focus.setHoveredNode(node)\n },\n [node, isRootNode],\n )\n const handleParentOnMouseLeave = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n Besigner.focus.clearHover()\n },\n [isRootNode],\n )\n\n const copyElements = useCopyElementsCallback()\n const pasteElements = usePasteElementsCallback()\n const handleCopyClick = useCallback(() => {\n if (isRootNode) return\n onAction?.()\n copyElements(multi ? Besigner.focus.getSelected() : [node])\n }, [node, isRootNode, multi, onAction, copyElements])\n\n const handlePasteClick = useCallback(() => {\n onAction?.()\n pasteElements(node)\n }, [node, onAction, pasteElements])\n\n // Dismiss FIRST, then open (AGL-3208). The dialog is no longer a child of\n // this menu — `SubtreeJsonDialogHost` holds it — so the menu closing can\n // no longer take the editor with it, and leaving the menu standing behind\n // a 95vw dialog only leaves something to click away onto.\n const handleEditJsonClick = useCallback(() => {\n onAction?.()\n openSubtreeJson(node)\n }, [node, onAction])\n\n // Observed, so the item enables the moment something is copied — even\n // from another document, where the entry arrives via localStorage.\n const canPaste = Besigner.clipboard.hasContent()\n const clipboardLabels = Besigner.clipboard.getLabels()\n\n /**\n * Start hidden until an interaction shows it (AGL-592).\n *\n * A DIFFERENT switch from the eye on the hierarchy row, and the naming is\n * the whole point. The eye hides an element outright — `display: none`,\n * nothing reveals it. This one enrols the element in a runtime contract:\n * it starts hidden, an interaction's show step reveals it, and the canvas\n * opens it while it is being designed. A mega-menu panel, a drawer, an\n * announcement that appears on scroll.\n *\n * `aglyn-hidden` is the storage — the published stylesheet, the show/hide\n * steps and the canvas reveal all key off it — and until this existed the\n * only way to set it was to know the literal string and type it into the\n * Classes box. An element property with no picker is a missing feature,\n * not a power-user path.\n */\n const [, setRevealedNodeIds] = useAglynBesignerFlag('revealedNodeIds')\n const hiddenOnSite = isNodeHiddenOnSite(node as never)\n const handleToggleHiddenClick = useCallback(() => {\n if (isRootNode) return\n onAction?.()\n const targets = multi ? Besigner.focus.getSelected() : [node]\n const changed: string[] = []\n action(() => {\n for (const target of targets) {\n if (!target || canvas.isRootNode(target)) continue\n const props = nodePropsWithHiddenOnSite(target as never, !hiddenOnSite)\n if (!props) continue\n target.props = props as never\n changed.push(target.$id)\n }\n })()\n // Showing an element again retires its canvas reveal with it. The flag\n // is only meaningful for something the site hides, so leaving an entry\n // behind means the next hide silently starts revealed. Hiding sets\n // nothing: hidden is hidden, and selecting the element — which\n // whichever surface opened this menu has already done — is what shows\n // it while it is being designed.\n if (hiddenOnSite && changed.length) {\n setRevealedNodeIds((current) =>\n (current ?? []).filter((id) => !changed.includes(id)),\n )\n }\n }, [node, isRootNode, multi, hiddenOnSite, onAction, setRevealedNodeIds])\n\n /**\n * Copy and paste a LOOK.\n *\n * `node.sx` — the Styles panel's whole output, including its responsive,\n * `@scheme` and state slices, which are keys inside that object. Classes\n * are deliberately not carried: a class is a name pointing at rules the\n * element does not own, and two of them carry behaviour rather than\n * appearance, so moving them under a label that promises looks would move\n * behaviour with it.\n *\n * Paste REPLACES. Merging makes the result depend on what the target\n * already had, so the same look pasted onto two elements could produce\n * two different ones — and there would be no way to paste \"no styles\".\n */\n const copiedStyleLabel = Besigner.styleClipboard.getStyleLabel()\n const canPasteStyles = Besigner.styleClipboard.hasStyles()\n const handleCopyStyles = useCallback(() => {\n if (isRootNode) return\n onAction?.()\n Besigner.styleClipboard.copyStyles(node)\n }, [node, isRootNode, onAction])\n const handlePasteStyles = useCallback(() => {\n if (isRootNode) return\n onAction?.()\n const targets = multi ? Besigner.focus.getSelected() : [node]\n for (const target of targets) {\n if (target && !canvas.isRootNode(target)) {\n Besigner.styleClipboard.pasteStyles(target)\n }\n }\n }, [node, isRootNode, multi, onAction])\n\n const deleteElementCallback = useDeleteElementCallback()\n const deleteElementsCallback = useDeleteElementsCallback()\n const handleDeleteClick = useCallback(() => {\n closeMore()\n onAction?.()\n if (multi) void deleteElementsCallback(Besigner.focus.getSelected())\n else void deleteElementCallback(node)\n }, [\n node,\n multi,\n closeMore,\n onAction,\n deleteElementCallback,\n deleteElementsCallback,\n ])\n\n return (\n <Paper\n ref={ref}\n sx={{\n width: 240,\n // Caps itself rather than growing past the window (AGL-1405). The\n // Popper can only slide a menu back inside the viewport if it FITS\n // in one; a taller menu was laid out past the bottom of the\n // document and the page grew a scrollbar around it. `dvh` so a\n // mobile browser's retracting toolbar does not leave the last item\n // under it.\n // Shorter than the window, not merely within it. A menu that only\n // just fits is one `preventOverflow` has to slide a long way to\n // place, and a menu that lands 200px from where it was asked for\n // reads as landing at random.\n maxHeight: 'min(420px, calc(100dvh - 24px))',\n overflowY: 'auto',\n overflowX: 'hidden',\n }}\n {...rest}\n >\n <MenuList dense>\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n component=\"div\"\n sx={{\n px: 1,\n py: 0.15,\n mb: 1,\n textAlign: 'center',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n backgroundColor: (theme) =>\n `rgba(${(theme as any).vars.palette.primary.darkChannel} / 0.12)`,\n }}\n >\n {node?.labelShort}\n </Typography>\n {multi ? null : (\n <MenuItem\n onClick={() => {\n onAction?.()\n handleAddElementClick(node)\n }}\n >\n <ListItemText inset>Add element</ListItemText>\n </MenuItem>\n )}\n {multi ? null : <Divider />}\n <MenuItem\n onClick={handleParentOnClick}\n disabled={isRootNode || multi}\n onMouseEnter={handleParentOnMouseEnter}\n onPointerEnter={handleParentOnMouseEnter}\n onMouseLeave={handleParentOnMouseLeave}\n onPointerLeave={handleParentOnMouseLeave}\n >\n <ListItemText inset>Select parent</ListItemText>\n </MenuItem>\n <MenuItem\n onClick={handleMoveUp}\n disabled={isRootNode || multi || !(node?.index > 0)}\n >\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_MOVE_UP.path}\n />\n </ListItemIcon>\n <ListItemText>Shift up</ListItemText>\n </MenuItem>\n <MenuItem\n onClick={handleMoveDown}\n disabled={\n isRootNode ||\n multi ||\n !(node?.index < node?.parent?.nodes?.length - 1)\n }\n >\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_MOVE_DOWN.path}\n />\n </ListItemIcon>\n <ListItemText>Shift down</ListItemText>\n </MenuItem>\n <MenuItem onClick={handleMoveOut} disabled={!canMoveOut}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_MOVE_OUT.path}\n />\n </ListItemIcon>\n <ListItemText>Move out of container</ListItemText>\n </MenuItem>\n <MenuItem onClick={handleMoveIn} disabled={!canMoveIn}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_MOVE_IN.path}\n />\n </ListItemIcon>\n <ListItemText>Move into element above</ListItemText>\n </MenuItem>\n {multi ? null : (\n <MenuItem onClick={handleEditJsonClick}>\n <ListItemText inset>Edit JSON</ListItemText>\n </MenuItem>\n )}\n <MenuItem disabled={isRootNode} onClick={handleToggleHiddenClick}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={\n hiddenOnSite\n ? ICON_VARIANT_VISIBILITY_SHOWN.path\n : ICON_VARIANT_VISIBILITY_HIDDEN.path\n }\n />\n </ListItemIcon>\n <ListItemText\n secondary={\n hiddenOnSite\n ? 'It will be on the page from the first paint'\n : 'For a menu panel or drawer. To hide it outright, use the eye on its Hierarchy row'\n }\n // Both lines wrap. A MenuItem is `nowrap`, and this is the one\n // item whose name is longer than the menu is wide, so with only\n // the description wrapping the name ran off the right edge.\n slotProps={{\n primary: { sx: { whiteSpace: 'normal' } },\n secondary: { sx: { whiteSpace: 'normal' } },\n }}\n >\n {hiddenOnSite\n ? 'Do not start hidden'\n : 'Start hidden until an interaction shows it'}\n </ListItemText>\n </MenuItem>\n <Divider />\n <MenuItem disabled={isRootNode} onClick={handleCopyClick}>\n <ListItemIcon>\n <MdiIcon fontSize=\"inherit\" path={ICON_VARIANT_MODIFY_COPY.path} />\n </ListItemIcon>\n <ListItemText>{multi ? 'Copy selection' : 'Copy'}</ListItemText>\n </MenuItem>\n <MenuItem disabled={isRootNode} onClick={handleCopyStyles}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_COPY.path}\n />\n </ListItemIcon>\n <ListItemText>{'Copy styles'}</ListItemText>\n </MenuItem>\n <MenuItem\n disabled={isRootNode || !canPasteStyles}\n onClick={handlePasteStyles}\n >\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_PASTE.path}\n />\n </ListItemIcon>\n <ListItemText\n slotProps={{\n primary: {\n sx: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n },\n }}\n >\n {copiedStyleLabel\n ? `Paste styles from ${copiedStyleLabel}`\n : 'Paste styles'}\n </ListItemText>\n </MenuItem>\n <Divider />\n <MenuItem disabled={!canPaste} onClick={handlePasteClick}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_PASTE.path}\n />\n </ListItemIcon>\n <ListItemText\n slotProps={{\n primary: {\n sx: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n },\n }}\n >\n {clipboardLabels.length === 1\n ? `Paste ${clipboardLabels[0]}`\n : clipboardLabels.length > 1\n ? `Paste ${clipboardLabels.length} elements`\n : 'Paste'}\n </ListItemText>\n </MenuItem>\n <Divider />\n <MenuItem disabled={isRootNode} onClick={handleDuplicateClick}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_DUPLICATE.path}\n />\n </ListItemIcon>\n <ListItemText>\n {multi ? 'Duplicate selection' : 'Duplicate'}\n </ListItemText>\n </MenuItem>\n <MenuItem disabled={isRootNode} onClick={handleDeleteClick}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_DELETE.path}\n />\n </ListItemIcon>\n <ListItemText>{multi ? 'Delete selection' : 'Delete'}</ListItemText>\n </MenuItem>\n </MenuList>\n </Paper>\n )\n }),\n)\nNodeContextMenu.displayName = 'NodeContextMenu'\n\nexport default NodeContextMenu\n"],"names":["canvas","Besigner","BesignerPanelTabFlag","setBesignerPanels","ICON_VARIANT_MODIFY_COPY","ICON_VARIANT_MODIFY_DELETE","ICON_VARIANT_MODIFY_DUPLICATE","ICON_VARIANT_MODIFY_MOVE_DOWN","ICON_VARIANT_MODIFY_MOVE_IN","ICON_VARIANT_MODIFY_MOVE_OUT","ICON_VARIANT_MODIFY_MOVE_UP","ICON_VARIANT_MODIFY_PASTE","ICON_VARIANT_VISIBILITY_HIDDEN","ICON_VARIANT_VISIBILITY_SHOWN","MdiIcon","Divider","ListItemIcon","ListItemText","MenuItem","MenuList","Paper","Typography","action","observer","forwardRef","useCallback","useState","useAglynBesignerFlag","useAddElementDrawerCallback","useBesignerAppContext","useCopyElementsCallback","usePasteElementsCallback","useDeleteElementCallback","useDeleteElementsCallback","useMoveNodeInCallback","useMoveNodeOutCallback","isNodeHiddenOnSite","nodePropsWithHiddenOnSite","openSubtreeJson","NodeContextMenu","props","ref","node","onAction","rest","isRootNode","multi","focus","hasMultipleSelected","app","handleAddElementClick","elementRef","refs","get","$id","moreOpen","setMoreOpen","moreButton","moreButtonRef","closeMore","openMore","handleDuplicateClick","e","targets","getSelected","target","duplicateNode","handleModifyClick","panels","panelRight","toggled","tab","ELEMENT_PROPS_FORM","handleMoveUp","reorderNode","index","handleMoveDown","moveNodeOut","moveNodeIn","canMoveOut","canMoveNodeOut","canMoveIn","canMoveNodeIn","handleMoveOut","handleMoveIn","handleParentOnClick","setSelectedNode","parent","handleParentOnMouseEnter","setHoveredNode","handleParentOnMouseLeave","clearHover","copyElements","pasteElements","handleCopyClick","handlePasteClick","handleEditJsonClick","canPaste","clipboard","hasContent","clipboardLabels","getLabels","setRevealedNodeIds","hiddenOnSite","handleToggleHiddenClick","changed","push","length","current","filter","id","includes","copiedStyleLabel","styleClipboard","getStyleLabel","canPasteStyles","hasStyles","handleCopyStyles","copyStyles","handlePasteStyles","pasteStyles","deleteElementCallback","deleteElementsCallback","handleDeleteClick","sx","width","maxHeight","overflowY","overflowX","dense","variant","color","component","px","py","mb","textAlign","textOverflow","overflow","whiteSpace","backgroundColor","theme","vars","palette","primary","darkChannel","labelShort","onClick","inset","disabled","onMouseEnter","onPointerEnter","onMouseLeave","onPointerLeave","fontSize","path","nodes","secondary","slotProps","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;;;AAGD,SAASA,MAAM,QAAQ,eAAc;AACrC,YAAYC,cAAc,kBAAiB;AAC3C,SACEC,oBAAoB,EACpBC,iBAAiB,QACZ,kBAAiB;AACxB,SACEC,wBAAwB,EACxBC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,6BAA6B,EAC7BC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,2BAA2B,EAC3BC,yBAAyB,EACzBC,8BAA8B,EAC9BC,6BAA6B,QACxB,2BAA0B;AACjC,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SACEC,OAAO,EACPC,YAAY,EACZC,YAAY,EACZC,QAAQ,EACRC,QAAQ,EACRC,KAAK,EAELC,UAAU,QACL,gBAAe;AACtB,SAASC,MAAM,QAAQ,OAAM;AAC7B,SAASC,QAAQ,QAAQ,kBAAiB;AAC1C,SAAsBC,U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AA8BqJ,IAAI;;;sCAG5C,KAAC1I;sCACE6B,QAAQ,wBAAwB;;;;8BAGrC,MAAC5B;oBAASmI,UAAUxG;oBAAYsG,SAASxB;;sCACvC,KAAC3G;sCACC,cAAA,KAACF;gCACC4I,UAAS;gCACTC,MAAMtJ,2BAA2BsJ,IAAI;;;sCAGzC,KAAC1I;sCAAc6B,QAAQ,qBAAqB;;;;;;;AAKtD,IACD;AACDP,gBAAgBwH,WAAW,GAAG;AAE9B,eAAexH,gBAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/node-context-menu.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { canvas } from '@aglyn/aglyn'\nimport * as Besigner from '@aglyn/besigner'\nimport {\n BesignerPanelTabFlag,\n setBesignerPanels,\n} from '@aglyn/besigner'\nimport {\n ICON_VARIANT_MODIFY_COPY,\n ICON_VARIANT_MODIFY_DELETE,\n ICON_VARIANT_MODIFY_DUPLICATE,\n ICON_VARIANT_MODIFY_MOVE_DOWN,\n ICON_VARIANT_MODIFY_MOVE_IN,\n ICON_VARIANT_MODIFY_MOVE_OUT,\n ICON_VARIANT_MODIFY_MOVE_UP,\n ICON_VARIANT_MODIFY_PASTE,\n ICON_VARIANT_VISIBILITY_HIDDEN,\n ICON_VARIANT_VISIBILITY_SHOWN,\n} from '@aglyn/shared-data-enums'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport {\n Divider,\n ListItemIcon,\n ListItemText,\n MenuItem,\n MenuList,\n Paper,\n type PaperProps,\n Typography,\n} from '@mui/material'\nimport { action } from 'mobx'\nimport { observer } from 'mobx-react-lite'\nimport { ChangeEvent, forwardRef, useCallback, useState } from 'react'\nimport useAglynBesignerFlag from '../hooks/use-aglyn-besigner-flag'\nimport useAddElementDrawerCallback from '../hooks/use-add-element-drawer-callback'\nimport useBesignerAppContext from '../hooks/use-besigner-app-context'\nimport {\n useCopyElementsCallback,\n usePasteElementsCallback,\n} from '../hooks/use-clipboard-callbacks'\nimport useDeleteElementCallback, {\n useDeleteElementsCallback,\n} from '../hooks/use-delete-element-callback'\nimport {\n useMoveNodeInCallback,\n useMoveNodeOutCallback,\n} from '../hooks/use-move-node-callbacks'\nimport {\n isNodeHiddenOnSite,\n nodePropsWithHiddenOnSite,\n} from '../utils/canvas-reveal'\nimport { canvasContextMenuTableCell } from '../utils/canvas-context-menu'\nimport { openSubtreeJson } from './subtree-json-dialog.component'\nimport { tableMenuItems } from './table-menu-items'\n\nexport interface NodeContextMenuProps extends PaperProps {\n node: Aglyn.NodeSchema<any>\n /** Invoked when a menu action should dismiss the hosting menu/tooltip. */\n onAction?: () => void\n}\n\nexport const NodeContextMenu = observer(\n forwardRef<any, NodeContextMenuProps>((props, ref) => {\n const { node, onAction, ...rest } = props\n\n const isRootNode = canvas.isRootNode(node)\n // Multi-selection (AGL-11): ambiguous single-target actions hide or\n // disable; Duplicate/Delete apply to the whole selection.\n const multi = Besigner.focus.hasMultipleSelected()\n const app = useBesignerAppContext()\n const handleAddElementClick = useAddElementDrawerCallback()\n const elementRef = Besigner.refs.get(node?.$id)\n const [moreOpen, setMoreOpen] = useState(false)\n const [moreButton, moreButtonRef] = useState<HTMLButtonElement | null>(null)\n\n const closeMore = useCallback(() => setMoreOpen(false), [])\n const openMore = useCallback(() => setMoreOpen(true), [])\n\n const handleDuplicateClick = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n onAction?.()\n const targets = multi ? Besigner.focus.getSelected() : [node]\n for (const target of targets) {\n if (target && !canvas.isRootNode(target)) {\n canvas.duplicateNode(target)\n }\n }\n },\n [node, isRootNode, multi, onAction],\n )\n\n const handleModifyClick = useCallback(\n (e: ChangeEvent<unknown>) => {\n setBesignerPanels(app, {\n panels: (panels) => ({\n ...panels,\n panelRight: {\n ...panels.panelRight,\n toggled: true,\n tab: BesignerPanelTabFlag.ELEMENT_PROPS_FORM,\n },\n }),\n })\n },\n [app],\n )\n const handleMoveUp = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n canvas.reorderNode(node, node?.index - 1)\n },\n [node, isRootNode],\n )\n const handleMoveDown = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n canvas.reorderNode(node, node?.index + 1)\n },\n [node, isRootNode],\n )\n\n /**\n * Reparenting by clicking (AGL-1405). Until these two existed, the only\n * way to move a node into a different container was to drag it — so a\n * node that ended up somewhere it can never render (AGL-1388) could only\n * be rescued by hand-editing the document's JSON.\n *\n * `canMove*` is read through the observer, so the items enable and\n * disable as the selection moves, and both refuse anything the renderer\n * could not draw rather than accepting it and stranding the subtree.\n */\n const moveNodeOut = useMoveNodeOutCallback()\n const moveNodeIn = useMoveNodeInCallback()\n const canMoveOut = !multi && Besigner.canMoveNodeOut(node)\n const canMoveIn = !multi && Besigner.canMoveNodeIn(node)\n\n const handleMoveOut = useCallback(() => {\n onAction?.()\n moveNodeOut(node)\n }, [node, onAction, moveNodeOut])\n\n const handleMoveIn = useCallback(() => {\n onAction?.()\n moveNodeIn(node)\n }, [node, onAction, moveNodeIn])\n\n const handleParentOnClick = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n Besigner.focus.setSelectedNode(node?.parent)\n },\n [node, isRootNode],\n )\n\n const handleParentOnMouseEnter = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n Besigner.focus.setHoveredNode(node)\n },\n [node, isRootNode],\n )\n const handleParentOnMouseLeave = useCallback(\n (e: ChangeEvent<unknown>) => {\n if (isRootNode) return\n Besigner.focus.clearHover()\n },\n [isRootNode],\n )\n\n const copyElements = useCopyElementsCallback()\n const pasteElements = usePasteElementsCallback()\n const handleCopyClick = useCallback(() => {\n if (isRootNode) return\n onAction?.()\n copyElements(multi ? Besigner.focus.getSelected() : [node])\n }, [node, isRootNode, multi, onAction, copyElements])\n\n const handlePasteClick = useCallback(() => {\n onAction?.()\n pasteElements(node)\n }, [node, onAction, pasteElements])\n\n // Dismiss FIRST, then open (AGL-3208). The dialog is no longer a child of\n // this menu — `SubtreeJsonDialogHost` holds it — so the menu closing can\n // no longer take the editor with it, and leaving the menu standing behind\n // a 95vw dialog only leaves something to click away onto.\n const handleEditJsonClick = useCallback(() => {\n onAction?.()\n openSubtreeJson(node)\n }, [node, onAction])\n\n // Observed, so the item enables the moment something is copied — even\n // from another document, where the entry arrives via localStorage.\n const canPaste = Besigner.clipboard.hasContent()\n const clipboardLabels = Besigner.clipboard.getLabels()\n\n /**\n * Start hidden until an interaction shows it (AGL-592).\n *\n * A DIFFERENT switch from the eye on the hierarchy row, and the naming is\n * the whole point. The eye hides an element outright — `display: none`,\n * nothing reveals it. This one enrols the element in a runtime contract:\n * it starts hidden, an interaction's show step reveals it, and the canvas\n * opens it while it is being designed. A mega-menu panel, a drawer, an\n * announcement that appears on scroll.\n *\n * `aglyn-hidden` is the storage — the published stylesheet, the show/hide\n * steps and the canvas reveal all key off it — and until this existed the\n * only way to set it was to know the literal string and type it into the\n * Classes box. An element property with no picker is a missing feature,\n * not a power-user path.\n */\n const [, setRevealedNodeIds] = useAglynBesignerFlag('revealedNodeIds')\n const hiddenOnSite = isNodeHiddenOnSite(node as never)\n const handleToggleHiddenClick = useCallback(() => {\n if (isRootNode) return\n onAction?.()\n const targets = multi ? Besigner.focus.getSelected() : [node]\n const changed: string[] = []\n action(() => {\n for (const target of targets) {\n if (!target || canvas.isRootNode(target)) continue\n const props = nodePropsWithHiddenOnSite(target as never, !hiddenOnSite)\n if (!props) continue\n target.props = props as never\n changed.push(target.$id)\n }\n })()\n // Showing an element again retires its canvas reveal with it. The flag\n // is only meaningful for something the site hides, so leaving an entry\n // behind means the next hide silently starts revealed. Hiding sets\n // nothing: hidden is hidden, and selecting the element — which\n // whichever surface opened this menu has already done — is what shows\n // it while it is being designed.\n if (hiddenOnSite && changed.length) {\n setRevealedNodeIds((current) =>\n (current ?? []).filter((id) => !changed.includes(id)),\n )\n }\n }, [node, isRootNode, multi, hiddenOnSite, onAction, setRevealedNodeIds])\n\n /**\n * Copy and paste a LOOK.\n *\n * `node.sx` — the Styles panel's whole output, including its responsive,\n * `@scheme` and state slices, which are keys inside that object. Classes\n * are deliberately not carried: a class is a name pointing at rules the\n * element does not own, and two of them carry behaviour rather than\n * appearance, so moving them under a label that promises looks would move\n * behaviour with it.\n *\n * Paste REPLACES. Merging makes the result depend on what the target\n * already had, so the same look pasted onto two elements could produce\n * two different ones — and there would be no way to paste \"no styles\".\n */\n const copiedStyleLabel = Besigner.styleClipboard.getStyleLabel()\n const canPasteStyles = Besigner.styleClipboard.hasStyles()\n const handleCopyStyles = useCallback(() => {\n if (isRootNode) return\n onAction?.()\n Besigner.styleClipboard.copyStyles(node)\n }, [node, isRootNode, onAction])\n const handlePasteStyles = useCallback(() => {\n if (isRootNode) return\n onAction?.()\n const targets = multi ? Besigner.focus.getSelected() : [node]\n for (const target of targets) {\n if (target && !canvas.isRootNode(target)) {\n Besigner.styleClipboard.pasteStyles(target)\n }\n }\n }, [node, isRootNode, multi, onAction])\n\n const deleteElementCallback = useDeleteElementCallback()\n const deleteElementsCallback = useDeleteElementsCallback()\n const handleDeleteClick = useCallback(() => {\n closeMore()\n onAction?.()\n if (multi) void deleteElementsCallback(Besigner.focus.getSelected())\n else void deleteElementCallback(node)\n }, [\n node,\n multi,\n closeMore,\n onAction,\n deleteElementCallback,\n deleteElementsCallback,\n ])\n\n return (\n <Paper\n ref={ref}\n sx={{\n width: 240,\n // Caps itself rather than growing past the window (AGL-1405). The\n // Popper can only slide a menu back inside the viewport if it FITS\n // in one; a taller menu was laid out past the bottom of the\n // document and the page grew a scrollbar around it. `dvh` so a\n // mobile browser's retracting toolbar does not leave the last item\n // under it.\n // Shorter than the window, not merely within it. A menu that only\n // just fits is one `preventOverflow` has to slide a long way to\n // place, and a menu that lands 200px from where it was asked for\n // reads as landing at random.\n maxHeight: 'min(420px, calc(100dvh - 24px))',\n overflowY: 'auto',\n overflowX: 'hidden',\n }}\n {...rest}\n >\n <MenuList dense>\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n component=\"div\"\n sx={{\n px: 1,\n py: 0.15,\n mb: 1,\n textAlign: 'center',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n backgroundColor: (theme) =>\n `rgba(${(theme as any).vars.palette.primary.darkChannel} / 0.12)`,\n }}\n >\n {node?.labelShort}\n </Typography>\n {tableMenuItems({\n node,\n cell: canvasContextMenuTableCell(node?.$id),\n multi,\n onAction,\n })}\n {multi ? null : (\n <MenuItem\n onClick={() => {\n onAction?.()\n handleAddElementClick(node)\n }}\n >\n <ListItemText inset>Add element</ListItemText>\n </MenuItem>\n )}\n {multi ? null : <Divider />}\n <MenuItem\n onClick={handleParentOnClick}\n disabled={isRootNode || multi}\n onMouseEnter={handleParentOnMouseEnter}\n onPointerEnter={handleParentOnMouseEnter}\n onMouseLeave={handleParentOnMouseLeave}\n onPointerLeave={handleParentOnMouseLeave}\n >\n <ListItemText inset>Select parent</ListItemText>\n </MenuItem>\n <MenuItem\n onClick={handleMoveUp}\n disabled={isRootNode || multi || !(node?.index > 0)}\n >\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_MOVE_UP.path}\n />\n </ListItemIcon>\n <ListItemText>Shift up</ListItemText>\n </MenuItem>\n <MenuItem\n onClick={handleMoveDown}\n disabled={\n isRootNode ||\n multi ||\n !(node?.index < node?.parent?.nodes?.length - 1)\n }\n >\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_MOVE_DOWN.path}\n />\n </ListItemIcon>\n <ListItemText>Shift down</ListItemText>\n </MenuItem>\n <MenuItem onClick={handleMoveOut} disabled={!canMoveOut}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_MOVE_OUT.path}\n />\n </ListItemIcon>\n <ListItemText>Move out of container</ListItemText>\n </MenuItem>\n <MenuItem onClick={handleMoveIn} disabled={!canMoveIn}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_MOVE_IN.path}\n />\n </ListItemIcon>\n <ListItemText>Move into element above</ListItemText>\n </MenuItem>\n {multi ? null : (\n <MenuItem onClick={handleEditJsonClick}>\n <ListItemText inset>Edit JSON</ListItemText>\n </MenuItem>\n )}\n <MenuItem disabled={isRootNode} onClick={handleToggleHiddenClick}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={\n hiddenOnSite\n ? ICON_VARIANT_VISIBILITY_SHOWN.path\n : ICON_VARIANT_VISIBILITY_HIDDEN.path\n }\n />\n </ListItemIcon>\n <ListItemText\n secondary={\n hiddenOnSite\n ? 'It will be on the page from the first paint'\n : 'For a menu panel or drawer. To hide it outright, use the eye on its Hierarchy row'\n }\n // Both lines wrap. A MenuItem is `nowrap`, and this is the one\n // item whose name is longer than the menu is wide, so with only\n // the description wrapping the name ran off the right edge.\n slotProps={{\n primary: { sx: { whiteSpace: 'normal' } },\n secondary: { sx: { whiteSpace: 'normal' } },\n }}\n >\n {hiddenOnSite\n ? 'Do not start hidden'\n : 'Start hidden until an interaction shows it'}\n </ListItemText>\n </MenuItem>\n <Divider />\n <MenuItem disabled={isRootNode} onClick={handleCopyClick}>\n <ListItemIcon>\n <MdiIcon fontSize=\"inherit\" path={ICON_VARIANT_MODIFY_COPY.path} />\n </ListItemIcon>\n <ListItemText>{multi ? 'Copy selection' : 'Copy'}</ListItemText>\n </MenuItem>\n <MenuItem disabled={isRootNode} onClick={handleCopyStyles}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_COPY.path}\n />\n </ListItemIcon>\n <ListItemText>{'Copy styles'}</ListItemText>\n </MenuItem>\n <MenuItem\n disabled={isRootNode || !canPasteStyles}\n onClick={handlePasteStyles}\n >\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_PASTE.path}\n />\n </ListItemIcon>\n <ListItemText\n slotProps={{\n primary: {\n sx: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n },\n }}\n >\n {copiedStyleLabel\n ? `Paste styles from ${copiedStyleLabel}`\n : 'Paste styles'}\n </ListItemText>\n </MenuItem>\n <Divider />\n <MenuItem disabled={!canPaste} onClick={handlePasteClick}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_PASTE.path}\n />\n </ListItemIcon>\n <ListItemText\n slotProps={{\n primary: {\n sx: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n },\n }}\n >\n {clipboardLabels.length === 1\n ? `Paste ${clipboardLabels[0]}`\n : clipboardLabels.length > 1\n ? `Paste ${clipboardLabels.length} elements`\n : 'Paste'}\n </ListItemText>\n </MenuItem>\n <Divider />\n <MenuItem disabled={isRootNode} onClick={handleDuplicateClick}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_DUPLICATE.path}\n />\n </ListItemIcon>\n <ListItemText>\n {multi ? 'Duplicate selection' : 'Duplicate'}\n </ListItemText>\n </MenuItem>\n <MenuItem disabled={isRootNode} onClick={handleDeleteClick}>\n <ListItemIcon>\n <MdiIcon\n fontSize=\"inherit\"\n path={ICON_VARIANT_MODIFY_DELETE.path}\n />\n </ListItemIcon>\n <ListItemText>{multi ? 'Delete selection' : 'Delete'}</ListItemText>\n </MenuItem>\n </MenuList>\n </Paper>\n )\n }),\n)\nNodeContextMenu.displayName = 'NodeContextMenu'\n\nexport default NodeContextMenu\n"],"names":["canvas","Besigner","BesignerPanelTabFlag","setBesignerPanels","ICON_VARIANT_MODIFY_COPY","ICON_VARIANT_MODIFY_DELETE","ICON_VARIANT_MODIFY_DUPLICATE","ICON_VARIANT_MODIFY_MOVE_DOWN","ICON_VARIANT_MODIFY_MOVE_IN","ICON_VARIANT_MODIFY_MOVE_OUT","ICON_VARIANT_MODIFY_MOVE_UP","ICON_VARIANT_MODIFY_PASTE","ICON_VARIANT_VISIBILITY_HIDDEN","ICON_VARIANT_VISIBILITY_SHOWN","MdiIcon","Divider","ListItemIcon","ListItemText","MenuItem","MenuList","Paper","Typography","action","observer","forwardRef","useCallback","useState","useAglynBesignerFlag","useAddElementDrawerCallback","useBesignerAppContext","useCopyElementsCallback","usePasteElementsCallback","useDeleteElementCallback","useDeleteElementsCallback","useMoveNodeInCallback","useMoveNodeOutCallback","isNodeHiddenOnSite","nodePropsWithHiddenOnSite","canvasContextMenuTableCell","openSubtreeJson","tableMenuItems","NodeContextMenu","props","ref","node","onAction","rest","isRootNode","multi","focus","hasMultipleSelected","app","handleAddElementClick","elementRef","refs","get","$id","moreOpen","setMoreOpen","moreButton","moreButtonRef","closeMore","openMore","handleDuplicateClick","e","targets","getSelected","target","duplicateNode","handleModifyClick","panels","panelRight","toggled","tab","ELEMENT_PROPS_FORM","handleMoveUp","reorderNode","index","handleMoveDown","moveNodeOut","moveNodeIn","canMoveOut","canMoveNodeOut","canMoveIn","canMoveNodeIn","handleMoveOut","handleMoveIn","handleParentOnClick","setSelectedNode","parent","handleParentOnMouseEnter","setHoveredNode","handleParentOnMouseLeave","clearHover","copyElements","pasteElements","handleCopyClick","handlePasteClick","handleEditJsonClick","canPaste","clipboard","hasContent","clipboardLabels","getLabels","setRevealedNodeIds","hiddenOnSite","handleToggleHiddenClick","changed","push","length","current","filter","id","includes","copiedStyleLabel","styleClipboard","getStyleLabel","canPasteStyles","hasStyles","handleCopyStyles","copyStyles","handlePasteStyles","pasteStyles","deleteElementCallback","deleteElementsCallback","handleDeleteClick","sx","width","maxHeight","overflowY","overflowX","dense","variant","color","component","px","py","mb","textAlign","textOverflow","overflow","whiteSpace","backgroundColor","theme","vars","palette","primary","darkChannel","labelShort","cell","onClick","inset","disabled","onMouseEnter","onPointerEnter","onMouseLeave","onPointerLeave","fontSize","path","nodes","secondary","slotProps","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;;;AAGD,SAASA,MAAM,QAAQ,eAAc;AACrC,YAAYC,cAAc,kBAAiB;AAC3C,SACEC,oBAAoB,EACpBC,iBAAiB,QACZ,kBAAiB;AACxB,SACEC,wBAAwB,EACxBC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,6BAA6B,EAC7BC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,2BAA2B,EAC3BC,yBAAyB,EACzBC,8BAA8B,EAC9BC,6BAA6B,QACxB,2BAA0B;AACjC,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SACEC,OAAO,EACPC,YAAY,EACZC,YAAY,EACZC,QAAQ,EACRC,QAAQ,EACRC,KAAK,EAELC,UAAU,QACL,gBAAe;AACtB,SAASC,MAAM,QAAQ,OAAM;AAC7B,SAASC,QAAQ,QAAQ,kBAAiB;AAC1C,SAAsBC,UAAU,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,QAAO;AACtE,OAAOC,0BAA0B,sCAAkC;AACnE,OAAOC,iCAAiC,8CAA0C;AAClF,OAAOC,2BAA2B,uCAAmC;AACrE,SACEC,uBAAuB,EACvBC,wBAAwB,QACnB,sCAAkC;AACzC,OAAOC,4BACLC,yBAAyB,QACpB,0CAAsC;AAC7C,SACEC,qBAAqB,EACrBC,sBAAsB,QACjB,sCAAkC;AACzC,SACEC,kBAAkB,EAClBC,yBAAyB,QACpB,4BAAwB;AAC/B,SAASC,0BAA0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,KAAC7I;sCAAc+B,QAAQ,qBAAqB;;;;;;;AAKtD,IACD;AACDP,gBAAgByH,WAAW,GAAG;AAE9B,eAAezH,gBAAe"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type * as Aglyn from '@aglyn/aglyn';
|
|
18
|
+
import type { ReactElement } from 'react';
|
|
19
|
+
import type { CanvasContextMenuTableCell } from '../utils/canvas-context-menu';
|
|
20
|
+
/**
|
|
21
|
+
* The Table's own items for the element menu (AGL-4203): rows and columns,
|
|
22
|
+
* edited where the author is looking instead of in the Attributes grid.
|
|
23
|
+
*
|
|
24
|
+
* Opened on a cell (a right-click), they are relative to it: insert above,
|
|
25
|
+
* below, left or right, and delete its row or column. Opened anywhere else
|
|
26
|
+
* (the ⋮ button), there is no cell to be relative to, so they append. An
|
|
27
|
+
* empty Table has neither, and is offered the same starter the Attributes
|
|
28
|
+
* grid writes.
|
|
29
|
+
*
|
|
30
|
+
* Returned as an ARRAY of items rather than a component: a `MenuList` reads
|
|
31
|
+
* its children for keyboard focus, and refuses a Fragment.
|
|
32
|
+
*/
|
|
33
|
+
export declare function tableMenuItems(options: {
|
|
34
|
+
node: Aglyn.NodeSchema<any> | undefined;
|
|
35
|
+
cell: CanvasContextMenuTableCell | null;
|
|
36
|
+
multi: boolean;
|
|
37
|
+
onAction?: () => void;
|
|
38
|
+
}): ReactElement[];
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { canvas } from "@aglyn/aglyn";
|
|
18
|
+
import { parseDataTableRows } from "@aglyn/shared-data-enums";
|
|
19
|
+
import { mdiTable, mdiTableColumnPlusAfter, mdiTableRowPlusAfter } from "@aglyn/shared-data-mdi";
|
|
20
|
+
import { MdiIcon } from "@aglyn/shared-ui-jsx";
|
|
21
|
+
import { Divider, ListItemIcon, ListItemText, MenuItem } from "@mui/material";
|
|
22
|
+
import { toJS } from "mobx";
|
|
23
|
+
import { dataTableCellActions, findDataTableAttributeName, withDataTableShapeEdit, withDataTableStarted } from "../utils/table-cell-edit.js";
|
|
24
|
+
/** Writes a Table's new props as one change: one undo entry. */ function writeTable(node, next) {
|
|
25
|
+
canvas.updateNodeProps(node, next);
|
|
26
|
+
}
|
|
27
|
+
function propsOf(node) {
|
|
28
|
+
var _toJS;
|
|
29
|
+
return (_toJS = toJS(node.props)) != null ? _toJS : {};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The Table's own items for the element menu (AGL-4203): rows and columns,
|
|
33
|
+
* edited where the author is looking instead of in the Attributes grid.
|
|
34
|
+
*
|
|
35
|
+
* Opened on a cell (a right-click), they are relative to it: insert above,
|
|
36
|
+
* below, left or right, and delete its row or column. Opened anywhere else
|
|
37
|
+
* (the ⋮ button), there is no cell to be relative to, so they append. An
|
|
38
|
+
* empty Table has neither, and is offered the same starter the Attributes
|
|
39
|
+
* grid writes.
|
|
40
|
+
*
|
|
41
|
+
* Returned as an ARRAY of items rather than a component: a `MenuList` reads
|
|
42
|
+
* its children for keyboard focus, and refuses a Fragment.
|
|
43
|
+
*/ export function tableMenuItems(options) {
|
|
44
|
+
var _node_props;
|
|
45
|
+
const { node, cell, multi, onAction } = options;
|
|
46
|
+
const attribute = node && !multi ? findDataTableAttributeName(node) : undefined;
|
|
47
|
+
if (!node || !attribute) return [];
|
|
48
|
+
const stored = (_node_props = node.props) == null ? void 0 : _node_props[attribute];
|
|
49
|
+
const grid = parseDataTableRows(stored);
|
|
50
|
+
const reshape = (edit)=>()=>{
|
|
51
|
+
onAction == null ? void 0 : onAction();
|
|
52
|
+
writeTable(node, withDataTableShapeEdit(propsOf(node), attribute, edit));
|
|
53
|
+
};
|
|
54
|
+
const items = [];
|
|
55
|
+
if (grid.length === 0) {
|
|
56
|
+
items.push(/*#__PURE__*/ _jsxs(MenuItem, {
|
|
57
|
+
onClick: ()=>{
|
|
58
|
+
onAction == null ? void 0 : onAction();
|
|
59
|
+
writeTable(node, withDataTableStarted(propsOf(node), attribute));
|
|
60
|
+
},
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ _jsx(ListItemIcon, {
|
|
63
|
+
children: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
64
|
+
fontSize: "inherit",
|
|
65
|
+
path: mdiTable.path
|
|
66
|
+
})
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ _jsx(ListItemText, {
|
|
69
|
+
children: 'Start a table'
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
}, "table-start"));
|
|
73
|
+
} else if (cell) {
|
|
74
|
+
for (const action of dataTableCellActions(stored, cell.row, cell.column)){
|
|
75
|
+
items.push(/*#__PURE__*/ _jsxs(MenuItem, {
|
|
76
|
+
disabled: action.disabled,
|
|
77
|
+
onClick: reshape(action.edit),
|
|
78
|
+
children: [
|
|
79
|
+
/*#__PURE__*/ _jsx(ListItemIcon, {
|
|
80
|
+
children: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
81
|
+
fontSize: "inherit",
|
|
82
|
+
path: action.icon
|
|
83
|
+
})
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ _jsx(ListItemText, {
|
|
86
|
+
children: action.label
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
}, `table-${action.key}`));
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
var _ref;
|
|
93
|
+
var _grid_;
|
|
94
|
+
items.push(/*#__PURE__*/ _jsxs(MenuItem, {
|
|
95
|
+
onClick: reshape({
|
|
96
|
+
kind: 'insertRow',
|
|
97
|
+
at: grid.length
|
|
98
|
+
}),
|
|
99
|
+
children: [
|
|
100
|
+
/*#__PURE__*/ _jsx(ListItemIcon, {
|
|
101
|
+
children: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
102
|
+
fontSize: "inherit",
|
|
103
|
+
path: mdiTableRowPlusAfter.path
|
|
104
|
+
})
|
|
105
|
+
}),
|
|
106
|
+
/*#__PURE__*/ _jsx(ListItemText, {
|
|
107
|
+
children: 'Add row'
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
}, "table-add-row"), /*#__PURE__*/ _jsxs(MenuItem, {
|
|
111
|
+
onClick: reshape({
|
|
112
|
+
kind: 'insertColumn',
|
|
113
|
+
at: (_ref = (_grid_ = grid[0]) == null ? void 0 : _grid_.length) != null ? _ref : 0
|
|
114
|
+
}),
|
|
115
|
+
children: [
|
|
116
|
+
/*#__PURE__*/ _jsx(ListItemIcon, {
|
|
117
|
+
children: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
118
|
+
fontSize: "inherit",
|
|
119
|
+
path: mdiTableColumnPlusAfter.path
|
|
120
|
+
})
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ _jsx(ListItemText, {
|
|
123
|
+
children: 'Add column'
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
}, "table-add-column"));
|
|
127
|
+
}
|
|
128
|
+
items.push(/*#__PURE__*/ _jsx(Divider, {}, "table-divider"));
|
|
129
|
+
return items;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=table-menu-items.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/table-menu-items.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { canvas } from '@aglyn/aglyn'\nimport type { DataTableShapeEdit } from '@aglyn/shared-data-enums'\nimport { parseDataTableRows } from '@aglyn/shared-data-enums'\nimport {\n mdiTable,\n mdiTableColumnPlusAfter,\n mdiTableRowPlusAfter,\n} from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { Divider, ListItemIcon, ListItemText, MenuItem } from '@mui/material'\nimport { toJS } from 'mobx'\nimport type { ReactElement } from 'react'\nimport type { CanvasContextMenuTableCell } from '../utils/canvas-context-menu'\nimport {\n dataTableCellActions,\n findDataTableAttributeName,\n withDataTableShapeEdit,\n withDataTableStarted,\n} from '../utils/table-cell-edit'\n\n/** Writes a Table's new props as one change: one undo entry. */\nfunction writeTable(\n node: Aglyn.NodeSchema<any>,\n next: Record<string, unknown>,\n): void {\n canvas.updateNodeProps(node, next as never)\n}\n\nfunction propsOf(node: Aglyn.NodeSchema<any>): Record<string, unknown> {\n return (toJS(node.props) ?? {}) as Record<string, unknown>\n}\n\n/**\n * The Table's own items for the element menu (AGL-4203): rows and columns,\n * edited where the author is looking instead of in the Attributes grid.\n *\n * Opened on a cell (a right-click), they are relative to it: insert above,\n * below, left or right, and delete its row or column. Opened anywhere else\n * (the ⋮ button), there is no cell to be relative to, so they append. An\n * empty Table has neither, and is offered the same starter the Attributes\n * grid writes.\n *\n * Returned as an ARRAY of items rather than a component: a `MenuList` reads\n * its children for keyboard focus, and refuses a Fragment.\n */\nexport function tableMenuItems(options: {\n node: Aglyn.NodeSchema<any> | undefined\n cell: CanvasContextMenuTableCell | null\n multi: boolean\n onAction?: () => void\n}): ReactElement[] {\n const { node, cell, multi, onAction } = options\n const attribute = node && !multi ? findDataTableAttributeName(node) : undefined\n if (!node || !attribute) return []\n const stored = (node.props as Record<string, unknown> | undefined)?.[attribute]\n const grid = parseDataTableRows(stored)\n\n const reshape = (edit: DataTableShapeEdit) => () => {\n onAction?.()\n writeTable(node, withDataTableShapeEdit(propsOf(node), attribute, edit))\n }\n\n const items: ReactElement[] = []\n if (grid.length === 0) {\n items.push(\n <MenuItem\n key=\"table-start\"\n onClick={() => {\n onAction?.()\n writeTable(node, withDataTableStarted(propsOf(node), attribute))\n }}\n >\n <ListItemIcon>\n <MdiIcon fontSize=\"inherit\" path={mdiTable.path} />\n </ListItemIcon>\n <ListItemText>{'Start a table'}</ListItemText>\n </MenuItem>,\n )\n } else if (cell) {\n for (const action of dataTableCellActions(stored, cell.row, cell.column)) {\n items.push(\n <MenuItem\n key={`table-${action.key}`}\n disabled={action.disabled}\n onClick={reshape(action.edit)}\n >\n <ListItemIcon>\n <MdiIcon fontSize=\"inherit\" path={action.icon} />\n </ListItemIcon>\n <ListItemText>{action.label}</ListItemText>\n </MenuItem>,\n )\n }\n } else {\n items.push(\n <MenuItem\n key=\"table-add-row\"\n onClick={reshape({ kind: 'insertRow', at: grid.length })}\n >\n <ListItemIcon>\n <MdiIcon fontSize=\"inherit\" path={mdiTableRowPlusAfter.path} />\n </ListItemIcon>\n <ListItemText>{'Add row'}</ListItemText>\n </MenuItem>,\n <MenuItem\n key=\"table-add-column\"\n onClick={reshape({\n kind: 'insertColumn',\n at: grid[0]?.length ?? 0,\n })}\n >\n <ListItemIcon>\n <MdiIcon fontSize=\"inherit\" path={mdiTableColumnPlusAfter.path} />\n </ListItemIcon>\n <ListItemText>{'Add column'}</ListItemText>\n </MenuItem>,\n )\n }\n items.push(<Divider key=\"table-divider\" />)\n return items\n}\n"],"names":["canvas","parseDataTableRows","mdiTable","mdiTableColumnPlusAfter","mdiTableRowPlusAfter","MdiIcon","Divider","ListItemIcon","ListItemText","MenuItem","toJS","dataTableCellActions","findDataTableAttributeName","withDataTableShapeEdit","withDataTableStarted","writeTable","node","next","updateNodeProps","propsOf","props","tableMenuItems","options","cell","multi","onAction","attribute","undefined","stored","grid","reshape","edit","items","length","push","onClick","fontSize","path","action","row","column","disabled","icon","label","key","kind","at"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,MAAM,QAAQ,eAAc;AAErC,SAASC,kBAAkB,QAAQ,2BAA0B;AAC7D,SACEC,QAAQ,EACRC,uBAAuB,EACvBC,oBAAoB,QACf,yBAAwB;AAC/B,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,OAAO,EAAEC,YAAY,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,gBAAe;AAC7E,SAASC,IAAI,QAAQ,OAAM;AAG3B,SACEC,oBAAoB,EACpBC,0BAA0B,EAC1BC,sBAAsB,EACtBC,oBAAoB,QACf,8BAA0B;AAEjC,8DAA8D,GAC9D,SAASC,WACPC,IAA2B,EAC3BC,IAA6B;I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,KAAK;;;eAPtB,CAAC,MAAM,EAAEL,OAAOM,GAAG,EAAE;QAUhC;IACF,OAAO;;YAeKf;QAdVG,MAAME,IAAI,eACR,MAACzB;YAEC0B,SAASL,QAAQ;gBAAEe,MAAM;gBAAaC,IAAIjB,KAAKI,MAAM;YAAC;;8BAEtD,KAAC1B;8BACC,cAAA,KAACF;wBAAQ+B,UAAS;wBAAUC,MAAMjC,qBAAqBiC,IAAI;;;8BAE7D,KAAC7B;8BAAc;;;WANX,gCAQN,MAACC;YAEC0B,SAASL,QAAQ;gBACfe,MAAM;gBACNC,EAAE,WAAEjB,SAAAA,IAAI,CAAC,EAAE,qBAAPA,OAASI,MAAM,mBAAI;YACzB;;8BAEA,KAAC1B;8BACC,cAAA,KAACF;wBAAQ+B,UAAS;wBAAUC,MAAMlC,wBAAwBkC,IAAI;;;8BAEhE,KAAC7B;8BAAc;;;WATX;IAYV;IACAwB,MAAME,IAAI,eAAC,KAAC5B,aAAY;IACxB,OAAO0B;AACT"}
|
|
@@ -14,8 +14,39 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Right-click on the canvas opens the element's ⋮ menu (AGL-1405).
|
|
19
|
+
*
|
|
20
|
+
* The hierarchy row can open its own menu directly — the row and the menu are
|
|
21
|
+
* the same component. The canvas cannot: the menu is rendered by
|
|
22
|
+
* `node-quick-actions`, inside the overlay, which only mounts for a node that
|
|
23
|
+
* is already selected or hovered. The right-click happens on the LEAF, in a
|
|
24
|
+
* closed shadow root, and the two never meet.
|
|
25
|
+
*
|
|
26
|
+
* So the leaf asks and the overlay answers. One node id in module-scope
|
|
27
|
+
* observable state, which is also what makes the ordering work: the leaf
|
|
28
|
+
* selects the node and records the request, the overlay mounts BECAUSE of
|
|
29
|
+
* that selection, and reads the request on its first render.
|
|
30
|
+
*
|
|
31
|
+
* A single id rather than a queue — only one context menu can be open, and a
|
|
32
|
+
* second right-click supersedes the first rather than stacking.
|
|
33
|
+
*/
|
|
34
|
+
/** The Table cell a right-click landed on (AGL-4203). */
|
|
35
|
+
export interface CanvasContextMenuTableCell {
|
|
36
|
+
row: number;
|
|
37
|
+
column: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Ask for the menu on this node; supersedes any earlier request. On a Table,
|
|
41
|
+
* `tableCell` says which cell was right-clicked, so the menu can offer rows
|
|
42
|
+
* and columns relative to it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function requestCanvasContextMenu(nodeId: string | undefined, tableCell?: CanvasContextMenuTableCell): void;
|
|
45
|
+
/**
|
|
46
|
+
* The Table cell the open menu was asked for on, or `null` when it was
|
|
47
|
+
* opened from the ⋮ button, the hierarchy, or anywhere but a cell.
|
|
48
|
+
*/
|
|
49
|
+
export declare function canvasContextMenuTableCell(nodeId: string | undefined): CanvasContextMenuTableCell | null;
|
|
19
50
|
/** Whether the open menu was asked for on this node. */
|
|
20
51
|
export declare function isCanvasContextMenuRequested(nodeId: string | undefined): boolean;
|
|
21
52
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
1
2
|
/**
|
|
2
3
|
* @license
|
|
3
4
|
* Copyright 2026 Aglyn LLC
|
|
@@ -14,30 +15,27 @@
|
|
|
14
15
|
* See the License for the specific language governing permissions and
|
|
15
16
|
* limitations under the License.
|
|
16
17
|
*/ import { observable, runInAction } from "mobx";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* The hierarchy row can open its own menu directly — the row and the menu are
|
|
21
|
-
* the same component. The canvas cannot: the menu is rendered by
|
|
22
|
-
* `node-quick-actions`, inside the overlay, which only mounts for a node that
|
|
23
|
-
* is already selected or hovered. The right-click happens on the LEAF, in a
|
|
24
|
-
* closed shadow root, and the two never meet.
|
|
25
|
-
*
|
|
26
|
-
* So the leaf asks and the overlay answers. One node id in module-scope
|
|
27
|
-
* observable state, which is also what makes the ordering work: the leaf
|
|
28
|
-
* selects the node and records the request, the overlay mounts BECAUSE of
|
|
29
|
-
* that selection, and reads the request on its first render.
|
|
30
|
-
*
|
|
31
|
-
* A single id rather than a queue — only one context menu can be open, and a
|
|
32
|
-
* second right-click supersedes the first rather than stacking.
|
|
33
|
-
*/ const state = observable({
|
|
34
|
-
nodeId: null
|
|
18
|
+
const state = observable({
|
|
19
|
+
nodeId: null,
|
|
20
|
+
tableCell: null
|
|
35
21
|
});
|
|
36
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Ask for the menu on this node; supersedes any earlier request. On a Table,
|
|
24
|
+
* `tableCell` says which cell was right-clicked, so the menu can offer rows
|
|
25
|
+
* and columns relative to it.
|
|
26
|
+
*/ export function requestCanvasContextMenu(nodeId, tableCell) {
|
|
37
27
|
runInAction(()=>{
|
|
38
28
|
state.nodeId = nodeId != null ? nodeId : null;
|
|
29
|
+
state.tableCell = nodeId && tableCell ? _extends({}, tableCell) : null;
|
|
39
30
|
});
|
|
40
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* The Table cell the open menu was asked for on, or `null` when it was
|
|
34
|
+
* opened from the ⋮ button, the hierarchy, or anywhere but a cell.
|
|
35
|
+
*/ export function canvasContextMenuTableCell(nodeId) {
|
|
36
|
+
if (!nodeId || state.nodeId !== nodeId) return null;
|
|
37
|
+
return state.tableCell;
|
|
38
|
+
}
|
|
41
39
|
/** Whether the open menu was asked for on this node. */ export function isCanvasContextMenuRequested(nodeId) {
|
|
42
40
|
return Boolean(nodeId) && state.nodeId === nodeId;
|
|
43
41
|
}
|
|
@@ -50,6 +48,7 @@
|
|
|
50
48
|
*/ export function clearCanvasContextMenu() {
|
|
51
49
|
runInAction(()=>{
|
|
52
50
|
state.nodeId = null;
|
|
51
|
+
state.tableCell = null;
|
|
53
52
|
});
|
|
54
53
|
}
|
|
55
54
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/canvas-context-menu.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { observable, runInAction } from 'mobx'\n\n/**\n * Right-click on the canvas opens the element's ⋮ menu (AGL-1405).\n *\n * The hierarchy row can open its own menu directly — the row and the menu are\n * the same component. The canvas cannot: the menu is rendered by\n * `node-quick-actions`, inside the overlay, which only mounts for a node that\n * is already selected or hovered. The right-click happens on the LEAF, in a\n * closed shadow root, and the two never meet.\n *\n * So the leaf asks and the overlay answers. One node id in module-scope\n * observable state, which is also what makes the ordering work: the leaf\n * selects the node and records the request, the overlay mounts BECAUSE of\n * that selection, and reads the request on its first render.\n *\n * A single id rather than a queue — only one context menu can be open, and a\n * second right-click supersedes the first rather than stacking.\n */\nconst state = observable<{
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/canvas-context-menu.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { observable, runInAction } from 'mobx'\n\n/**\n * Right-click on the canvas opens the element's ⋮ menu (AGL-1405).\n *\n * The hierarchy row can open its own menu directly — the row and the menu are\n * the same component. The canvas cannot: the menu is rendered by\n * `node-quick-actions`, inside the overlay, which only mounts for a node that\n * is already selected or hovered. The right-click happens on the LEAF, in a\n * closed shadow root, and the two never meet.\n *\n * So the leaf asks and the overlay answers. One node id in module-scope\n * observable state, which is also what makes the ordering work: the leaf\n * selects the node and records the request, the overlay mounts BECAUSE of\n * that selection, and reads the request on its first render.\n *\n * A single id rather than a queue — only one context menu can be open, and a\n * second right-click supersedes the first rather than stacking.\n */\n/** The Table cell a right-click landed on (AGL-4203). */\nexport interface CanvasContextMenuTableCell {\n row: number\n column: number\n}\n\nconst state = observable<{\n nodeId: string | null\n tableCell: CanvasContextMenuTableCell | null\n}>({ nodeId: null, tableCell: null })\n\n/**\n * Ask for the menu on this node; supersedes any earlier request. On a Table,\n * `tableCell` says which cell was right-clicked, so the menu can offer rows\n * and columns relative to it.\n */\nexport function requestCanvasContextMenu(\n nodeId: string | undefined,\n tableCell?: CanvasContextMenuTableCell,\n): void {\n runInAction(() => {\n state.nodeId = nodeId ?? null\n state.tableCell = nodeId && tableCell ? { ...tableCell } : null\n })\n}\n\n/**\n * The Table cell the open menu was asked for on, or `null` when it was\n * opened from the ⋮ button, the hierarchy, or anywhere but a cell.\n */\nexport function canvasContextMenuTableCell(\n nodeId: string | undefined,\n): CanvasContextMenuTableCell | null {\n if (!nodeId || state.nodeId !== nodeId) return null\n return state.tableCell\n}\n\n/** Whether the open menu was asked for on this node. */\nexport function isCanvasContextMenuRequested(\n nodeId: string | undefined,\n): boolean {\n return Boolean(nodeId) && state.nodeId === nodeId\n}\n\n/**\n * Withdraw the request.\n *\n * Called when the menu closes, and unconditionally rather than only for the\n * node that asked: a request left standing re-opens the menu the next time\n * that node's overlay mounts, which reads as the menu opening by itself.\n */\nexport function clearCanvasContextMenu(): void {\n runInAction(() => {\n state.nodeId = null\n state.tableCell = null\n })\n}\n"],"names":["observable","runInAction","state","nodeId","tableCell","requestCanvasContextMenu","canvasContextMenuTableCell","isCanvasContextMenuRequested","Boolean","clearCanvasContextMenu"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,UAAU,EAAEC,WAAW,QAAQ,OAAM;AAyB9C,MAAMC,QAAQF,WAGX;IAAEG,QAAQ;IAAMC,WAAW;AAAK;AAEnC;;;;CAIC,GACD,OAAO,SAASC,yBACdF,MAA0B,EAC1BC,SAAsC;IAEtCH,YAAY;QACVC,MAAMC,MAAM,GAAGA,iBAAAA,SAAU;QACzBD,MAAME,SAAS,GAAGD,UAAUC,YAAY,aAAKA,aAAc;IAC7D;AACF;AAEA;;;CAGC,GACD,OAAO,SAASE,2BACdH,MAA0B;IAE1B,IAAI,CAACA,UAAUD,MAAMC,MAAM,KAAKA,QAAQ,OAAO;IAC/C,OAAOD,MAAME,SAAS;AACxB;AAEA,sDAAsD,GACtD,OAAO,SAASG,6BACdJ,MAA0B;IAE1B,OAAOK,QAAQL,WAAWD,MAAMC,MAAM,KAAKA;AAC7C;AAEA;;;;;;CAMC,GACD,OAAO,SAASM;IACdR,YAAY;QACVC,MAAMC,MAAM,GAAG;QACfD,MAAME,SAAS,GAAG;IACpB;AACF"}
|
|
@@ -56,8 +56,9 @@ export interface InlinePropEditTarget {
|
|
|
56
56
|
/**
|
|
57
57
|
* Table-cell edit target: the editor is anchored on one rendered cell of a
|
|
58
58
|
* Table element, and the commit rewrites that cell inside the node's grid
|
|
59
|
-
* attribute instead of its `children` (see `table-cell-edit.ts`).
|
|
60
|
-
*
|
|
59
|
+
* attribute instead of its `children` (see `table-cell-edit.ts`). A
|
|
60
|
+
* formatting surface limited to inline formatting and links (AGL-4203): a
|
|
61
|
+
* cell is one line of a pipe grid, so it holds no blocks.
|
|
61
62
|
*/
|
|
62
63
|
export interface InlineCellEditTarget {
|
|
63
64
|
/** The attribute holding the grid string. */
|
|
@@ -65,8 +66,10 @@ export interface InlineCellEditTarget {
|
|
|
65
66
|
/** Row in the parsed grid, header row included. */
|
|
66
67
|
row: number;
|
|
67
68
|
column: number;
|
|
68
|
-
/** The cell's
|
|
69
|
+
/** The cell's words when the edit opened. */
|
|
69
70
|
initialText: string;
|
|
71
|
+
/** The cell's markup when it was formatted, or `''`. */
|
|
72
|
+
initialHtml?: string;
|
|
70
73
|
}
|
|
71
74
|
/**
|
|
72
75
|
* State for the inline canvas text editor: which node is being edited and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/inline-text-edit.store.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { makeAutoObservable, observableRef } from 'mobx'\n\nexport interface InlineTextEditRect {\n left: number\n top: number\n width: number\n height: number\n}\n\n/**\n * Prop-override edit target (AGL-1304): the editor is anchored on a grafted\n * text leaf INSIDE a component instance, and the commit writes the\n * instance's `propValues[propName]` instead of the node's `children`. The\n * `node` held by the store stays the INSTANCE — the grafted leaf is not a\n * canvas node, only the anchor rect came from it.\n */\nexport interface InlinePropEditTarget {\n /** Declared prop name the edit commits to. */\n propName: string\n /**\n * The text the leaf currently renders (override unless unset, else the\n * declared default — `getInstanceEffectivePropText`). Captured at open\n * because the editor cannot re-derive it without the definition.\n */\n initialText: string\n /**\n * The schema of the element the prop fills — what decides which\n * formatting commands are offered, as a node's own schema does for it.\n */\n schema?: Aglyn.ComponentSchema<any>\n /**\n * Whether the edit is formatted text: every element the prop fills draws\n * markup. One that cannot would show the author bold that never renders.\n */\n rich?: boolean\n /**\n * The prop's formatted text as the instance stores it, or `''` — the\n * markup the editor opens with in place of the plain `initialText`.\n */\n initialHtml?: string\n}\n\n/**\n * Table-cell edit target: the editor is anchored on one rendered cell of a\n * Table element, and the commit rewrites that cell inside the node's grid\n * attribute instead of its `children` (see `table-cell-edit.ts`).
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/inline-text-edit.store.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { makeAutoObservable, observableRef } from 'mobx'\n\nexport interface InlineTextEditRect {\n left: number\n top: number\n width: number\n height: number\n}\n\n/**\n * Prop-override edit target (AGL-1304): the editor is anchored on a grafted\n * text leaf INSIDE a component instance, and the commit writes the\n * instance's `propValues[propName]` instead of the node's `children`. The\n * `node` held by the store stays the INSTANCE — the grafted leaf is not a\n * canvas node, only the anchor rect came from it.\n */\nexport interface InlinePropEditTarget {\n /** Declared prop name the edit commits to. */\n propName: string\n /**\n * The text the leaf currently renders (override unless unset, else the\n * declared default — `getInstanceEffectivePropText`). Captured at open\n * because the editor cannot re-derive it without the definition.\n */\n initialText: string\n /**\n * The schema of the element the prop fills — what decides which\n * formatting commands are offered, as a node's own schema does for it.\n */\n schema?: Aglyn.ComponentSchema<any>\n /**\n * Whether the edit is formatted text: every element the prop fills draws\n * markup. One that cannot would show the author bold that never renders.\n */\n rich?: boolean\n /**\n * The prop's formatted text as the instance stores it, or `''` — the\n * markup the editor opens with in place of the plain `initialText`.\n */\n initialHtml?: string\n}\n\n/**\n * Table-cell edit target: the editor is anchored on one rendered cell of a\n * Table element, and the commit rewrites that cell inside the node's grid\n * attribute instead of its `children` (see `table-cell-edit.ts`). A\n * formatting surface limited to inline formatting and links (AGL-4203): a\n * cell is one line of a pipe grid, so it holds no blocks.\n */\nexport interface InlineCellEditTarget {\n /** The attribute holding the grid string. */\n attribute: string\n /** Row in the parsed grid, header row included. */\n row: number\n column: number\n /** The cell's words when the edit opened. */\n initialText: string\n /** The cell's markup when it was formatted, or `''`. */\n initialHtml?: string\n}\n\n/**\n * State for the inline canvas text editor: which node is being edited and\n * where its element sits in viewport coordinates (the editor renders as a\n * fixed overlay OUTSIDE the closed canvas shadow root, so screen coordinates\n * are the only shared frame of reference).\n *\n * `anchor` is the element the rect was measured from, kept so the editor can\n * re-measure rather than drift when the canvas scrolls (AGL-1644). It is the\n * anchor RATHER than the node's `Besigner.refs` entry because a prop-override\n * edit measures a grafted preview leaf, which is not a canvas node and has no\n * ref — the case a ref lookup would have missed silently.\n *\n * An `observableRef`: a DOM node is a foreign object graph, and mobx has no\n * business walking into it.\n */\nclass InlineTextEditStore {\n node?: Aglyn.NodeSchema<any> = undefined\n rect?: InlineTextEditRect = undefined\n anchor?: Element = undefined\n propTarget?: InlinePropEditTarget = undefined\n cellTarget?: InlineCellEditTarget = undefined\n\n constructor() {\n makeAutoObservable(this, { anchor: observableRef })\n }\n\n open(\n node: Aglyn.NodeSchema<any>,\n rect: InlineTextEditRect,\n propTarget?: InlinePropEditTarget,\n anchor?: Element,\n ) {\n this.node = node\n this.rect = rect\n this.propTarget = propTarget\n this.cellTarget = undefined\n this.anchor = anchor\n }\n\n /** Opens the editor on one Table cell — see {@link InlineCellEditTarget}. */\n openCell(\n node: Aglyn.NodeSchema<any>,\n rect: InlineTextEditRect,\n cellTarget: InlineCellEditTarget,\n anchor: Element,\n ) {\n this.node = node\n this.rect = rect\n this.propTarget = undefined\n this.cellTarget = cellTarget\n this.anchor = anchor\n }\n\n close() {\n this.node = undefined\n this.rect = undefined\n this.anchor = undefined\n this.propTarget = undefined\n this.cellTarget = undefined\n }\n}\n\nexport const inlineTextEdit = new InlineTextEditStore()\n\n/**\n * Whether an inline text edit is open ON or INSIDE `element` (AGL-2486).\n *\n * The one place the \"stand down, someone is typing in here\" rule is\n * expressed. Every canvas leaf registers its own pointer handlers, and those\n * handlers begin by preventing the default — which is the default the\n * browser uses to place a caret. Asking only \"is this leaf the node being\n * edited?\" is not enough, and worse than not enough: a nested run stands its\n * own leaf down, the event then BUBBLES to the ancestor leaf, and the\n * ancestor prevents the default instead. The author sees an editor that is\n * open, styled and completely uninteractive — no caret, no drag-select, no\n * double-click-to-select-a-word.\n *\n * Containment, not identity, and by DOM rather than by node tree: the anchor\n * is the element that was measured, which is the one thing that is true for\n * a grafted instance leaf as well as a canvas node, and `contains` answers\n * for any nesting depth including the element itself.\n */\nexport function isInlineEditWithin(\n element: Element | null | undefined,\n): boolean {\n const anchor = inlineTextEdit.anchor\n return Boolean(anchor && element && element.contains(anchor))\n}\n\nexport default inlineTextEdit\n"],"names":["makeAutoObservable","observableRef","InlineTextEditStore","open","node","rect","propTarget","anchor","cellTarget","undefined","openCell","close","inlineTextEdit","isInlineEditWithin","element","Boolean","contains"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,OAAM;AA6DxD;;;;;;;;;;;;;;CAcC,GACD,IAAA,AAAMC,sBAAN,MAAMA;IAWJC,KACEC,IAA2B,EAC3BC,IAAwB,EACxBC,UAAiC,EACjCC,MAAgB,EAChB;QACA,IAAI,CAACH,IAAI,GAAGA;QACZ,IAAI,CAACC,IAAI,GAAGA;QACZ,IAAI,CAACC,UAAU,GAAGA;QAClB,IAAI,CAACE,UAAU,GAAGC;QAClB,IAAI,CAACF,MAAM,GAAGA;IAChB;IAEA,2EAA2E,GAC3EG,SACEN,IAA2B,EAC3BC,IAAwB,EACxBG,UAAgC,EAChCD,MAAe,EACf;QACA,IAAI,CAACH,IAAI,GAAGA;QACZ,IAAI,CAACC,IAAI,GAAGA;QACZ,IAAI,CAACC,UAAU,GAAGG;QAClB,IAAI,CAACD,UAAU,GAAGA;QAClB,IAAI,CAACD,MAAM,GAAGA;IAChB;IAEAI,QAAQ;QACN,IAAI,CAACP,IAAI,GAAGK;QACZ,IAAI,CAACJ,IAAI,GAAGI;QACZ,IAAI,CAACF,MAAM,GAAGE;QACd,IAAI,CAACH,UAAU,GAAGG;QAClB,IAAI,CAACD,UAAU,GAAGC;IACpB;IArCA,aAAc;aANdL,OAA+BK;aAC/BJ,OAA4BI;aAC5BF,SAAmBE;aACnBH,aAAoCG;aACpCD,aAAoCC;QAGlCT,mBAAmB,IAAI,EAAE;YAAEO,QAAQN;QAAc;IACnD;AAoCF;AAEA,OAAO,MAAMW,iBAAiB,IAAIV,sBAAqB;AAEvD;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASW,mBACdC,OAAmC;IAEnC,MAAMP,SAASK,eAAeL,MAAM;IACpC,OAAOQ,QAAQR,UAAUO,WAAWA,QAAQE,QAAQ,CAACT;AACvD;AAEA,eAAeK,eAAc"}
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
/** How much markup one commit may keep — see {@link PHRASING_TAGS}. */
|
|
18
18
|
export interface SanitizeRichTextOptions {
|
|
19
19
|
phrasingOnly?: boolean;
|
|
20
|
+
/** With `phrasingOnly`: keep links too (a Table cell). */
|
|
21
|
+
links?: boolean;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Allowlist HTML sanitizer for inline rich text: keeps basic formatting
|
|
@@ -59,6 +59,14 @@ import { escapeHtml } from "@aglyn/shared-util-tools/escape-html";
|
|
|
59
59
|
'br',
|
|
60
60
|
'span'
|
|
61
61
|
]);
|
|
62
|
+
/**
|
|
63
|
+
* Phrasing content plus links (AGL-4203) — a Table cell. A cell is one line
|
|
64
|
+
* of a pipe grid, so it takes no block; but unlike a control's label it is
|
|
65
|
+
* not itself a control, so an anchor inside it is valid.
|
|
66
|
+
*/ const PHRASING_AND_LINK_TAGS = new Set([
|
|
67
|
+
...PHRASING_TAGS,
|
|
68
|
+
'a'
|
|
69
|
+
]);
|
|
62
70
|
const SAFE_HREF = /^(https?:\/\/|mailto:|tel:|sms:|\/)/i;
|
|
63
71
|
/**
|
|
64
72
|
* Allowlist HTML sanitizer for inline rich text: keeps basic formatting
|
|
@@ -71,7 +79,7 @@ const SAFE_HREF = /^(https?:\/\/|mailto:|tel:|sms:|\/)/i;
|
|
|
71
79
|
* inside a control (AGL-2557); omitted, every existing caller is unchanged.
|
|
72
80
|
*/ export function sanitizeRichText(html, options) {
|
|
73
81
|
if (typeof document === 'undefined') return '';
|
|
74
|
-
const allowed = (options == null ? void 0 : options.phrasingOnly) ? PHRASING_TAGS : ALLOWED_TAGS;
|
|
82
|
+
const allowed = (options == null ? void 0 : options.phrasingOnly) ? options.links ? PHRASING_AND_LINK_TAGS : PHRASING_TAGS : ALLOWED_TAGS;
|
|
75
83
|
const template = document.createElement('template');
|
|
76
84
|
template.innerHTML = html;
|
|
77
85
|
const sanitizeNode = (node)=>{
|