@aglyn/besigner-ui 1.15.2 → 1.17.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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/besigner-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.
|
|
29
|
-
"@aglyn/aglyn-markdown-editor": "1.
|
|
30
|
-
"@aglyn/aglyn-node-renderer": "1.
|
|
31
|
-
"@aglyn/besigner": "1.
|
|
32
|
-
"@aglyn/shared-data-enums": "1.
|
|
33
|
-
"@aglyn/shared-data-mdi": "1.
|
|
34
|
-
"@aglyn/shared-data-types": "1.
|
|
35
|
-
"@aglyn/shared-svg-icons": "1.
|
|
36
|
-
"@aglyn/shared-ui-json-editor": "1.
|
|
37
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
38
|
-
"@aglyn/shared-ui-jsx-forms": "1.
|
|
39
|
-
"@aglyn/shared-ui-snackstack": "1.
|
|
40
|
-
"@aglyn/shared-ui-theme": "1.
|
|
41
|
-
"@aglyn/shared-util-dom": "1.
|
|
42
|
-
"@aglyn/shared-util-tools": "1.
|
|
43
|
-
"@aglyn/shared-util-vendor": "1.
|
|
28
|
+
"@aglyn/aglyn": "1.17.0",
|
|
29
|
+
"@aglyn/aglyn-markdown-editor": "1.17.0",
|
|
30
|
+
"@aglyn/aglyn-node-renderer": "1.17.0",
|
|
31
|
+
"@aglyn/besigner": "1.17.0",
|
|
32
|
+
"@aglyn/shared-data-enums": "1.17.0",
|
|
33
|
+
"@aglyn/shared-data-mdi": "1.17.0",
|
|
34
|
+
"@aglyn/shared-data-types": "1.17.0",
|
|
35
|
+
"@aglyn/shared-svg-icons": "1.17.0",
|
|
36
|
+
"@aglyn/shared-ui-json-editor": "1.17.0",
|
|
37
|
+
"@aglyn/shared-ui-jsx": "1.17.0",
|
|
38
|
+
"@aglyn/shared-ui-jsx-forms": "1.17.0",
|
|
39
|
+
"@aglyn/shared-ui-snackstack": "1.17.0",
|
|
40
|
+
"@aglyn/shared-ui-theme": "1.17.0",
|
|
41
|
+
"@aglyn/shared-util-dom": "1.17.0",
|
|
42
|
+
"@aglyn/shared-util-tools": "1.17.0",
|
|
43
|
+
"@aglyn/shared-util-vendor": "1.17.0",
|
|
44
44
|
"@dnd-kit/core": "^6.3.1",
|
|
45
45
|
"@dnd-kit/utilities": "^3.2.2",
|
|
46
46
|
"@react-aria/utils": "^3.34.1",
|
|
@@ -30,7 +30,7 @@ import { requestCanvasContextMenu } from "../../utils/canvas-context-menu.js";
|
|
|
30
30
|
import { findInstanceLeafAtPoint, findPlacementPartAtPoint } from "../../utils/instance-leaf-hit.js";
|
|
31
31
|
import { pickPlacementPart } from "../../utils/placement-part-pick.js";
|
|
32
32
|
import { findLeafTextElement } from "../../utils/in-place-edit-surface.js";
|
|
33
|
-
import { findDataTableAttributeName, findDataTableCellAtPoint,
|
|
33
|
+
import { findDataTableAttributeName, findDataTableCellAtPoint, readDataTableCellForEdit } from "../../utils/table-cell-edit.js";
|
|
34
34
|
import { holdKeyboardForEdit } from "../../utils/touch-keyboard.js";
|
|
35
35
|
import { repeatCopyAt, repeatCopyStandIns } from "../../utils/repeat-copy.js";
|
|
36
36
|
import { DropSurface } from "./drop-surface.js";
|
|
@@ -298,7 +298,15 @@ export const DraggableDroppable = observer((props)=>{
|
|
|
298
298
|
const target = (_ref = copy == null ? void 0 : copy.original) != null ? _ref : node;
|
|
299
299
|
Besigner.focus.setSelectedNode(target);
|
|
300
300
|
repeatCopyStandIns.set('selected', copy);
|
|
301
|
-
|
|
301
|
+
// On a Table, which cell was right-clicked (AGL-4203): the menu
|
|
302
|
+
// offers rows and columns relative to it. Not on a repeat copy,
|
|
303
|
+
// whose cells are a preview of the original's.
|
|
304
|
+
const pointer = e;
|
|
305
|
+
const tableCell = !copy && findDataTableAttributeName(target) ? findDataTableCellAtPoint(el, pointer.clientX, pointer.clientY) : undefined;
|
|
306
|
+
requestCanvasContextMenu(target == null ? void 0 : target.$id, tableCell ? {
|
|
307
|
+
row: tableCell.row,
|
|
308
|
+
column: tableCell.column
|
|
309
|
+
} : undefined);
|
|
302
310
|
}
|
|
303
311
|
function handleMouseOver(e) {
|
|
304
312
|
var _ref;
|
|
@@ -473,6 +481,7 @@ export const DraggableDroppable = observer((props)=>{
|
|
|
473
481
|
if (!cell) return false;
|
|
474
482
|
const stored = (_node_props1 = node.props) == null ? void 0 : _node_props1[tableAttribute];
|
|
475
483
|
const cellRect = cell.element.getBoundingClientRect();
|
|
484
|
+
const content = readDataTableCellForEdit(stored, cell.row, cell.column);
|
|
476
485
|
// Editing an element is selecting it, as for markdown below: the
|
|
477
486
|
// two mousedowns of the double-click toggled the selection off.
|
|
478
487
|
Besigner.focus.setSelectedNode(node);
|
|
@@ -485,7 +494,8 @@ export const DraggableDroppable = observer((props)=>{
|
|
|
485
494
|
attribute: tableAttribute,
|
|
486
495
|
row: cell.row,
|
|
487
496
|
column: cell.column,
|
|
488
|
-
initialText:
|
|
497
|
+
initialText: content.text,
|
|
498
|
+
initialHtml: content.html
|
|
489
499
|
}, cell.element);
|
|
490
500
|
return true;
|
|
491
501
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../libs/besigner/feature/designer/src/lib/components/dnd/draggable-droppable.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2023 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 {\n canvas,\n components,\n FEATURE_FLAG,\n getInstanceEffectivePropHtml,\n getInstanceEffectivePropText,\n inheritedMediaAlt,\n isDefinitionPlacement,\n listPropFedTextNodeIds,\n placementDefinitionFor,\n resolveInstanceLeafBinding,\n REUSABLE_INSTANCE_COMPONENT_ID,\n REUSABLE_INSTANCE_PROP_VALUES_KEY,\n} from '@aglyn/aglyn'\nimport * as Besigner from '@aglyn/besigner'\nimport { mergeRefs, useId } from '@aglyn/shared-ui-jsx'\nimport { useDraggable, useDroppable } from '@dnd-kit/core'\nimport { CSS as css } from '@dnd-kit/utilities'\nimport { mergeProps } from '@react-aria/utils'\nimport { observer } from 'mobx-react-lite'\nimport {\n Children,\n cloneElement,\n CSSProperties,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react'\nimport ComponentPromotionContext from '../../contexts/component-promotion-context'\nimport { MediaPickerContext } from '../../contexts/media-picker-context'\nimport {\n findMarkdownAttributeName,\n inlineMarkdownEdit,\n} from '../../utils/inline-markdown-edit.store'\nimport {\n inlineTextEdit,\n isInlineEditWithin,\n} from '../../utils/inline-text-edit.store'\nimport { requestCanvasContextMenu } from '../../utils/canvas-context-menu'\nimport {\n findInstanceLeafAtPoint,\n findPlacementPartAtPoint,\n} from '../../utils/instance-leaf-hit'\nimport { pickPlacementPart } from '../../utils/placement-part-pick'\nimport { findLeafTextElement } from '../../utils/in-place-edit-surface'\nimport {\n findDataTableAttributeName,\n findDataTableCellAtPoint,\n readDataTableCell,\n} from '../../utils/table-cell-edit'\nimport { holdKeyboardForEdit } from '../../utils/touch-keyboard'\nimport { repeatCopyAt, repeatCopyStandIns } from '../../utils/repeat-copy'\nimport { DropSurface } from './drop-surface'\n\n/** A pointer position, from a mouse event or a touch. */\ntype ClientPoint = { clientX: number; clientY: number }\n\n/** A finger's position and the event time it was read at. */\ntype TapPoint = { x: number; y: number; at: number }\n\n/** The furthest a finger may slide and still be tapping, in px. */\nconst TAP_SLOP_PX = 10\n/** The longest a press may last and still be a tap, in ms; longer is a hold. */\nconst TAP_MAX_MS = 300\n/** How soon the second tap of a double-tap must follow the first, in ms. */\nconst DOUBLE_TAP_WITHIN_MS = 350\n/** How far from the first tap the second may land, in px. */\nconst DOUBLE_TAP_SLOP_PX = 24\n\nconst distance = (a: { x: number; y: number }, b: { x: number; y: number }) =>\n Math.hypot(a.x - b.x, a.y - b.y)\n\nexport interface DraggableDroppableProps<T extends Aglyn.NodeSchema<any>> {\n children: JSX.Element\n node: T\n type: Besigner.DragType\n accept: Besigner.DragType[]\n disableDragging?: boolean\n disableDropping?: boolean\n idSuffix?: string\n}\n\nexport const DraggableDroppable = observer(\n <T extends Aglyn.NodeSchema<any>>(props: DraggableDroppableProps<T>) => {\n const {\n node,\n type,\n disableDragging,\n disableDropping,\n accept,\n children,\n idSuffix,\n } = props\n const id = useId(node?.$id)\n const ref = useRef<HTMLElement>(null)\n /**\n * The element as STATE, beside the ref, so the listeners below follow it.\n *\n * A component may render a different element for the same node: a\n * Typography whose text gains a line break holds block content, which a\n * `<p>` cannot, so it re-renders as a `<div>`. The listeners were bound\n * once per node, to the element that was there first, and stayed on the\n * detached `<p>` — a click on the text then reached the parent instead,\n * which selected the Stack around it, and a double-click opened nothing.\n */\n const [element, setElement] = useState<HTMLElement | null>(null)\n // Records a real element only. The merged ref below is a fresh callback\n // every render, so React hands it `null` and then the element on each\n // commit; setting the same element again bails out, a `null` would not.\n const trackElement = useCallback((next: HTMLElement | null) => {\n if (next) setElement(next)\n }, [])\n\n const draggable = useDraggable({\n id: `${id}:${type}${idSuffix || ''}`,\n data: { type, node },\n disabled: disableDragging,\n })\n\n const droppable = useDroppable({\n id: `${id}:${type}${idSuffix || ''}`,\n data: {\n type,\n node,\n accept,\n surface: DropSurface.CANVAS,\n // Measured live by the drop marker: dnd-kit's cached rect cannot\n // follow the canvas scrolling from inside its shadow root.\n getElement: () => ref.current,\n },\n disabled: disableDropping,\n })\n\n const transform = draggable.transform\n const isTransforming = Boolean(draggable.transform)\n const child = Children.only(children)\n const style: CSSProperties = {\n ...child.props.style,\n // cursor: 'move',\n outlineWidth: 2,\n outlineOffset: -1,\n outlineColor: 'grey',\n outlineStyle: 'dotted',\n // transform: css.Transform.toString(transform),\n // scale: css.Scale.toString(transform),\n translate: css.Translate.toString(transform),\n\n ...(isTransforming\n ? {\n // transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`,\n // cursor: 'grab',\n }\n : {}),\n ...(droppable.isOver\n ? {\n outlineColor: 'lime',\n outlineStyle: 'solid',\n outlineOffset: '3',\n }\n : {}),\n ...(draggable.isDragging\n ? {\n outlineColor: 'grey',\n outlineStyle: 'double',\n outlineOffset: -1 as any,\n opacity: 0.5,\n cursor: 'move',\n }\n : {}),\n // Element-picker affordance (AGL-574): while the interaction builder\n // is picking a target, every leaf shows the crosshair and the hovered\n // one gets a distinct violet ring — deliberately unlike the normal\n // selection/drop outlines so \"pick this\" reads as its own mode.\n ...(Besigner.pick.isPicking() ? { cursor: 'crosshair' } : {}),\n ...(Besigner.pick.isPicking() && Besigner.focus.isNodeHovered(node)\n ? {\n outlineColor: '#7c4dff',\n outlineStyle: 'solid',\n outlineWidth: 2,\n outlineOffset: 2 as any,\n }\n : {}),\n }\n\n // Instance-internals double-click (AGL-1304) needs the component\n // definitions (hit-test) and the host's media picker (image props).\n // Read through a ref so the listener effect below keeps its `[node]`\n // dependency — context updates must not re-register DOM listeners.\n const { definitions, formDesigns } = useContext(ComponentPromotionContext)\n const { onPickMedia } = useContext(MediaPickerContext)\n const instanceEditRef = useRef({ definitions, formDesigns, onPickMedia })\n instanceEditRef.current = { definitions, formDesigns, onPickMedia }\n // Same reason: the touch listener below reads the live dnd-kit handlers.\n const listenersRef = useRef(draggable.listeners)\n listenersRef.current = draggable.listeners\n\n useEffect(() => {\n Besigner.refs.set(node.$id, ref)\n return () => {\n Besigner.refs.delete(node.$id)\n }\n }, [node?.$id])\n\n useEffect(() => {\n Besigner.handles.set(node.$id, {\n ...draggable.listeners,\n style: isTransforming ? { cursor: 'grab' } : { cursor: 'move' },\n })\n return () => {\n Besigner.handles.delete(node.$id)\n }\n }, [node.$id, draggable.listeners, isTransforming])\n\n useEffect(() => {\n const el = ref.current\n /**\n * Whether this element was already selected when the latest press on\n * it began. Read by the touch drag below, and reset by it, because the\n * press that selects an element must not also pick it up.\n */\n let selectedAtPress = false\n /** Where and when the finger on this element came down. */\n let pressStart: TapPoint | null = null\n /** The last quick, still tap on this element, waiting for its pair. */\n let lastTap: TapPoint | null = null\n /** When a double-tap opened an editor here, by event time. */\n let editOpenedByTapAt = -Infinity\n if (el) {\n el.addEventListener('mouseover', handleMouseOver)\n el.addEventListener('pointerover', handleMouseOver)\n el.addEventListener('mousedown', handleMouseDown)\n el.addEventListener('pointerdown', handleMouseDown)\n el.addEventListener('dblclick', handleDoubleClick)\n el.addEventListener('contextmenu', handleContextMenu)\n el.addEventListener('touchstart', handleTouchStart)\n el.addEventListener('touchend', handleTouchEnd)\n\n return () => {\n el.removeEventListener('mouseover', handleMouseOver)\n el.removeEventListener('pointerover', handleMouseOver)\n el.removeEventListener('mousedown', handleMouseDown)\n el.removeEventListener('pointerdown', handleMouseDown)\n el.removeEventListener('dblclick', handleDoubleClick)\n el.removeEventListener('contextmenu', handleContextMenu)\n el.removeEventListener('touchstart', handleTouchStart)\n el.removeEventListener('touchend', handleTouchEnd)\n }\n }\n /**\n * Press and hold a selected element to drag it on a touch screen.\n *\n * The element itself has never been a drag source: a mouse drags it by\n * the grip in its toolbar, and on a mouse that costs nothing, because a\n * press on the body selects it and the page stays put. A finger pressing\n * the body scrolls the page instead, which is what an author trying to\n * move the element saw. Handing the press to dnd-kit's TouchSensor\n * keeps a swipe a scroll — the sensor waits for a still hold before it\n * takes over — and makes a hold a drag.\n *\n * Native, like its neighbours: the canvas is a closed shadow root, so a\n * React `onTouchStart` would never fire. The sensor reads only\n * `nativeEvent`, and marks it, so an ancestor that is also selected\n * cannot claim the same touch.\n */\n function handleTouchStart(e: TouchEvent) {\n const touch = e.touches.length === 1 ? e.touches[0] : undefined\n pressStart = touch\n ? { x: touch.clientX, y: touch.clientY, at: e.timeStamp }\n : null\n const selected = selectedAtPress\n selectedAtPress = false\n if (!selected || isInlineEditWithin(el) || Besigner.pick.isPicking()) {\n return\n }\n listenersRef.current?.onTouchStart?.({ nativeEvent: e } as any)\n }\n /**\n * Double-tap a text element to edit it in place on a touch screen.\n *\n * A mouse gets there by `dblclick`, and on a touch screen that event is\n * the browser's to give. Chrome on Android turns two taps into one; on\n * a phone the in-place editor, and the B / I / U toolbar that comes\n * with it, did not open. So the two taps are counted here, by rules\n * that are this canvas's own rather than each browser's, and the same\n * open runs.\n *\n * Opening this way also puts the keyboard up (`holdKeyboardForEdit`),\n * which iOS only allows while the tap is still being handled — and the\n * `preventDefault` keeps Safari from zooming on the second tap, or\n * sending the `dblclick` Chrome would have sent after it.\n *\n * Two taps make a double-tap when each is quick and still, and the\n * second lands near the first soon after it. A hold is a drag, a slide\n * is a scroll, and neither counts.\n */\n function handleTouchEnd(e: TouchEvent) {\n const start = pressStart\n pressStart = null\n const touch = e.changedTouches[0]\n if (\n !start ||\n !touch ||\n e.touches.length > 0 ||\n // Inside an open edit, a double-tap selects a word.\n isInlineEditWithin(el) ||\n Besigner.pick.isPicking()\n ) {\n lastTap = null\n return\n }\n const tap = { x: touch.clientX, y: touch.clientY, at: e.timeStamp }\n if (\n distance(tap, start) > TAP_SLOP_PX ||\n tap.at - start.at > TAP_MAX_MS\n ) {\n lastTap = null\n return\n }\n const first = lastTap\n lastTap = tap\n if (\n !first ||\n tap.at - first.at > DOUBLE_TAP_WITHIN_MS ||\n distance(tap, first) > DOUBLE_TAP_SLOP_PX\n ) {\n return\n }\n lastTap = null\n if (!openEditAt({ clientX: tap.x, clientY: tap.y })) return\n e.preventDefault()\n e.stopPropagation()\n editOpenedByTapAt = e.timeStamp\n // A prop-fed image opens the media picker instead, which wants no\n // keyboard.\n if (inlineTextEdit.node || inlineMarkdownEdit.node) {\n holdKeyboardForEdit(tap)\n }\n }\n /**\n * Right-click opens this element's ⋮ menu (AGL-1405).\n *\n * A native listener like its neighbours, not an `onContextMenu` prop:\n * React delegates at the root container and the canvas is a closed\n * shadow root, so a delegated handler never sees the event.\n *\n * Selects first. The menu is rendered by the overlay, which only mounts\n * for a selected or hovered node — and right-clicking an element is a\n * statement about THAT element, so leaving the previous selection in\n * place would open the wrong menu.\n */\n function handleContextMenu(e: Event) {\n if (isInlineEditWithin(el)) {\n // An open text editor keeps the browser's own menu: cut, paste and\n // spellcheck are the whole point of a right-click there.\n e.stopPropagation()\n return\n }\n e.preventDefault()\n e.stopPropagation()\n // On a repeat copy, the menu is the element the copy draws, and the\n // selection is outlined on the copy (`repeatCopyStandIns`).\n const copy = repeatCopyAt(e.target)\n const target = copy?.original ?? node\n Besigner.focus.setSelectedNode(target)\n repeatCopyStandIns.set('selected', copy)\n requestCanvasContextMenu(target?.$id)\n }\n function handleMouseOver(e: Event) {\n // Same stand-down, same reason to consume it: a hover repaint while\n // the author is typing is a re-render of the subtree they are\n // editing, and an ancestor leaf would repaint for them instead.\n if (isInlineEditWithin(el)) {\n e.stopPropagation()\n return\n }\n e.preventDefault()\n e.stopPropagation()\n // On a repeat copy: the element it draws, outlined on the copy.\n const copy = repeatCopyAt(e.target)\n Besigner.focus.setHoveredNode(copy?.original ?? node)\n repeatCopyStandIns.set('hovered', copy)\n }\n function handleMouseDown(e: Event) {\n // Stand down while an edit is open in this leaf OR ANY LEAF INSIDE\n // IT (AGL-2486) — but CONSUME the event rather than ignoring it.\n //\n // Two different mistakes produced the same symptom, an editor that\n // was open, styled and completely uninteractive. First, asking only\n // \"is this leaf the node being edited?\": a nested run — a Span\n // typography inside a Typography — silenced its OWN leaf, the event\n // bubbled to the ancestor leaf, and the ancestor called the\n // `preventDefault` that suppresses caret placement. Second, standing\n // down by simply returning: that also skipped `stopPropagation`, so\n // the gesture carried on up to the viewport, which treats a\n // mousedown on empty canvas as a deselect — and moving the selection\n // off the node closes the editor. A drag meant to select three words\n // tore the editor down instead.\n //\n // So: no `preventDefault`, because that is the caret; but still\n // `stopPropagation`, because nothing else on this canvas should see\n // a gesture aimed at text being edited. `stopPropagation` does not\n // suppress a default action, only delivery.\n if (isInlineEditWithin(el)) {\n e.stopPropagation()\n return\n }\n if (e.type === 'pointerdown') {\n selectedAtPress = Besigner.focus.isNodeSelected(node)\n }\n e.preventDefault()\n e.stopPropagation()\n // A press on one of this element's repeat copies (Sam, Jordan) means\n // the element that copy draws, not this one around it — see\n // `repeatCopyAt`. Its selection is outlined on the copy pressed.\n const copy = repeatCopyAt(e.target)\n const original = copy?.original ?? null\n const target = original ?? node\n // Element-picker capture (AGL-574): while the interaction builder is\n // picking, this click resolves the target and exits pick mode —\n // never the normal select/navigate, so the designer's selection and\n // the open interaction stay put.\n if (Besigner.pick.isPicking()) {\n Besigner.pick.handlePickClick(target.$id)\n return\n }\n // Canvas multi-selection modifiers (AGL-12), mirroring the\n // hierarchy panel: Shift ranges, Cmd/Ctrl toggles.\n const pointer = e as globalThis.MouseEvent\n if (pointer.shiftKey) {\n Besigner.focus.rangeSelectNode(target)\n } else {\n Besigner.focus.handleNodeSelection(\n target,\n pointer.metaKey || pointer.ctrlKey,\n )\n if (!original && !pointer.metaKey && !pointer.ctrlKey) {\n pickPartUnder(pointer)\n }\n }\n repeatCopyStandIns.set('selected', copy)\n }\n /**\n * A plain click on a placement (a component instance or a placed form)\n * also says WHICH part of it was under the pointer (AGL-3288), so the\n * Styles and Attributes tabs aim \"Which part?\" at what the author just\n * clicked. The parts themselves stay unselectable — they are drawn\n * inert — so this is the only way a click can reach one.\n */\n function pickPartUnder(pointer: globalThis.MouseEvent) {\n if (!isDefinitionPlacement(node)) return\n const container = ref.current\n if (!container || typeof pointer.clientX !== 'number') return\n const { definitions, formDesigns } = instanceEditRef.current\n const definition = placementDefinitionFor(node, {\n definitions,\n formDesigns,\n })\n if (!definition) return\n const key = findPlacementPartAtPoint(\n container,\n pointer.clientX,\n pointer.clientY,\n node.$id,\n (graftedId) =>\n resolveInstanceLeafBinding(\n graftedId,\n node.$id,\n definition,\n 'children',\n definition.rootId,\n ),\n definition.rootId,\n )\n pickPlacementPart(node.$id, key ?? '')\n }\n function handleDoubleClick(e: Event) {\n // The `dblclick` a browser may still send for two taps that already\n // opened an editor (see handleTouchEnd): consumed, not run twice.\n if (e.timeStamp - editOpenedByTapAt < DOUBLE_TAP_WITHIN_MS * 2) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n // Inside an open edit, a double-click selects a word, as the\n // double-tap does (see handleTouchEnd). The default is the word\n // selection, so it is left alone; only delivery stops, or an\n // instance would reopen its prop edit over the text being typed.\n if (isInlineEditWithin(el)) {\n e.stopPropagation()\n return\n }\n if (!openEditAt(e as globalThis.MouseEvent)) return\n e.preventDefault()\n e.stopPropagation()\n }\n /**\n * Opens this element's in-place editor for a double-click or a\n * double-tap at `point`, and says whether one opened — which is also\n * whether the gesture is spent here or goes on to an ancestor.\n */\n function openEditAt(point: ClientPoint): boolean {\n if (!el) return false\n // Prop-fed instance internals (AGL-1304): the rendered preview sits\n // under `pointer-events: none`, so the double-click lands HERE, on\n // the instance — hit-test the preview geometrically, map the grafted\n // leaf back to the definition, and if a declared prop feeds it, edit\n // that prop inline. Leaves the component owns stay locked (the\n // selection this dblclick's mousedowns already made puts AGL-1303's\n // \"Edit component\" in the panel — nothing extra to build).\n if (\n node?.componentId === REUSABLE_INSTANCE_COMPONENT_ID &&\n Besigner.dnd.canDragNode(node)\n ) {\n return handleInstanceDoubleClick(point)\n }\n // Locked nodes (layout chrome in the screen besigner) stay read-only —\n // same gate the drag system uses — and while the interaction builder\n // is picking a target, a double-click is two picks, never an edit.\n if (!Besigner.dnd.canDragNode(node) || Besigner.pick.isPicking()) {\n return false\n }\n // Inline text editing for components that declare textEditable.\n const flag = node?.componentSchema?.flags?.textEditable\n const editable =\n typeof flag === 'number' && (flag & FEATURE_FLAG.ENABLED) !== 0\n if (editable) {\n const root = el\n // The node's own `<aglyn-text>` whenever it renders one, and the\n // root only as a fallback (AGL-2556). In-place editing EMPTIES\n // whatever it is given, so handing it a composite's root deletes\n // the chrome that composite built — for Accordion Summary that is\n // the content div carrying MUI's `textAlign: 'start'`, without\n // which the UA stylesheet centres the label inside the `<button>`\n // for as long as the edit is open.\n const element = findLeafTextElement(root) ?? root\n const rect = element.getBoundingClientRect()\n inlineTextEdit.open(\n node,\n {\n left: rect.left,\n top: rect.top,\n width: rect.width,\n height: rect.height,\n },\n undefined,\n // The measured element travels with the rect so the overlay can\n // re-measure on scroll instead of drifting (AGL-1644).\n element,\n )\n return true\n }\n // In-place Table cell editing: a component whose schema declares a\n // DATA_TABLE attribute stores its grid as one string, so a cell is\n // not a node of its own. The double-clicked cell becomes the editing\n // surface and the commit rewrites that one cell in the grid — the\n // same edit the attributes panel's grid makes. A double-click that\n // lands outside every cell (the empty-table hint) falls through.\n const tableAttribute = findDataTableAttributeName(node)\n if (tableAttribute) {\n const cell = findDataTableCellAtPoint(el, point.clientX, point.clientY)\n if (!cell) return false\n const stored = (node.props as Record<string, unknown> | undefined)?.[\n tableAttribute\n ]\n const cellRect = cell.element.getBoundingClientRect()\n // Editing an element is selecting it, as for markdown below: the\n // two mousedowns of the double-click toggled the selection off.\n Besigner.focus.setSelectedNode(node)\n inlineTextEdit.openCell(\n node,\n {\n left: cellRect.left,\n top: cellRect.top,\n width: cellRect.width,\n height: cellRect.height,\n },\n {\n attribute: tableAttribute,\n row: cell.row,\n column: cell.column,\n initialText: readDataTableCell(stored, cell.row, cell.column),\n },\n cell.element,\n )\n return true\n }\n // In-place markdown editing (AGL-1624): a component whose schema\n // declares a MARKDOWN attribute — the Markdown element's `content` is\n // the one that exists — opens the WYSIWYG over the element, editing\n // the whole document without a trip to the attributes panel.\n //\n // `stopPropagation` on the NATIVE event is what keeps the canvas still:\n // React delegates `onDoubleClick` at the root container, so an event\n // consumed here never reaches `ZoomablePanningComponent`'s\n // double-click-to-zoom. That is the same guarantee the textEditable\n // branch above has always relied on, not a new mechanism.\n const markdownAttribute = findMarkdownAttributeName(node)\n if (!markdownAttribute) return false\n const markdownElement = el\n const markdownRect = markdownElement.getBoundingClientRect()\n const stored = (node.props as Record<string, unknown> | undefined)?.[\n markdownAttribute\n ]\n // The two mousedowns of a double-click TOGGLE selection, so by the time\n // this fires the node has been selected and then deselected again.\n // Editing an element is selecting it — the attributes panel should be\n // showing it — and the editor closes when the selection moves off the\n // node, so it has to be put back before the editor opens.\n Besigner.focus.setSelectedNode(node)\n inlineMarkdownEdit.open(\n node,\n {\n left: markdownRect.left,\n top: markdownRect.top,\n width: markdownRect.width,\n height: markdownRect.height,\n },\n markdownAttribute,\n typeof stored === 'string' ? stored : '',\n markdownElement,\n )\n return true\n }\n /** True when the double-click resolved to a prop edit it opened. */\n function handleInstanceDoubleClick(pointer: ClientPoint) {\n const { definitions, onPickMedia } = instanceEditRef.current\n const refId = (node?.props as { refId?: string } | undefined)?.refId\n const definition = refId ? definitions?.[refId] : undefined\n const container = ref.current\n if (!definition || !container) return false\n const hit = findInstanceLeafAtPoint(\n container,\n pointer.clientX,\n pointer.clientY,\n )\n if (!hit) return false\n // Text first: a leaf whose `children` a declared prop feeds opens\n // the EXISTING inline editor, anchored on the clicked leaf, and the\n // commit writes propValues[prop] on the instance (one undo entry,\n // mirrored to peers like any node edit).\n const text = resolveInstanceLeafBinding(\n hit.graftedId,\n node.$id,\n definition,\n )\n if (text?.boundProp) {\n const rect = hit.element.getBoundingClientRect()\n const propName = text.boundProp\n // The schema of the element the prop fills decides the toolbar, as\n // a node's own schema does. Formatting is offered only when EVERY\n // element the prop fills draws markup: the graft hands the markup\n // to each of them, and one that ignores it would show bold that\n // never renders.\n const schemaOf = (id: string) =>\n components.getSchema(\n (definition.nodes as Record<string, { componentId?: string }>)[\n id\n ]?.componentId as Aglyn.ComponentId,\n )\n const rich = listPropFedTextNodeIds(definition.nodes, propName).every(\n (id) =>\n ((schemaOf(id)?.flags?.richTextEditable ??\n FEATURE_FLAG.DISABLED) &\n FEATURE_FLAG.ENABLED) !==\n 0,\n )\n inlineTextEdit.open(\n node,\n {\n left: rect.left,\n top: rect.top,\n width: rect.width,\n height: rect.height,\n },\n {\n propName,\n initialText: getInstanceEffectivePropText(\n node.props,\n definition.props,\n propName,\n ),\n schema: schemaOf(text.componentInternalId),\n rich,\n initialHtml: rich\n ? getInstanceEffectivePropHtml(\n node.props,\n definition.props,\n propName,\n )\n : '',\n },\n // The GRAFTED leaf, not the instance node: it is what was measured,\n // and it is the one anchor `Besigner.refs` could never supply\n // because it is not a canvas node (AGL-1644).\n hit.element,\n )\n return true\n }\n // Image half: `src` fed by a declared prop opens the host's media\n // picker, committing the picked value to the same propValues slot —\n // the exact pipeline the Attributes panel's Browse button uses.\n const src = resolveInstanceLeafBinding(\n hit.graftedId,\n node.$id,\n definition,\n 'src',\n )\n if (src?.boundProp && onPickMedia) {\n const propName = src.boundProp\n // The SAME leaf's `alt`, if the component author bound one to a\n // declared prop too (AGL-1896). Resolvable here and nowhere else\n // in the instance pipeline: this path starts from a concrete leaf\n // in the definition tree, so \"which declared prop feeds this\n // image's alt\" is a lookup rather than a guess. The attributes\n // panel only ever sees a declared prop's NAME, and no convention\n // says which other prop is its alt — so it does not try.\n const altBinding = resolveInstanceLeafBinding(\n hit.graftedId,\n node.$id,\n definition,\n 'alt',\n )\n onPickMedia((value, asset) => {\n // Written through verbatim (media reference or raw URL — the\n // host app decides; AGL-1215). Snapshot via toJSON like the\n // panel: updateNodeProps REPLACES the props object.\n const current = (canvas.toJSON().nodes as Record<string, any>)[\n node.$id\n ]\n // What the instance renders for the alt prop TODAY — its own\n // override, else the component's default. Not the raw override:\n // a component whose default alt is already a real sentence must\n // not have it replaced just because this instance never set one.\n const altPropName = altBinding?.boundProp\n const effectiveAlt = altPropName\n ? getInstanceEffectivePropText(\n current?.props,\n definition.props,\n altPropName,\n )\n : undefined\n const inheritedAlt = altPropName\n ? inheritedMediaAlt({\n placementAlt: effectiveAlt,\n assetAlt: asset?.alt,\n })\n : undefined\n canvas.updateNodeProps(node, {\n ...current?.props,\n [REUSABLE_INSTANCE_PROP_VALUES_KEY]: {\n ...current?.props?.[REUSABLE_INSTANCE_PROP_VALUES_KEY],\n [propName]: value,\n ...(inheritedAlt && altPropName\n ? { [altPropName]: inheritedAlt }\n : {}),\n },\n })\n })\n return true\n }\n return false\n }\n }, [node, element])\n\n return cloneElement(\n child,\n mergeProps(child.props, draggable.attributes, {\n ref: mergeRefs(\n ref,\n trackElement,\n child.props.ref,\n draggable.setNodeRef,\n droppable.setNodeRef,\n ),\n style,\n sx: {\n '&, &:hover, &:focus': {\n cursor: draggable.isDragging ? 'move' : 'initial',\n },\n },\n }),\n )\n },\n)\n\nDraggableDroppable.displayName = 'DraggableDroppable'\n\nexport default DraggableDroppable\n"],"names":["canvas","components","FEATURE_FLAG","getInstanceEffectivePropHtml","getInstanceEffectivePropText","inheritedMediaAlt","isDefinitionPlacement","listPropFedTextNodeIds","placementDefinitionFor","resolveInstanceLeafBinding","REUSABLE_INSTANCE_COMPONENT_ID","REUSABLE_INSTANCE_PROP_VALUES_KEY","Besigner","mergeRefs","useId","useDraggable","useDroppable","CSS","css","mergeProps","observer","Children","cloneElement","useCallback","useContext","useEffect","useRef","useState","ComponentPromotionContext","MediaPickerContext","findMarkdownAttributeName","inlineMarkdownEdit","inlineTextEdit","isInlineEditWithin","requestCanvasContextMenu","findInstanceLeafAtPoint","findPlacementPartAtPoint","pickPlacementPart","findLeafTextElement","findDataTableAttributeName","findDataTableCellAtPoint","readDataTableCell","holdKeyboardForEdit","repeatCopyAt","repeatCopyStandIns","DropSurface","TAP_SLOP_PX","TAP_MAX_MS","DOUBLE_TAP_WITHIN_MS","DOUBLE_TAP_SLOP_PX","distance","a","b","Math","hypot","x","y","DraggableDroppable","props","node","type","disableDragging","disableDropping","accept","children","idSuffix","id","$id","ref","element","setElement","trackElement","next","draggable","data","disabled","droppable","surface","CANVAS","getElement","current","transform","isTransforming","Boolean","child","only","style","outlineWidth","outlineOffset","outlineColor","outlineStyle","translate","Translate","toString","isOver","isDragging","opacity","cursor","pick","isPicking","focus","isNodeHovered","definitions","formDesigns","onPickMedia","instanceEditRef","listenersRef","listeners","refs","set","delete","handles","el","selectedAtPress","pressStart","lastTap","editOpenedByTapAt","Infinity","addEventListener","handleMouseOver","handleMouseDown","handleDoubleClick","handleContextMenu","handleTouchStart","handleTouchEnd","removeEventListener","e","touch","touches","length","undefined","clientX","clientY","at","timeStamp","selected","onTouchStart","nativeEvent","start","changedTouches","tap","first","openEditAt","preventDefault","stopPropagation","copy","target","original","setSelectedNode","setHoveredNode","isNodeSelected","handlePickClick","pointer","shiftKey","rangeSelectNode","handleNodeSelection","metaKey","ctrlKey","pickPartUnder","container","definition","key","graftedId","rootId","point","componentId","dnd","canDragNode","handleInstanceDoubleClick","flag","componentSchema","flags","textEditable","editable","ENABLED","root","rect","getBoundingClientRect","open","left","top","width","height","tableAttribute","cell","stored","cellRect","openCell","attribute","row","column","initialText","markdownAttribute","markdownElement","markdownRect","refId","hit","text","boundProp","propName","schemaOf","getSchema","nodes","rich","every","richTextEditable","DISABLED","schema","componentInternalId","initialHtml","src","altBinding","value","asset","toJSON","altPropName","effectiveAlt","inheritedAlt","placementAlt","assetAlt","alt","updateNodeProps","attributes","setNodeRef","sx","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SACEA,MAAM,EACNC,UAAU,EACVC,YAAY,EACZC,4BAA4B,EAC5BC,4BAA4B,EAC5BC,iBAAiB,EACjBC,qBAAqB,EACrBC,sBAAsB,EACtBC,sBAAsB,EACtBC,0BAA0B,EAC1BC,8BAA8B,EAC9BC,iCAAiC,QAC5B,eAAc;AACrB,YAAYC,cAAc,kBAAiB;AAC3C,SAASC,SAAS,EAAEC,KAAK,QAAQ,uBAAsB;AACvD,SAASC,YAAY,EAAEC,YAAY,QAAQ,gBAAe;AAC1D,SAASC,OAAOC,GAAG,QAAQ,qBAAoB;AAC/C,SAASC,UAAU,QAAQ,oBAAmB;AAC9C,SAASC,QAAQ,QAAQ,kBAAiB;AAC1C,SACEC,QAAQ,EACRC,YAAY,EAEZC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,QAAO;AACd,OAAOC,+BAA+B,gDAA4C;AAClF,SAASC,kBAAkB,QAAQ,yCAAqC;AACxE,SACEC,yBAAyB,EACzBC,kBAAkB,QACb,4CAAwC;AAC/C,SACEC,cAAc,EACdC,kBAAkB,QACb,wCAAoC;AAC3C,SAASC,wBAAwB,QAAQ,qCAAiC;AAC1E,SACEC,uBAAuB,EACvB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A,WAAYb,SAAS;oBACzC,MAAMkB,eAAeD,cACjBnN,6BACE4E,2BAAAA,QAAStB,KAAK,EACdsG,WAAWtG,KAAK,EAChB6J,eAEFrF;oBACJ,MAAMuF,eAAeF,cACjBlN,kBAAkB;wBAChBqN,cAAcF;wBACdG,QAAQ,EAAEN,yBAAAA,MAAOO,GAAG;oBACtB,KACA1F;oBACJlI,OAAO6N,eAAe,CAAClK,MAAM,aACxBqB,2BAAAA,QAAStB,KAAK;wBACjB,CAAC/C,kCAAkC,EAAE,aAChCqE,4BAAAA,iBAAAA,QAAStB,KAAK,qBAAdsB,cAAgB,CAACrE,kCAAkC;4BACtD,CAAC4L,SAAS,EAAEa;2BACRK,gBAAgBF,cAChB;4BAAE,CAACA,YAAY,EAAEE;wBAAa,IAC9B,CAAC;;gBAGX;gBACA,OAAO;YACT;YACA,OAAO;QACT;IACF,GAAG;QAAC9J;QAAMU;KAAQ;IAElB,qBAAO/C,aACL8D,OACAjE,WAAWiE,MAAM1B,KAAK,EAAEe,UAAUqJ,UAAU,EAAE;QAC5C1J,KAAKvD,UACHuD,KACAG,cACAa,MAAM1B,KAAK,CAACU,GAAG,EACfK,UAAUsJ,UAAU,EACpBnJ,UAAUmJ,UAAU;QAEtBzI;QACA0I,IAAI;YACF,uBAAuB;gBACrB/H,QAAQxB,UAAUsB,UAAU,GAAG,SAAS;YAC1C;QACF;IACF;AAEJ,GACD;AAEDtC,mBAAmBwK,WAAW,GAAG;AAEjC,eAAexK,mBAAkB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../libs/besigner/feature/designer/src/lib/components/dnd/draggable-droppable.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2023 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 {\n canvas,\n components,\n FEATURE_FLAG,\n getInstanceEffectivePropHtml,\n getInstanceEffectivePropText,\n inheritedMediaAlt,\n isDefinitionPlacement,\n listPropFedTextNodeIds,\n placementDefinitionFor,\n resolveInstanceLeafBinding,\n REUSABLE_INSTANCE_COMPONENT_ID,\n REUSABLE_INSTANCE_PROP_VALUES_KEY,\n} from '@aglyn/aglyn'\nimport * as Besigner from '@aglyn/besigner'\nimport { mergeRefs, useId } from '@aglyn/shared-ui-jsx'\nimport { useDraggable, useDroppable } from '@dnd-kit/core'\nimport { CSS as css } from '@dnd-kit/utilities'\nimport { mergeProps } from '@react-aria/utils'\nimport { observer } from 'mobx-react-lite'\nimport {\n Children,\n cloneElement,\n CSSProperties,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react'\nimport ComponentPromotionContext from '../../contexts/component-promotion-context'\nimport { MediaPickerContext } from '../../contexts/media-picker-context'\nimport {\n findMarkdownAttributeName,\n inlineMarkdownEdit,\n} from '../../utils/inline-markdown-edit.store'\nimport {\n inlineTextEdit,\n isInlineEditWithin,\n} from '../../utils/inline-text-edit.store'\nimport { requestCanvasContextMenu } from '../../utils/canvas-context-menu'\nimport {\n findInstanceLeafAtPoint,\n findPlacementPartAtPoint,\n} from '../../utils/instance-leaf-hit'\nimport { pickPlacementPart } from '../../utils/placement-part-pick'\nimport { findLeafTextElement } from '../../utils/in-place-edit-surface'\nimport {\n findDataTableAttributeName,\n findDataTableCellAtPoint,\n readDataTableCellForEdit,\n} from '../../utils/table-cell-edit'\nimport { holdKeyboardForEdit } from '../../utils/touch-keyboard'\nimport { repeatCopyAt, repeatCopyStandIns } from '../../utils/repeat-copy'\nimport { DropSurface } from './drop-surface'\n\n/** A pointer position, from a mouse event or a touch. */\ntype ClientPoint = { clientX: number; clientY: number }\n\n/** A finger's position and the event time it was read at. */\ntype TapPoint = { x: number; y: number; at: number }\n\n/** The furthest a finger may slide and still be tapping, in px. */\nconst TAP_SLOP_PX = 10\n/** The longest a press may last and still be a tap, in ms; longer is a hold. */\nconst TAP_MAX_MS = 300\n/** How soon the second tap of a double-tap must follow the first, in ms. */\nconst DOUBLE_TAP_WITHIN_MS = 350\n/** How far from the first tap the second may land, in px. */\nconst DOUBLE_TAP_SLOP_PX = 24\n\nconst distance = (a: { x: number; y: number }, b: { x: number; y: number }) =>\n Math.hypot(a.x - b.x, a.y - b.y)\n\nexport interface DraggableDroppableProps<T extends Aglyn.NodeSchema<any>> {\n children: JSX.Element\n node: T\n type: Besigner.DragType\n accept: Besigner.DragType[]\n disableDragging?: boolean\n disableDropping?: boolean\n idSuffix?: string\n}\n\nexport const DraggableDroppable = observer(\n <T extends Aglyn.NodeSchema<any>>(props: DraggableDroppableProps<T>) => {\n const {\n node,\n type,\n disableDragging,\n disableDropping,\n accept,\n children,\n idSuffix,\n } = props\n const id = useId(node?.$id)\n const ref = useRef<HTMLElement>(null)\n /**\n * The element as STATE, beside the ref, so the listeners below follow it.\n *\n * A component may render a different element for the same node: a\n * Typography whose text gains a line break holds block content, which a\n * `<p>` cannot, so it re-renders as a `<div>`. The listeners were bound\n * once per node, to the element that was there first, and stayed on the\n * detached `<p>` — a click on the text then reached the parent instead,\n * which selected the Stack around it, and a double-click opened nothing.\n */\n const [element, setElement] = useState<HTMLElement | null>(null)\n // Records a real element only. The merged ref below is a fresh callback\n // every render, so React hands it `null` and then the element on each\n // commit; setting the same element again bails out, a `null` would not.\n const trackElement = useCallback((next: HTMLElement | null) => {\n if (next) setElement(next)\n }, [])\n\n const draggable = useDraggable({\n id: `${id}:${type}${idSuffix || ''}`,\n data: { type, node },\n disabled: disableDragging,\n })\n\n const droppable = useDroppable({\n id: `${id}:${type}${idSuffix || ''}`,\n data: {\n type,\n node,\n accept,\n surface: DropSurface.CANVAS,\n // Measured live by the drop marker: dnd-kit's cached rect cannot\n // follow the canvas scrolling from inside its shadow root.\n getElement: () => ref.current,\n },\n disabled: disableDropping,\n })\n\n const transform = draggable.transform\n const isTransforming = Boolean(draggable.transform)\n const child = Children.only(children)\n const style: CSSProperties = {\n ...child.props.style,\n // cursor: 'move',\n outlineWidth: 2,\n outlineOffset: -1,\n outlineColor: 'grey',\n outlineStyle: 'dotted',\n // transform: css.Transform.toString(transform),\n // scale: css.Scale.toString(transform),\n translate: css.Translate.toString(transform),\n\n ...(isTransforming\n ? {\n // transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`,\n // cursor: 'grab',\n }\n : {}),\n ...(droppable.isOver\n ? {\n outlineColor: 'lime',\n outlineStyle: 'solid',\n outlineOffset: '3',\n }\n : {}),\n ...(draggable.isDragging\n ? {\n outlineColor: 'grey',\n outlineStyle: 'double',\n outlineOffset: -1 as any,\n opacity: 0.5,\n cursor: 'move',\n }\n : {}),\n // Element-picker affordance (AGL-574): while the interaction builder\n // is picking a target, every leaf shows the crosshair and the hovered\n // one gets a distinct violet ring — deliberately unlike the normal\n // selection/drop outlines so \"pick this\" reads as its own mode.\n ...(Besigner.pick.isPicking() ? { cursor: 'crosshair' } : {}),\n ...(Besigner.pick.isPicking() && Besigner.focus.isNodeHovered(node)\n ? {\n outlineColor: '#7c4dff',\n outlineStyle: 'solid',\n outlineWidth: 2,\n outlineOffset: 2 as any,\n }\n : {}),\n }\n\n // Instance-internals double-click (AGL-1304) needs the component\n // definitions (hit-test) and the host's media picker (image props).\n // Read through a ref so the listener effect below keeps its `[node]`\n // dependency — context updates must not re-register DOM listeners.\n const { definitions, formDesigns } = useContext(ComponentPromotionContext)\n const { onPickMedia } = useContext(MediaPickerContext)\n const instanceEditRef = useRef({ definitions, formDesigns, onPickMedia })\n instanceEditRef.current = { definitions, formDesigns, onPickMedia }\n // Same reason: the touch listener below reads the live dnd-kit handlers.\n const listenersRef = useRef(draggable.listeners)\n listenersRef.current = draggable.listeners\n\n useEffect(() => {\n Besigner.refs.set(node.$id, ref)\n return () => {\n Besigner.refs.delete(node.$id)\n }\n }, [node?.$id])\n\n useEffect(() => {\n Besigner.handles.set(node.$id, {\n ...draggable.listeners,\n style: isTransforming ? { cursor: 'grab' } : { cursor: 'move' },\n })\n return () => {\n Besigner.handles.delete(node.$id)\n }\n }, [node.$id, draggable.listeners, isTransforming])\n\n useEffect(() => {\n const el = ref.current\n /**\n * Whether this element was already selected when the latest press on\n * it began. Read by the touch drag below, and reset by it, because the\n * press that selects an element must not also pick it up.\n */\n let selectedAtPress = false\n /** Where and when the finger on this element came down. */\n let pressStart: TapPoint | null = null\n /** The last quick, still tap on this element, waiting for its pair. */\n let lastTap: TapPoint | null = null\n /** When a double-tap opened an editor here, by event time. */\n let editOpenedByTapAt = -Infinity\n if (el) {\n el.addEventListener('mouseover', handleMouseOver)\n el.addEventListener('pointerover', handleMouseOver)\n el.addEventListener('mousedown', handleMouseDown)\n el.addEventListener('pointerdown', handleMouseDown)\n el.addEventListener('dblclick', handleDoubleClick)\n el.addEventListener('contextmenu', handleContextMenu)\n el.addEventListener('touchstart', handleTouchStart)\n el.addEventListener('touchend', handleTouchEnd)\n\n return () => {\n el.removeEventListener('mouseover', handleMouseOver)\n el.removeEventListener('pointerover', handleMouseOver)\n el.removeEventListener('mousedown', handleMouseDown)\n el.removeEventListener('pointerdown', handleMouseDown)\n el.removeEventListener('dblclick', handleDoubleClick)\n el.removeEventListener('contextmenu', handleContextMenu)\n el.removeEventListener('touchstart', handleTouchStart)\n el.removeEventListener('touchend', handleTouchEnd)\n }\n }\n /**\n * Press and hold a selected element to drag it on a touch screen.\n *\n * The element itself has never been a drag source: a mouse drags it by\n * the grip in its toolbar, and on a mouse that costs nothing, because a\n * press on the body selects it and the page stays put. A finger pressing\n * the body scrolls the page instead, which is what an author trying to\n * move the element saw. Handing the press to dnd-kit's TouchSensor\n * keeps a swipe a scroll — the sensor waits for a still hold before it\n * takes over — and makes a hold a drag.\n *\n * Native, like its neighbours: the canvas is a closed shadow root, so a\n * React `onTouchStart` would never fire. The sensor reads only\n * `nativeEvent`, and marks it, so an ancestor that is also selected\n * cannot claim the same touch.\n */\n function handleTouchStart(e: TouchEvent) {\n const touch = e.touches.length === 1 ? e.touches[0] : undefined\n pressStart = touch\n ? { x: touch.clientX, y: touch.clientY, at: e.timeStamp }\n : null\n const selected = selectedAtPress\n selectedAtPress = false\n if (!selected || isInlineEditWithin(el) || Besigner.pick.isPicking()) {\n return\n }\n listenersRef.current?.onTouchStart?.({ nativeEvent: e } as any)\n }\n /**\n * Double-tap a text element to edit it in place on a touch screen.\n *\n * A mouse gets there by `dblclick`, and on a touch screen that event is\n * the browser's to give. Chrome on Android turns two taps into one; on\n * a phone the in-place editor, and the B / I / U toolbar that comes\n * with it, did not open. So the two taps are counted here, by rules\n * that are this canvas's own rather than each browser's, and the same\n * open runs.\n *\n * Opening this way also puts the keyboard up (`holdKeyboardForEdit`),\n * which iOS only allows while the tap is still being handled — and the\n * `preventDefault` keeps Safari from zooming on the second tap, or\n * sending the `dblclick` Chrome would have sent after it.\n *\n * Two taps make a double-tap when each is quick and still, and the\n * second lands near the first soon after it. A hold is a drag, a slide\n * is a scroll, and neither counts.\n */\n function handleTouchEnd(e: TouchEvent) {\n const start = pressStart\n pressStart = null\n const touch = e.changedTouches[0]\n if (\n !start ||\n !touch ||\n e.touches.length > 0 ||\n // Inside an open edit, a double-tap selects a word.\n isInlineEditWithin(el) ||\n Besigner.pick.isPicking()\n ) {\n lastTap = null\n return\n }\n const tap = { x: touch.clientX, y: touch.clientY, at: e.timeStamp }\n if (\n distance(tap, start) > TAP_SLOP_PX ||\n tap.at - start.at > TAP_MAX_MS\n ) {\n lastTap = null\n return\n }\n const first = lastTap\n lastTap = tap\n if (\n !first ||\n tap.at - first.at > DOUBLE_TAP_WITHIN_MS ||\n distance(tap, first) > DOUBLE_TAP_SLOP_PX\n ) {\n return\n }\n lastTap = null\n if (!openEditAt({ clientX: tap.x, clientY: tap.y })) return\n e.preventDefault()\n e.stopPropagation()\n editOpenedByTapAt = e.timeStamp\n // A prop-fed image opens the media picker instead, which wants no\n // keyboard.\n if (inlineTextEdit.node || inlineMarkdownEdit.node) {\n holdKeyboardForEdit(tap)\n }\n }\n /**\n * Right-click opens this element's ⋮ menu (AGL-1405).\n *\n * A native listener like its neighbours, not an `onContextMenu` prop:\n * React delegates at the root container and the canvas is a closed\n * shadow root, so a delegated handler never sees the event.\n *\n * Selects first. The menu is rendered by the overlay, which only mounts\n * for a selected or hovered node — and right-clicking an element is a\n * statement about THAT element, so leaving the previous selection in\n * place would open the wrong menu.\n */\n function handleContextMenu(e: Event) {\n if (isInlineEditWithin(el)) {\n // An open text editor keeps the browser's own menu: cut, paste and\n // spellcheck are the whole point of a right-click there.\n e.stopPropagation()\n return\n }\n e.preventDefault()\n e.stopPropagation()\n // On a repeat copy, the menu is the element the copy draws, and the\n // selection is outlined on the copy (`repeatCopyStandIns`).\n const copy = repeatCopyAt(e.target)\n const target = copy?.original ?? node\n Besigner.focus.setSelectedNode(target)\n repeatCopyStandIns.set('selected', copy)\n // On a Table, which cell was right-clicked (AGL-4203): the menu\n // offers rows and columns relative to it. Not on a repeat copy,\n // whose cells are a preview of the original's.\n const pointer = e as MouseEvent\n const tableCell =\n !copy && findDataTableAttributeName(target)\n ? findDataTableCellAtPoint(el, pointer.clientX, pointer.clientY)\n : undefined\n requestCanvasContextMenu(\n target?.$id,\n tableCell\n ? { row: tableCell.row, column: tableCell.column }\n : undefined,\n )\n }\n function handleMouseOver(e: Event) {\n // Same stand-down, same reason to consume it: a hover repaint while\n // the author is typing is a re-render of the subtree they are\n // editing, and an ancestor leaf would repaint for them instead.\n if (isInlineEditWithin(el)) {\n e.stopPropagation()\n return\n }\n e.preventDefault()\n e.stopPropagation()\n // On a repeat copy: the element it draws, outlined on the copy.\n const copy = repeatCopyAt(e.target)\n Besigner.focus.setHoveredNode(copy?.original ?? node)\n repeatCopyStandIns.set('hovered', copy)\n }\n function handleMouseDown(e: Event) {\n // Stand down while an edit is open in this leaf OR ANY LEAF INSIDE\n // IT (AGL-2486) — but CONSUME the event rather than ignoring it.\n //\n // Two different mistakes produced the same symptom, an editor that\n // was open, styled and completely uninteractive. First, asking only\n // \"is this leaf the node being edited?\": a nested run — a Span\n // typography inside a Typography — silenced its OWN leaf, the event\n // bubbled to the ancestor leaf, and the ancestor called the\n // `preventDefault` that suppresses caret placement. Second, standing\n // down by simply returning: that also skipped `stopPropagation`, so\n // the gesture carried on up to the viewport, which treats a\n // mousedown on empty canvas as a deselect — and moving the selection\n // off the node closes the editor. A drag meant to select three words\n // tore the editor down instead.\n //\n // So: no `preventDefault`, because that is the caret; but still\n // `stopPropagation`, because nothing else on this canvas should see\n // a gesture aimed at text being edited. `stopPropagation` does not\n // suppress a default action, only delivery.\n if (isInlineEditWithin(el)) {\n e.stopPropagation()\n return\n }\n if (e.type === 'pointerdown') {\n selectedAtPress = Besigner.focus.isNodeSelected(node)\n }\n e.preventDefault()\n e.stopPropagation()\n // A press on one of this element's repeat copies (Sam, Jordan) means\n // the element that copy draws, not this one around it — see\n // `repeatCopyAt`. Its selection is outlined on the copy pressed.\n const copy = repeatCopyAt(e.target)\n const original = copy?.original ?? null\n const target = original ?? node\n // Element-picker capture (AGL-574): while the interaction builder is\n // picking, this click resolves the target and exits pick mode —\n // never the normal select/navigate, so the designer's selection and\n // the open interaction stay put.\n if (Besigner.pick.isPicking()) {\n Besigner.pick.handlePickClick(target.$id)\n return\n }\n // Canvas multi-selection modifiers (AGL-12), mirroring the\n // hierarchy panel: Shift ranges, Cmd/Ctrl toggles.\n const pointer = e as globalThis.MouseEvent\n if (pointer.shiftKey) {\n Besigner.focus.rangeSelectNode(target)\n } else {\n Besigner.focus.handleNodeSelection(\n target,\n pointer.metaKey || pointer.ctrlKey,\n )\n if (!original && !pointer.metaKey && !pointer.ctrlKey) {\n pickPartUnder(pointer)\n }\n }\n repeatCopyStandIns.set('selected', copy)\n }\n /**\n * A plain click on a placement (a component instance or a placed form)\n * also says WHICH part of it was under the pointer (AGL-3288), so the\n * Styles and Attributes tabs aim \"Which part?\" at what the author just\n * clicked. The parts themselves stay unselectable — they are drawn\n * inert — so this is the only way a click can reach one.\n */\n function pickPartUnder(pointer: globalThis.MouseEvent) {\n if (!isDefinitionPlacement(node)) return\n const container = ref.current\n if (!container || typeof pointer.clientX !== 'number') return\n const { definitions, formDesigns } = instanceEditRef.current\n const definition = placementDefinitionFor(node, {\n definitions,\n formDesigns,\n })\n if (!definition) return\n const key = findPlacementPartAtPoint(\n container,\n pointer.clientX,\n pointer.clientY,\n node.$id,\n (graftedId) =>\n resolveInstanceLeafBinding(\n graftedId,\n node.$id,\n definition,\n 'children',\n definition.rootId,\n ),\n definition.rootId,\n )\n pickPlacementPart(node.$id, key ?? '')\n }\n function handleDoubleClick(e: Event) {\n // The `dblclick` a browser may still send for two taps that already\n // opened an editor (see handleTouchEnd): consumed, not run twice.\n if (e.timeStamp - editOpenedByTapAt < DOUBLE_TAP_WITHIN_MS * 2) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n // Inside an open edit, a double-click selects a word, as the\n // double-tap does (see handleTouchEnd). The default is the word\n // selection, so it is left alone; only delivery stops, or an\n // instance would reopen its prop edit over the text being typed.\n if (isInlineEditWithin(el)) {\n e.stopPropagation()\n return\n }\n if (!openEditAt(e as globalThis.MouseEvent)) return\n e.preventDefault()\n e.stopPropagation()\n }\n /**\n * Opens this element's in-place editor for a double-click or a\n * double-tap at `point`, and says whether one opened — which is also\n * whether the gesture is spent here or goes on to an ancestor.\n */\n function openEditAt(point: ClientPoint): boolean {\n if (!el) return false\n // Prop-fed instance internals (AGL-1304): the rendered preview sits\n // under `pointer-events: none`, so the double-click lands HERE, on\n // the instance — hit-test the preview geometrically, map the grafted\n // leaf back to the definition, and if a declared prop feeds it, edit\n // that prop inline. Leaves the component owns stay locked (the\n // selection this dblclick's mousedowns already made puts AGL-1303's\n // \"Edit component\" in the panel — nothing extra to build).\n if (\n node?.componentId === REUSABLE_INSTANCE_COMPONENT_ID &&\n Besigner.dnd.canDragNode(node)\n ) {\n return handleInstanceDoubleClick(point)\n }\n // Locked nodes (layout chrome in the screen besigner) stay read-only —\n // same gate the drag system uses — and while the interaction builder\n // is picking a target, a double-click is two picks, never an edit.\n if (!Besigner.dnd.canDragNode(node) || Besigner.pick.isPicking()) {\n return false\n }\n // Inline text editing for components that declare textEditable.\n const flag = node?.componentSchema?.flags?.textEditable\n const editable =\n typeof flag === 'number' && (flag & FEATURE_FLAG.ENABLED) !== 0\n if (editable) {\n const root = el\n // The node's own `<aglyn-text>` whenever it renders one, and the\n // root only as a fallback (AGL-2556). In-place editing EMPTIES\n // whatever it is given, so handing it a composite's root deletes\n // the chrome that composite built — for Accordion Summary that is\n // the content div carrying MUI's `textAlign: 'start'`, without\n // which the UA stylesheet centres the label inside the `<button>`\n // for as long as the edit is open.\n const element = findLeafTextElement(root) ?? root\n const rect = element.getBoundingClientRect()\n inlineTextEdit.open(\n node,\n {\n left: rect.left,\n top: rect.top,\n width: rect.width,\n height: rect.height,\n },\n undefined,\n // The measured element travels with the rect so the overlay can\n // re-measure on scroll instead of drifting (AGL-1644).\n element,\n )\n return true\n }\n // In-place Table cell editing: a component whose schema declares a\n // DATA_TABLE attribute stores its grid as one string, so a cell is\n // not a node of its own. The double-clicked cell becomes the editing\n // surface and the commit rewrites that one cell in the grid — the\n // same edit the attributes panel's grid makes. A double-click that\n // lands outside every cell (the empty-table hint) falls through.\n const tableAttribute = findDataTableAttributeName(node)\n if (tableAttribute) {\n const cell = findDataTableCellAtPoint(el, point.clientX, point.clientY)\n if (!cell) return false\n const stored = (node.props as Record<string, unknown> | undefined)?.[\n tableAttribute\n ]\n const cellRect = cell.element.getBoundingClientRect()\n const content = readDataTableCellForEdit(stored, cell.row, cell.column)\n // Editing an element is selecting it, as for markdown below: the\n // two mousedowns of the double-click toggled the selection off.\n Besigner.focus.setSelectedNode(node)\n inlineTextEdit.openCell(\n node,\n {\n left: cellRect.left,\n top: cellRect.top,\n width: cellRect.width,\n height: cellRect.height,\n },\n {\n attribute: tableAttribute,\n row: cell.row,\n column: cell.column,\n initialText: content.text,\n initialHtml: content.html,\n },\n cell.element,\n )\n return true\n }\n // In-place markdown editing (AGL-1624): a component whose schema\n // declares a MARKDOWN attribute — the Markdown element's `content` is\n // the one that exists — opens the WYSIWYG over the element, editing\n // the whole document without a trip to the attributes panel.\n //\n // `stopPropagation` on the NATIVE event is what keeps the canvas still:\n // React delegates `onDoubleClick` at the root container, so an event\n // consumed here never reaches `ZoomablePanningComponent`'s\n // double-click-to-zoom. That is the same guarantee the textEditable\n // branch above has always relied on, not a new mechanism.\n const markdownAttribute = findMarkdownAttributeName(node)\n if (!markdownAttribute) return false\n const markdownElement = el\n const markdownRect = markdownElement.getBoundingClientRect()\n const stored = (node.props as Record<string, unknown> | undefined)?.[\n markdownAttribute\n ]\n // The two mousedowns of a double-click TOGGLE selection, so by the time\n // this fires the node has been selected and then deselected again.\n // Editing an element is selecting it — the attributes panel should be\n // showing it — and the editor closes when the selection moves off the\n // node, so it has to be put back before the editor opens.\n Besigner.focus.setSelectedNode(node)\n inlineMarkdownEdit.open(\n node,\n {\n left: markdownRect.left,\n top: markdownRect.top,\n width: markdownRect.width,\n height: markdownRect.height,\n },\n markdownAttribute,\n typeof stored === 'string' ? stored : '',\n markdownElement,\n )\n return true\n }\n /** True when the double-click resolved to a prop edit it opened. */\n function handleInstanceDoubleClick(pointer: ClientPoint) {\n const { definitions, onPickMedia } = instanceEditRef.current\n const refId = (node?.props as { refId?: string } | undefined)?.refId\n const definition = refId ? definitions?.[refId] : undefined\n const container = ref.current\n if (!definition || !container) return false\n const hit = findInstanceLeafAtPoint(\n container,\n pointer.clientX,\n pointer.clientY,\n )\n if (!hit) return false\n // Text first: a leaf whose `children` a declared prop feeds opens\n // the EXISTING inline editor, anchored on the clicked leaf, and the\n // commit writes propValues[prop] on the instance (one undo entry,\n // mirrored to peers like any node edit).\n const text = resolveInstanceLeafBinding(\n hit.graftedId,\n node.$id,\n definition,\n )\n if (text?.boundProp) {\n const rect = hit.element.getBoundingClientRect()\n const propName = text.boundProp\n // The schema of the element the prop fills decides the toolbar, as\n // a node's own schema does. Formatting is offered only when EVERY\n // element the prop fills draws markup: the graft hands the markup\n // to each of them, and one that ignores it would show bold that\n // never renders.\n const schemaOf = (id: string) =>\n components.getSchema(\n (definition.nodes as Record<string, { componentId?: string }>)[\n id\n ]?.componentId as Aglyn.ComponentId,\n )\n const rich = listPropFedTextNodeIds(definition.nodes, propName).every(\n (id) =>\n ((schemaOf(id)?.flags?.richTextEditable ??\n FEATURE_FLAG.DISABLED) &\n FEATURE_FLAG.ENABLED) !==\n 0,\n )\n inlineTextEdit.open(\n node,\n {\n left: rect.left,\n top: rect.top,\n width: rect.width,\n height: rect.height,\n },\n {\n propName,\n initialText: getInstanceEffectivePropText(\n node.props,\n definition.props,\n propName,\n ),\n schema: schemaOf(text.componentInternalId),\n rich,\n initialHtml: rich\n ? getInstanceEffectivePropHtml(\n node.props,\n definition.props,\n propName,\n )\n : '',\n },\n // The GRAFTED leaf, not the instance node: it is what was measured,\n // and it is the one anchor `Besigner.refs` could never supply\n // because it is not a canvas node (AGL-1644).\n hit.element,\n )\n return true\n }\n // Image half: `src` fed by a declared prop opens the host's media\n // picker, committing the picked value to the same propValues slot —\n // the exact pipeline the Attributes panel's Browse button uses.\n const src = resolveInstanceLeafBinding(\n hit.graftedId,\n node.$id,\n definition,\n 'src',\n )\n if (src?.boundProp && onPickMedia) {\n const propName = src.boundProp\n // The SAME leaf's `alt`, if the component author bound one to a\n // declared prop too (AGL-1896). Resolvable here and nowhere else\n // in the instance pipeline: this path starts from a concrete leaf\n // in the definition tree, so \"which declared prop feeds this\n // image's alt\" is a lookup rather than a guess. The attributes\n // panel only ever sees a declared prop's NAME, and no convention\n // says which other prop is its alt — so it does not try.\n const altBinding = resolveInstanceLeafBinding(\n hit.graftedId,\n node.$id,\n definition,\n 'alt',\n )\n onPickMedia((value, asset) => {\n // Written through verbatim (media reference or raw URL — the\n // host app decides; AGL-1215). Snapshot via toJSON like the\n // panel: updateNodeProps REPLACES the props object.\n const current = (canvas.toJSON().nodes as Record<string, any>)[\n node.$id\n ]\n // What the instance renders for the alt prop TODAY — its own\n // override, else the component's default. Not the raw override:\n // a component whose default alt is already a real sentence must\n // not have it replaced just because this instance never set one.\n const altPropName = altBinding?.boundProp\n const effectiveAlt = altPropName\n ? getInstanceEffectivePropText(\n current?.props,\n definition.props,\n altPropName,\n )\n : undefined\n const inheritedAlt = altPropName\n ? inheritedMediaAlt({\n placementAlt: effectiveAlt,\n assetAlt: asset?.alt,\n })\n : undefined\n canvas.updateNodeProps(node, {\n ...current?.props,\n [REUSABLE_INSTANCE_PROP_VALUES_KEY]: {\n ...current?.props?.[REUSABLE_INSTANCE_PROP_VALUES_KEY],\n [propName]: value,\n ...(inheritedAlt && altPropName\n ? { [altPropName]: inheritedAlt }\n : {}),\n },\n })\n })\n return true\n }\n return false\n }\n }, [node, element])\n\n return cloneElement(\n child,\n mergeProps(child.props, draggable.attributes, {\n ref: mergeRefs(\n ref,\n trackElement,\n child.props.ref,\n draggable.setNodeRef,\n droppable.setNodeRef,\n ),\n style,\n sx: {\n '&, &:hover, &:focus': {\n cursor: draggable.isDragging ? 'move' : 'initial',\n },\n },\n }),\n )\n },\n)\n\nDraggableDroppable.displayName = 'DraggableDroppable'\n\nexport default DraggableDroppable\n"],"names":["canvas","components","FEATURE_FLAG","getInstanceEffectivePropHtml","getInstanceEffectivePropText","inheritedMediaAlt","isDefinitionPlacement","listPropFedTextNodeIds","placementDefinitionFor","resolveInstanceLeafBinding","REUSABLE_INSTANCE_COMPONENT_ID","REUSABLE_INSTANCE_PROP_VALUES_KEY","Besigner","mergeRefs","useId","useDraggable","useDroppable","CSS","css","mergeProps","observer","Children","cloneElement","useCallback","useContext","useEffect","useRef","useState","ComponentPromotionContext","MediaPickerContext","findMarkdownAttributeName","inlineMarkdownEdit","inlineTextEdit","isInlineEditWithin","requestCanvasContextMenu","findInstanceLeafAtPoint","findPlacementPartAtPoint","pickPlacementPart","findLeafTextElement","findDataTableAttributeName","findDataTableCellAtPoint","readDataTableCellForEdit","holdKeyboardForEdit","repeatCopyAt","repeatCopyStandIns","DropSurface","TAP_SLOP_PX","TAP_MAX_MS","DOUBLE_TAP_WITHIN_MS","DOUBLE_TAP_SLOP_PX","distance","a","b","Math","hypot","x","y","DraggableDroppable","props","node","type","disableDragging","disableDropping","accept","children","idSuffix","id","$id","ref","element","setElement","trackElement","next","draggable","data","disabled","droppable","surface","CANVAS","getElement","current","transform","isTransforming","Boolean","child","only","style","outlineWidth","outlineOffset","outlineColor","outlineStyle","translate","Translate","toString","isOver","isDragging","opacity","cursor","pick","isPicking","focus","isNodeHovered","definitions","formDesigns","onPickMedia","instanceEditRef","listenersRef","listeners","refs","set","delete","handles","el","selectedAtPress","pressStart","lastTap","editOpenedByTapAt","Infinity","addEventListener","handleMouseOver","handleMouseDown","handleDoubleClick","handleContextMenu","handleTouchStart","handleTouchEnd","removeEventListener","e","touch","touches","length","undefined","clientX","clientY","at","timeStamp","selected","onTouchStart","nativeEvent","start","changedTouches","tap","first","openEditAt","preventDefault","stopPropagation","copy","target","original","setSelectedNode","pointer","tableCell","row","column","setHoveredNode","isNodeSelected","handlePickClick","shiftKey","rangeSelectNode","handleNodeSelection","metaKey","ctrlKey","pickPartUnder","container","definition","key","graftedId","rootId","point","componentId","dnd","canDragNode","handleInstanceDoubleClick","flag","componentSchema","flags","textEditable","editable","ENABLED","root","rect","getBoundingClientRect","open","left","top","width","height","tableAttribute","cell","stored","cellRect","content","openCell","attribute","initialText","text","initialHtml","html","markdownAttribute","markdownElement","markdownRect","refId","hit","boundProp","propName","schemaOf","getSchema","nodes","rich","every","richTextEditable","DISABLED","schema","componentInternalId","src","altBinding","value","asset","toJSON","altPropName","effectiveAlt","inheritedAlt","placementAlt","assetAlt","alt","updateNodeProps","attributes","setNodeRef","sx","displayName"],"mappings":"AAAA;;;;;;;;;;;;;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EAChBgK,eAEFxF;oBACJ,MAAM0F,eAAeF,cACjBrN,kBAAkB;wBAChBwN,cAAcF;wBACdG,QAAQ,EAAEN,yBAAAA,MAAOO,GAAG;oBACtB,KACA7F;oBACJlI,OAAOgO,eAAe,CAACrK,MAAM,aACxBqB,2BAAAA,QAAStB,KAAK;wBACjB,CAAC/C,kCAAkC,EAAE,aAChCqE,4BAAAA,iBAAAA,QAAStB,KAAK,qBAAdsB,cAAgB,CAACrE,kCAAkC;4BACtD,CAACgM,SAAS,EAAEY;2BACRK,gBAAgBF,cAChB;4BAAE,CAACA,YAAY,EAAEE;wBAAa,IAC9B,CAAC;;gBAGX;gBACA,OAAO;YACT;YACA,OAAO;QACT;IACF,GAAG;QAACjK;QAAMU;KAAQ;IAElB,qBAAO/C,aACL8D,OACAjE,WAAWiE,MAAM1B,KAAK,EAAEe,UAAUwJ,UAAU,EAAE;QAC5C7J,KAAKvD,UACHuD,KACAG,cACAa,MAAM1B,KAAK,CAACU,GAAG,EACfK,UAAUyJ,UAAU,EACpBtJ,UAAUsJ,UAAU;QAEtB5I;QACA6I,IAAI;YACF,uBAAuB;gBACrBlI,QAAQxB,UAAUsB,UAAU,GAAG,SAAS;YAC1C;QACF;IACF;AAEJ,GACD;AAEDtC,mBAAmB2K,WAAW,GAAG;AAEjC,eAAe3K,mBAAkB"}
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
17
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
18
|
import { canvas, FEATURE_FLAG, REUSABLE_INSTANCE_PROP_HTML_KEY, REUSABLE_INSTANCE_PROP_VALUES_KEY, RICH_TEXT_COMMANDS } from "@aglyn/aglyn";
|
|
19
|
-
import { mdiCodeBraces } from "@aglyn/shared-data-mdi";
|
|
19
|
+
import { mdiCodeBraces, mdiTable } from "@aglyn/shared-data-mdi";
|
|
20
20
|
import { MdiIcon } from "@aglyn/shared-ui-jsx";
|
|
21
|
-
import { Box, Button, IconButton, Paper, useTheme } from "@mui/material";
|
|
21
|
+
import { Box, Button, IconButton, ListItemIcon, ListItemText, Menu, MenuItem, Paper, useTheme } from "@mui/material";
|
|
22
22
|
import isEqual from "lodash-es/isEqual.js";
|
|
23
23
|
import { toJS } from "mobx";
|
|
24
24
|
import { observer } from "mobx-react-lite";
|
|
@@ -27,7 +27,7 @@ import { clampToViewport, useAnchoredRect } from "../hooks/use-anchored-rect.js"
|
|
|
27
27
|
import useInsertTokenOptions from "../hooks/use-insert-token-options.js";
|
|
28
28
|
import { addCaretStops, beginInPlaceEdit, selectionOf, withoutCaretStops } from "../utils/in-place-edit-surface.js";
|
|
29
29
|
import { inlineTextEdit } from "../utils/inline-text-edit.store.js";
|
|
30
|
-
import { writeDataTableCell } from "../utils/table-cell-edit.js";
|
|
30
|
+
import { dataTableCellActions, dataTableCellValueFromEdit, withDataTableShapeEdit, writeDataTableCell } from "../utils/table-cell-edit.js";
|
|
31
31
|
import { RICH_COMMANDS, richTextCommandGroups } from "../utils/rich-text-commands.js";
|
|
32
32
|
import { richTextToPlain, sanitizeRichText, textToHtml } from "../utils/sanitize-rich-text.js";
|
|
33
33
|
import { createTokenPillElement, materializeTokenPillsInElement, readTokenSegmentsFromDom, replacePillsWithTokenText, TOKEN_PILL_ATTR } from "../utils/token-editable-dom.js";
|
|
@@ -66,7 +66,14 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
66
66
|
* and a see-through surface in that position is what drew two texts over
|
|
67
67
|
* each other; covering what it stands on is honest, blending with it is not.
|
|
68
68
|
* Everything else edits the canvas leaf itself and needs no surface here.
|
|
69
|
-
*/
|
|
69
|
+
*/ /**
|
|
70
|
+
* What a Table cell's toolbar offers (AGL-4203): bold, italic, underline and
|
|
71
|
+
* a link. No lists — a cell is one line of a pipe grid.
|
|
72
|
+
*/ const TABLE_CELL_COMMANDS = new Set([
|
|
73
|
+
RICH_TEXT_COMMANDS.EMPHASIS,
|
|
74
|
+
RICH_TEXT_COMMANDS.LINK
|
|
75
|
+
]);
|
|
76
|
+
const BOXED_SURFACE_SX = {
|
|
70
77
|
p: 0.5,
|
|
71
78
|
bgcolor: 'background.paper',
|
|
72
79
|
color: 'text.primary',
|
|
@@ -105,7 +112,7 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
105
112
|
* clearing the Attributes field does.
|
|
106
113
|
*/ export const InlineTextEditorComponent = observer(function InlineTextEditorComponent() {
|
|
107
114
|
var _ref, _ref1, _ref2;
|
|
108
|
-
var _node_componentSchema_flags, _node_componentSchema;
|
|
115
|
+
var _node_componentSchema_flags, _node_componentSchema, _node_props;
|
|
109
116
|
const node = inlineTextEdit.node;
|
|
110
117
|
const rect = inlineTextEdit.rect;
|
|
111
118
|
const propTarget = inlineTextEdit.propTarget;
|
|
@@ -151,6 +158,13 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
151
158
|
* Nothing can be lost by refusing: a surface that was never built holds
|
|
152
159
|
* no caret and no typing.
|
|
153
160
|
*/ const seededRef = useRef(false);
|
|
161
|
+
/**
|
|
162
|
+
* A row or column action picked from a Table cell's toolbar menu
|
|
163
|
+
* (AGL-4203), applied by the commit it triggers. A ref rather than an
|
|
164
|
+
* argument: `commit` is also a click handler and a key handler, and
|
|
165
|
+
* would be handed their events.
|
|
166
|
+
*/ const pendingShapeEditRef = useRef(undefined);
|
|
167
|
+
/** Where the Table cell's row and column menu hangs, while it is open. */ const [tableMenuAnchor, setTableMenuAnchor] = useState(null);
|
|
154
168
|
/** The canvas leaf while it IS the editing surface — see beginInPlaceEdit. */ const inPlaceRef = useRef(undefined);
|
|
155
169
|
/**
|
|
156
170
|
* Latest handlers for the listeners bound onto the leaf. They are bound
|
|
@@ -199,12 +213,12 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
199
213
|
// A prop edit is formatted when every element the prop fills draws
|
|
200
214
|
// markup (decided where the edit opens): its markup rides the instance's
|
|
201
215
|
// own `propHtml`, as a node's rides `html`.
|
|
202
|
-
// A Table cell
|
|
203
|
-
const rich = cellTarget ?
|
|
216
|
+
// A Table cell is formatted text (AGL-4203): inline formatting and links.
|
|
217
|
+
const rich = cellTarget ? true : propTarget ? Boolean(propTarget.rich) : (((_ref = node == null ? void 0 : (_node_componentSchema = node.componentSchema) == null ? void 0 : (_node_componentSchema_flags = _node_componentSchema.flags) == null ? void 0 : _node_componentSchema_flags.richTextEditable) != null ? _ref : FEATURE_FLAG.DISABLED) & FEATURE_FLAG.ENABLED) !== 0;
|
|
204
218
|
// What THIS component's schema allows (AGL-2557); a schema that names
|
|
205
219
|
// nothing allows everything, which is what leaves Typography alone. For a
|
|
206
220
|
// prop edit that is the schema of the element the prop fills.
|
|
207
|
-
const commandGroups = richTextCommandGroups(propTarget ? propTarget.schema : node == null ? void 0 : node.componentSchema);
|
|
221
|
+
const commandGroups = cellTarget ? TABLE_CELL_COMMANDS : richTextCommandGroups(propTarget ? propTarget.schema : node == null ? void 0 : node.componentSchema);
|
|
208
222
|
/**
|
|
209
223
|
* The surface may hold phrasing content only.
|
|
210
224
|
*
|
|
@@ -213,7 +227,11 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
213
227
|
* block and no nested control, and that single fact is what the commit
|
|
214
228
|
* sanitizer, the Enter key and the toolbar all need. Two ways to say it
|
|
215
229
|
* would eventually say two different things.
|
|
216
|
-
*/
|
|
230
|
+
*/ //
|
|
231
|
+
// A Table cell is the one surface that is phrasing-only AND takes links
|
|
232
|
+
// (AGL-4203): it is a line of a pipe grid, so no block fits in it, but
|
|
233
|
+
// it is not a control, so an anchor does.
|
|
234
|
+
const phrasingOnly = rich && (Boolean(cellTarget) || !commandGroups.has(RICH_TEXT_COMMANDS.LIST) && !commandGroups.has(RICH_TEXT_COMMANDS.LINK));
|
|
217
235
|
const activeEditable = useCallback(()=>{
|
|
218
236
|
var _ref;
|
|
219
237
|
var _inPlaceRef_current;
|
|
@@ -308,7 +326,7 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
308
326
|
const props = _extends({}, node.props, node.resolvedProps);
|
|
309
327
|
const text = cellTarget ? cellTarget.initialText : propTarget ? propTarget.initialText : typeof (props == null ? void 0 : props.children) === 'string' ? props.children : '';
|
|
310
328
|
const resolve = (token)=>resolveTokenLabel(token, labelContextRef.current);
|
|
311
|
-
const markup = propTarget ? propTarget.initialHtml : props == null ? void 0 : props.html;
|
|
329
|
+
const markup = cellTarget ? cellTarget.initialHtml : propTarget ? propTarget.initialHtml : props == null ? void 0 : props.html;
|
|
312
330
|
const build = (target)=>{
|
|
313
331
|
if (rich) {
|
|
314
332
|
const initial = typeof markup === 'string' && markup ? markup : textToHtml(text);
|
|
@@ -437,6 +455,9 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
437
455
|
// text — the markup beside it.
|
|
438
456
|
let plain;
|
|
439
457
|
let markup;
|
|
458
|
+
// The whole sanitized surface, markup or not — a Table cell needs it
|
|
459
|
+
// to store literal `<` as typed (see `dataTableCellValueFromEdit`).
|
|
460
|
+
let sanitizedSurface;
|
|
440
461
|
if (rich && surface) {
|
|
441
462
|
// Pills serialize back to raw tokens BEFORE sanitizing (the
|
|
442
463
|
// sanitizer strips attributes, and pill labels must never
|
|
@@ -448,8 +469,10 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
448
469
|
// it — so the commit strips it first and what is stored is what
|
|
449
470
|
// the page will draw.
|
|
450
471
|
const sanitized = withoutCaretStops(sanitizeRichText(clone.innerHTML, {
|
|
451
|
-
phrasingOnly
|
|
472
|
+
phrasingOnly,
|
|
473
|
+
links: Boolean(inlineTextEdit.cellTarget)
|
|
452
474
|
}));
|
|
475
|
+
sanitizedSurface = sanitized;
|
|
453
476
|
plain = richTextToPlain(sanitized);
|
|
454
477
|
if (/<[a-z]/i.test(sanitized)) markup = sanitized;
|
|
455
478
|
} else if (surface) {
|
|
@@ -463,11 +486,15 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
463
486
|
var _current_props;
|
|
464
487
|
// One Table cell: rewrite that cell inside the grid string, and
|
|
465
488
|
// leave every other cell, the alignments and the rest of the
|
|
466
|
-
// props as they were.
|
|
489
|
+
// props as they were. A row or column action picked from the
|
|
490
|
+
// toolbar rides the SAME write (AGL-4203), so the text typed so
|
|
491
|
+
// far and the new row are one undo step, not two.
|
|
467
492
|
const stored = (_current_props = current.props) == null ? void 0 : _current_props[cell.attribute];
|
|
468
|
-
|
|
469
|
-
[cell.attribute]: writeDataTableCell(stored, cell.row, cell.column, plain)
|
|
493
|
+
const withCell = _extends({}, toJS(current.props), {
|
|
494
|
+
[cell.attribute]: writeDataTableCell(stored, cell.row, cell.column, dataTableCellValueFromEdit(plain, sanitizedSurface != null ? sanitizedSurface : plain))
|
|
470
495
|
});
|
|
496
|
+
const shapeEdit = pendingShapeEditRef.current;
|
|
497
|
+
nextWrite = shapeEdit ? withDataTableShapeEdit(withCell, cell.attribute, shapeEdit) : withCell;
|
|
471
498
|
} else if (plain !== undefined && target) {
|
|
472
499
|
var _current_props1, _current_props2;
|
|
473
500
|
// Instance prop override (AGL-1304): the edit rides the
|
|
@@ -515,6 +542,7 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
515
542
|
});
|
|
516
543
|
}
|
|
517
544
|
}
|
|
545
|
+
pendingShapeEditRef.current = undefined;
|
|
518
546
|
(_inPlaceRef_current = inPlaceRef.current) == null ? void 0 : _inPlaceRef_current.dispose();
|
|
519
547
|
inPlaceRef.current = undefined;
|
|
520
548
|
if (current && nextWrite) commitProps(current, nextWrite);
|
|
@@ -923,6 +951,22 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
923
951
|
}, [
|
|
924
952
|
activeEditable
|
|
925
953
|
]);
|
|
954
|
+
/** Closes the cell's row and column menu and goes back to typing. */ const closeTableMenu = useCallback(()=>{
|
|
955
|
+
var _activeEditable;
|
|
956
|
+
setTableMenuAnchor(null);
|
|
957
|
+
menuOpenRef.current = false;
|
|
958
|
+
(_activeEditable = activeEditable()) == null ? void 0 : _activeEditable.focus();
|
|
959
|
+
}, [
|
|
960
|
+
activeEditable
|
|
961
|
+
]);
|
|
962
|
+
/** Applies a row or column action, with the cell's text, as one commit. */ const pickShapeEdit = useCallback((edit)=>{
|
|
963
|
+
setTableMenuAnchor(null);
|
|
964
|
+
menuOpenRef.current = false;
|
|
965
|
+
pendingShapeEditRef.current = edit;
|
|
966
|
+
commit();
|
|
967
|
+
}, [
|
|
968
|
+
commit
|
|
969
|
+
]);
|
|
926
970
|
const handleInsertPick = useCallback((token)=>{
|
|
927
971
|
var _ref;
|
|
928
972
|
const editable = activeEditable();
|
|
@@ -1111,6 +1155,28 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
1111
1155
|
},
|
|
1112
1156
|
children: '\u{1F517}'
|
|
1113
1157
|
}) : null,
|
|
1158
|
+
cellTarget ? /*#__PURE__*/ _jsx(IconButton, {
|
|
1159
|
+
size: "small",
|
|
1160
|
+
title: "Rows and columns",
|
|
1161
|
+
"aria-label": "Rows and columns",
|
|
1162
|
+
"aria-haspopup": "menu",
|
|
1163
|
+
onMouseDown: keepFocus,
|
|
1164
|
+
onClick: (event)=>{
|
|
1165
|
+
// Up BEFORE the menu takes focus: the blur that follows must
|
|
1166
|
+
// not read as the author leaving the cell.
|
|
1167
|
+
menuOpenRef.current = true;
|
|
1168
|
+
setTableMenuAnchor(event.currentTarget);
|
|
1169
|
+
},
|
|
1170
|
+
sx: {
|
|
1171
|
+
width: toolSize,
|
|
1172
|
+
height: toolSize,
|
|
1173
|
+
borderRadius: 0.5
|
|
1174
|
+
},
|
|
1175
|
+
children: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
1176
|
+
path: mdiTable.path,
|
|
1177
|
+
fontSize: "small"
|
|
1178
|
+
})
|
|
1179
|
+
}) : null,
|
|
1114
1180
|
insertButton,
|
|
1115
1181
|
/*#__PURE__*/ _jsx(Button, {
|
|
1116
1182
|
size: "small",
|
|
@@ -1144,6 +1210,31 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
1144
1210
|
onMouseDown: handleEditableMouseDown,
|
|
1145
1211
|
sx: plainSurfaceSx
|
|
1146
1212
|
}),
|
|
1213
|
+
cellTarget ? /*#__PURE__*/ _jsx(Menu, {
|
|
1214
|
+
anchorEl: tableMenuAnchor,
|
|
1215
|
+
open: Boolean(tableMenuAnchor),
|
|
1216
|
+
onClose: closeTableMenu,
|
|
1217
|
+
slotProps: {
|
|
1218
|
+
list: {
|
|
1219
|
+
dense: true
|
|
1220
|
+
}
|
|
1221
|
+
},
|
|
1222
|
+
children: dataTableCellActions((_node_props = node.props) == null ? void 0 : _node_props[cellTarget.attribute], cellTarget.row, cellTarget.column).map((action)=>/*#__PURE__*/ _jsxs(MenuItem, {
|
|
1223
|
+
disabled: action.disabled,
|
|
1224
|
+
onClick: ()=>pickShapeEdit(action.edit),
|
|
1225
|
+
children: [
|
|
1226
|
+
/*#__PURE__*/ _jsx(ListItemIcon, {
|
|
1227
|
+
children: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
1228
|
+
fontSize: "inherit",
|
|
1229
|
+
path: action.icon
|
|
1230
|
+
})
|
|
1231
|
+
}),
|
|
1232
|
+
/*#__PURE__*/ _jsx(ListItemText, {
|
|
1233
|
+
children: action.label
|
|
1234
|
+
})
|
|
1235
|
+
]
|
|
1236
|
+
}, action.key))
|
|
1237
|
+
}) : null,
|
|
1147
1238
|
/*#__PURE__*/ _jsx(InsertTokenMenu, {
|
|
1148
1239
|
anchorEl: (_ref1 = insertMenu == null ? void 0 : insertMenu.anchorEl) != null ? _ref1 : null,
|
|
1149
1240
|
open: Boolean(insertMenu),
|