@aglyn/besigner-ui 1.20.2 → 1.20.3

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,182 @@
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
+ */ 'use client';
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
+ import { canvas } from "@aglyn/aglyn";
19
+ import { TableEdgeAddButton } from "@aglyn/aglyn-markdown-editor";
20
+ import * as Besigner from "@aglyn/besigner";
21
+ import { Box } from "@mui/material";
22
+ import { toJS } from "mobx";
23
+ import { observer } from "mobx-react-lite";
24
+ import { useEffect, useState } from "react";
25
+ import { useAnchoredRect } from "../hooks/use-anchored-rect.js";
26
+ import { inlineMarkdownEdit } from "../utils/inline-markdown-edit.store.js";
27
+ import { inlineTextEdit } from "../utils/inline-text-edit.store.js";
28
+ import { dataTableAppendEdits, findDataTableAttributeName, withDataTableShapeEdit } from "../utils/table-cell-edit.js";
29
+ /** The canvas scroller, the box these controls are clipped to. */ const CANVAS_VIEWPORT_ID = 'aglyn:viewport-canvas';
30
+ /** Space between a table's edge and its bar. */ const GAP = 6;
31
+ /** The bar's thickness, as `TableEdgeAddButton` draws it. */ const BAR = 20;
32
+ /**
33
+ * Where the row bar sits under a SELECTED table: below the element's action
34
+ * strip, which hangs centred off the selection's bottom edge (about 23px
35
+ * tall), exactly where a full-width bar would run. A fixed clearance rather
36
+ * than a measurement: the strip's popper places itself after these bars do,
37
+ * so a reading of it is a frame stale whenever the table changes size.
38
+ */ const ROW_GAP_UNDER_ACTIONS = 30;
39
+ const NO_RECT = {
40
+ left: 0,
41
+ top: 0,
42
+ width: 0,
43
+ height: 0
44
+ };
45
+ /**
46
+ * The open cell editor's way of applying a row or column edit (AGL-4203).
47
+ *
48
+ * While a cell is being typed into, its text is not yet in the stored grid.
49
+ * A "+" pressed then has to land in the SAME write as that text, or the row
50
+ * arrives and the words just typed are lost — so the editor registers the
51
+ * one-commit path it already uses for its own Rows and columns menu, and the
52
+ * bars call that instead of writing the grid themselves.
53
+ */ let cellEditShapeHandler = null;
54
+ export function registerCellEditShapeHandler(handler) {
55
+ cellEditShapeHandler = handler;
56
+ return ()=>{
57
+ if (cellEditShapeHandler === handler) cellEditShapeHandler = null;
58
+ };
59
+ }
60
+ /**
61
+ * Marks controls that act on an open in-place edit from outside its own
62
+ * toolbar. The cell editor treats a press on one as part of the edit, not
63
+ * as a click away from it.
64
+ */ export const EDIT_COMPANION_SELECTOR = '[data-aglyn-edit-companion]';
65
+ /** The `<table>` an element draws: itself, or the first one inside it. */ function tableWithin(element) {
66
+ var _element_querySelector;
67
+ if (!element) return undefined;
68
+ if (element.tagName === 'TABLE') return element;
69
+ return (_element_querySelector = element.querySelector('table')) != null ? _element_querySelector : undefined;
70
+ }
71
+ /** The Table being typed into, or else the one selected, if either. */ function targetTable() {
72
+ var _Besigner_focus_getLastSelected, _Besigner_refs_get;
73
+ // A Markdown block's own editor carries its own table controls.
74
+ if (inlineMarkdownEdit.node) return null;
75
+ const cell = inlineTextEdit.cellTarget;
76
+ if (cell && inlineTextEdit.node) {
77
+ var _ref;
78
+ var _inlineTextEdit_anchor;
79
+ return {
80
+ node: inlineTextEdit.node,
81
+ attribute: cell.attribute,
82
+ table: (_ref = (_inlineTextEdit_anchor = inlineTextEdit.anchor) == null ? void 0 : _inlineTextEdit_anchor.closest('table')) != null ? _ref : undefined,
83
+ editing: true
84
+ };
85
+ }
86
+ // Any other in-place edit owns the canvas while it is open.
87
+ if (inlineTextEdit.node) return null;
88
+ if (Besigner.focus.getSelected().length !== 1) return null;
89
+ const $id = (_Besigner_focus_getLastSelected = Besigner.focus.getLastSelected()) == null ? void 0 : _Besigner_focus_getLastSelected.$id;
90
+ const node = $id ? canvas.getNode($id) : undefined;
91
+ const attribute = findDataTableAttributeName(node);
92
+ if (!node || !attribute) return null;
93
+ return {
94
+ node,
95
+ attribute,
96
+ table: tableWithin((_Besigner_refs_get = Besigner.refs.get($id)) == null ? void 0 : _Besigner_refs_get.current),
97
+ editing: false
98
+ };
99
+ }
100
+ /**
101
+ * "+" bars along the bottom and right edges of the canvas Table being edited
102
+ * or selected, for adding a row or a column without hunting for a menu.
103
+ *
104
+ * Mounted once among the viewport overlays. It sits outside the canvas's
105
+ * closed shadow root and positions in screen coordinates, clipped to the
106
+ * canvas scroller so a bar never paints over the designer's panels.
107
+ */ export const TableEdgeControlsComponent = observer(function TableEdgeControlsComponent() {
108
+ var _toJS;
109
+ const target = targetTable();
110
+ const props = target ? (_toJS = toJS(target.node.props)) != null ? _toJS : {} : undefined;
111
+ const edits = target && props ? dataTableAppendEdits(props[target.attribute]) : null;
112
+ const rect = useAnchoredRect(target == null ? void 0 : target.table, NO_RECT);
113
+ const [scroller, setScroller] = useState(null);
114
+ useEffect(()=>{
115
+ setScroller(document.getElementById(CANVAS_VIEWPORT_ID));
116
+ }, []);
117
+ const viewport = useAnchoredRect(scroller != null ? scroller : undefined, NO_RECT);
118
+ if (!target || !props || !edits || !target.table) return null;
119
+ if (rect.width === 0 || viewport.width === 0) return null;
120
+ // Entirely scrolled out of the canvas: nothing to reach.
121
+ if (rect.top + rect.height < viewport.top || rect.top > viewport.top + viewport.height) {
122
+ return null;
123
+ }
124
+ const apply = (edit)=>{
125
+ if (target.editing && cellEditShapeHandler) {
126
+ cellEditShapeHandler(edit);
127
+ return;
128
+ }
129
+ canvas.updateNodeProps(target.node, withDataTableShapeEdit(props, target.attribute, edit));
130
+ };
131
+ const left = rect.left - viewport.left;
132
+ const top = rect.top - viewport.top;
133
+ // A table as wide as the canvas leaves no room on its right; the bar then
134
+ // sits just inside the edge rather than off-screen.
135
+ const roomRight = left + rect.width + GAP + BAR <= viewport.width;
136
+ const columnLeft = roomRight ? left + rect.width + GAP : left + rect.width - BAR - 2;
137
+ // While a cell is being typed into the strip stands down, so the bar
138
+ // sits right under the table.
139
+ const rowGap = target.editing ? GAP : ROW_GAP_UNDER_ACTIONS;
140
+ return /*#__PURE__*/ _jsxs(Box, {
141
+ "data-aglyn": "overlay:table-edges",
142
+ "data-aglyn-edit-companion": "",
143
+ sx: {
144
+ position: 'fixed',
145
+ left: viewport.left,
146
+ top: viewport.top,
147
+ width: viewport.width,
148
+ height: viewport.height,
149
+ overflow: 'hidden',
150
+ pointerEvents: 'none',
151
+ '& [data-table-edge]': {
152
+ pointerEvents: 'auto'
153
+ }
154
+ },
155
+ children: [
156
+ /*#__PURE__*/ _jsx(TableEdgeAddButton, {
157
+ edge: "column",
158
+ onClick: ()=>apply(edits.column),
159
+ sx: {
160
+ position: 'absolute',
161
+ left: columnLeft,
162
+ top,
163
+ height: rect.height
164
+ }
165
+ }),
166
+ /*#__PURE__*/ _jsx(TableEdgeAddButton, {
167
+ edge: "row",
168
+ onClick: ()=>apply(edits.row),
169
+ sx: {
170
+ position: 'absolute',
171
+ left,
172
+ top: top + rect.height + rowGap,
173
+ width: rect.width
174
+ }
175
+ })
176
+ ]
177
+ });
178
+ });
179
+ TableEdgeControlsComponent.displayName = 'TableEdgeControlsComponent';
180
+ export default TableEdgeControlsComponent;
181
+
182
+ //# sourceMappingURL=table-edge-controls.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/table-edge-controls.component.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'use client'\n\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { canvas } from '@aglyn/aglyn'\nimport { TableEdgeAddButton } from '@aglyn/aglyn-markdown-editor'\nimport * as Besigner from '@aglyn/besigner'\nimport type { DataTableShapeEdit } from '@aglyn/shared-data-enums'\nimport { Box } from '@mui/material'\nimport { toJS } from 'mobx'\nimport { observer } from 'mobx-react-lite'\nimport { useEffect, useState } from 'react'\nimport { useAnchoredRect } from '../hooks/use-anchored-rect'\nimport { inlineMarkdownEdit } from '../utils/inline-markdown-edit.store'\nimport { inlineTextEdit } from '../utils/inline-text-edit.store'\nimport {\n dataTableAppendEdits,\n findDataTableAttributeName,\n withDataTableShapeEdit,\n} from '../utils/table-cell-edit'\n\n/** The canvas scroller, the box these controls are clipped to. */\nconst CANVAS_VIEWPORT_ID = 'aglyn:viewport-canvas'\n/** Space between a table's edge and its bar. */\nconst GAP = 6\n/** The bar's thickness, as `TableEdgeAddButton` draws it. */\nconst BAR = 20\n/**\n * Where the row bar sits under a SELECTED table: below the element's action\n * strip, which hangs centred off the selection's bottom edge (about 23px\n * tall), exactly where a full-width bar would run. A fixed clearance rather\n * than a measurement: the strip's popper places itself after these bars do,\n * so a reading of it is a frame stale whenever the table changes size.\n */\nconst ROW_GAP_UNDER_ACTIONS = 30\nconst NO_RECT = { left: 0, top: 0, width: 0, height: 0 }\n\n/**\n * The open cell editor's way of applying a row or column edit (AGL-4203).\n *\n * While a cell is being typed into, its text is not yet in the stored grid.\n * A \"+\" pressed then has to land in the SAME write as that text, or the row\n * arrives and the words just typed are lost — so the editor registers the\n * one-commit path it already uses for its own Rows and columns menu, and the\n * bars call that instead of writing the grid themselves.\n */\nlet cellEditShapeHandler: ((edit: DataTableShapeEdit) => void) | null = null\n\nexport function registerCellEditShapeHandler(\n handler: (edit: DataTableShapeEdit) => void,\n): () => void {\n cellEditShapeHandler = handler\n return () => {\n if (cellEditShapeHandler === handler) cellEditShapeHandler = null\n }\n}\n\n/**\n * Marks controls that act on an open in-place edit from outside its own\n * toolbar. The cell editor treats a press on one as part of the edit, not\n * as a click away from it.\n */\nexport const EDIT_COMPANION_SELECTOR = '[data-aglyn-edit-companion]'\n\n/** The `<table>` an element draws: itself, or the first one inside it. */\nfunction tableWithin(element: Element | null | undefined): Element | undefined {\n if (!element) return undefined\n if (element.tagName === 'TABLE') return element\n return element.querySelector('table') ?? undefined\n}\n\ninterface TargetTable {\n node: Aglyn.NodeSchema<any>\n attribute: string\n table: Element | undefined\n editing: boolean\n}\n\n/** The Table being typed into, or else the one selected, if either. */\nfunction targetTable(): TargetTable | null {\n // A Markdown block's own editor carries its own table controls.\n if (inlineMarkdownEdit.node) return null\n const cell = inlineTextEdit.cellTarget\n if (cell && inlineTextEdit.node) {\n return {\n node: inlineTextEdit.node,\n attribute: cell.attribute,\n table: inlineTextEdit.anchor?.closest('table') ?? undefined,\n editing: true,\n }\n }\n // Any other in-place edit owns the canvas while it is open.\n if (inlineTextEdit.node) return null\n if (Besigner.focus.getSelected().length !== 1) return null\n const $id = Besigner.focus.getLastSelected()?.$id\n const node = $id ? canvas.getNode($id) : undefined\n const attribute = findDataTableAttributeName(node)\n if (!node || !attribute) return null\n return {\n node,\n attribute,\n table: tableWithin(Besigner.refs.get($id)?.current),\n editing: false,\n }\n}\n\n/**\n * \"+\" bars along the bottom and right edges of the canvas Table being edited\n * or selected, for adding a row or a column without hunting for a menu.\n *\n * Mounted once among the viewport overlays. It sits outside the canvas's\n * closed shadow root and positions in screen coordinates, clipped to the\n * canvas scroller so a bar never paints over the designer's panels.\n */\nexport const TableEdgeControlsComponent = observer(\n function TableEdgeControlsComponent() {\n const target = targetTable()\n const props = target\n ? ((toJS(target.node.props) ?? {}) as Record<string, unknown>)\n : undefined\n const edits =\n target && props ? dataTableAppendEdits(props[target.attribute]) : null\n\n const rect = useAnchoredRect(target?.table, NO_RECT)\n const [scroller, setScroller] = useState<Element | null>(null)\n useEffect(() => {\n setScroller(document.getElementById(CANVAS_VIEWPORT_ID))\n }, [])\n const viewport = useAnchoredRect(scroller ?? undefined, NO_RECT)\n if (!target || !props || !edits || !target.table) return null\n if (rect.width === 0 || viewport.width === 0) return null\n // Entirely scrolled out of the canvas: nothing to reach.\n if (\n rect.top + rect.height < viewport.top ||\n rect.top > viewport.top + viewport.height\n ) {\n return null\n }\n\n const apply = (edit: DataTableShapeEdit) => {\n if (target.editing && cellEditShapeHandler) {\n cellEditShapeHandler(edit)\n return\n }\n canvas.updateNodeProps(\n target.node,\n withDataTableShapeEdit(props, target.attribute, edit) as never,\n )\n }\n\n const left = rect.left - viewport.left\n const top = rect.top - viewport.top\n // A table as wide as the canvas leaves no room on its right; the bar then\n // sits just inside the edge rather than off-screen.\n const roomRight = left + rect.width + GAP + BAR <= viewport.width\n const columnLeft = roomRight\n ? left + rect.width + GAP\n : left + rect.width - BAR - 2\n // While a cell is being typed into the strip stands down, so the bar\n // sits right under the table.\n const rowGap = target.editing ? GAP : ROW_GAP_UNDER_ACTIONS\n\n return (\n <Box\n data-aglyn=\"overlay:table-edges\"\n data-aglyn-edit-companion=\"\"\n sx={{\n position: 'fixed',\n left: viewport.left,\n top: viewport.top,\n width: viewport.width,\n height: viewport.height,\n overflow: 'hidden',\n pointerEvents: 'none',\n '& [data-table-edge]': { pointerEvents: 'auto' },\n }}\n >\n <TableEdgeAddButton\n edge=\"column\"\n onClick={() => apply(edits.column)}\n sx={{\n position: 'absolute',\n left: columnLeft,\n top,\n height: rect.height,\n }}\n />\n <TableEdgeAddButton\n edge=\"row\"\n onClick={() => apply(edits.row)}\n sx={{\n position: 'absolute',\n left,\n top: top + rect.height + rowGap,\n width: rect.width,\n }}\n />\n </Box>\n )\n },\n)\nTableEdgeControlsComponent.displayName = 'TableEdgeControlsComponent'\n\nexport default TableEdgeControlsComponent\n"],"names":["canvas","TableEdgeAddButton","Besigner","Box","toJS","observer","useEffect","useState","useAnchoredRect","inlineMarkdownEdit","inlineTextEdit","dataTableAppendEdits","findDataTableAttributeName","withDataTableShapeEdit","CANVAS_VIEWPORT_ID","GAP","BAR","ROW_GAP_UNDER_ACTIONS","NO_RECT","left","top","width","height","cellEditShapeHandler","registerCellEditShapeHandler","handler","EDIT_COMPANION_SELECTOR","tableWithin","element","undefined","tagName","querySelector","targetTable","node","cell","cellTarget","attribute","table","anchor","closest","editing","focus","getSelected","length","$id","getLastSelected","getNode","refs","get","current","TableEdgeControlsComponent","target","props","edits","rect","scroller","setScroller","document","getElementById","viewport","apply","edit","updateNodeProps","roomRight","columnLeft","rowGap","data-aglyn","data-aglyn-edit-companion","sx","position","overflow","pointerEvents","edge","onClick","column","row","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAGA,SAASA,MAAM,QAAQ,eAAc;AACrC,SAASC,kBAAkB,QAAQ,+BAA8B;AACjE,YAAYC,cAAc,kBAAiB;AAE3C,SAASC,GAAG,QAAQ,gBAAe;AACnC,SAASC,IAAI,QAAQ,OAAM;AAC3B,SAASC,QAAQ,QAAQ,kBAAiB;AAC1C,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC3C,SAASC,eAAe,QAAQ,gCAA4B;AAC5D,SAASC,kBAAkB,QAAQ,yCAAqC;AACxE,SAASC,cAAc,QAAQ,qCAAiC;AAChE,SACEC,oBAAoB,EACpBC,0BAA0B,EAC1BC,sBAAsB,QACjB,8BAA0B;AAEjC,gEAAgE,GAChE,MAAMC,qBAAqB;AAC3B,8CAA8C,GAC9C,MAAMC,MAAM;AACZ,2DAA2D,GAC3D,MAAMC,MAAM;AACZ;;;;;;CAMC,GACD,MAAMC,wBAAwB;AAC9B,MAAMC,UAAU;IAAEC,MAAM;IAAGC,KAAK;IAAGC,OAAO;IAAGC,QAAQ;AA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mC,KAAKjC,KAAK,GAAGN,MAAMC,OAAO2C,SAAStC,KAAK;IACjE,MAAM2C,aAAaD,YACf5C,OAAOmC,KAAKjC,KAAK,GAAGN,MACpBI,OAAOmC,KAAKjC,KAAK,GAAGL,MAAM;IAC9B,qEAAqE;IACrE,8BAA8B;IAC9B,MAAMiD,SAASd,OAAOX,OAAO,GAAGzB,MAAME;IAEtC,qBACE,MAACd;QACC+D,cAAW;QACXC,6BAA0B;QAC1BC,IAAI;YACFC,UAAU;YACVlD,MAAMwC,SAASxC,IAAI;YACnBC,KAAKuC,SAASvC,GAAG;YACjBC,OAAOsC,SAAStC,KAAK;YACrBC,QAAQqC,SAASrC,MAAM;YACvBgD,UAAU;YACVC,eAAe;YACf,uBAAuB;gBAAEA,eAAe;YAAO;QACjD;;0BAEA,KAACtE;gBACCuE,MAAK;gBACLC,SAAS,IAAMb,MAAMP,MAAMqB,MAAM;gBACjCN,IAAI;oBACFC,UAAU;oBACVlD,MAAM6C;oBACN5C;oBACAE,QAAQgC,KAAKhC,MAAM;gBACrB;;0BAEF,KAACrB;gBACCuE,MAAK;gBACLC,SAAS,IAAMb,MAAMP,MAAMsB,GAAG;gBAC9BP,IAAI;oBACFC,UAAU;oBACVlD;oBACAC,KAAKA,MAAMkC,KAAKhC,MAAM,GAAG2C;oBACzB5C,OAAOiC,KAAKjC,KAAK;gBACnB;;;;AAIR,GACD;AACD6B,2BAA2B0B,WAAW,GAAG;AAEzC,eAAe1B,2BAA0B"}
@@ -41,6 +41,7 @@ import { hoistStateSx } from "../utils/state-sx.js";
41
41
  import CanvasDropIndicator from "./dnd/canvas-drop-indicator.js";
42
42
  import InlineMarkdownEditorComponent from "./inline-markdown-editor.component.js";
43
43
  import InlineTextEditorComponent from "./inline-text-editor.component.js";
44
+ import TableEdgeControlsComponent from "./table-edge-controls.component.js";
44
45
  import LayoutPartMenu, { findLayoutPart, layoutPartMenu } from "./layout-part-menu.component.js";
45
46
  import NodeLeaf, { MediaFactsLeaf } from "./node-leaf.js";
46
47
  import NodeOverlay from "./node-overlay.js";
@@ -360,6 +361,7 @@ const Overlays = /*#__PURE__*/ forwardRef((props, ref)=>{
360
361
  }),
361
362
  /*#__PURE__*/ _jsx(CanvasDropIndicator, {}),
362
363
  /*#__PURE__*/ _jsx(LayoutPartMenu, {}),
364
+ /*#__PURE__*/ _jsx(TableEdgeControlsComponent, {}),
363
365
  /*#__PURE__*/ _jsx(InlineTextEditorComponent, {}),
364
366
  /*#__PURE__*/ _jsx(InlineMarkdownEditorComponent, {})
365
367
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/viewport-frame.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2024 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 { canvas, LAYOUT_SLOT_COMPONENT_ID, NODE_ROOT_ID } from '@aglyn/aglyn'\n// Deep import, NOT the barrel (AGL-2486) — see `plugin-styles-ui.tsx`.\nimport { PluginStyles } from '@aglyn/aglyn/plugin-manager/plugin-styles-ui'\nimport {\n AglynNodeRenderer,\n Leaf,\n LeafSxTransformContext,\n} from '@aglyn/aglyn-node-renderer'\nimport * as Besigner from '@aglyn/besigner'\nimport {\n useAglynSiteSchemeThemes,\n useAglynSiteTheme,\n} from '@aglyn/aglyn-node-renderer'\nimport {\n MuiShadowDom,\n type MuiShadowRootProps,\n useMuiShadowDomContext,\n} from '@aglyn/shared-ui-jsx'\nimport {\n SiteSchemeThemesContext,\n styled,\n type Theme,\n ThemeProvider,\n useHostThemeDocument,\n} from '@aglyn/shared-ui-theme'\nimport {\n Box,\n type BoxProps,\n CssBaseline,\n GlobalStyles,\n useTheme,\n} from '@mui/material'\nimport { observer } from 'mobx-react-lite'\n// import {MuiShadowDom} from '@aglyn/shared-ui-jsx'\nimport {\n type ComponentProps,\n forwardRef,\n HTMLAttributes,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react'\nimport CanvasChromeThemeContext from '../contexts/canvas-chrome-theme-context'\nimport { CanvasHostTokensProvider } from '../contexts/canvas-host-tokens-context'\nimport CanvasPageRecordContext from '../contexts/canvas-page-record-context'\nimport RepeatRecordContext from '../contexts/repeat-record-context'\nimport CanvasRevealContext, {\n CanvasMutedClassesContext,\n} from '../contexts/canvas-reveal-context'\nimport { useLayoutChromeContext } from '../contexts/layout-chrome-context'\nimport useAglynBesignerFlag from '../hooks/use-aglyn-besigner-flag'\nimport {\n createDevicePinnedTheme,\n devicePreviewWidth,\n resolveSxForDeviceWidth,\n} from '../utils/device-preview-styles'\nimport { applyMutedStyles } from '../utils/muted-styles'\nimport { hoistStateSx } from '../utils/state-sx'\nimport CanvasDropIndicator from './dnd/canvas-drop-indicator'\nimport InlineMarkdownEditorComponent from './inline-markdown-editor.component'\nimport InlineTextEditorComponent from './inline-text-editor.component'\nimport LayoutPartMenu, {\n findLayoutPart,\n layoutPartMenu,\n} from './layout-part-menu.component'\nimport NodeLeaf, { MediaFactsLeaf } from './node-leaf'\nimport NodeOverlay from './node-overlay'\n\nconst ViewportFrame = styled('div', {\n name: 'AglynViewportFrame',\n})(({ theme }) => {\n // In CSS vars mode, theme.palette.* is pinned to the static light-mode values.\n // Use (theme.vars || theme) so these resolve to CSS custom-property references\n // that update automatically when setMode() applies the .dark class.\n const t = theme as any\n const tv = t.vars || theme\n return {\n flexGrow: 1,\n minHeight: '100%',\n width: '100%',\n background: tv.palette.background.paper,\n borderColor: tv.palette.divider,\n borderWidth: `0.3em`,\n borderStyle: 'solid',\n display: 'flex',\n // position: 'relative',\n }\n})\nViewportFrame.displayName = 'ViewportFrame'\n\ntype SiteShadowDomProps = HTMLAttributes<HTMLDivElement> & MuiShadowRootProps\nconst SiteShadowDom = styled(MuiShadowDom.div, {\n name: 'AglynViewportShadowDom',\n})<SiteShadowDomProps>(({ theme }) => ({\n minHeight: '100%',\n width: '100%',\n /**\n * Positioning hack\n * @see https://stackoverflow.com/a/70422489/16134372\n */\n transform: 'scale(1)',\n}))\nSiteShadowDom.displayName = 'SiteShadowDom'\nconst FramePaper = styled('div', {\n name: 'AglynFramePaper',\n})<SiteShadowDomProps>(({ theme }) => {\n const tv = (theme as any).vars || theme\n return {\n // CssBaseline styles the document body, which a closed shadow root never\n // sees (and `:host { all: initial }` resets inheritance), so this surface\n // carries the body-level baseline itself.\n ...theme.typography.body1,\n color: tv.palette.text.primary,\n backgroundColor: tv.palette.background.default,\n colorScheme: theme.palette.mode,\n WebkitFontSmoothing: 'antialiased',\n MozOsxFontSmoothing: 'grayscale',\n height: '100%',\n width: '100%',\n [`> [data-aglyn=\"leaf\\\\:_@_\"]`]: {\n minHeight: '100%',\n width: '100%',\n },\n }\n})\nFramePaper.displayName = 'FramePaper'\n\n/**\n * What `CssBaseline` gives a published page and a closed shadow root never\n * inherits (AGL-3146).\n *\n * `:host { all: initial }` cuts inheritance at the artboard, so the canvas\n * carries the document baseline itself — `FramePaper` takes the body's\n * typography, color and background, and the structural half belongs here,\n * because `box-sizing` is inherited from the root element rather than set on\n * each one. Without it every element on the canvas is `content-box` while the\n * same element on the site is `border-box`, so a band that sets a height AND\n * padding measures the padding twice in the editor and once on the page.\n *\n * The same pair CssBaseline emits, for the same reason: declared on the host\n * and inherited by everything under it, so an author's own `box-sizing` still\n * wins wherever they set one.\n */\nexport const VIEWPORT_BASELINE_STYLES = {\n ':host': {\n all: 'initial',\n boxSizing: 'border-box',\n },\n '*, *::before, *::after': {\n boxSizing: 'inherit',\n },\n} as const\n\nconst ViewportGlobalStyles = (\n <GlobalStyles\n styles={{\n ...VIEWPORT_BASELINE_STYLES,\n // Canvas-sense for aglyn-hidden elements (AGL-592): start closed\n // like the live site, and stay closed unless the leaf itself is\n // flagged as revealed. `node-leaf` decides that from the reveal\n // toggle and the selection and stamps the flag on the hidden\n // element — the same element this rule hides — so no wrapper a\n // component renders around its children can separate the two.\n // Expressed as a :not() guard (not hide-then-revert) so a revealed\n // panel keeps its natural display. Injected into the closed shadow\n // root via the shadow-scoped emotion cache — the live tenant is\n // untouched.\n '.aglyn-hidden:not([data-aglyn-revealed])': {\n display: 'none !important',\n },\n }}\n />\n)\nconst ThemedElementContainer = ({ children }) => {\n const shadowDom = useMuiShadowDomContext()\n const hostThemeDoc = useHostThemeDocument()\n const [canvasScheme] = useAglynBesignerFlag('canvasScheme')\n const hostTheme = useAglynSiteTheme({\n container: shadowDom,\n theme: hostThemeDoc,\n scheme: canvasScheme,\n })\n // Artboard device preview (AGL-581): media queries evaluate against\n // the browser viewport, never the artboard, so a selected device pins\n // the canvas subtree instead — a theme whose breakpoint helpers are\n // forced for the device width (responsive sx values, Stack/Grid\n // props, component styles), plus a per-Leaf sx transform that\n // resolves width media keys (visibility bands, custom CSS) at that\n // width. Fluid Responsive leaves both untouched, and the published\n // tenant never mounts any of this.\n const [devicePreview] = useAglynBesignerFlag('devicePreview')\n const deviceWidth = devicePreviewWidth(\n devicePreview,\n hostTheme.breakpoints?.values,\n )\n // The console's own theme, read before the site's replaces it below.\n const chromeTheme = useTheme()\n const canvasTheme = useMemo(\n () =>\n deviceWidth == null\n ? hostTheme\n : createDevicePinnedTheme(hostTheme, deviceWidth),\n [hostTheme, deviceWidth],\n )\n // The other scheme, for an \"Always light\" / \"Always dark\" element\n // (AGL-3284), pinned to the same device width so a forced band re-resolves\n // its responsive values at the artboard width like everything around it.\n const pinToDevice = useCallback(\n (theme: Theme) =>\n deviceWidth == null ? theme : createDevicePinnedTheme(theme, deviceWidth),\n [deviceWidth],\n )\n const schemeThemes = useAglynSiteSchemeThemes({\n container: shadowDom,\n theme: hostThemeDoc,\n active: canvasTheme,\n finish: pinToDevice,\n })\n // Interaction-state hold (AGL-2486): while the Styles panel is editing a\n // state slice, the SELECTED element renders as if it were in that state —\n // you cannot hover an element from a side panel, so a state you cannot see\n // is a state you cannot design. Composed into the SAME canvas-only\n // transform the device-width pin uses, so there is still exactly one\n // substitution path and the tenant (which never mounts this provider) is\n // untouched. The hoist runs FIRST so a media key inside the slice reaches\n // the width transform at the top level.\n const [heldState] = useAglynBesignerFlag('heldState')\n const [heldStateNodeId] = useAglynBesignerFlag('heldStateNodeId')\n // Declarations switched off for comparison (AGL-2486). Third rider on the\n // same canvas-only transform, and it runs FIRST: a muted base declaration\n // has to be gone before a held state's slice is folded over it, and a muted\n // slice declaration has to leave the slice so the base shows through.\n const [mutedStyles] = useAglynBesignerFlag('mutedStyles')\n const sxTransform = useMemo(() => {\n const held = heldState && heldStateNodeId ? heldState : null\n const muted = mutedStyles?.length ? mutedStyles : null\n if (deviceWidth == null && !held && !muted) return undefined\n return (sx: unknown, nodeId?: string) => {\n const unmuted = muted ? applyMutedStyles(sx, nodeId, muted) : sx\n const scoped =\n held && nodeId === heldStateNodeId\n ? hoistStateSx(unmuted, held)\n : unmuted\n return deviceWidth == null\n ? scoped\n : resolveSxForDeviceWidth(scoped, deviceWidth)\n }\n }, [deviceWidth, heldState, heldStateNodeId, mutedStyles])\n // Elements the author opened up for designing (AGL-592). Subscribed once\n // here, exactly like the held state above, and handed down by context so a\n // canvas of several hundred leaves carries one subscription rather than one\n // per element.\n const [revealedNodeIds] = useAglynBesignerFlag('revealedNodeIds')\n // Classes switched off for comparison (AGL-2486), subscribed the same way.\n const [mutedClasses] = useAglynBesignerFlag('mutedClasses')\n // A record template's previewed record (AGL-3475), laid over the editable\n // document and its chrome alike, as the published page's composition lays\n // the routed record over both. A repeat inside the page provides its own.\n const pageRecord = useContext(CanvasPageRecordContext)\n const pageScope = useMemo(\n () =>\n pageRecord\n ? {\n record: pageRecord.record,\n model: pageRecord.model,\n datasetsByKey: pageRecord.datasetsByKey,\n }\n : undefined,\n [pageRecord],\n )\n return (\n <SiteSchemeThemesContext.Provider value={schemeThemes}>\n <CanvasChromeThemeContext.Provider value={chromeTheme}>\n <ThemeProvider theme={canvasTheme}>\n <CssBaseline />\n <CanvasRevealContext.Provider value={revealedNodeIds}>\n <CanvasMutedClassesContext.Provider value={mutedClasses}>\n <LeafSxTransformContext.Provider value={sxTransform}>\n {/* The site whose host variables every leaf fills in (AGL-2881),\n decided once for the editable document and its chrome alike. */}\n <CanvasHostTokensProvider>\n {pageScope ? (\n <RepeatRecordContext.Provider value={pageScope}>\n {children}\n </RepeatRecordContext.Provider>\n ) : (\n children\n )}\n </CanvasHostTokensProvider>\n </LeafSxTransformContext.Provider>\n </CanvasMutedClassesContext.Provider>\n </CanvasRevealContext.Provider>\n </ThemeProvider>\n </CanvasChromeThemeContext.Provider>\n </SiteSchemeThemesContext.Provider>\n )\n}\n\nconst EditableScreenRenderer = observer(() => (\n <AglynNodeRenderer\n node={canvas.getNode(NODE_ROOT_ID)!}\n LeafComponent={NodeLeaf}\n />\n))\nEditableScreenRenderer.displayName = 'EditableScreenRenderer'\n\n/**\n * Leaf for the read-only layout chrome tree: the LayoutSlot renders the\n * editable screen canvas after any chrome the designer left inside the slot\n * (matching composition semantics); everything else renders with the\n * production Leaf, which carries none of the designer's selection/dnd\n * behavior — the chrome is locked by construction.\n */\nconst LayoutChromeLeaf = forwardRef<any, any>((props, ref) => {\n const { node, children, ...rest } = props\n if (node?.componentId === LAYOUT_SLOT_COMPONENT_ID) {\n return (\n <Leaf ref={ref} node={node} {...rest}>\n {children}\n <EditableScreenRenderer />\n </Leaf>\n )\n }\n // An image or film in the chrome shows its DAM asset's current facts, as the\n // published page composes it (AGL-2838, AGL-2856).\n return (\n <MediaFactsLeaf ref={ref} node={node} {...rest}>\n {children}\n </MediaFactsLeaf>\n )\n})\nLayoutChromeLeaf.displayName = 'LayoutChromeLeaf'\n\nconst SiteContainer = observer(\n forwardRef<any, SiteShadowDomProps>((props, ref) => {\n const { ...rest } = props\n const { chromeCanvas } = useLayoutChromeContext()\n const chromeRoot = chromeCanvas?.getNode(NODE_ROOT_ID)\n // State, not a ref: the paper mounts inside the shadow root after this\n // component does, and the listener below has to follow it there.\n const [paper, setPaper] = useState<HTMLElement | null>(null)\n useEffect(() => {\n if (!paper || !chromeCanvas) return\n // Native, like every canvas listener: React never sees an event from\n // inside the closed shadow root.\n const onClick = (event: MouseEvent) => {\n const part = findLayoutPart(event.target, chromeCanvas)\n if (!part) return\n // A link in the layout's nav would otherwise navigate the editor.\n event.preventDefault()\n layoutPartMenu.open(part, { left: event.clientX, top: event.clientY })\n }\n paper.addEventListener('click', onClick)\n return () => paper.removeEventListener('click', onClick)\n }, [paper, chromeCanvas])\n return (\n <SiteShadowDom\n ref={ref}\n data-aglyn={'viewport:dom'}\n mode=\"closed\"\n {...rest}\n >\n <>\n {ViewportGlobalStyles}\n {/* Plugin stylesheets (AGL-2486). THIS is the gap `8dc718ed4` named\n and left open: a plugin's raw CSS goes into `document.head`,\n which a `mode: 'closed'` shadow root with `:host { all: initial }`\n and no `adoptedStyleSheets` never sees. Measured — the identical\n rule that beats every `@layer mui` declaration on the published\n page had literally NO effect on this canvas. Rendered here as a\n plain `<style>` child, so it lands in the shadow root in the same\n unlayered slot it occupies on the published document; `shadow`\n scope is what pulls in the MIRRORED sheets a bundle injected into\n the console's own head, which is the copy that never crossed. */}\n <PluginStyles scope=\"shadow\" />\n <ThemedElementContainer>\n <FramePaper ref={setPaper}>\n {chromeRoot ? (\n <AglynNodeRenderer\n node={chromeRoot}\n LeafComponent={LayoutChromeLeaf}\n />\n ) : (\n <EditableScreenRenderer />\n )}\n </FramePaper>\n </ThemedElementContainer>\n </>\n </SiteShadowDom>\n )\n }),\n)\n\nconst Overlays = forwardRef<any, Partial<BoxProps>>((props, ref) => {\n const { ...rest } = props\n\n return (\n <Box\n ref={ref}\n data-aglyn=\"viewport:popover\"\n sx={{\n // position: 'relative',\n // Above the canvas content, below the designer chrome (app bars and\n // breadcrumbs sit at zIndex.appBar) within the workspace context.\n zIndex: 10,\n }}\n {...rest}\n >\n {/* Document order is the only thing separating these two. Each\n overlay root is a fixed-position popper and therefore its own\n stacking context, so a z-index declared inside one cannot lift it\n past the other — the roots paint in the order they are rendered.\n The overlay carrying the action strip goes LAST so its buttons stay\n above the other overlay's outline, which draws the SELECTED\n treatment whenever the pointer is resting on the selected node,\n i.e. whenever someone is reaching for those buttons. The canvas\n chrome rendered after them keeps painting above both. */}\n <NodeOverlay data-aglyn=\"overlay:hovered\" variant=\"hovered\" />\n <NodeOverlay data-aglyn=\"overlay:selected\" variant=\"selected\" />\n <CanvasDropIndicator />\n <LayoutPartMenu />\n <InlineTextEditorComponent />\n <InlineMarkdownEditorComponent />\n </Box>\n )\n})\n\nexport interface ViewportFrameComponentProps extends ComponentProps<\n typeof ViewportFrame\n> {}\n\nexport const ViewportFrameComponent = forwardRef<\n any,\n ViewportFrameComponentProps\n>((props, ref) => {\n const { onMouseLeave, ...rest } = props\n\n const handlePointerLeave = useCallback(\n (e) => {\n // e.stopPropagation()\n Besigner.focus.clearHover()\n onMouseLeave && onMouseLeave(e)\n },\n [onMouseLeave],\n )\n\n return (\n <ViewportFrame\n ref={ref}\n data-aglyn=\"viewport:frame\"\n onMouseLeave={handlePointerLeave}\n onPointerLeave={handlePointerLeave}\n {...rest}\n >\n <SiteContainer />\n <Overlays />\n </ViewportFrame>\n )\n})\n\nViewportFrameComponent.displayName = 'ViewportFrameComponent'\nViewportFrameComponent.aglyn = true\n\nexport default ViewportFrameComponent\n"],"names":["canvas","LAYOUT_SLOT_COMPONENT_ID","NODE_ROOT_ID","PluginStyles","AglynNodeRenderer","Leaf","LeafSxTransformContext","Besigner","useAglynSiteSchemeThemes","useAglynSiteTheme","MuiShadowDom","useMuiShadowDomContext","SiteSchemeThemesContext","styled","ThemeProvider","useHostThemeDocument","Box","CssBaseline","GlobalStyles","useTheme","observer","forwardRef","useCallback","useContext","useEffect","useMemo","useState","CanvasChromeThemeContext","CanvasHostTokensProvider","CanvasPageRecordContext","RepeatRecordContext","CanvasRevealContext","CanvasMutedClassesContext","useLayoutChromeContext","useAglynBesignerFlag","createDevicePinnedTheme","devicePreviewWidth","resolveSxForDeviceWidth","applyMutedStyles","hoistStateSx","CanvasDropIndicator","InlineMarkdownEditorComponent","InlineTextEditorComponent","LayoutPartMenu","findLayoutPart","layoutPartMenu","NodeLeaf","MediaFactsLeaf","NodeOverlay","ViewportFrame","name","theme","t","tv","vars","flexGrow","minHeight","width","background","palette","paper","borderColor","divider","borderWidth","borderStyle","display","displayName","SiteShadowDom","div","transform","FramePaper","typography","body1","color","text","primary","backgroundColor","default","colorScheme","mode","WebkitFontSmoothing","MozOsxFontSmoothing","height","VIEWPORT_BASELINE_STYLES","all","boxSizing","ViewportGlobalStyles","styles","ThemedElementContainer","children","hostTheme","shadowDom","hostThemeDoc","canvasScheme","container","scheme","devicePreview","deviceWidth","breakpoints","values","chromeTheme","canvasTheme","pinToDevice","schemeThemes","active","finish","heldState","heldStateNodeId","mutedStyles","sxTransform","held","muted","length","undefined","sx","nodeId","unmuted","scoped","revealedNodeIds","mutedClasses","pageRecord","pageScope","record","model","datasetsByKey","Provider","value","EditableScreenRenderer","node","getNode","LeafComponent","LayoutChromeLeaf","props","ref","rest","componentId","SiteContainer","chromeCanvas","chromeRoot","setPaper","onClick","event","part","target","preventDefault","open","left","clientX","top","clientY","addEventListener","removeEventListener","data-aglyn","scope","Overlays","zIndex","variant","ViewportFrameComponent","onMouseLeave","handlePointerLeave","e","focus","clearHover","onPointerLeave","aglyn"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,MAAM,EAAEC,wBAAwB,EAAEC,YAAY,QAAQ,eAAc;AAC7E,uEAAuE;AACvE,SAASC,YAAY,QAAQ,+CAA8C;AAC3E,SACEC,iBAAiB,EACjBC,IAAI,EACJC,sBAAsB,QACjB,6BAA4B;AACnC,YAAYC,cAAc,kBAAiB;AAC3C,SACEC,wBAAwB,EACxB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E;QACCkE,KAAKA;QACLmB,cAAY;QACZzE,MAAK;OACDuD;kBAEJ,cAAA;;gBACGhD;8BAWD,KAACnF;oBAAasJ,OAAM;;8BACpB,KAACjE;8BACC,cAAA,KAAClB;wBAAW+D,KAAKM;kCACdD,2BACC,KAACtI;4BACC4H,MAAMU;4BACNR,eAAeC;2CAGjB,KAACJ;;;;;;AAOf;AAGF,MAAM2B,yBAAWrI,WAAmC,CAAC+G,OAAOC;IAC1D,MAAM,EAAW,GAAGD,OAATE,oBAASF;IAEpB,qBACE,MAACpH;QACCqH,KAAKA;QACLmB,cAAW;QACXtC,IAAI;YACF,wBAAwB;YACxB,oEAAoE;YACpE,kEAAkE;YAClEyC,QAAQ;QACV;OACIrB;;0BAWJ,KAACtF;gBAAYwG,cAAW;gBAAkBI,SAAQ;;0BAClD,KAAC5G;gBAAYwG,cAAW;gBAAmBI,SAAQ;;0BACnD,KAACpH;0BACD,KAACG;0BACD,KAACD;0BACD,KAACD;;;AAGP;AAMA,OAAO,MAAMoH,uCAAyBxI,WAGpC,CAAC+G,OAAOC;IACR,MAAM,EAAEyB,YAAY,EAAW,GAAG1B,OAATE,wCAASF;;;IAElC,MAAM2B,qBAAqBzI,YACzB,CAAC0I;QACC,sBAAsB;QACtBzJ,SAAS0J,KAAK,CAACC,UAAU;QACzBJ,gBAAgBA,aAAaE;IAC/B,GACA;QAACF;KAAa;IAGhB,qBACE,MAAC7G;QACCoF,KAAKA;QACLmB,cAAW;QACXM,cAAcC;QACdI,gBAAgBJ;OACZzB;;0BAEJ,KAACE;0BACD,KAACkB;;;AAGP,GAAE;AAEFG,uBAAuB3F,WAAW,GAAG;AACrC2F,uBAAuBO,KAAK,GAAG;AAE/B,eAAeP,uBAAsB"}
1
+ {"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/viewport-frame.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2024 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 { canvas, LAYOUT_SLOT_COMPONENT_ID, NODE_ROOT_ID } from '@aglyn/aglyn'\n// Deep import, NOT the barrel (AGL-2486) — see `plugin-styles-ui.tsx`.\nimport { PluginStyles } from '@aglyn/aglyn/plugin-manager/plugin-styles-ui'\nimport {\n AglynNodeRenderer,\n Leaf,\n LeafSxTransformContext,\n} from '@aglyn/aglyn-node-renderer'\nimport * as Besigner from '@aglyn/besigner'\nimport {\n useAglynSiteSchemeThemes,\n useAglynSiteTheme,\n} from '@aglyn/aglyn-node-renderer'\nimport {\n MuiShadowDom,\n type MuiShadowRootProps,\n useMuiShadowDomContext,\n} from '@aglyn/shared-ui-jsx'\nimport {\n SiteSchemeThemesContext,\n styled,\n type Theme,\n ThemeProvider,\n useHostThemeDocument,\n} from '@aglyn/shared-ui-theme'\nimport {\n Box,\n type BoxProps,\n CssBaseline,\n GlobalStyles,\n useTheme,\n} from '@mui/material'\nimport { observer } from 'mobx-react-lite'\n// import {MuiShadowDom} from '@aglyn/shared-ui-jsx'\nimport {\n type ComponentProps,\n forwardRef,\n HTMLAttributes,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react'\nimport CanvasChromeThemeContext from '../contexts/canvas-chrome-theme-context'\nimport { CanvasHostTokensProvider } from '../contexts/canvas-host-tokens-context'\nimport CanvasPageRecordContext from '../contexts/canvas-page-record-context'\nimport RepeatRecordContext from '../contexts/repeat-record-context'\nimport CanvasRevealContext, {\n CanvasMutedClassesContext,\n} from '../contexts/canvas-reveal-context'\nimport { useLayoutChromeContext } from '../contexts/layout-chrome-context'\nimport useAglynBesignerFlag from '../hooks/use-aglyn-besigner-flag'\nimport {\n createDevicePinnedTheme,\n devicePreviewWidth,\n resolveSxForDeviceWidth,\n} from '../utils/device-preview-styles'\nimport { applyMutedStyles } from '../utils/muted-styles'\nimport { hoistStateSx } from '../utils/state-sx'\nimport CanvasDropIndicator from './dnd/canvas-drop-indicator'\nimport InlineMarkdownEditorComponent from './inline-markdown-editor.component'\nimport InlineTextEditorComponent from './inline-text-editor.component'\nimport TableEdgeControlsComponent from './table-edge-controls.component'\nimport LayoutPartMenu, {\n findLayoutPart,\n layoutPartMenu,\n} from './layout-part-menu.component'\nimport NodeLeaf, { MediaFactsLeaf } from './node-leaf'\nimport NodeOverlay from './node-overlay'\n\nconst ViewportFrame = styled('div', {\n name: 'AglynViewportFrame',\n})(({ theme }) => {\n // In CSS vars mode, theme.palette.* is pinned to the static light-mode values.\n // Use (theme.vars || theme) so these resolve to CSS custom-property references\n // that update automatically when setMode() applies the .dark class.\n const t = theme as any\n const tv = t.vars || theme\n return {\n flexGrow: 1,\n minHeight: '100%',\n width: '100%',\n background: tv.palette.background.paper,\n borderColor: tv.palette.divider,\n borderWidth: `0.3em`,\n borderStyle: 'solid',\n display: 'flex',\n // position: 'relative',\n }\n})\nViewportFrame.displayName = 'ViewportFrame'\n\ntype SiteShadowDomProps = HTMLAttributes<HTMLDivElement> & MuiShadowRootProps\nconst SiteShadowDom = styled(MuiShadowDom.div, {\n name: 'AglynViewportShadowDom',\n})<SiteShadowDomProps>(({ theme }) => ({\n minHeight: '100%',\n width: '100%',\n /**\n * Positioning hack\n * @see https://stackoverflow.com/a/70422489/16134372\n */\n transform: 'scale(1)',\n}))\nSiteShadowDom.displayName = 'SiteShadowDom'\nconst FramePaper = styled('div', {\n name: 'AglynFramePaper',\n})<SiteShadowDomProps>(({ theme }) => {\n const tv = (theme as any).vars || theme\n return {\n // CssBaseline styles the document body, which a closed shadow root never\n // sees (and `:host { all: initial }` resets inheritance), so this surface\n // carries the body-level baseline itself.\n ...theme.typography.body1,\n color: tv.palette.text.primary,\n backgroundColor: tv.palette.background.default,\n colorScheme: theme.palette.mode,\n WebkitFontSmoothing: 'antialiased',\n MozOsxFontSmoothing: 'grayscale',\n height: '100%',\n width: '100%',\n [`> [data-aglyn=\"leaf\\\\:_@_\"]`]: {\n minHeight: '100%',\n width: '100%',\n },\n }\n})\nFramePaper.displayName = 'FramePaper'\n\n/**\n * What `CssBaseline` gives a published page and a closed shadow root never\n * inherits (AGL-3146).\n *\n * `:host { all: initial }` cuts inheritance at the artboard, so the canvas\n * carries the document baseline itself — `FramePaper` takes the body's\n * typography, color and background, and the structural half belongs here,\n * because `box-sizing` is inherited from the root element rather than set on\n * each one. Without it every element on the canvas is `content-box` while the\n * same element on the site is `border-box`, so a band that sets a height AND\n * padding measures the padding twice in the editor and once on the page.\n *\n * The same pair CssBaseline emits, for the same reason: declared on the host\n * and inherited by everything under it, so an author's own `box-sizing` still\n * wins wherever they set one.\n */\nexport const VIEWPORT_BASELINE_STYLES = {\n ':host': {\n all: 'initial',\n boxSizing: 'border-box',\n },\n '*, *::before, *::after': {\n boxSizing: 'inherit',\n },\n} as const\n\nconst ViewportGlobalStyles = (\n <GlobalStyles\n styles={{\n ...VIEWPORT_BASELINE_STYLES,\n // Canvas-sense for aglyn-hidden elements (AGL-592): start closed\n // like the live site, and stay closed unless the leaf itself is\n // flagged as revealed. `node-leaf` decides that from the reveal\n // toggle and the selection and stamps the flag on the hidden\n // element — the same element this rule hides — so no wrapper a\n // component renders around its children can separate the two.\n // Expressed as a :not() guard (not hide-then-revert) so a revealed\n // panel keeps its natural display. Injected into the closed shadow\n // root via the shadow-scoped emotion cache — the live tenant is\n // untouched.\n '.aglyn-hidden:not([data-aglyn-revealed])': {\n display: 'none !important',\n },\n }}\n />\n)\nconst ThemedElementContainer = ({ children }) => {\n const shadowDom = useMuiShadowDomContext()\n const hostThemeDoc = useHostThemeDocument()\n const [canvasScheme] = useAglynBesignerFlag('canvasScheme')\n const hostTheme = useAglynSiteTheme({\n container: shadowDom,\n theme: hostThemeDoc,\n scheme: canvasScheme,\n })\n // Artboard device preview (AGL-581): media queries evaluate against\n // the browser viewport, never the artboard, so a selected device pins\n // the canvas subtree instead — a theme whose breakpoint helpers are\n // forced for the device width (responsive sx values, Stack/Grid\n // props, component styles), plus a per-Leaf sx transform that\n // resolves width media keys (visibility bands, custom CSS) at that\n // width. Fluid Responsive leaves both untouched, and the published\n // tenant never mounts any of this.\n const [devicePreview] = useAglynBesignerFlag('devicePreview')\n const deviceWidth = devicePreviewWidth(\n devicePreview,\n hostTheme.breakpoints?.values,\n )\n // The console's own theme, read before the site's replaces it below.\n const chromeTheme = useTheme()\n const canvasTheme = useMemo(\n () =>\n deviceWidth == null\n ? hostTheme\n : createDevicePinnedTheme(hostTheme, deviceWidth),\n [hostTheme, deviceWidth],\n )\n // The other scheme, for an \"Always light\" / \"Always dark\" element\n // (AGL-3284), pinned to the same device width so a forced band re-resolves\n // its responsive values at the artboard width like everything around it.\n const pinToDevice = useCallback(\n (theme: Theme) =>\n deviceWidth == null ? theme : createDevicePinnedTheme(theme, deviceWidth),\n [deviceWidth],\n )\n const schemeThemes = useAglynSiteSchemeThemes({\n container: shadowDom,\n theme: hostThemeDoc,\n active: canvasTheme,\n finish: pinToDevice,\n })\n // Interaction-state hold (AGL-2486): while the Styles panel is editing a\n // state slice, the SELECTED element renders as if it were in that state —\n // you cannot hover an element from a side panel, so a state you cannot see\n // is a state you cannot design. Composed into the SAME canvas-only\n // transform the device-width pin uses, so there is still exactly one\n // substitution path and the tenant (which never mounts this provider) is\n // untouched. The hoist runs FIRST so a media key inside the slice reaches\n // the width transform at the top level.\n const [heldState] = useAglynBesignerFlag('heldState')\n const [heldStateNodeId] = useAglynBesignerFlag('heldStateNodeId')\n // Declarations switched off for comparison (AGL-2486). Third rider on the\n // same canvas-only transform, and it runs FIRST: a muted base declaration\n // has to be gone before a held state's slice is folded over it, and a muted\n // slice declaration has to leave the slice so the base shows through.\n const [mutedStyles] = useAglynBesignerFlag('mutedStyles')\n const sxTransform = useMemo(() => {\n const held = heldState && heldStateNodeId ? heldState : null\n const muted = mutedStyles?.length ? mutedStyles : null\n if (deviceWidth == null && !held && !muted) return undefined\n return (sx: unknown, nodeId?: string) => {\n const unmuted = muted ? applyMutedStyles(sx, nodeId, muted) : sx\n const scoped =\n held && nodeId === heldStateNodeId\n ? hoistStateSx(unmuted, held)\n : unmuted\n return deviceWidth == null\n ? scoped\n : resolveSxForDeviceWidth(scoped, deviceWidth)\n }\n }, [deviceWidth, heldState, heldStateNodeId, mutedStyles])\n // Elements the author opened up for designing (AGL-592). Subscribed once\n // here, exactly like the held state above, and handed down by context so a\n // canvas of several hundred leaves carries one subscription rather than one\n // per element.\n const [revealedNodeIds] = useAglynBesignerFlag('revealedNodeIds')\n // Classes switched off for comparison (AGL-2486), subscribed the same way.\n const [mutedClasses] = useAglynBesignerFlag('mutedClasses')\n // A record template's previewed record (AGL-3475), laid over the editable\n // document and its chrome alike, as the published page's composition lays\n // the routed record over both. A repeat inside the page provides its own.\n const pageRecord = useContext(CanvasPageRecordContext)\n const pageScope = useMemo(\n () =>\n pageRecord\n ? {\n record: pageRecord.record,\n model: pageRecord.model,\n datasetsByKey: pageRecord.datasetsByKey,\n }\n : undefined,\n [pageRecord],\n )\n return (\n <SiteSchemeThemesContext.Provider value={schemeThemes}>\n <CanvasChromeThemeContext.Provider value={chromeTheme}>\n <ThemeProvider theme={canvasTheme}>\n <CssBaseline />\n <CanvasRevealContext.Provider value={revealedNodeIds}>\n <CanvasMutedClassesContext.Provider value={mutedClasses}>\n <LeafSxTransformContext.Provider value={sxTransform}>\n {/* The site whose host variables every leaf fills in (AGL-2881),\n decided once for the editable document and its chrome alike. */}\n <CanvasHostTokensProvider>\n {pageScope ? (\n <RepeatRecordContext.Provider value={pageScope}>\n {children}\n </RepeatRecordContext.Provider>\n ) : (\n children\n )}\n </CanvasHostTokensProvider>\n </LeafSxTransformContext.Provider>\n </CanvasMutedClassesContext.Provider>\n </CanvasRevealContext.Provider>\n </ThemeProvider>\n </CanvasChromeThemeContext.Provider>\n </SiteSchemeThemesContext.Provider>\n )\n}\n\nconst EditableScreenRenderer = observer(() => (\n <AglynNodeRenderer\n node={canvas.getNode(NODE_ROOT_ID)!}\n LeafComponent={NodeLeaf}\n />\n))\nEditableScreenRenderer.displayName = 'EditableScreenRenderer'\n\n/**\n * Leaf for the read-only layout chrome tree: the LayoutSlot renders the\n * editable screen canvas after any chrome the designer left inside the slot\n * (matching composition semantics); everything else renders with the\n * production Leaf, which carries none of the designer's selection/dnd\n * behavior — the chrome is locked by construction.\n */\nconst LayoutChromeLeaf = forwardRef<any, any>((props, ref) => {\n const { node, children, ...rest } = props\n if (node?.componentId === LAYOUT_SLOT_COMPONENT_ID) {\n return (\n <Leaf ref={ref} node={node} {...rest}>\n {children}\n <EditableScreenRenderer />\n </Leaf>\n )\n }\n // An image or film in the chrome shows its DAM asset's current facts, as the\n // published page composes it (AGL-2838, AGL-2856).\n return (\n <MediaFactsLeaf ref={ref} node={node} {...rest}>\n {children}\n </MediaFactsLeaf>\n )\n})\nLayoutChromeLeaf.displayName = 'LayoutChromeLeaf'\n\nconst SiteContainer = observer(\n forwardRef<any, SiteShadowDomProps>((props, ref) => {\n const { ...rest } = props\n const { chromeCanvas } = useLayoutChromeContext()\n const chromeRoot = chromeCanvas?.getNode(NODE_ROOT_ID)\n // State, not a ref: the paper mounts inside the shadow root after this\n // component does, and the listener below has to follow it there.\n const [paper, setPaper] = useState<HTMLElement | null>(null)\n useEffect(() => {\n if (!paper || !chromeCanvas) return\n // Native, like every canvas listener: React never sees an event from\n // inside the closed shadow root.\n const onClick = (event: MouseEvent) => {\n const part = findLayoutPart(event.target, chromeCanvas)\n if (!part) return\n // A link in the layout's nav would otherwise navigate the editor.\n event.preventDefault()\n layoutPartMenu.open(part, { left: event.clientX, top: event.clientY })\n }\n paper.addEventListener('click', onClick)\n return () => paper.removeEventListener('click', onClick)\n }, [paper, chromeCanvas])\n return (\n <SiteShadowDom\n ref={ref}\n data-aglyn={'viewport:dom'}\n mode=\"closed\"\n {...rest}\n >\n <>\n {ViewportGlobalStyles}\n {/* Plugin stylesheets (AGL-2486). THIS is the gap `8dc718ed4` named\n and left open: a plugin's raw CSS goes into `document.head`,\n which a `mode: 'closed'` shadow root with `:host { all: initial }`\n and no `adoptedStyleSheets` never sees. Measured — the identical\n rule that beats every `@layer mui` declaration on the published\n page had literally NO effect on this canvas. Rendered here as a\n plain `<style>` child, so it lands in the shadow root in the same\n unlayered slot it occupies on the published document; `shadow`\n scope is what pulls in the MIRRORED sheets a bundle injected into\n the console's own head, which is the copy that never crossed. */}\n <PluginStyles scope=\"shadow\" />\n <ThemedElementContainer>\n <FramePaper ref={setPaper}>\n {chromeRoot ? (\n <AglynNodeRenderer\n node={chromeRoot}\n LeafComponent={LayoutChromeLeaf}\n />\n ) : (\n <EditableScreenRenderer />\n )}\n </FramePaper>\n </ThemedElementContainer>\n </>\n </SiteShadowDom>\n )\n }),\n)\n\nconst Overlays = forwardRef<any, Partial<BoxProps>>((props, ref) => {\n const { ...rest } = props\n\n return (\n <Box\n ref={ref}\n data-aglyn=\"viewport:popover\"\n sx={{\n // position: 'relative',\n // Above the canvas content, below the designer chrome (app bars and\n // breadcrumbs sit at zIndex.appBar) within the workspace context.\n zIndex: 10,\n }}\n {...rest}\n >\n {/* Document order is the only thing separating these two. Each\n overlay root is a fixed-position popper and therefore its own\n stacking context, so a z-index declared inside one cannot lift it\n past the other — the roots paint in the order they are rendered.\n The overlay carrying the action strip goes LAST so its buttons stay\n above the other overlay's outline, which draws the SELECTED\n treatment whenever the pointer is resting on the selected node,\n i.e. whenever someone is reaching for those buttons. The canvas\n chrome rendered after them keeps painting above both. */}\n <NodeOverlay data-aglyn=\"overlay:hovered\" variant=\"hovered\" />\n <NodeOverlay data-aglyn=\"overlay:selected\" variant=\"selected\" />\n <CanvasDropIndicator />\n <LayoutPartMenu />\n {/* Before the editors, so a cell editor's toolbar paints over a bar. */}\n <TableEdgeControlsComponent />\n <InlineTextEditorComponent />\n <InlineMarkdownEditorComponent />\n </Box>\n )\n})\n\nexport interface ViewportFrameComponentProps extends ComponentProps<\n typeof ViewportFrame\n> {}\n\nexport const ViewportFrameComponent = forwardRef<\n any,\n ViewportFrameComponentProps\n>((props, ref) => {\n const { onMouseLeave, ...rest } = props\n\n const handlePointerLeave = useCallback(\n (e) => {\n // e.stopPropagation()\n Besigner.focus.clearHover()\n onMouseLeave && onMouseLeave(e)\n },\n [onMouseLeave],\n )\n\n return (\n <ViewportFrame\n ref={ref}\n data-aglyn=\"viewport:frame\"\n onMouseLeave={handlePointerLeave}\n onPointerLeave={handlePointerLeave}\n {...rest}\n >\n <SiteContainer />\n <Overlays />\n </ViewportFrame>\n )\n})\n\nViewportFrameComponent.displayName = 'ViewportFrameComponent'\nViewportFrameComponent.aglyn = true\n\nexport default ViewportFrameComponent\n"],"names":["canvas","LAYOUT_SLOT_COMPONENT_ID","NODE_ROOT_ID","PluginStyles","AglynNodeRenderer","Leaf","LeafSxTransformContext","Besigner","useAglynSiteSchemeThemes","useAglynSiteTheme","MuiShadowDom","useMuiShadowDomContext","SiteSchemeThemesContext","styled","ThemeProvider","useHostThemeDocument","Box","CssBaseline","GlobalStyles","useTheme","observer","forwardRef","useCallback","useContext","useEffect","useMemo","useState","CanvasChromeThemeContext","CanvasHostTokensProvider","CanvasPageRecordContext","RepeatRecordContext","CanvasRevealContext","CanvasMutedClassesContext","useLayoutChromeContext","useAglynBesignerFlag","createDevicePinnedTheme","devicePreviewWidth","resolveSxForDeviceWidth","applyMutedStyles","hoistStateSx","CanvasDropIndicator","InlineMarkdownEditorComponent","InlineTextEditorComponent","TableEdgeControlsComponent","LayoutPartMenu","findLayoutPart","layoutPartMenu","NodeLeaf","MediaFactsLeaf","NodeOverlay","ViewportFrame","name","theme","t","tv","vars","flexGrow","minHeight","width","background","palette","paper","borderColor","divider","borderWidth","borderStyle","display","displayName","SiteShadowDom","div","transform","FramePaper","typography","body1","color","text","primary","backgroundColor","default","colorScheme","mode","WebkitFontSmoothing","MozOsxFontSmoothing","height","VIEWPORT_BASELINE_STYLES","all","boxSizing","ViewportGlobalStyles","styles","ThemedElementContainer","children","hostTheme","shadowDom","hostThemeDoc","canvasScheme","container","scheme","devicePreview","deviceWidth","breakpoints","values","chromeTheme","canvasTheme","pinToDevice","schemeThemes","active","finish","heldState","heldStateNodeId","mutedStyles","sxTransform","held","muted","length","undefined","sx","nodeId","unmuted","scoped","revealedNodeIds","mutedClasses","pageRecord","pageScope","record","model","datasetsByKey","Provider","value","EditableScreenRenderer","node","getNode","LeafComponent","LayoutChromeLeaf","props","ref","rest","componentId","SiteContainer","chromeCanvas","chromeRoot","setPaper","onClick","event","part","target","preventDefault","open","left","clientX","top","clientY","addEventListener","removeEventListener","data-aglyn","scope","Overlays","zIndex","variant","ViewportFrameComponent","onMouseLeave","handlePointerLeave","e","focus","clearHover","onPointerLeave","aglyn"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,MAAM,EAAEC,wBAAwB,EAAEC,YAAY,QAAQ,eAAc;AAC7E,uEAAuE;AACvE,SAASC,YAAY,QAAQ,+CAA8C;AAC3E,SACEC,iBAAiB,EACjBC,IAAI,EACJC,sBAAsB,QACjB,6BAA4B;AACnC,YAAYC,cAAc,kBAAiB;AAC3C,SACEC,wBAAwB,EACxBC,iBAAiB,QACZ,6BAA4B;AACnC,SACEC,YAAY,EAEZC,sBAAsB,QACjB,uBAAsB;AAC7B,SACEC,uBAAuB,EACvBC,MAAM,EAENC,aAAa,EACbC,oBAAoB,QACf,yBAAwB;AAC/B,SACEC,GAAG,EAEHC,WAAW,EACXC,YAAY,EACZC,QAAQ,QACH,gBAAe;AACtB,SAASC,QAAQ,QAAQ,kBAAiB;AAC1C,oDAAoD;AACpD,SAEEC,UAAU,EAEVC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,QAAO;AACd,OAAOC,8BAA8B,6CAAyC;AAC9E,SAASC,w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AAI;YACF,wBAAwB;YACxB,oEAAoE;YACpE,kEAAkE;YAClEyC,QAAQ;QACV;OACIrB;;0BAWJ,KAACtF;gBAAYwG,cAAW;gBAAkBI,SAAQ;;0BAClD,KAAC5G;gBAAYwG,cAAW;gBAAmBI,SAAQ;;0BACnD,KAACrH;0BACD,KAACI;0BAED,KAACD;0BACD,KAACD;0BACD,KAACD;;;AAGP;AAMA,OAAO,MAAMqH,uCAAyBzI,WAGpC,CAACgH,OAAOC;IACR,MAAM,EAAEyB,YAAY,EAAW,GAAG1B,OAATE,wCAASF;;;IAElC,MAAM2B,qBAAqB1I,YACzB,CAAC2I;QACC,sBAAsB;QACtB1J,SAAS2J,KAAK,CAACC,UAAU;QACzBJ,gBAAgBA,aAAaE;IAC/B,GACA;QAACF;KAAa;IAGhB,qBACE,MAAC7G;QACCoF,KAAKA;QACLmB,cAAW;QACXM,cAAcC;QACdI,gBAAgBJ;OACZzB;;0BAEJ,KAACE;0BACD,KAACkB;;;AAGP,GAAE;AAEFG,uBAAuB3F,WAAW,GAAG;AACrC2F,uBAAuBO,KAAK,GAAG;AAE/B,eAAeP,uBAAsB"}
@@ -93,6 +93,15 @@ export declare function dataTableCellValueFromEdit(plain: string, sanitized: str
93
93
  export declare function withDataTableShapeEdit(props: Record<string, unknown>, attribute: string, edit: DataTableShapeEdit): Record<string, unknown>;
94
94
  /** `props` with an empty table started — the same starter the Attributes grid writes. */
95
95
  export declare function withDataTableStarted(props: Record<string, unknown>, attribute: string): Record<string, unknown>;
96
+ /**
97
+ * The edits the "+" bars along a Table's edges make: a row after the last
98
+ * one, a column after the last one. `null` for an empty grid, which has no
99
+ * edge to add along — its first table is started from the right-click menu.
100
+ */
101
+ export declare function dataTableAppendEdits(value: unknown): {
102
+ row: DataTableShapeEdit;
103
+ column: DataTableShapeEdit;
104
+ } | null;
96
105
  /** One row or column action offered on a cell. */
97
106
  export interface DataTableCellAction {
98
107
  key: string;
@@ -143,6 +143,27 @@ import { mdiTableColumnPlusAfter, mdiTableColumnPlusBefore, mdiTableColumnRemove
143
143
  [attribute]: dataTableStarterValue()
144
144
  });
145
145
  }
146
+ /**
147
+ * The edits the "+" bars along a Table's edges make: a row after the last
148
+ * one, a column after the last one. `null` for an empty grid, which has no
149
+ * edge to add along — its first table is started from the right-click menu.
150
+ */ export function dataTableAppendEdits(value) {
151
+ var _ref;
152
+ var _grid_;
153
+ const grid = parseDataTableRows(value);
154
+ const width = (_ref = (_grid_ = grid[0]) == null ? void 0 : _grid_.length) != null ? _ref : 0;
155
+ if (grid.length === 0 || width === 0) return null;
156
+ return {
157
+ row: {
158
+ kind: 'insertRow',
159
+ at: grid.length
160
+ },
161
+ column: {
162
+ kind: 'insertColumn',
163
+ at: width
164
+ }
165
+ };
166
+ }
146
167
  /**
147
168
  * The row and column actions for one cell, in the order both the right-click
148
169
  * menu and the cell editor's toolbar list them (AGL-4203). Deleting the last
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/table-cell-edit.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 { FieldComponentType } from '@aglyn/aglyn'\nimport {\n DATA_TABLE_EMPHASIS_PROP,\n type DataTableShapeEdit,\n dataTableCellText,\n dataTableStarterValue,\n editDataTableShape,\n emphasisAfterShapeEdit,\n isDataTableCellMarkup,\n normalizeEmphasisColumn,\n parseDataTableRows,\n readDataTableAlignments,\n serializeDataTable,\n withCellSet,\n} from '@aglyn/shared-data-enums'\nimport {\n mdiTableColumnPlusAfter,\n mdiTableColumnPlusBefore,\n mdiTableColumnRemove,\n mdiTableRowPlusAfter,\n mdiTableRowPlusBefore,\n mdiTableRowRemove,\n} from '@aglyn/shared-data-mdi'\n\n/**\n * In-place editing of one Table cell on the canvas.\n *\n * The Table element stores its whole grid as ONE string attribute (see\n * `@aglyn/shared-data-enums`'s `data-table`), so a cell is not a canvas node\n * and has no `children` of its own to edit. A double-click on a cell opens\n * the same in-place text editor every text element uses, anchored on the\n * cell, and the commit rewrites that one cell inside the stored string —\n * through the same parser and serializer the attributes-panel grid uses, so\n * the two surfaces can never disagree about what a table string means.\n */\n\n/**\n * The attribute holding the grid, or `undefined` when the component declares\n * none. Keyed on the schema's own `DATA_TABLE` field declaration — the same\n * declaration that gives the attributes panel its grid — rather than on a\n * component id, so any element that stores a grid this way is editable on\n * the canvas too.\n */\nexport function findDataTableAttributeName(\n node: Aglyn.NodeSchema<any> | undefined,\n): string | undefined {\n for (const attribute of node?.componentSchema?.attributes ?? []) {\n if (attribute?.component === FieldComponentType.DATA_TABLE) {\n return attribute.name\n }\n }\n return undefined\n}\n\n/** The cell a point falls in, and where it sits in the stored grid. */\nexport interface DataTableCellHit {\n element: HTMLElement\n /** Row in the parsed grid — the header row, when there is one, is row 0. */\n row: number\n column: number\n}\n\n/**\n * The rendered cell under a client point inside `root`, if any.\n *\n * Geometric rather than `elementFromPoint`, for the reason instance leaves\n * are hit-tested that way: the canvas is a closed shadow root and the point\n * may come from a touch, so the event target is not something to rely on.\n *\n * The grid row is the cell's `<tr>` index across the whole table. The\n * renderer draws exactly one `<tr>` per parsed row, header included, so the\n * two indexes are the same thing.\n */\nexport function findDataTableCellAtPoint(\n root: Element,\n clientX: number,\n clientY: number,\n): DataTableCellHit | undefined {\n const rows = Array.from(root.querySelectorAll('tr'))\n for (let row = 0; row < rows.length; row++) {\n const cells = Array.from(rows[row].children).filter(\n (cell): cell is HTMLElement =>\n cell.tagName === 'TD' || cell.tagName === 'TH',\n )\n for (let column = 0; column < cells.length; column++) {\n const rect = cells[column].getBoundingClientRect()\n if (\n clientX >= rect.left &&\n clientX <= rect.right &&\n clientY >= rect.top &&\n clientY <= rect.bottom\n ) {\n return { element: cells[column], row, column }\n }\n }\n }\n return undefined\n}\n\n/** The text a stored grid holds at one cell, or `''` when it is outside it. */\nexport function readDataTableCell(\n value: unknown,\n row: number,\n column: number,\n): string {\n return parseDataTableRows(value)[row]?.[column] ?? ''\n}\n\n/**\n * The stored grid with one cell replaced.\n *\n * A cell is one line — the storage is one row per line — so a line break\n * typed into the cell becomes a space instead of splitting the row. Column\n * alignments survive: they ride the same string as a divider row, and are\n * read back out and written again with the grid.\n */\nexport function writeDataTableCell(\n value: unknown,\n row: number,\n column: number,\n text: string,\n): string {\n const grid = parseDataTableRows(value)\n const width = grid[0]?.length ?? 0\n const alignments = readDataTableAlignments(value, width)\n const cell = text.replace(/\\s*\\r?\\n\\s*/g, ' ').trim()\n return serializeDataTable(withCellSet(grid, row, column, cell), alignments)\n}\n\n/**\n * What the cell editor opens with (AGL-4203): the cell's words, and its\n * markup when it was formatted. A plain cell has no markup, and the editor\n * builds its surface from the words as it does for unformatted text.\n */\nexport function readDataTableCellForEdit(\n value: unknown,\n row: number,\n column: number,\n): { text: string; html: string } {\n const raw = readDataTableCell(value, row, column)\n return isDataTableCellMarkup(raw)\n ? { text: dataTableCellText(raw), html: raw }\n : { text: raw, html: '' }\n}\n\n/**\n * What a cell edit stores (AGL-4203): the sanitized markup when the author\n * formatted something, the plain words otherwise — so a table nobody formats\n * stays the plain grid it always was.\n *\n * One case keeps the markup without any formatting: plain words that would\n * READ as markup (`a &lt; b` typed out literally, or a tag spelled in text).\n * Stored plain, the renderer would draw them as a tag; stored escaped, they\n * draw as typed.\n */\nexport function dataTableCellValueFromEdit(\n plain: string,\n sanitized: string,\n): string {\n if (/<[a-z]/i.test(sanitized)) return sanitized\n if (isDataTableCellMarkup(plain)) return sanitized\n return plain\n}\n\n/**\n * `props` after one change to the table's shape: the grid, and the\n * emphasized column moved with its column (AGL-4203). The emphasis is\n * written only when it moves, so a row edit never touches it.\n */\nexport function withDataTableShapeEdit(\n props: Record<string, unknown>,\n attribute: string,\n edit: DataTableShapeEdit,\n): Record<string, unknown> {\n const stored = props[attribute]\n const width = parseDataTableRows(stored)[0]?.length ?? 0\n const next: Record<string, unknown> = {\n ...props,\n [attribute]: editDataTableShape(stored, edit),\n }\n if (DATA_TABLE_EMPHASIS_PROP in props) {\n const before = normalizeEmphasisColumn(props[DATA_TABLE_EMPHASIS_PROP], width)\n const after = emphasisAfterShapeEdit(\n props[DATA_TABLE_EMPHASIS_PROP],\n width,\n edit,\n )\n if (after !== before) next[DATA_TABLE_EMPHASIS_PROP] = after\n }\n return next\n}\n\n/** `props` with an empty table started — the same starter the Attributes grid writes. */\nexport function withDataTableStarted(\n props: Record<string, unknown>,\n attribute: string,\n): Record<string, unknown> {\n return { ...props, [attribute]: dataTableStarterValue() }\n}\n\n/** One row or column action offered on a cell. */\nexport interface DataTableCellAction {\n key: string\n label: string\n icon: string\n edit: DataTableShapeEdit\n disabled: boolean\n}\n\n/**\n * The row and column actions for one cell, in the order both the right-click\n * menu and the cell editor's toolbar list them (AGL-4203). Deleting the last\n * row or the last column is offered but disabled, as the Attributes grid\n * does: a table with no cells left has nothing to click to get one back.\n */\nexport function dataTableCellActions(\n value: unknown,\n row: number,\n column: number,\n): DataTableCellAction[] {\n const grid = parseDataTableRows(value)\n const rows = grid.length\n const columns = grid[0]?.length ?? 0\n return [\n {\n key: 'row-above',\n label: 'Insert row above',\n icon: mdiTableRowPlusBefore.path,\n edit: { kind: 'insertRow', at: row },\n disabled: false,\n },\n {\n key: 'row-below',\n label: 'Insert row below',\n icon: mdiTableRowPlusAfter.path,\n edit: { kind: 'insertRow', at: row + 1 },\n disabled: false,\n },\n {\n key: 'column-left',\n label: 'Insert column left',\n icon: mdiTableColumnPlusBefore.path,\n edit: { kind: 'insertColumn', at: column },\n disabled: false,\n },\n {\n key: 'column-right',\n label: 'Insert column right',\n icon: mdiTableColumnPlusAfter.path,\n edit: { kind: 'insertColumn', at: column + 1 },\n disabled: false,\n },\n {\n key: 'row-delete',\n label: 'Delete row',\n icon: mdiTableRowRemove.path,\n edit: { kind: 'removeRow', at: row },\n disabled: rows <= 1,\n },\n {\n key: 'column-delete',\n label: 'Delete column',\n icon: mdiTableColumnRemove.path,\n edit: { kind: 'removeColumn', at: column },\n disabled: columns <= 1,\n },\n ]\n}\n"],"names":["FieldComponentType","DATA_TABLE_EMPHASIS_PROP","dataTableCellText","dataTableStarterValue","editDataTableShape","emphasisAfterShapeEdit","isDataTableCellMarkup","normalizeEmphasisColumn","parseDataTableRows","readDataTableAlignments","serializeDataTable","withCellSet","mdiTableColumnPlusAfter","mdiTableColumnPlusBefore","mdiTableColumnRemove","mdiTableRowPlusAfter","mdiTableRowPlusBefore","mdiTableRowRemove","findDataTableAttributeName","node","attribute","componentSchema","attributes","component","DATA_TABLE","name","undefined","findDataTableCellAtPoint","root","clientX","clientY","rows","Array","from","querySelectorAll","row","length","cells","children","filter","cell","tagName","column","rect","getBoundingClientRect","left","right","top","bottom","element","readDataTableCell","value","writeDataTableCell","text","grid","width","alignments","replace","trim","readDataTableCellForEdit","raw","html","dataTableCellValueFromEdit","plain","sanitized","test","withDataTableShapeEdit","props","edit","stored","next","before","after","withDataTableStarted","dataTableCellActions","columns","key","label","icon","path","kind","at","disabled"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,kBAAkB,QAAQ,eAAc;AACjD,SACEC,wBAAwB,EAExBC,iBAAiB,EACjBC,qBAAqB,EACrBC,kBAAkB,EAClBC,sBAAsB,EACtBC,qBAAqB,EACrBC,uBAAuB,EACvBC,kBAAkB,EAClBC,uBAAuB,EACvBC,kBAAkB,EAClBC,WAAW,QACN,2BAA0B;AACjC,SACEC,uBAAuB,EACvBC,wBAAwB,EACxBC,oBAAoB,EACpBC,oBAAoB,EACpBC,qBAAqB,EACrBC,iBAAiB,QACZ,yBA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YACzCwC,UAAUP,WAAW;QACvB;KACD;AACH"}
1
+ {"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/table-cell-edit.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 { FieldComponentType } from '@aglyn/aglyn'\nimport {\n DATA_TABLE_EMPHASIS_PROP,\n type DataTableShapeEdit,\n dataTableCellText,\n dataTableStarterValue,\n editDataTableShape,\n emphasisAfterShapeEdit,\n isDataTableCellMarkup,\n normalizeEmphasisColumn,\n parseDataTableRows,\n readDataTableAlignments,\n serializeDataTable,\n withCellSet,\n} from '@aglyn/shared-data-enums'\nimport {\n mdiTableColumnPlusAfter,\n mdiTableColumnPlusBefore,\n mdiTableColumnRemove,\n mdiTableRowPlusAfter,\n mdiTableRowPlusBefore,\n mdiTableRowRemove,\n} from '@aglyn/shared-data-mdi'\n\n/**\n * In-place editing of one Table cell on the canvas.\n *\n * The Table element stores its whole grid as ONE string attribute (see\n * `@aglyn/shared-data-enums`'s `data-table`), so a cell is not a canvas node\n * and has no `children` of its own to edit. A double-click on a cell opens\n * the same in-place text editor every text element uses, anchored on the\n * cell, and the commit rewrites that one cell inside the stored string —\n * through the same parser and serializer the attributes-panel grid uses, so\n * the two surfaces can never disagree about what a table string means.\n */\n\n/**\n * The attribute holding the grid, or `undefined` when the component declares\n * none. Keyed on the schema's own `DATA_TABLE` field declaration — the same\n * declaration that gives the attributes panel its grid — rather than on a\n * component id, so any element that stores a grid this way is editable on\n * the canvas too.\n */\nexport function findDataTableAttributeName(\n node: Aglyn.NodeSchema<any> | undefined,\n): string | undefined {\n for (const attribute of node?.componentSchema?.attributes ?? []) {\n if (attribute?.component === FieldComponentType.DATA_TABLE) {\n return attribute.name\n }\n }\n return undefined\n}\n\n/** The cell a point falls in, and where it sits in the stored grid. */\nexport interface DataTableCellHit {\n element: HTMLElement\n /** Row in the parsed grid — the header row, when there is one, is row 0. */\n row: number\n column: number\n}\n\n/**\n * The rendered cell under a client point inside `root`, if any.\n *\n * Geometric rather than `elementFromPoint`, for the reason instance leaves\n * are hit-tested that way: the canvas is a closed shadow root and the point\n * may come from a touch, so the event target is not something to rely on.\n *\n * The grid row is the cell's `<tr>` index across the whole table. The\n * renderer draws exactly one `<tr>` per parsed row, header included, so the\n * two indexes are the same thing.\n */\nexport function findDataTableCellAtPoint(\n root: Element,\n clientX: number,\n clientY: number,\n): DataTableCellHit | undefined {\n const rows = Array.from(root.querySelectorAll('tr'))\n for (let row = 0; row < rows.length; row++) {\n const cells = Array.from(rows[row].children).filter(\n (cell): cell is HTMLElement =>\n cell.tagName === 'TD' || cell.tagName === 'TH',\n )\n for (let column = 0; column < cells.length; column++) {\n const rect = cells[column].getBoundingClientRect()\n if (\n clientX >= rect.left &&\n clientX <= rect.right &&\n clientY >= rect.top &&\n clientY <= rect.bottom\n ) {\n return { element: cells[column], row, column }\n }\n }\n }\n return undefined\n}\n\n/** The text a stored grid holds at one cell, or `''` when it is outside it. */\nexport function readDataTableCell(\n value: unknown,\n row: number,\n column: number,\n): string {\n return parseDataTableRows(value)[row]?.[column] ?? ''\n}\n\n/**\n * The stored grid with one cell replaced.\n *\n * A cell is one line — the storage is one row per line — so a line break\n * typed into the cell becomes a space instead of splitting the row. Column\n * alignments survive: they ride the same string as a divider row, and are\n * read back out and written again with the grid.\n */\nexport function writeDataTableCell(\n value: unknown,\n row: number,\n column: number,\n text: string,\n): string {\n const grid = parseDataTableRows(value)\n const width = grid[0]?.length ?? 0\n const alignments = readDataTableAlignments(value, width)\n const cell = text.replace(/\\s*\\r?\\n\\s*/g, ' ').trim()\n return serializeDataTable(withCellSet(grid, row, column, cell), alignments)\n}\n\n/**\n * What the cell editor opens with (AGL-4203): the cell's words, and its\n * markup when it was formatted. A plain cell has no markup, and the editor\n * builds its surface from the words as it does for unformatted text.\n */\nexport function readDataTableCellForEdit(\n value: unknown,\n row: number,\n column: number,\n): { text: string; html: string } {\n const raw = readDataTableCell(value, row, column)\n return isDataTableCellMarkup(raw)\n ? { text: dataTableCellText(raw), html: raw }\n : { text: raw, html: '' }\n}\n\n/**\n * What a cell edit stores (AGL-4203): the sanitized markup when the author\n * formatted something, the plain words otherwise — so a table nobody formats\n * stays the plain grid it always was.\n *\n * One case keeps the markup without any formatting: plain words that would\n * READ as markup (`a &lt; b` typed out literally, or a tag spelled in text).\n * Stored plain, the renderer would draw them as a tag; stored escaped, they\n * draw as typed.\n */\nexport function dataTableCellValueFromEdit(\n plain: string,\n sanitized: string,\n): string {\n if (/<[a-z]/i.test(sanitized)) return sanitized\n if (isDataTableCellMarkup(plain)) return sanitized\n return plain\n}\n\n/**\n * `props` after one change to the table's shape: the grid, and the\n * emphasized column moved with its column (AGL-4203). The emphasis is\n * written only when it moves, so a row edit never touches it.\n */\nexport function withDataTableShapeEdit(\n props: Record<string, unknown>,\n attribute: string,\n edit: DataTableShapeEdit,\n): Record<string, unknown> {\n const stored = props[attribute]\n const width = parseDataTableRows(stored)[0]?.length ?? 0\n const next: Record<string, unknown> = {\n ...props,\n [attribute]: editDataTableShape(stored, edit),\n }\n if (DATA_TABLE_EMPHASIS_PROP in props) {\n const before = normalizeEmphasisColumn(props[DATA_TABLE_EMPHASIS_PROP], width)\n const after = emphasisAfterShapeEdit(\n props[DATA_TABLE_EMPHASIS_PROP],\n width,\n edit,\n )\n if (after !== before) next[DATA_TABLE_EMPHASIS_PROP] = after\n }\n return next\n}\n\n/** `props` with an empty table started — the same starter the Attributes grid writes. */\nexport function withDataTableStarted(\n props: Record<string, unknown>,\n attribute: string,\n): Record<string, unknown> {\n return { ...props, [attribute]: dataTableStarterValue() }\n}\n\n/**\n * The edits the \"+\" bars along a Table's edges make: a row after the last\n * one, a column after the last one. `null` for an empty grid, which has no\n * edge to add along — its first table is started from the right-click menu.\n */\nexport function dataTableAppendEdits(\n value: unknown,\n): { row: DataTableShapeEdit; column: DataTableShapeEdit } | null {\n const grid = parseDataTableRows(value)\n const width = grid[0]?.length ?? 0\n if (grid.length === 0 || width === 0) return null\n return {\n row: { kind: 'insertRow', at: grid.length },\n column: { kind: 'insertColumn', at: width },\n }\n}\n\n/** One row or column action offered on a cell. */\nexport interface DataTableCellAction {\n key: string\n label: string\n icon: string\n edit: DataTableShapeEdit\n disabled: boolean\n}\n\n/**\n * The row and column actions for one cell, in the order both the right-click\n * menu and the cell editor's toolbar list them (AGL-4203). Deleting the last\n * row or the last column is offered but disabled, as the Attributes grid\n * does: a table with no cells left has nothing to click to get one back.\n */\nexport function dataTableCellActions(\n value: unknown,\n row: number,\n column: number,\n): DataTableCellAction[] {\n const grid = parseDataTableRows(value)\n const rows = grid.length\n const columns = grid[0]?.length ?? 0\n return [\n {\n key: 'row-above',\n label: 'Insert row above',\n icon: mdiTableRowPlusBefore.path,\n edit: { kind: 'insertRow', at: row },\n disabled: false,\n },\n {\n key: 'row-below',\n label: 'Insert row below',\n icon: mdiTableRowPlusAfter.path,\n edit: { kind: 'insertRow', at: row + 1 },\n disabled: false,\n },\n {\n key: 'column-left',\n label: 'Insert column left',\n icon: mdiTableColumnPlusBefore.path,\n edit: { kind: 'insertColumn', at: column },\n disabled: false,\n },\n {\n key: 'column-right',\n label: 'Insert column right',\n icon: mdiTableColumnPlusAfter.path,\n edit: { kind: 'insertColumn', at: column + 1 },\n disabled: false,\n },\n {\n key: 'row-delete',\n label: 'Delete row',\n icon: mdiTableRowRemove.path,\n edit: { kind: 'removeRow', at: row },\n disabled: rows <= 1,\n },\n {\n key: 'column-delete',\n label: 'Delete column',\n icon: mdiTableColumnRemove.path,\n edit: { kind: 'removeColumn', at: column },\n disabled: columns <= 1,\n },\n ]\n}\n"],"names":["FieldComponentType","DATA_TABLE_EMPHASIS_PROP","dataTableCellText","dataTableStarterValue","editDataTableShape","emphasisAfterShapeEdit","isDataTableCellMarkup","normalizeEmphasisColumn","parseDataTableRows","readDataTableAlignments","serializeDataTable","withCellSet","mdiTableColumnPlusAfter","mdiTableColumnPlusBefore","mdiTableColumnRemove","mdiTableRowPlusAfter","mdiTableRowPlusBefore","mdiTableRowRemove","findDataTableAttributeName","node","attribute","componentSchema","attributes","component","DATA_TABLE","name","undefined","findDataTableCellAtPoint","root","clientX","clientY","rows","Array","from","querySelectorAll","row","length","cells","children","filter","cell","tagName","column","rect","getBoundingClientRect","left","right","top","bottom","element","readDataTableCell","value","writeDataTableCell","text","grid","width","alignments","replace","trim","readDataTableCellForEdit","raw","html","dataTableCellValueFromEdit","plain","sanitized","test","withDataTableShapeEdit","props","edit","stored","next","before","after","withDataTableStarted","dataTableAppendEdits","kind","at","dataTableCellActions","columns","key","label","icon","path","disabled"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,kBAAkB,QAAQ,eAAc;AACjD,SACEC,wBAAwB,EAExBC,iBAAiB,EACjBC,qBAAqB,EACrBC,kBAAkB,EAClBC,sBAAsB,EACtBC,qBAAqB,EACrBC,uBAAuB,EACvBC,kBAAkB,EAClBC,uBAAuB,EACvBC,kBAAkB,EAClBC,WAAW,QACN,2BAA0B;AACjC,SACEC,uBAAuB,EACvBC,wBAAwB,EACxBC,oBAAoB,EACpBC,oBAAoB,EACpBC,qBAAqB,EACrBC,iBAAiB,QACZ,yBAAwB;AAE/B;;;;;;;;;;CAUC,GAED;;;;;;CAMC,GACD,OAAO,SAASC,2BACdC,IAAuC;;QAEfA;IAAxB,KAAK,MAAMC,qBAAaD,yBAAAA,wBAAAA,KAAME,eAAe,qBAArBF,sBAAuBG,UAAU,mBAAI,EAAE,CAAE;QAC/D,IAAIF,CAAAA,6BAAAA,U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