@aglyn/besigner-ui 1.15.0 → 1.15.1
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/connection-records-scope.d.ts +18 -0
- package/src/lib/components/connection-records-scope.js +54 -0
- package/src/lib/components/connection-records-scope.js.map +1 -0
- package/src/lib/components/dnd/draggable-droppable.js +30 -0
- package/src/lib/components/dnd/draggable-droppable.js.map +1 -1
- package/src/lib/components/inline-text-editor.component.js +20 -6
- package/src/lib/components/inline-text-editor.component.js.map +1 -1
- package/src/lib/components/node-leaf.js +115 -106
- package/src/lib/components/node-leaf.js.map +1 -1
- package/src/lib/utils/inline-text-edit.store.d.ts +18 -0
- package/src/lib/utils/inline-text-edit.store.js +10 -0
- package/src/lib/utils/inline-text-edit.store.js.map +1 -1
- package/src/lib/utils/table-cell-edit.d.ts +66 -0
- package/src/lib/utils/table-cell-edit.js +93 -0
- package/src/lib/utils/table-cell-edit.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/besigner-ui",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.1",
|
|
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.15.
|
|
29
|
-
"@aglyn/aglyn-markdown-editor": "1.15.
|
|
30
|
-
"@aglyn/aglyn-node-renderer": "1.15.
|
|
31
|
-
"@aglyn/besigner": "1.15.
|
|
32
|
-
"@aglyn/shared-data-enums": "1.15.
|
|
33
|
-
"@aglyn/shared-data-mdi": "1.15.
|
|
34
|
-
"@aglyn/shared-data-types": "1.15.
|
|
35
|
-
"@aglyn/shared-svg-icons": "1.15.
|
|
36
|
-
"@aglyn/shared-ui-json-editor": "1.15.
|
|
37
|
-
"@aglyn/shared-ui-jsx": "1.15.
|
|
38
|
-
"@aglyn/shared-ui-jsx-forms": "1.15.
|
|
39
|
-
"@aglyn/shared-ui-snackstack": "1.15.
|
|
40
|
-
"@aglyn/shared-ui-theme": "1.15.
|
|
41
|
-
"@aglyn/shared-util-dom": "1.15.
|
|
42
|
-
"@aglyn/shared-util-tools": "1.15.
|
|
43
|
-
"@aglyn/shared-util-vendor": "1.15.
|
|
28
|
+
"@aglyn/aglyn": "1.15.1",
|
|
29
|
+
"@aglyn/aglyn-markdown-editor": "1.15.1",
|
|
30
|
+
"@aglyn/aglyn-node-renderer": "1.15.1",
|
|
31
|
+
"@aglyn/besigner": "1.15.1",
|
|
32
|
+
"@aglyn/shared-data-enums": "1.15.1",
|
|
33
|
+
"@aglyn/shared-data-mdi": "1.15.1",
|
|
34
|
+
"@aglyn/shared-data-types": "1.15.1",
|
|
35
|
+
"@aglyn/shared-svg-icons": "1.15.1",
|
|
36
|
+
"@aglyn/shared-ui-json-editor": "1.15.1",
|
|
37
|
+
"@aglyn/shared-ui-jsx": "1.15.1",
|
|
38
|
+
"@aglyn/shared-ui-jsx-forms": "1.15.1",
|
|
39
|
+
"@aglyn/shared-ui-snackstack": "1.15.1",
|
|
40
|
+
"@aglyn/shared-ui-theme": "1.15.1",
|
|
41
|
+
"@aglyn/shared-util-dom": "1.15.1",
|
|
42
|
+
"@aglyn/shared-util-tools": "1.15.1",
|
|
43
|
+
"@aglyn/shared-util-vendor": "1.15.1",
|
|
44
44
|
"@dnd-kit/core": "^6.3.1",
|
|
45
45
|
"@dnd-kit/utilities": "^3.2.2",
|
|
46
46
|
"@react-aria/utils": "^3.34.1",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A signed marketplace element on the canvas, handed its own listing's
|
|
4
|
+
* connection records (AGL-4196), the way the published page hands them.
|
|
5
|
+
*
|
|
6
|
+
* Attributed per element, as it renders, so an element dropped a moment ago
|
|
7
|
+
* reads its record as readily as one the document was saved with. Anything
|
|
8
|
+
* that is not a namespaced element, or a site with no records, passes
|
|
9
|
+
* through untouched.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ConnectionRecordsScope(props: {
|
|
12
|
+
node: {
|
|
13
|
+
$id?: unknown;
|
|
14
|
+
componentId?: unknown;
|
|
15
|
+
} | null | undefined;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
export default ConnectionRecordsScope;
|
|
@@ -0,0 +1,54 @@
|
|
|
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, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
+
import { EditorPluginConnectionsContext, editorConnectionRecordsPageData } from "@aglyn/aglyn/app-utils/plugin-connection-editor";
|
|
19
|
+
import { PluginConnectionRecordsContext } from "@aglyn/aglyn/app-utils/plugin-connection-records-context";
|
|
20
|
+
import { useContext, useMemo } from "react";
|
|
21
|
+
/**
|
|
22
|
+
* A signed marketplace element on the canvas, handed its own listing's
|
|
23
|
+
* connection records (AGL-4196), the way the published page hands them.
|
|
24
|
+
*
|
|
25
|
+
* Attributed per element, as it renders, so an element dropped a moment ago
|
|
26
|
+
* reads its record as readily as one the document was saved with. Anything
|
|
27
|
+
* that is not a namespaced element, or a site with no records, passes
|
|
28
|
+
* through untouched.
|
|
29
|
+
*/ export function ConnectionRecordsScope(props) {
|
|
30
|
+
const { node, children } = props;
|
|
31
|
+
const connections = useContext(EditorPluginConnectionsContext);
|
|
32
|
+
const nodeId = node == null ? void 0 : node.$id;
|
|
33
|
+
const componentId = node == null ? void 0 : node.componentId;
|
|
34
|
+
const value = useMemo(()=>editorConnectionRecordsPageData(connections, [
|
|
35
|
+
{
|
|
36
|
+
$id: nodeId,
|
|
37
|
+
componentId
|
|
38
|
+
}
|
|
39
|
+
]), [
|
|
40
|
+
connections,
|
|
41
|
+
nodeId,
|
|
42
|
+
componentId
|
|
43
|
+
]);
|
|
44
|
+
if (!value) return /*#__PURE__*/ _jsx(_Fragment, {
|
|
45
|
+
children: children
|
|
46
|
+
});
|
|
47
|
+
return /*#__PURE__*/ _jsx(PluginConnectionRecordsContext.Provider, {
|
|
48
|
+
value: value,
|
|
49
|
+
children: children
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export default ConnectionRecordsScope;
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=connection-records-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/connection-records-scope.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 {\n EditorPluginConnectionsContext,\n editorConnectionRecordsPageData,\n} from '@aglyn/aglyn/app-utils/plugin-connection-editor'\nimport { PluginConnectionRecordsContext } from '@aglyn/aglyn/app-utils/plugin-connection-records-context'\nimport { useContext, useMemo, type ReactNode } from 'react'\n\n/**\n * A signed marketplace element on the canvas, handed its own listing's\n * connection records (AGL-4196), the way the published page hands them.\n *\n * Attributed per element, as it renders, so an element dropped a moment ago\n * reads its record as readily as one the document was saved with. Anything\n * that is not a namespaced element, or a site with no records, passes\n * through untouched.\n */\nexport function ConnectionRecordsScope(props: {\n node: { $id?: unknown; componentId?: unknown } | null | undefined\n children: ReactNode\n}) {\n const { node, children } = props\n const connections = useContext(EditorPluginConnectionsContext)\n const nodeId = node?.$id\n const componentId = node?.componentId\n const value = useMemo(\n () => editorConnectionRecordsPageData(connections, [{ $id: nodeId, componentId }]),\n [connections, nodeId, componentId],\n )\n if (!value) return <>{children}</>\n return <PluginConnectionRecordsContext.Provider value={value}>{children}</PluginConnectionRecordsContext.Provider>\n}\n\nexport default ConnectionRecordsScope\n"],"names":["EditorPluginConnectionsContext","editorConnectionRecordsPageData","PluginConnectionRecordsContext","useContext","useMemo","ConnectionRecordsScope","props","node","children","connections","nodeId","$id","componentId","value","Provider"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,8BAA8B,EAC9BC,+BAA+B,QAC1B,kDAAiD;AACxD,SAASC,8BAA8B,QAAQ,2DAA0D;AACzG,SAASC,UAAU,EAAEC,OAAO,QAAwB,QAAO;AAE3D;;;;;;;;CAQC,GACD,OAAO,SAASC,uBAAuBC,KAGtC;IACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGF;IAC3B,MAAMG,cAAcN,WAAWH;IAC/B,MAAMU,SAASH,wBAAAA,KAAMI,GAAG;IACxB,MAAMC,cAAcL,wBAAAA,KAAMK,WAAW;IACrC,MAAMC,QAAQT,QACZ,IAAMH,gCAAgCQ,aAAa;YAAC;gBAAEE,KAAKD;gBAAQE;YAAY;SAAE,GACjF;QAACH;QAAaC;QAAQE;KAAY;IAEpC,IAAI,CAACC,OAAO,qBAAO;kBAAGL;;IACtB,qBAAO,KAACN,+BAA+BY,QAAQ;QAACD,OAAOA;kBAAQL;;AACjE;AAEA,eAAeH,uBAAsB"}
|
|
@@ -30,6 +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, readDataTableCell } from "../../utils/table-cell-edit.js";
|
|
33
34
|
import { holdKeyboardForEdit } from "../../utils/touch-keyboard.js";
|
|
34
35
|
import { repeatCopyAt, repeatCopyStandIns } from "../../utils/repeat-copy.js";
|
|
35
36
|
import { DropSurface } from "./drop-surface.js";
|
|
@@ -459,6 +460,35 @@ export const DraggableDroppable = observer((props)=>{
|
|
|
459
460
|
element);
|
|
460
461
|
return true;
|
|
461
462
|
}
|
|
463
|
+
// In-place Table cell editing: a component whose schema declares a
|
|
464
|
+
// DATA_TABLE attribute stores its grid as one string, so a cell is
|
|
465
|
+
// not a node of its own. The double-clicked cell becomes the editing
|
|
466
|
+
// surface and the commit rewrites that one cell in the grid — the
|
|
467
|
+
// same edit the attributes panel's grid makes. A double-click that
|
|
468
|
+
// lands outside every cell (the empty-table hint) falls through.
|
|
469
|
+
const tableAttribute = findDataTableAttributeName(node);
|
|
470
|
+
if (tableAttribute) {
|
|
471
|
+
var _node_props1;
|
|
472
|
+
const cell = findDataTableCellAtPoint(el, point.clientX, point.clientY);
|
|
473
|
+
if (!cell) return false;
|
|
474
|
+
const stored = (_node_props1 = node.props) == null ? void 0 : _node_props1[tableAttribute];
|
|
475
|
+
const cellRect = cell.element.getBoundingClientRect();
|
|
476
|
+
// Editing an element is selecting it, as for markdown below: the
|
|
477
|
+
// two mousedowns of the double-click toggled the selection off.
|
|
478
|
+
Besigner.focus.setSelectedNode(node);
|
|
479
|
+
inlineTextEdit.openCell(node, {
|
|
480
|
+
left: cellRect.left,
|
|
481
|
+
top: cellRect.top,
|
|
482
|
+
width: cellRect.width,
|
|
483
|
+
height: cellRect.height
|
|
484
|
+
}, {
|
|
485
|
+
attribute: tableAttribute,
|
|
486
|
+
row: cell.row,
|
|
487
|
+
column: cell.column,
|
|
488
|
+
initialText: readDataTableCell(stored, cell.row, cell.column)
|
|
489
|
+
}, cell.element);
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
462
492
|
// In-place markdown editing (AGL-1624): a component whose schema
|
|
463
493
|
// declares a MARKDOWN attribute — the Markdown element's `content` is
|
|
464
494
|
// the one that exists — opens the WYSIWYG over the element, editing
|
|
@@ -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 { 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 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","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","markdownAttribute","markdownElement","markdownRect","stored","refId","hit","text","boundProp","propName","schemaOf","getSchema","nodes","rich","every","richTextEditable","DISABLED","initialText","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,EAC9B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C5C,kCAAkC,EAAE,aAChCkE,4BAAAA,iBAAAA,QAAStB,KAAK,qBAAdsB,cAAgB,CAAClE,kCAAkC;4BACtD,CAACiL,SAAS,EAAEc;2BACRK,gBAAgBF,cAChB;4BAAE,CAACA,YAAY,EAAEE;wBAAa,IAC9B,CAAC;;gBAGX;gBACA,OAAO;YACT;YACA,OAAO;QACT;IACF,GAAG;QAACvJ;QAAMU;KAAQ;IAElB,qBAAO5C,aACL2D,OACA9D,WAAW8D,MAAM1B,KAAK,EAAEe,UAAU8I,UAAU,EAAE;QAC5CnJ,KAAKpD,UACHoD,KACAG,cACAa,MAAM1B,KAAK,CAACU,GAAG,EACfK,UAAU+I,UAAU,EACpB5I,UAAU4I,UAAU;QAEtBlI;QACAmI,IAAI;YACF,uBAAuB;gBACrBxH,QAAQxB,UAAUsB,UAAU,GAAG,SAAS;YAC1C;QACF;IACF;AAEJ,GACD;AAEDtC,mBAAmBiK,WAAW,GAAG;AAEjC,eAAejK,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 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,kBAA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MAAMA,UAAU,AAAChF,OAAOsN,MAAM,GAAGZ,KAAK,AAAwB,CAC5D/I,KAAKQ,GAAG,CACT;oBACD,6DAA6D;oBAC7D,gEAAgE;oBAChE,gEAAgE;oBAChE,iEAAiE;oBACjE,MAAMoJ,cAAcJ,8BAAAA,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"}
|
|
@@ -27,6 +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
31
|
import { RICH_COMMANDS, richTextCommandGroups } from "../utils/rich-text-commands.js";
|
|
31
32
|
import { richTextToPlain, sanitizeRichText, textToHtml } from "../utils/sanitize-rich-text.js";
|
|
32
33
|
import { createTokenPillElement, materializeTokenPillsInElement, readTokenSegmentsFromDom, replacePillsWithTokenText, TOKEN_PILL_ATTR } from "../utils/token-editable-dom.js";
|
|
@@ -108,6 +109,7 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
108
109
|
const node = inlineTextEdit.node;
|
|
109
110
|
const rect = inlineTextEdit.rect;
|
|
110
111
|
const propTarget = inlineTextEdit.propTarget;
|
|
112
|
+
const cellTarget = inlineTextEdit.cellTarget;
|
|
111
113
|
// Follows the element as the canvas scrolls or resizes (AGL-1644). Called
|
|
112
114
|
// unconditionally, above the `!node || !rect` bail-out further down, so the
|
|
113
115
|
// hook order is stable whether or not an edit is open.
|
|
@@ -197,7 +199,8 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
197
199
|
// A prop edit is formatted when every element the prop fills draws
|
|
198
200
|
// markup (decided where the edit opens): its markup rides the instance's
|
|
199
201
|
// own `propHtml`, as a node's rides `html`.
|
|
200
|
-
|
|
202
|
+
// A Table cell stores plain text, so its edit is never formatted.
|
|
203
|
+
const rich = cellTarget ? false : 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;
|
|
201
204
|
// What THIS component's schema allows (AGL-2557); a schema that names
|
|
202
205
|
// nothing allows everything, which is what leaves Typography alone. For a
|
|
203
206
|
// prop edit that is the schema of the element the prop fills.
|
|
@@ -303,7 +306,7 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
303
306
|
savedRangeRef.current = null;
|
|
304
307
|
seededRef.current = false;
|
|
305
308
|
const props = _extends({}, node.props, node.resolvedProps);
|
|
306
|
-
const text = propTarget ? propTarget.initialText : typeof (props == null ? void 0 : props.children) === 'string' ? props.children : '';
|
|
309
|
+
const text = cellTarget ? cellTarget.initialText : propTarget ? propTarget.initialText : typeof (props == null ? void 0 : props.children) === 'string' ? props.children : '';
|
|
307
310
|
const resolve = (token)=>resolveTokenLabel(token, labelContextRef.current);
|
|
308
311
|
const markup = propTarget ? propTarget.initialHtml : props == null ? void 0 : props.html;
|
|
309
312
|
const build = (target)=>{
|
|
@@ -377,6 +380,7 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
377
380
|
node,
|
|
378
381
|
rich,
|
|
379
382
|
propTarget,
|
|
383
|
+
cellTarget,
|
|
380
384
|
anchor
|
|
381
385
|
]);
|
|
382
386
|
/**
|
|
@@ -454,16 +458,26 @@ import { paintTokenPills, TokenPillPopover, tokenPillContainerSx } from "./token
|
|
|
454
458
|
if (plain === '\n') plain = '';
|
|
455
459
|
}
|
|
456
460
|
const target = inlineTextEdit.propTarget;
|
|
457
|
-
|
|
458
|
-
|
|
461
|
+
const cell = inlineTextEdit.cellTarget;
|
|
462
|
+
if (plain !== undefined && cell) {
|
|
463
|
+
var _current_props;
|
|
464
|
+
// One Table cell: rewrite that cell inside the grid string, and
|
|
465
|
+
// leave every other cell, the alignments and the rest of the
|
|
466
|
+
// props as they were.
|
|
467
|
+
const stored = (_current_props = current.props) == null ? void 0 : _current_props[cell.attribute];
|
|
468
|
+
nextWrite = _extends({}, toJS(current.props), {
|
|
469
|
+
[cell.attribute]: writeDataTableCell(stored, cell.row, cell.column, plain)
|
|
470
|
+
});
|
|
471
|
+
} else if (plain !== undefined && target) {
|
|
472
|
+
var _current_props1, _current_props2;
|
|
459
473
|
// Instance prop override (AGL-1304): the edit rides the
|
|
460
474
|
// INSTANCE's nested propValues, never the grafted leaf (which
|
|
461
475
|
// is not a canvas node). An emptied value REMOVES the key —
|
|
462
476
|
// the graft treats '' as unset anyway, and a cleared override
|
|
463
477
|
// must read as clean, exactly like the style-override layer.
|
|
464
478
|
// Formatting rides `propHtml` beside it, and goes with it.
|
|
465
|
-
const values = _extends({}, (
|
|
466
|
-
const formatted = _extends({}, (
|
|
479
|
+
const values = _extends({}, (_current_props1 = current.props) == null ? void 0 : _current_props1[REUSABLE_INSTANCE_PROP_VALUES_KEY]);
|
|
480
|
+
const formatted = _extends({}, (_current_props2 = current.props) == null ? void 0 : _current_props2[REUSABLE_INSTANCE_PROP_HTML_KEY]);
|
|
467
481
|
if (plain === '') delete values[target.propName];
|
|
468
482
|
else values[target.propName] = plain;
|
|
469
483
|
if (plain !== '' && markup) formatted[target.propName] = markup;
|