@aglyn/besigner-ui 1.0.0-beta.274 → 1.0.0-beta.277

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.
Files changed (65) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/app-bar-breadcrumbs.component.js +4 -2
  3. package/src/lib/components/app-bar-breadcrumbs.component.js.map +1 -1
  4. package/src/lib/components/aside-panel.component.js +19 -3
  5. package/src/lib/components/aside-panel.component.js.map +1 -1
  6. package/src/lib/components/besigner-dnd-context.component.js +46 -5
  7. package/src/lib/components/besigner-dnd-context.component.js.map +1 -1
  8. package/src/lib/components/dnd/canvas-drop-indicator.d.ts +11 -0
  9. package/src/lib/components/dnd/canvas-drop-indicator.js +32 -34
  10. package/src/lib/components/dnd/canvas-drop-indicator.js.map +1 -1
  11. package/src/lib/components/dnd/draggable-droppable.js +124 -23
  12. package/src/lib/components/dnd/draggable-droppable.js.map +1 -1
  13. package/src/lib/components/dnd/drop-indicator-geometry.d.ts +64 -0
  14. package/src/lib/components/dnd/drop-indicator-geometry.js +77 -0
  15. package/src/lib/components/dnd/drop-indicator-geometry.js.map +1 -0
  16. package/src/lib/components/dnd/drop-indicator.d.ts +13 -11
  17. package/src/lib/components/dnd/drop-indicator.js +52 -63
  18. package/src/lib/components/dnd/drop-indicator.js.map +1 -1
  19. package/src/lib/components/dnd/drop-surface.d.ts +91 -0
  20. package/src/lib/components/dnd/drop-surface.js +172 -0
  21. package/src/lib/components/dnd/drop-surface.js.map +1 -0
  22. package/src/lib/components/dnd/drop-targeting.d.ts +94 -0
  23. package/src/lib/components/dnd/drop-targeting.js +184 -0
  24. package/src/lib/components/dnd/drop-targeting.js.map +1 -0
  25. package/src/lib/components/element-interactions-form.component.js +5 -9
  26. package/src/lib/components/element-interactions-form.component.js.map +1 -1
  27. package/src/lib/components/element-props-form.component.js +0 -4
  28. package/src/lib/components/element-props-form.component.js.map +1 -1
  29. package/src/lib/components/layout-part-menu.component.d.ts +65 -0
  30. package/src/lib/components/layout-part-menu.component.js +151 -0
  31. package/src/lib/components/layout-part-menu.component.js.map +1 -0
  32. package/src/lib/components/layout-style-picker.component.d.ts +2 -0
  33. package/src/lib/components/layout-style-picker.component.js +2 -2
  34. package/src/lib/components/layout-style-picker.component.js.map +1 -1
  35. package/src/lib/components/node-context-menu.js +8 -0
  36. package/src/lib/components/node-context-menu.js.map +1 -1
  37. package/src/lib/components/node-leaf.js +50 -19
  38. package/src/lib/components/node-leaf.js.map +1 -1
  39. package/src/lib/components/node-overlay.js +61 -21
  40. package/src/lib/components/node-overlay.js.map +1 -1
  41. package/src/lib/components/node-quick-actions.js +40 -23
  42. package/src/lib/components/node-quick-actions.js.map +1 -1
  43. package/src/lib/components/node-tree-view.d.ts +2 -0
  44. package/src/lib/components/node-tree-view.js +16 -4
  45. package/src/lib/components/node-tree-view.js.map +1 -1
  46. package/src/lib/components/viewport-canvas.component.js +3 -1
  47. package/src/lib/components/viewport-canvas.component.js.map +1 -1
  48. package/src/lib/components/viewport-frame.component.js +27 -1
  49. package/src/lib/components/viewport-frame.component.js.map +1 -1
  50. package/src/lib/components/workspace-editor.component.js +43 -22
  51. package/src/lib/components/workspace-editor.component.js.map +1 -1
  52. package/src/lib/contexts/layout-chrome-context.d.ts +10 -0
  53. package/src/lib/contexts/layout-chrome-context.js.map +1 -1
  54. package/src/lib/hooks/use-leaf-drop.d.ts +7 -1
  55. package/src/lib/hooks/use-leaf-drop.js +11 -5
  56. package/src/lib/hooks/use-leaf-drop.js.map +1 -1
  57. package/src/lib/hooks/use-preview-repeats.d.ts +22 -0
  58. package/src/lib/hooks/use-preview-repeats.js +91 -0
  59. package/src/lib/hooks/use-preview-repeats.js.map +1 -0
  60. package/src/lib/utils/repeat-copy.d.ts +36 -0
  61. package/src/lib/utils/repeat-copy.js +51 -0
  62. package/src/lib/utils/repeat-copy.js.map +1 -0
  63. package/src/lib/utils/touch-keyboard.d.ts +41 -0
  64. package/src/lib/utils/touch-keyboard.js +72 -0
  65. package/src/lib/utils/touch-keyboard.js.map +1 -0
@@ -16,43 +16,41 @@ import { jsx as _jsx } from "react/jsx-runtime";
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */ import * as Besigner from "@aglyn/besigner";
19
- import { useDndMonitor } from "@dnd-kit/core";
19
+ import { useDndContext } from "@dnd-kit/core";
20
20
  import { observer } from "mobx-react-lite";
21
- import { useState } from "react";
22
21
  import DropIndicator from "./drop-indicator.js";
23
- const DEFAULT = {
24
- region: Besigner.DropRegion.CHILDREN,
25
- rect: {
26
- left: 0,
27
- top: 0,
28
- height: 0,
29
- right: 0,
30
- bottom: 0,
31
- width: 0
32
- }
33
- };
34
- export const CanvasDropIndicator = observer(()=>{
35
- const [visible, setVisible] = useState(false);
36
- const [rect, setRect] = useState(()=>_extends({}, DEFAULT.rect));
37
- const [region, setRegion] = useState(DEFAULT.region);
38
- useDndMonitor({
39
- onDragStart: (event)=>setVisible(true),
40
- onDragEnd: (event)=>setVisible(false),
41
- onDragCancel: (event)=>setVisible(false),
42
- onDragOver (event) {
43
- var _event_over;
44
- setVisible(Boolean(event.over));
45
- if (event.over) setRect((_event_over = event.over) == null ? void 0 : _event_over.rect);
46
- },
47
- onDragMove: (event)=>{
48
- var _event_over;
49
- setRegion(((_event_over = event.over) == null ? void 0 : _event_over.data.current.region) || DEFAULT.region);
50
- }
51
- });
22
+ import { dropIndicatorBox } from "./drop-indicator-geometry.js";
23
+ import { DropSurface, visibleSurfaceRect } from "./drop-surface.js";
24
+ import { dropTargetRect, insideLandingTarget } from "./drop-targeting.js";
25
+ /**
26
+ * The drop marker for every besigner drag — canvas, hierarchy and breadcrumbs.
27
+ *
28
+ * It reads one source for each half of what it draws: the target from
29
+ * dnd-kit's live `over`, the region from the dnd store the workspace fills on
30
+ * every move. It used to keep its own copies, taking the rectangle only when
31
+ * the target changed and the region from a value the workspace wrote onto
32
+ * the target — which this component's listener, registered first, read
33
+ * before the workspace had written it. So the marker showed the region from
34
+ * one move ago, on a rectangle from whenever the target was entered.
35
+ */ export const CanvasDropIndicator = observer(()=>{
36
+ const { active, over } = useDndContext();
37
+ const region = Besigner.dnd.dropRegion;
38
+ const rect = active && over && region ? dropTargetRect(over) : null;
39
+ const data = over == null ? void 0 : over.data.current;
40
+ const clip = rect ? visibleSurfaceRect(data == null ? void 0 : data.surface, rect) : null;
41
+ const landing = rect && region === Besigner.DropRegion.CHILDREN && (data == null ? void 0 : data.surface) === DropSurface.CANVAS ? insideLandingTarget(data.node) : null;
42
+ const box = landing ? dropIndicatorBox(_extends({}, landing, {
43
+ clip
44
+ })) : rect ? dropIndicatorBox({
45
+ region,
46
+ rect,
47
+ inset: data == null ? void 0 : data.inset,
48
+ clip
49
+ }) : null;
50
+ const rejected = Boolean(box) && Besigner.dnd.describeDropRejection() != null;
52
51
  return /*#__PURE__*/ _jsx(DropIndicator, {
53
- rect: rect,
54
- visible: visible,
55
- region: region
52
+ box: box,
53
+ rejected: rejected
56
54
  });
57
55
  });
58
56
  CanvasDropIndicator.displayName = 'CanvasDropIndicator';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../libs/besigner/feature/designer/src/lib/components/dnd/canvas-drop-indicator.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 * as Besigner from '@aglyn/besigner'\nimport {\n type ClientRect,\n type DragCancelEvent,\n type DragEndEvent,\n type DragMoveEvent,\n DragOverEvent,\n type DragStartEvent,\n useDndMonitor,\n} from '@dnd-kit/core'\nimport { observer } from 'mobx-react-lite'\nimport { useState } from 'react'\nimport DropIndicator from './drop-indicator'\n\nconst DEFAULT: { region: Besigner.DropRegion; rect: ClientRect } = {\n region: Besigner.DropRegion.CHILDREN,\n rect: {\n left: 0,\n top: 0,\n height: 0,\n right: 0,\n bottom: 0,\n width: 0,\n },\n}\n\nexport const CanvasDropIndicator = observer(() => {\n const [visible, setVisible] = useState(false)\n const [rect, setRect] = useState<ClientRect>(() => ({ ...DEFAULT.rect }))\n const [region, setRegion] = useState<Besigner.DropRegion>(DEFAULT.region)\n\n useDndMonitor({\n onDragStart: (event: DragStartEvent) => setVisible(true),\n onDragEnd: (event: DragEndEvent) => setVisible(false),\n onDragCancel: (event: DragCancelEvent) => setVisible(false),\n onDragOver(event: DragOverEvent) {\n setVisible(Boolean(event.over))\n if (event.over) setRect(event.over?.rect)\n },\n onDragMove: (event: DragMoveEvent) => {\n setRegion(event.over?.data.current.region || DEFAULT.region)\n },\n })\n\n return <DropIndicator rect={rect} visible={visible} region={region} />\n})\nCanvasDropIndicator.displayName = 'CanvasDropIndicator'\n\nexport default CanvasDropIndicator\n"],"names":["Besigner","useDndMonitor","observer","useState","DropIndicator","DEFAULT","region","DropRegion","CHILDREN","rect","left","top","height","right","bottom","width","CanvasDropIndicator","visible","setVisible","setRect","setRegion","onDragStart","event","onDragEnd","onDragCancel","onDragOver","Boolean","over","onDragMove","data","current","displayName"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,cAAc,kBAAiB;AAC3C,SAOEC,aAAa,QACR,gBAAe;AACtB,SAASC,QAAQ,QAAQ,kBAAiB;AAC1C,SAASC,QAAQ,QAAQ,QAAO;AAChC,OAAOC,mBAAmB,sBAAkB;AAE5C,MAAMC,UAA6D;IACjEC,QAAQN,SAASO,UAAU,CAACC,QAAQ;IACpCC,MAAM;QACJC,MAAM;QACNC,KAAK;QACLC,QAAQ;QACRC,OAAO;QACPC,QAAQ;QACRC,OAAO;IACT;AACF;AAEA,OAAO,MAAMC,sBAAsBd,SAAS;IAC1C,MAAM,CAACe,SAASC,WAAW,GAAGf,SAAS;IACvC,MAAM,CAACM,MAAMU,QAAQ,GAAGhB,SAAqB,IAAO,aAAKE,QAAQI,IAAI;IACrE,MAAM,CAACH,QAAQc,UAAU,GAAGjB,SAA8BE,QAAQC,MAAM;IAExEL,cAAc;QACZoB,aAAa,CAACC,QAA0BJ,WAAW;QACnDK,WAAW,CAACD,QAAwBJ,WAAW;QAC/CM,cAAc,CAACF,QAA2BJ,WAAW;QACrDO,YAAWH,KAAoB;gBAELA;YADxBJ,WAAWQ,QAAQJ,MAAMK,IAAI;YAC7B,IAAIL,MAAMK,IAAI,EAAER,SAAQG,cAAAA,MAAMK,IAAI,qBAAVL,YAAYb,IAAI;QAC1C;QACAmB,YAAY,CAACN;gBACDA;YAAVF,UAAUE,EAAAA,cAAAA,MAAMK,IAAI,qBAAVL,YAAYO,IAAI,CAACC,OAAO,CAACxB,MAAM,KAAID,QAAQC,MAAM;QAC7D;IACF;IAEA,qBAAO,KAACF;QAAcK,MAAMA;QAAMQ,SAASA;QAASX,QAAQA;;AAC9D,GAAE;AACFU,oBAAoBe,WAAW,GAAG;AAElC,eAAef,oBAAmB"}
1
+ {"version":3,"sources":["../../../../../../../../../libs/besigner/feature/designer/src/lib/components/dnd/canvas-drop-indicator.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 * as Besigner from '@aglyn/besigner'\nimport { useDndContext } from '@dnd-kit/core'\nimport { observer } from 'mobx-react-lite'\nimport DropIndicator from './drop-indicator'\nimport { dropIndicatorBox } from './drop-indicator-geometry'\nimport { DropSurface, visibleSurfaceRect } from './drop-surface'\nimport {\n type DropTargetData,\n dropTargetRect,\n insideLandingTarget,\n} from './drop-targeting'\n\n/**\n * The drop marker for every besigner drag — canvas, hierarchy and breadcrumbs.\n *\n * It reads one source for each half of what it draws: the target from\n * dnd-kit's live `over`, the region from the dnd store the workspace fills on\n * every move. It used to keep its own copies, taking the rectangle only when\n * the target changed and the region from a value the workspace wrote onto\n * the target — which this component's listener, registered first, read\n * before the workspace had written it. So the marker showed the region from\n * one move ago, on a rectangle from whenever the target was entered.\n */\nexport const CanvasDropIndicator = observer(() => {\n const { active, over } = useDndContext()\n const region = Besigner.dnd.dropRegion\n const rect = active && over && region ? dropTargetRect(over) : null\n const data = over?.data.current as DropTargetData | undefined\n const clip = rect ? visibleSurfaceRect(data?.surface, rect) : null\n const landing =\n rect &&\n region === Besigner.DropRegion.CHILDREN &&\n data?.surface === DropSurface.CANVAS\n ? insideLandingTarget(data.node)\n : null\n const box = landing\n ? dropIndicatorBox({ ...landing, clip })\n : rect\n ? dropIndicatorBox({ region, rect, inset: data?.inset, clip })\n : null\n const rejected = Boolean(box) && Besigner.dnd.describeDropRejection() != null\n\n return <DropIndicator box={box} rejected={rejected} />\n})\nCanvasDropIndicator.displayName = 'CanvasDropIndicator'\n\nexport default CanvasDropIndicator\n"],"names":["Besigner","useDndContext","observer","DropIndicator","dropIndicatorBox","DropSurface","visibleSurfaceRect","dropTargetRect","insideLandingTarget","CanvasDropIndicator","active","over","region","dnd","dropRegion","rect","data","current","clip","surface","landing","DropRegion","CHILDREN","CANVAS","node","box","inset","rejected","Boolean","describeDropRejection","displayName"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,cAAc,kBAAiB;AAC3C,SAASC,aAAa,QAAQ,gBAAe;AAC7C,SAASC,QAAQ,QAAQ,kBAAiB;AAC1C,OAAOC,mBAAmB,sBAAkB;AAC5C,SAASC,gBAAgB,QAAQ,+BAA2B;AAC5D,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,oBAAgB;AAChE,SAEEC,cAAc,EACdC,mBAAmB,QACd,sBAAkB;AAEzB;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,sBAAsBP,SAAS;IAC1C,MAAM,EAAEQ,MAAM,EAAEC,IAAI,EAAE,GAAGV;IACzB,MAAMW,SAASZ,SAASa,GAAG,CAACC,UAAU;IACtC,MAAMC,OAAOL,UAAUC,QAAQC,SAASL,eAAeI,QAAQ;IAC/D,MAAMK,OAAOL,wBAAAA,KAAMK,IAAI,CAACC,OAAO;IAC/B,MAAMC,OAAOH,OAAOT,mBAAmBU,wBAAAA,KAAMG,OAAO,EAAEJ,QAAQ;IAC9D,MAAMK,UACJL,QACAH,WAAWZ,SAASqB,UAAU,CAACC,QAAQ,IACvCN,CAAAA,wBAAAA,KAAMG,OAAO,MAAKd,YAAYkB,MAAM,GAChCf,oBAAoBQ,KAAKQ,IAAI,IAC7B;IACN,MAAMC,MAAML,UACRhB,iBAAiB,aAAKgB;QAASF;UAC/BH,OACEX,iBAAiB;QAAEQ;QAAQG;QAAMW,KAAK,EAAEV,wBAAAA,KAAMU,KAAK;QAAER;IAAK,KAC1D;IACN,MAAMS,WAAWC,QAAQH,QAAQzB,SAASa,GAAG,CAACgB,qBAAqB,MAAM;IAEzE,qBAAO,KAAC1B;QAAcsB,KAAKA;QAAKE,UAAUA;;AAC5C,GAAE;AACFlB,oBAAoBqB,WAAW,GAAG;AAElC,eAAerB,oBAAmB"}
@@ -30,9 +30,18 @@ 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 { holdKeyboardForEdit } from "../../utils/touch-keyboard.js";
34
+ import { repeatOriginalAt } from "../../utils/repeat-copy.js";
35
+ import { DropSurface } from "./drop-surface.js";
36
+ /** The furthest a finger may slide and still be tapping, in px. */ const TAP_SLOP_PX = 10;
37
+ /** The longest a press may last and still be a tap, in ms; longer is a hold. */ const TAP_MAX_MS = 300;
38
+ /** How soon the second tap of a double-tap must follow the first, in ms. */ const DOUBLE_TAP_WITHIN_MS = 350;
39
+ /** How far from the first tap the second may land, in px. */ const DOUBLE_TAP_SLOP_PX = 24;
40
+ const distance = (a, b)=>Math.hypot(a.x - b.x, a.y - b.y);
33
41
  export const DraggableDroppable = observer((props)=>{
34
42
  const { node, type, disableDragging, disableDropping, accept, children, idSuffix } = props;
35
43
  const id = useId(node == null ? void 0 : node.$id);
44
+ const ref = useRef(null);
36
45
  const draggable = useDraggable({
37
46
  id: `${id}:${type}${idSuffix || ''}`,
38
47
  data: {
@@ -46,7 +55,11 @@ export const DraggableDroppable = observer((props)=>{
46
55
  data: {
47
56
  type,
48
57
  node,
49
- accept
58
+ accept,
59
+ surface: DropSurface.CANVAS,
60
+ // Measured live by the drop marker: dnd-kit's cached rect cannot
61
+ // follow the canvas scrolling from inside its shadow root.
62
+ getElement: ()=>ref.current
50
63
  },
51
64
  disabled: disableDropping
52
65
  });
@@ -81,7 +94,6 @@ export const DraggableDroppable = observer((props)=>{
81
94
  outlineWidth: 2,
82
95
  outlineOffset: 2
83
96
  } : {});
84
- const ref = useRef(null);
85
97
  // Instance-internals double-click (AGL-1304) needs the component
86
98
  // definitions (hit-test) and the host's media picker (image props).
87
99
  // Read through a ref so the listener effect below keeps its `[node]`
@@ -132,6 +144,9 @@ export const DraggableDroppable = observer((props)=>{
132
144
  * it began. Read by the touch drag below, and reset by it, because the
133
145
  * press that selects an element must not also pick it up.
134
146
  */ let selectedAtPress = false;
147
+ /** Where and when the finger on this element came down. */ let pressStart = null;
148
+ /** The last quick, still tap on this element, waiting for its pair. */ let lastTap = null;
149
+ /** When a double-tap opened an editor here, by event time. */ let editOpenedByTapAt = -Infinity;
135
150
  if (el) {
136
151
  el.addEventListener('mouseover', handleMouseOver);
137
152
  el.addEventListener('pointerover', handleMouseOver);
@@ -140,6 +155,7 @@ export const DraggableDroppable = observer((props)=>{
140
155
  el.addEventListener('dblclick', handleDoubleClick);
141
156
  el.addEventListener('contextmenu', handleContextMenu);
142
157
  el.addEventListener('touchstart', handleTouchStart);
158
+ el.addEventListener('touchend', handleTouchEnd);
143
159
  return ()=>{
144
160
  el.removeEventListener('mouseover', handleMouseOver);
145
161
  el.removeEventListener('pointerover', handleMouseOver);
@@ -148,6 +164,7 @@ export const DraggableDroppable = observer((props)=>{
148
164
  el.removeEventListener('dblclick', handleDoubleClick);
149
165
  el.removeEventListener('contextmenu', handleContextMenu);
150
166
  el.removeEventListener('touchstart', handleTouchStart);
167
+ el.removeEventListener('touchend', handleTouchEnd);
151
168
  };
152
169
  }
153
170
  /**
@@ -167,6 +184,12 @@ export const DraggableDroppable = observer((props)=>{
167
184
  * cannot claim the same touch.
168
185
  */ function handleTouchStart(e) {
169
186
  var _listenersRef_current_onTouchStart, _listenersRef_current;
187
+ const touch = e.touches.length === 1 ? e.touches[0] : undefined;
188
+ pressStart = touch ? {
189
+ x: touch.clientX,
190
+ y: touch.clientY,
191
+ at: e.timeStamp
192
+ } : null;
170
193
  const selected = selectedAtPress;
171
194
  selectedAtPress = false;
172
195
  if (!selected || isInlineEditWithin(el) || Besigner.pick.isPicking()) {
@@ -177,6 +200,61 @@ export const DraggableDroppable = observer((props)=>{
177
200
  });
178
201
  }
179
202
  /**
203
+ * Double-tap a text element to edit it in place on a touch screen.
204
+ *
205
+ * A mouse gets there by `dblclick`, and on a touch screen that event is
206
+ * the browser's to give. Chrome on Android turns two taps into one; on
207
+ * a phone the in-place editor, and the B / I / U toolbar that comes
208
+ * with it, did not open. So the two taps are counted here, by rules
209
+ * that are this canvas's own rather than each browser's, and the same
210
+ * open runs.
211
+ *
212
+ * Opening this way also puts the keyboard up (`holdKeyboardForEdit`),
213
+ * which iOS only allows while the tap is still being handled — and the
214
+ * `preventDefault` keeps Safari from zooming on the second tap, or
215
+ * sending the `dblclick` Chrome would have sent after it.
216
+ *
217
+ * Two taps make a double-tap when each is quick and still, and the
218
+ * second lands near the first soon after it. A hold is a drag, a slide
219
+ * is a scroll, and neither counts.
220
+ */ function handleTouchEnd(e) {
221
+ const start = pressStart;
222
+ pressStart = null;
223
+ const touch = e.changedTouches[0];
224
+ if (!start || !touch || e.touches.length > 0 || // Inside an open edit, a double-tap selects a word.
225
+ isInlineEditWithin(el) || Besigner.pick.isPicking()) {
226
+ lastTap = null;
227
+ return;
228
+ }
229
+ const tap = {
230
+ x: touch.clientX,
231
+ y: touch.clientY,
232
+ at: e.timeStamp
233
+ };
234
+ if (distance(tap, start) > TAP_SLOP_PX || tap.at - start.at > TAP_MAX_MS) {
235
+ lastTap = null;
236
+ return;
237
+ }
238
+ const first = lastTap;
239
+ lastTap = tap;
240
+ if (!first || tap.at - first.at > DOUBLE_TAP_WITHIN_MS || distance(tap, first) > DOUBLE_TAP_SLOP_PX) {
241
+ return;
242
+ }
243
+ lastTap = null;
244
+ if (!openEditAt({
245
+ clientX: tap.x,
246
+ clientY: tap.y
247
+ })) return;
248
+ e.preventDefault();
249
+ e.stopPropagation();
250
+ editOpenedByTapAt = e.timeStamp;
251
+ // A prop-fed image opens the media picker instead, which wants no
252
+ // keyboard.
253
+ if (inlineTextEdit.node || inlineMarkdownEdit.node) {
254
+ holdKeyboardForEdit(tap);
255
+ }
256
+ }
257
+ /**
180
258
  * Right-click opens this element's ⋮ menu (AGL-1405).
181
259
  *
182
260
  * A native listener like its neighbours, not an `onContextMenu` prop:
@@ -188,6 +266,7 @@ export const DraggableDroppable = observer((props)=>{
188
266
  * statement about THAT element, so leaving the previous selection in
189
267
  * place would open the wrong menu.
190
268
  */ function handleContextMenu(e) {
269
+ var _repeatOriginalAt;
191
270
  if (isInlineEditWithin(el)) {
192
271
  // An open text editor keeps the browser's own menu: cut, paste and
193
272
  // spellcheck are the whole point of a right-click there.
@@ -196,10 +275,13 @@ export const DraggableDroppable = observer((props)=>{
196
275
  }
197
276
  e.preventDefault();
198
277
  e.stopPropagation();
199
- Besigner.focus.setSelectedNode(node);
200
- requestCanvasContextMenu(node == null ? void 0 : node.$id);
278
+ // On a repeat copy, the menu is the element the copy draws.
279
+ const target = (_repeatOriginalAt = repeatOriginalAt(e.target)) != null ? _repeatOriginalAt : node;
280
+ Besigner.focus.setSelectedNode(target);
281
+ requestCanvasContextMenu(target == null ? void 0 : target.$id);
201
282
  }
202
283
  function handleMouseOver(e) {
284
+ var _repeatOriginalAt;
203
285
  // Same stand-down, same reason to consume it: a hover repaint while
204
286
  // the author is typing is a re-render of the subtree they are
205
287
  // editing, and an ancestor leaf would repaint for them instead.
@@ -209,7 +291,7 @@ export const DraggableDroppable = observer((props)=>{
209
291
  }
210
292
  e.preventDefault();
211
293
  e.stopPropagation();
212
- Besigner.focus.setHoveredNode(node);
294
+ Besigner.focus.setHoveredNode((_repeatOriginalAt = repeatOriginalAt(e.target)) != null ? _repeatOriginalAt : node);
213
295
  }
214
296
  function handleMouseDown(e) {
215
297
  // Stand down while an edit is open in this leaf OR ANY LEAF INSIDE
@@ -240,22 +322,29 @@ export const DraggableDroppable = observer((props)=>{
240
322
  }
241
323
  e.preventDefault();
242
324
  e.stopPropagation();
325
+ // A press on one of this element's repeat copies (Sam, Jordan) means
326
+ // the element that copy draws, not this one around it — see
327
+ // `repeatOriginalAt`.
328
+ const original = repeatOriginalAt(e.target);
329
+ const target = original != null ? original : node;
243
330
  // Element-picker capture (AGL-574): while the interaction builder is
244
331
  // picking, this click resolves the target and exits pick mode —
245
332
  // never the normal select/navigate, so the designer's selection and
246
333
  // the open interaction stay put.
247
334
  if (Besigner.pick.isPicking()) {
248
- Besigner.pick.handlePickClick(node.$id);
335
+ Besigner.pick.handlePickClick(target.$id);
249
336
  return;
250
337
  }
251
338
  // Canvas multi-selection modifiers (AGL-12), mirroring the
252
339
  // hierarchy panel: Shift ranges, Cmd/Ctrl toggles.
253
340
  const pointer = e;
254
341
  if (pointer.shiftKey) {
255
- Besigner.focus.rangeSelectNode(node);
342
+ Besigner.focus.rangeSelectNode(target);
256
343
  } else {
257
- Besigner.focus.handleNodeSelection(node, pointer.metaKey || pointer.ctrlKey);
258
- if (!pointer.metaKey && !pointer.ctrlKey) pickPartUnder(pointer);
344
+ Besigner.focus.handleNodeSelection(target, pointer.metaKey || pointer.ctrlKey);
345
+ if (!original && !pointer.metaKey && !pointer.ctrlKey) {
346
+ pickPartUnder(pointer);
347
+ }
259
348
  }
260
349
  }
261
350
  /**
@@ -278,7 +367,24 @@ export const DraggableDroppable = observer((props)=>{
278
367
  pickPlacementPart(node.$id, key != null ? key : '');
279
368
  }
280
369
  function handleDoubleClick(e) {
370
+ // The `dblclick` a browser may still send for two taps that already
371
+ // opened an editor (see handleTouchEnd): consumed, not run twice.
372
+ if (e.timeStamp - editOpenedByTapAt < DOUBLE_TAP_WITHIN_MS * 2) {
373
+ e.preventDefault();
374
+ e.stopPropagation();
375
+ return;
376
+ }
377
+ if (!openEditAt(e)) return;
378
+ e.preventDefault();
379
+ e.stopPropagation();
380
+ }
381
+ /**
382
+ * Opens this element's in-place editor for a double-click or a
383
+ * double-tap at `point`, and says whether one opened — which is also
384
+ * whether the gesture is spent here or goes on to an ancestor.
385
+ */ function openEditAt(point) {
281
386
  var _node_componentSchema_flags, _node_componentSchema, _node_props;
387
+ if (!el) return false;
282
388
  // Prop-fed instance internals (AGL-1304): the rendered preview sits
283
389
  // under `pointer-events: none`, so the double-click lands HERE, on
284
390
  // the instance — hit-test the preview geometrically, map the grafted
@@ -287,24 +393,20 @@ export const DraggableDroppable = observer((props)=>{
287
393
  // selection this dblclick's mousedowns already made puts AGL-1303's
288
394
  // "Edit component" in the panel — nothing extra to build).
289
395
  if ((node == null ? void 0 : node.componentId) === REUSABLE_INSTANCE_COMPONENT_ID && Besigner.dnd.canDragNode(node)) {
290
- if (handleInstanceDoubleClick(e)) {
291
- e.preventDefault();
292
- e.stopPropagation();
293
- }
294
- return;
396
+ return handleInstanceDoubleClick(point);
295
397
  }
296
398
  // Locked nodes (layout chrome in the screen besigner) stay read-only —
297
399
  // same gate the drag system uses — and while the interaction builder
298
400
  // is picking a target, a double-click is two picks, never an edit.
299
- if (!Besigner.dnd.canDragNode(node) || Besigner.pick.isPicking()) return;
401
+ if (!Besigner.dnd.canDragNode(node) || Besigner.pick.isPicking()) {
402
+ return false;
403
+ }
300
404
  // Inline text editing for components that declare textEditable.
301
405
  const flag = node == null ? void 0 : (_node_componentSchema = node.componentSchema) == null ? void 0 : (_node_componentSchema_flags = _node_componentSchema.flags) == null ? void 0 : _node_componentSchema_flags.textEditable;
302
406
  const editable = typeof flag === 'number' && (flag & FEATURE_FLAG.ENABLED) !== 0;
303
407
  if (editable) {
304
408
  var _findLeafTextElement;
305
- e.preventDefault();
306
- e.stopPropagation();
307
- const root = e.currentTarget;
409
+ const root = el;
308
410
  // The node's own `<aglyn-text>` whenever it renders one, and the
309
411
  // root only as a fallback (AGL-2556). In-place editing EMPTIES
310
412
  // whatever it is given, so handing it a composite's root deletes
@@ -322,7 +424,7 @@ export const DraggableDroppable = observer((props)=>{
322
424
  }, undefined, // The measured element travels with the rect so the overlay can
323
425
  // re-measure on scroll instead of drifting (AGL-1644).
324
426
  element);
325
- return;
427
+ return true;
326
428
  }
327
429
  // In-place markdown editing (AGL-1624): a component whose schema
328
430
  // declares a MARKDOWN attribute — the Markdown element's `content` is
@@ -335,10 +437,8 @@ export const DraggableDroppable = observer((props)=>{
335
437
  // double-click-to-zoom. That is the same guarantee the textEditable
336
438
  // branch above has always relied on, not a new mechanism.
337
439
  const markdownAttribute = findMarkdownAttributeName(node);
338
- if (!markdownAttribute) return;
339
- e.preventDefault();
340
- e.stopPropagation();
341
- const markdownElement = e.currentTarget;
440
+ if (!markdownAttribute) return false;
441
+ const markdownElement = el;
342
442
  const markdownRect = markdownElement.getBoundingClientRect();
343
443
  const stored = (_node_props = node.props) == null ? void 0 : _node_props[markdownAttribute];
344
444
  // The two mousedowns of a double-click TOGGLE selection, so by the time
@@ -353,6 +453,7 @@ export const DraggableDroppable = observer((props)=>{
353
453
  width: markdownRect.width,
354
454
  height: markdownRect.height
355
455
  }, markdownAttribute, typeof stored === 'string' ? stored : '', markdownElement);
456
+ return true;
356
457
  }
357
458
  /** True when the double-click resolved to a prop edit it opened. */ function handleInstanceDoubleClick(pointer) {
358
459
  var _node_props;
@@ -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 FEATURE_FLAG,\n getInstanceEffectivePropText,\n inheritedMediaAlt,\n isDefinitionPlacement,\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 useContext,\n useEffect,\n useRef,\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'\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\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: { type, node, accept },\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 const ref = useRef<HTMLElement>(null)\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 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\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 }\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 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 * 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 Besigner.focus.setSelectedNode(node)\n requestCanvasContextMenu(node?.$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 Besigner.focus.setHoveredNode(node)\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 // 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(node.$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(node)\n } else {\n Besigner.focus.handleNodeSelection(\n node,\n pointer.metaKey || pointer.ctrlKey,\n )\n if (!pointer.metaKey && !pointer.ctrlKey) pickPartUnder(pointer)\n }\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 // 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 if (handleInstanceDoubleClick(e as globalThis.MouseEvent)) {\n e.preventDefault()\n e.stopPropagation()\n }\n return\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()) return\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 e.preventDefault()\n e.stopPropagation()\n const root = e.currentTarget as Element\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\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\n e.preventDefault()\n e.stopPropagation()\n const markdownElement = e.currentTarget as Element\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 }\n /** True when the double-click resolved to a prop edit it opened. */\n function handleInstanceDoubleClick(pointer: globalThis.MouseEvent) {\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 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: text.boundProp,\n initialText: getInstanceEffectivePropText(\n node.props,\n definition.props,\n text.boundProp,\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])\n\n return cloneElement(\n child,\n mergeProps(child.props, draggable.attributes, {\n ref: mergeRefs(\n ref,\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","FEATURE_FLAG","getInstanceEffectivePropText","inheritedMediaAlt","isDefinitionPlacement","placementDefinitionFor","resolveInstanceLeafBinding","REUSABLE_INSTANCE_COMPONENT_ID","REUSABLE_INSTANCE_PROP_VALUES_KEY","Besigner","mergeRefs","useId","useDraggable","useDroppable","CSS","css","mergeProps","observer","Children","cloneElement","useContext","useEffect","useRef","ComponentPromotionContext","MediaPickerContext","findMarkdownAttributeName","inlineMarkdownEdit","inlineTextEdit","isInlineEditWithin","requestCanvasContextMenu","findInstanceLeafAtPoint","findPlacementPartAtPoint","pickPlacementPart","findLeafTextElement","DraggableDroppable","props","node","type","disableDragging","disableDropping","accept","children","idSuffix","id","$id","draggable","data","disabled","droppable","transform","isTransforming","Boolean","child","only","style","outlineWidth","outlineOffset","outlineColor","outlineStyle","translate","Translate","toString","isOver","isDragging","opacity","cursor","pick","isPicking","focus","isNodeHovered","ref","definitions","formDesigns","onPickMedia","instanceEditRef","current","listenersRef","listeners","refs","set","delete","handles","el","selectedAtPress","addEventListener","handleMouseOver","handleMouseDown","handleDoubleClick","handleContextMenu","handleTouchStart","removeEventListener","e","selected","onTouchStart","nativeEvent","stopPropagation","preventDefault","setSelectedNode","setHoveredNode","isNodeSelected","handlePickClick","pointer","shiftKey","rangeSelectNode","handleNodeSelection","metaKey","ctrlKey","pickPartUnder","container","clientX","definition","key","clientY","graftedId","rootId","componentId","dnd","canDragNode","handleInstanceDoubleClick","flag","componentSchema","flags","textEditable","editable","ENABLED","root","currentTarget","element","rect","getBoundingClientRect","open","left","top","width","height","undefined","markdownAttribute","markdownElement","markdownRect","stored","refId","hit","text","boundProp","propName","initialText","src","altBinding","value","asset","toJSON","nodes","altPropName","effectiveAlt","inheritedAlt","placementAlt","assetAlt","alt","updateNodeProps","attributes","setNodeRef","sx","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SACEA,MAAM,EACNC,YAAY,EACZC,4BAA4B,EAC5BC,iBAAiB,EACjBC,qBAAqB,EACrBC,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,UAAU,EACVC,SAAS,EACTC,MAAM,QACD,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,EACvBC,wBAAwB,QACnB,mCAA+B;AACtC,SAASC,iBAAiB,Q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UkB,UAAU,GAAG,SAAS;YAC1C;QACF;IACF;AAEJ,GACD;AAED7B,mBAAmBgI,WAAW,GAAG;AAEjC,eAAehI,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 FEATURE_FLAG,\n getInstanceEffectivePropText,\n inheritedMediaAlt,\n isDefinitionPlacement,\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 useContext,\n useEffect,\n useRef,\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 { repeatOriginalAt } 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 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.\n const target = repeatOriginalAt(e.target) ?? node\n Besigner.focus.setSelectedNode(target)\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 Besigner.focus.setHoveredNode(repeatOriginalAt(e.target) ?? node)\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 // `repeatOriginalAt`.\n const original = repeatOriginalAt(e.target)\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 }\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 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 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: text.boundProp,\n initialText: getInstanceEffectivePropText(\n node.props,\n definition.props,\n text.boundProp,\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])\n\n return cloneElement(\n child,\n mergeProps(child.props, draggable.attributes, {\n ref: mergeRefs(\n ref,\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","FEATURE_FLAG","getInstanceEffectivePropText","inheritedMediaAlt","isDefinitionPlacement","placementDefinitionFor","resolveInstanceLeafBinding","REUSABLE_INSTANCE_COMPONENT_ID","REUSABLE_INSTANCE_PROP_VALUES_KEY","Besigner","mergeRefs","useId","useDraggable","useDroppable","CSS","css","mergeProps","observer","Children","cloneElement","useContext","useEffect","useRef","ComponentPromotionContext","MediaPickerContext","findMarkdownAttributeName","inlineMarkdownEdit","inlineTextEdit","isInlineEditWithin","requestCanvasContextMenu","findInstanceLeafAtPoint","findPlacementPartAtPoint","pickPlacementPart","findLeafTextElement","holdKeyboardForEdit","repeatOriginalAt","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","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","target","setSelectedNode","setHoveredNode","isNodeSelected","original","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","element","rect","getBoundingClientRect","open","left","top","width","height","markdownAttribute","markdownElement","markdownRect","stored","refId","hit","text","boundProp","propName","initialText","src","altBinding","value","asset","toJSON","nodes","altPropName","effectiveAlt","inheritedAlt","placementAlt","assetAlt","alt","updateNodeProps","attributes","setNodeRef","sx","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SACEA,MAAM,EACNC,YAAY,EACZC,4BAA4B,EAC5BC,iBAAiB,EACjBC,qBAAqB,EACrBC,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,UAAU,EACVC,SAAS,EACTC,MAAM,QACD,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,EACvBC,wBAAwB,QACnB,mCAA+B;AACtC,SAASC,iBAAiB,QAAQ,qCAAiC;AACnE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