@widgetic/canvas 0.5.34 → 0.5.36

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 (212) hide show
  1. package/README.md +105 -36
  2. package/dist/canvas/DomCanvas.svelte +454 -0
  3. package/dist/canvas/DomCanvas.svelte.d.ts +222 -0
  4. package/dist/canvas/autosaveScheduler.d.ts +58 -0
  5. package/dist/canvas/autosaveScheduler.js +157 -0
  6. package/dist/canvas/boardFrame.d.ts +13 -0
  7. package/dist/canvas/boardFrame.js +13 -0
  8. package/dist/canvas/boardSurface.d.ts +9 -0
  9. package/dist/canvas/boardSurface.js +9 -0
  10. package/dist/canvas/chromeLayout.d.ts +76 -0
  11. package/dist/canvas/chromeLayout.js +121 -0
  12. package/dist/canvas/emptyBoardHint.d.ts +17 -0
  13. package/dist/canvas/emptyBoardHint.js +12 -0
  14. package/dist/canvas/eventScope.d.ts +1 -1
  15. package/dist/canvas/eventScope.js +1 -1
  16. package/dist/canvas/host/CanvasHost.d.ts +351 -0
  17. package/dist/canvas/host/CanvasHost.js +1740 -0
  18. package/dist/canvas/host/CanvasHostApi.d.ts +30 -0
  19. package/dist/canvas/host/CanvasHostApi.js +95 -0
  20. package/dist/canvas/host/browserServices.d.ts +46 -0
  21. package/dist/canvas/host/browserServices.js +167 -0
  22. package/dist/canvas/host/conversion.d.ts +51 -0
  23. package/dist/canvas/host/conversion.js +123 -0
  24. package/dist/canvas/host/hostObject.d.ts +40 -0
  25. package/dist/canvas/host/hostObject.js +93 -0
  26. package/dist/canvas/host/pageEvents.d.ts +24 -0
  27. package/dist/canvas/host/pageEvents.js +35 -0
  28. package/dist/canvas/host/screenRects.d.ts +66 -0
  29. package/dist/canvas/host/screenRects.js +102 -0
  30. package/dist/canvas/host/strokeSnap.d.ts +67 -0
  31. package/dist/canvas/host/strokeSnap.js +165 -0
  32. package/dist/canvas/index.d.ts +9 -7
  33. package/dist/canvas/index.js +9 -7
  34. package/dist/canvas/openMarks.d.ts +17 -0
  35. package/dist/canvas/openMarks.js +26 -0
  36. package/dist/canvas/panZoomPosition.d.ts +15 -0
  37. package/dist/canvas/panZoomPosition.js +16 -0
  38. package/dist/canvas/preferredTextFont.d.ts +12 -0
  39. package/dist/canvas/preferredTextFont.js +38 -0
  40. package/dist/canvas/shapes/ShapeLibrary.d.ts +1 -1
  41. package/dist/canvas/shapes/ShapeLibrary.js +13 -1
  42. package/dist/canvas/shapes/strokeShapeSnap.d.ts +14 -12
  43. package/dist/canvas/shapes/strokeShapeSnap.js +10 -8
  44. package/dist/canvas/toolbarPosition.d.ts +24 -0
  45. package/dist/canvas/toolbarPosition.js +24 -0
  46. package/dist/canvas/types.d.ts +14 -0
  47. package/dist/canvas/ui/CanvasContextMenu.svelte +173 -0
  48. package/dist/canvas/ui/CanvasContextMenu.svelte.d.ts +12 -0
  49. package/dist/canvas/ui/CanvasHint.svelte +20 -0
  50. package/dist/canvas/ui/CanvasHint.svelte.d.ts +18 -0
  51. package/dist/canvas/ui/CanvasToolbar.svelte +95 -0
  52. package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +14 -0
  53. package/dist/canvas/ui/ColorField.svelte +155 -0
  54. package/dist/canvas/ui/ColorField.svelte.d.ts +14 -0
  55. package/dist/canvas/ui/LoadNotice.svelte +39 -0
  56. package/dist/canvas/ui/LoadNotice.svelte.d.ts +8 -0
  57. package/dist/canvas/ui/SelectionPanel.svelte +300 -0
  58. package/dist/canvas/ui/SelectionPanel.svelte.d.ts +20 -0
  59. package/dist/canvas/ui/SelectorBar.svelte +82 -0
  60. package/dist/canvas/ui/SelectorBar.svelte.d.ts +12 -0
  61. package/dist/canvas/ui/ShapesMenu.svelte +185 -0
  62. package/dist/canvas/ui/ShapesMenu.svelte.d.ts +15 -0
  63. package/dist/canvas/ui/ShortcutsPanel.svelte +124 -0
  64. package/dist/canvas/ui/ShortcutsPanel.svelte.d.ts +7 -0
  65. package/dist/canvas/ui/ToolButton.svelte +78 -0
  66. package/dist/canvas/ui/ToolButton.svelte.d.ts +20 -0
  67. package/dist/canvas/ui/WidgetActions.svelte +152 -0
  68. package/dist/canvas/ui/WidgetActions.svelte.d.ts +19 -0
  69. package/dist/canvas/ui/ZoomControl.svelte +89 -0
  70. package/dist/canvas/ui/ZoomControl.svelte.d.ts +18 -0
  71. package/dist/canvas/ui/colorModel.d.ts +18 -0
  72. package/dist/canvas/ui/colorModel.js +85 -0
  73. package/dist/canvas/ui/colorPickerMessages.d.ts +5 -0
  74. package/dist/canvas/ui/colorPickerMessages.js +15 -0
  75. package/dist/canvas/ui/floatingCard.d.ts +107 -0
  76. package/dist/canvas/ui/floatingCard.js +107 -0
  77. package/dist/canvas/ui/floatingLayer.d.ts +21 -0
  78. package/dist/canvas/ui/floatingLayer.js +52 -0
  79. package/dist/canvas/ui/icons.d.ts +12 -0
  80. package/dist/canvas/ui/icons.js +7 -0
  81. package/dist/canvas/ui/keyHints.d.ts +27 -0
  82. package/dist/canvas/ui/keyHints.js +43 -0
  83. package/dist/canvas/ui/popoverSide.d.ts +5 -0
  84. package/dist/canvas/ui/popoverSide.js +20 -0
  85. package/dist/canvas/ui/selectionTraits.d.ts +61 -0
  86. package/dist/canvas/ui/selectionTraits.js +99 -0
  87. package/dist/canvas/view/CanvasStage.svelte +132 -0
  88. package/dist/canvas/view/CanvasStage.svelte.d.ts +21 -0
  89. package/dist/canvas/view/EraserTrail.svelte +50 -0
  90. package/dist/canvas/view/EraserTrail.svelte.d.ts +9 -0
  91. package/dist/canvas/view/ObjectView.svelte +245 -0
  92. package/dist/canvas/view/ObjectView.svelte.d.ts +21 -0
  93. package/dist/canvas/view/SelectionOverlay.svelte +487 -0
  94. package/dist/canvas/view/SelectionOverlay.svelte.d.ts +17 -0
  95. package/dist/canvas/view/TextEditor.svelte +76 -0
  96. package/dist/canvas/view/TextEditor.svelte.d.ts +9 -0
  97. package/dist/canvas/view/WidgetChromeLayer.svelte +83 -0
  98. package/dist/canvas/view/WidgetChromeLayer.svelte.d.ts +13 -0
  99. package/dist/canvas/view/erasingMarks.d.ts +13 -0
  100. package/dist/canvas/view/erasingMarks.js +34 -0
  101. package/dist/canvas/view/geometry.d.ts +169 -0
  102. package/dist/canvas/view/geometry.js +272 -0
  103. package/dist/components/CanvasBoardPlaceholder.svelte +5 -3
  104. package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +3 -3
  105. package/dist/components/index.js +1 -1
  106. package/dist/components/input-controls/ColorIC.svelte +2 -2
  107. package/dist/engine/EngineCore.d.ts +273 -0
  108. package/dist/engine/EngineCore.js +1051 -0
  109. package/dist/engine/codec/canvasDocument.d.ts +57 -0
  110. package/dist/engine/codec/canvasDocument.js +471 -0
  111. package/dist/engine/codec/hostReadableKeys.d.ts +25 -0
  112. package/dist/engine/codec/hostReadableKeys.js +25 -0
  113. package/dist/engine/core/arrange.d.ts +20 -0
  114. package/dist/engine/core/arrange.js +81 -0
  115. package/dist/engine/core/arrow.d.ts +91 -0
  116. package/dist/engine/core/arrow.js +182 -0
  117. package/dist/engine/core/brush.d.ts +68 -0
  118. package/dist/engine/core/brush.js +173 -0
  119. package/dist/engine/core/defaults.d.ts +70 -0
  120. package/dist/engine/core/defaults.js +158 -0
  121. package/dist/engine/core/freehand.d.ts +130 -0
  122. package/dist/engine/core/freehand.js +430 -0
  123. package/dist/engine/core/geometry.d.ts +44 -0
  124. package/dist/engine/core/geometry.js +216 -0
  125. package/dist/engine/core/history.d.ts +39 -0
  126. package/dist/engine/core/history.js +69 -0
  127. package/dist/engine/core/hitTest.d.ts +54 -0
  128. package/dist/engine/core/hitTest.js +298 -0
  129. package/dist/engine/core/matrix.d.ts +47 -0
  130. package/dist/engine/core/matrix.js +101 -0
  131. package/dist/engine/core/pathData.d.ts +50 -0
  132. package/dist/engine/core/pathData.js +550 -0
  133. package/dist/engine/core/rotationReset.d.ts +10 -0
  134. package/dist/engine/core/rotationReset.js +17 -0
  135. package/dist/engine/core/scene.d.ts +99 -0
  136. package/dist/engine/core/scene.js +450 -0
  137. package/dist/engine/core/scribble.d.ts +64 -0
  138. package/dist/engine/core/scribble.js +121 -0
  139. package/dist/engine/core/shapePaths.d.ts +34 -0
  140. package/dist/engine/core/shapePaths.js +69 -0
  141. package/dist/engine/core/shapeTools.d.ts +80 -0
  142. package/dist/engine/core/shapeTools.js +161 -0
  143. package/dist/engine/core/snapping.d.ts +64 -0
  144. package/dist/engine/core/snapping.js +164 -0
  145. package/dist/engine/core/style.d.ts +40 -0
  146. package/dist/engine/core/style.js +151 -0
  147. package/dist/engine/core/transform.d.ts +79 -0
  148. package/dist/engine/core/transform.js +258 -0
  149. package/dist/engine/core/types.d.ts +238 -0
  150. package/dist/engine/core/types.js +31 -0
  151. package/dist/engine/core/viewport.d.ts +32 -0
  152. package/dist/engine/core/viewport.js +84 -0
  153. package/dist/engine/input/PointerController.d.ts +38 -0
  154. package/dist/engine/input/PointerController.js +545 -0
  155. package/dist/engine/input/arrowHandles.d.ts +38 -0
  156. package/dist/engine/input/arrowHandles.js +60 -0
  157. package/dist/engine/input/gestures.d.ts +79 -0
  158. package/dist/engine/input/gestures.js +769 -0
  159. package/dist/engine/input/hoverCursor.d.ts +29 -0
  160. package/dist/engine/input/hoverCursor.js +23 -0
  161. package/dist/engine/input/keyboard.d.ts +75 -0
  162. package/dist/engine/input/keyboard.js +264 -0
  163. package/dist/engine/input/selectionHandles.d.ts +89 -0
  164. package/dist/engine/input/selectionHandles.js +169 -0
  165. package/dist/engine/input/types.d.ts +82 -0
  166. package/dist/engine/input/types.js +5 -0
  167. package/dist/engine/render/rasterize.d.ts +74 -0
  168. package/dist/engine/render/rasterize.js +273 -0
  169. package/dist/engine/state.d.ts +124 -0
  170. package/dist/engine/state.js +47 -0
  171. package/dist/engine/text/layoutText.d.ts +53 -0
  172. package/dist/engine/text/layoutText.js +170 -0
  173. package/dist/engine/widgets.d.ts +124 -0
  174. package/dist/engine/widgets.js +345 -0
  175. package/dist/i18n/labels.d.ts +4 -15
  176. package/dist/i18n/labels.js +33 -53
  177. package/dist/i18n/language.d.ts +3 -3
  178. package/dist/i18n/messages.d.ts +51 -122
  179. package/dist/i18n/messages.js +58 -131
  180. package/dist/i18n/shortcuts.d.ts +0 -1
  181. package/dist/i18n/shortcuts.js +2 -11
  182. package/dist/index.d.ts +6 -2
  183. package/dist/index.js +6 -2
  184. package/package.json +30 -5
  185. package/dist/canvas/Canvas.svelte +0 -13299
  186. package/dist/canvas/Canvas.svelte.d.ts +0 -281
  187. package/dist/canvas/CanvasToolbar.svelte +0 -1498
  188. package/dist/canvas/CanvasToolbar.svelte.d.ts +0 -69
  189. package/dist/canvas/ContextMenu.svelte +0 -305
  190. package/dist/canvas/ContextMenu.svelte.d.ts +0 -42
  191. package/dist/canvas/PanZoomPanel.svelte +0 -478
  192. package/dist/canvas/PanZoomPanel.svelte.d.ts +0 -38
  193. package/dist/canvas/WidgetSelectionLayer.svelte +0 -156
  194. package/dist/canvas/WidgetSelectionLayer.svelte.d.ts +0 -11
  195. package/dist/canvas/props-panel/PropsPanel.svelte +0 -2075
  196. package/dist/canvas/props-panel/PropsPanel.svelte.d.ts +0 -84
  197. package/dist/canvas/props-panel/TextPropsICSection.svelte +0 -242
  198. package/dist/canvas/props-panel/TextPropsICSection.svelte.d.ts +0 -40
  199. package/dist/canvas/shadowRootText.d.ts +0 -5
  200. package/dist/canvas/shadowRootText.js +0 -43
  201. package/dist/canvas/shapes/FrameShape.d.ts +0 -97
  202. package/dist/canvas/shapes/FrameShape.js +0 -953
  203. package/dist/canvas/shapes/ImageShape.d.ts +0 -47
  204. package/dist/canvas/shapes/ImageShape.js +0 -339
  205. package/dist/canvas/shapes/WidgetShape.d.ts +0 -30
  206. package/dist/canvas/shapes/WidgetShape.js +0 -200
  207. package/dist/canvas/widgetPreviewGeometry.d.ts +0 -19
  208. package/dist/canvas/widgetPreviewGeometry.js +0 -66
  209. package/dist/i18n/shapeWords.d.ts +0 -30
  210. package/dist/i18n/shapeWords.js +0 -36
  211. package/dist/i18n/slots.d.ts +0 -20
  212. package/dist/i18n/slots.js +0 -40
@@ -0,0 +1,487 @@
1
+ <!--
2
+ What the board draws on top of the objects, in screen pixels: the frame around the selection with its handles, its size
3
+ and the dot that turns it, the outline of what is under the pointer, the rectangle of a marquee (with the same outline on
4
+ every unit it would take if it were let go), the alignment guides, the dashed box of a text being dragged out, the figure
5
+ in the middle of a selection that is stretched or turned, and the arrow of a text's corner while it is dragged.
6
+
7
+ Figma "Selection Box": a 1.5 px ring outline, 8 px handles (background fill, 1.5 px ring border, 2 px corners) and a size
8
+ label of inverse colours under the frame. It is drawn in the board's pixels rather than inside the world layer, so a line
9
+ and a handle are the same size at every zoom. The engine finds the handles itself (selectionHandles.ts), so on the board
10
+ nothing here takes the pointer.
11
+
12
+ The frame follows what is done with the selection, the way the Memoreco canvas does: while it is carried the handles step
13
+ aside; while it is stretched the outline is dashed, the turning dot is gone and its size is the figure in the middle;
14
+ while it is turned the dot stays, grown, and the angle is the figure. The dot is 8 px at rest, 24 px under the pointer.
15
+
16
+ One selected arrow has no frame at all (the way tldraw shows one): its own thin outline, a round handle on each end and one in
17
+ the middle that bends it. No corners, no turning dot, no size: an arrow is a line from here to there, and it points where its
18
+ ends are. A handle grows under the pointer and while it is dragged.
19
+
20
+ It is mounted twice when the page lays live widgets over the board. The board's copy draws everything but the frame of a
21
+ selected widget card; the copy in the page's own layer (`layer="above-widgets"`) draws only that frame, above the live
22
+ widget, and its handles pass the press on to the host, because the layer is not inside the board.
23
+ -->
24
+ <script lang="ts">
25
+ import { isArrow } from '../../engine/core/arrow.js';
26
+ import type { ArrowHandleId, ArrowObject } from '../../engine/core/arrow.js';
27
+ import type { ObjectId, Point } from '../../engine/core/types.js';
28
+ import { handleDirection } from '../../engine/core/transform.js';
29
+ import type { ResizeHandle } from '../../engine/core/transform.js';
30
+ import { arrowHandlePositions, bendHandleAvailable, singleArrowOf } from '../../engine/input/arrowHandles.js';
31
+ import { ROTATION_DOT_OFFSET, availableHandles, cursorForHandle } from '../../engine/input/selectionHandles.js';
32
+ import type { EngineState } from '../../engine/state.js';
33
+ import { worldToScreen } from '../../engine/core/viewport.js';
34
+ import type { CanvasHost } from '../host/CanvasHost.js';
35
+ import {
36
+ arrowOutlinePlacement,
37
+ cssCursor,
38
+ formatReadout,
39
+ layerBoxStyle,
40
+ layerCenteredStyle,
41
+ layerPointStyle,
42
+ marqueeOutlinesOf,
43
+ outlineOfUnit,
44
+ outlinePathsOf,
45
+ pointBelowFrame,
46
+ restingSizeLabelPoint,
47
+ screenFrameOf,
48
+ screenFrameStyle
49
+ } from './geometry.js';
50
+
51
+ interface Props {
52
+ state: EngineState;
53
+ host: CanvasHost;
54
+ /** What the host is doing with the pointer now ("move", "resize", "rotate", …), or null. */
55
+ gestureKind: string | null;
56
+ /** Whether the page's advanced tools are on (a widget card's chrome, and the primary widget's ring, depend on it). */
57
+ advancedFeatures?: boolean;
58
+ /** 'board': everything. 'above-widgets': only the frame of the selected widget card, with handles that take the pointer. */
59
+ layer?: 'board' | 'above-widgets';
60
+ /** True when the frame of the selected widget card is drawn in the layer above the live widgets instead. */
61
+ frameElsewhere?: boolean;
62
+ }
63
+
64
+ let { state, host, gestureKind, advancedFeatures = false, layer = 'board', frameElsewhere = false }: Props = $props();
65
+
66
+ // The square around the dot that takes a press in the layer above the live widgets (the engine's own reach is a little more).
67
+ const DOT_TARGET_SIZE = 36;
68
+ // The double arrow drawn on a text's corner while it is dragged.
69
+ const VIRTUAL_CURSOR_SIZE = 24;
70
+ const VIRTUAL_CURSOR_PATH = 'M2 12 L7 7 V10 H17 V7 L22 12 L17 17 V14 H7 V17 Z';
71
+ // The red of the primary widget's stroke, as the saved boards always drew it.
72
+ const PRIMARY_RING_COLOR = '#DC2626';
73
+ // How much wider than the line itself the pale band round an arrow under the pointer is, in pixels (three on each side).
74
+ const ARROW_HOVER_BAND = 6;
75
+ // The units a marquee takes when it takes none.
76
+ const NO_UNITS: readonly ObjectId[] = Object.freeze([]);
77
+
78
+ const onBoard = $derived(layer === 'board');
79
+
80
+ // The frame is only shown while the person can use it: the Select tool, nothing being typed.
81
+ const frameVisible = $derived(
82
+ (layer === 'above-widgets' || !frameElsewhere) &&
83
+ state.selectedIds.length > 0 &&
84
+ state.editingTextId === null &&
85
+ (state.tool === 'select' || state.tool === 'pan') &&
86
+ gestureKind !== 'marquee' &&
87
+ gestureKind !== 'draw' &&
88
+ gestureKind !== 'erase'
89
+ );
90
+
91
+ // One selected arrow has handles of its own instead of a frame: its outline, and where its start, end and middle are on the screen.
92
+ const arrowSelection = $derived.by(() => {
93
+ if (!onBoard || !frameVisible) return null;
94
+ // The scene and the selection are what the handles are made from: read them so they follow both.
95
+ void state.scene;
96
+ void state.selectedIds;
97
+ const arrow = singleArrowOf(host.engine.selectedShapes(), state.selectedIds);
98
+ if (!arrow) return null;
99
+ const positions = arrowHandlePositions(arrow, state.viewport);
100
+ const handles: { id: ArrowHandleId; point: Point }[] = [
101
+ { id: 'start', point: positions.start },
102
+ { id: 'end', point: positions.end }
103
+ ];
104
+ if (bendHandleAvailable(positions)) handles.push({ id: 'bend', point: positions.bend });
105
+ return { arrow, handles };
106
+ });
107
+
108
+ const frame = $derived.by(() => {
109
+ if (!frameVisible || arrowSelection) return null;
110
+ // The scene and the selection are what the frame is made from: read them so it follows both.
111
+ void state.scene;
112
+ void state.selectedIds;
113
+ const worldFrame = host.engine.selectionFrame();
114
+ return worldFrame ? { world: worldFrame, screen: screenFrameOf(worldFrame, state.viewport) } : null;
115
+ });
116
+
117
+ // What the selection offers (the frame is made from the same scene and selection, so this follows them too).
118
+ const availability = $derived(frame ? availableHandles(host.engine.selectedShapes(), frame.world, state.viewport, !advancedFeatures) : null);
119
+
120
+ // What is being done with the selection since the press became a drag, and what the frame shows for it.
121
+ const dragging = $derived(state.overlay.dragging);
122
+ // The handles step aside while the selection is carried.
123
+ const shownHandles = $derived(dragging !== 'move' && availability ? availability.handles : []);
124
+ const showDot = $derived(!!availability?.canRotate && (dragging === null || dragging === 'rotate'));
125
+ const dotActive = $derived(state.rotationDotHovered || dragging === 'rotate');
126
+ const dotCenter = $derived(frame && showDot ? pointBelowFrame(frame.screen, ROTATION_DOT_OFFSET) : null);
127
+ const readoutText = $derived(state.overlay.readout ? formatReadout(state.overlay.readout) : null);
128
+
129
+ // The red ring of the primary widget, drawn above its live widget (the board draws it under the card's own picture).
130
+ const primaryRing = $derived.by(() => {
131
+ if (layer !== 'above-widgets' || !advancedFeatures || !frame) return false;
132
+ const only = host.engine.selectedShapes();
133
+ return only.length === 1 && only[0].type === 'widget' && only[0].isPrimary;
134
+ });
135
+
136
+ // The unit under the pointer, unless it is already selected.
137
+ const hoveredId = $derived.by(() => {
138
+ if (!onBoard) return null;
139
+ const id = state.hoverId;
140
+ if (!id || state.selectedIds.includes(id) || state.tool !== 'select' || gestureKind !== null) return null;
141
+ return id;
142
+ });
143
+
144
+ // An arrow under the pointer is outlined along its line; anything else by its box.
145
+ const hoverArrow = $derived.by(() => {
146
+ if (!hoveredId) return null;
147
+ const object = state.scene.find((candidate) => candidate.id === hoveredId);
148
+ return object && object.type === 'path' && isArrow(object) ? object : null;
149
+ });
150
+
151
+ const hoverFrame = $derived.by(() => {
152
+ if (!hoveredId || hoverArrow) return null;
153
+ const outline = outlineOfUnit(state.scene, hoveredId);
154
+ return outline ? screenFrameOf(outline, state.viewport) : null;
155
+ });
156
+
157
+ const marquee = $derived.by(() => {
158
+ const rect = onBoard ? state.overlay.marquee : null;
159
+ if (!rect) return null;
160
+ const topLeft = worldToScreen(state.viewport, { x: rect.x, y: rect.y });
161
+ return { left: topLeft.x, top: topLeft.y, width: rect.width * state.viewport.zoom, height: rect.height * state.viewport.zoom };
162
+ });
163
+
164
+ // What a marquee that is being dragged would take if it were let go: each unit is outlined as it is under the pointer, so the
165
+ // release holds no surprise. The first three are read on their own because `state` is a new record at every tick of the
166
+ // engine: each hands back the same list, scene or viewport until it really changes, so the outlines (one pass over the scene)
167
+ // are made again only when the units, the scene or the view change, and not at every step of the drag.
168
+ const marqueeHoverIds = $derived(onBoard ? state.overlay.marqueeHover : NO_UNITS);
169
+ const marqueeScene = $derived(state.scene);
170
+ const marqueeViewport = $derived(state.viewport);
171
+ const marqueeOutlines = $derived(marqueeOutlinesOf(marqueeScene, marqueeHoverIds, marqueeViewport));
172
+ // The boxes of those units as two paths, not an element each: a marquee over a whole board would otherwise make hundreds of
173
+ // elements as it grows and destroy them all in the frame of the release.
174
+ const marqueePaths = $derived(outlinePathsOf(marqueeOutlines.frames));
175
+
176
+ const textDraft = $derived.by(() => {
177
+ const rect = onBoard ? state.overlay.textDraft : null;
178
+ if (!rect) return null;
179
+ const topLeft = worldToScreen(state.viewport, { x: rect.x, y: rect.y });
180
+ return { left: topLeft.x, top: topLeft.y, width: rect.width * state.viewport.zoom, height: rect.height * state.viewport.zoom };
181
+ });
182
+
183
+ const guideLines = $derived(
184
+ onBoard
185
+ ? state.overlay.guides.map((guide) => {
186
+ const start = worldToScreen(state.viewport, guide.orientation === 'vertical' ? { x: guide.position, y: guide.from } : { x: guide.from, y: guide.position });
187
+ const end = worldToScreen(state.viewport, guide.orientation === 'vertical' ? { x: guide.position, y: guide.to } : { x: guide.to, y: guide.position });
188
+ // A guide is a hairline over the board: as long as the stretch it marks, from its top left end.
189
+ return {
190
+ orientation: guide.orientation,
191
+ style: layerBoxStyle({
192
+ left: Math.min(start.x, end.x),
193
+ top: Math.min(start.y, end.y),
194
+ ...(guide.orientation === 'vertical' ? { height: Math.abs(end.y - start.y) } : { width: Math.abs(end.x - start.x) })
195
+ })
196
+ };
197
+ })
198
+ : []
199
+ );
200
+
201
+ // The size is shown at rest in the frame centre (same place as while resizing); while resizing or turning the readout in the middle says it instead.
202
+ const sizeLabel = $derived.by(() => {
203
+ if (!frame || gestureKind !== null) return null;
204
+ const text = formatReadout({ kind: 'size', width: Math.round(frame.world.width), height: Math.round(frame.world.height) });
205
+ const at = restingSizeLabelPoint(frame.screen, text);
206
+ if (!at) return null;
207
+ return { x: at.x, y: at.y, text };
208
+ });
209
+
210
+ /** Where one handle sits on the frame, as the percentages of its width and height. */
211
+ function handleStyle(handle: ResizeHandle): string {
212
+ const direction = handleDirection(handle);
213
+ // rtl-ok: a handle sits on a side of the drawn frame, which is not turned around on a right to left screen
214
+ return `left:${(direction.x + 1) * 50}%;top:${(direction.y + 1) * 50}%;`;
215
+ }
216
+
217
+ /** The pointer cursor over one handle of a frame that may be turned. */
218
+ function handleCursor(handle: ResizeHandle): string {
219
+ return cssCursor(cursorForHandle(handle, frame?.world.rotation ?? 0));
220
+ }
221
+
222
+ /**
223
+ * A press on a handle in the layer above the live widgets is handed to the host as if it had landed on the board: the
224
+ * engine finds the handle under the pointer itself. The host captures the pointer on the board, so the rest of the
225
+ * gesture arrives there and nothing more is forwarded.
226
+ */
227
+ function passPressToHost(event: PointerEvent): void {
228
+ if (event.button !== 0) return;
229
+ event.stopPropagation();
230
+ host.handlePointerDown(event);
231
+ }
232
+
233
+ function passMoveToHost(event: PointerEvent): void {
234
+ if (host.boardElement?.hasPointerCapture(event.pointerId)) return;
235
+ host.handlePointerMove(event);
236
+ }
237
+
238
+ function passReleaseToHost(event: PointerEvent): void {
239
+ if (host.boardElement?.hasPointerCapture(event.pointerId)) return;
240
+ host.handlePointerUp(event);
241
+ }
242
+ </script>
243
+
244
+ <div class="pointer-events-none absolute inset-0 overflow-hidden" aria-hidden="true" data-canvas-overlay={layer}>
245
+ {#if marquee}
246
+ <div
247
+ class="absolute border border-ring bg-ring/10"
248
+ style={layerBoxStyle(marquee)}
249
+ ></div>
250
+ {/if}
251
+
252
+ {#if textDraft}
253
+ <div
254
+ class="absolute border border-dashed border-ring"
255
+ style={layerBoxStyle(textDraft)}
256
+ ></div>
257
+ {/if}
258
+
259
+ <!--
260
+ The outline of a unit under the pointer, and of each unit a marquee would take (below): one line of 1 px in the selection
261
+ colour, just outside the edge of the box and not on it. The default shapes have a stroke of their own on their edge, and a
262
+ line drawn there is lost in it (seen enlarged in Chrome: a line on the edge, even at 60 %, blended with the stroke into one
263
+ dark line, and a shape under the pointer could not be told from one at rest).
264
+ -->
265
+ {#if hoverFrame}
266
+ <div class="absolute outline outline-1 outline-ring" style={screenFrameStyle(hoverFrame)} data-canvas-hover-outline="pointer"></div>
267
+ {/if}
268
+
269
+ {#if hoverArrow}
270
+ {@render arrowOutline(hoverArrow, true)}
271
+ {/if}
272
+
273
+ <!--
274
+ What the marquee would take, outlined exactly as a unit under the pointer is (the same line of 1 px just outside the edge,
275
+ the same band round an arrow). The boxes are two paths in the board's pixels, whatever their number; the one of the boxes
276
+ that stand upright is drawn with crisp edges, so each line covers whole pixels, as the outline of an element does.
277
+ -->
278
+ {#if marqueePaths.upright || marqueePaths.turned}
279
+ <svg class="pointer-events-none absolute inset-0 size-full overflow-visible" data-canvas-marquee-outlines>
280
+ {#if marqueePaths.upright}
281
+ <path class="fill-none stroke-ring" d={marqueePaths.upright} stroke-width="1" shape-rendering="crispEdges" data-canvas-hover-outline="marquee" />
282
+ {/if}
283
+ {#if marqueePaths.turned}
284
+ <path class="fill-none stroke-ring" d={marqueePaths.turned} stroke-width="1" data-canvas-hover-outline="marquee" />
285
+ {/if}
286
+ </svg>
287
+ {/if}
288
+ {#each marqueeOutlines.arrows as arrow (arrow.id)}
289
+ {@render arrowOutline(arrow, true)}
290
+ {/each}
291
+
292
+ {#if arrowSelection}
293
+ {@render arrowOutline(arrowSelection.arrow, false)}
294
+ {#each dragging === 'move' ? [] : arrowSelection.handles as handle (handle.id)}
295
+ {@const active = state.arrowHandleHovered === handle.id}
296
+ <!-- A round handle: 10 px on an end, 8 px on the middle, 14 px under the pointer and while it is dragged. -->
297
+ <span
298
+ class="absolute -translate-x-1/2 -translate-y-1/2 rounded-full border-[1.5px] border-ring transition-[width,height,background-color] duration-150 ease-out {active
299
+ ? 'size-3.5 bg-ring'
300
+ : handle.id === 'bend'
301
+ ? 'size-2 bg-background'
302
+ : 'size-2.5 bg-background'}"
303
+ style={layerPointStyle(handle.point)}
304
+ data-canvas-arrow-handle={handle.id}
305
+ data-active={active}
306
+ ></span>
307
+ {/each}
308
+ {/if}
309
+
310
+ {#each guideLines as guide, guideIndex (guideIndex)}
311
+ <div class="absolute bg-pink-500 {guide.orientation === 'vertical' ? 'w-px' : 'h-px'}" style={guide.style}></div>
312
+ {/each}
313
+
314
+ {#if frame}
315
+ {#if primaryRing}
316
+ <div class="absolute box-border border-2" style="{screenFrameStyle(frame.screen)}border-color:{PRIMARY_RING_COLOR};"></div>
317
+ {/if}
318
+ <div
319
+ class="absolute box-border border-[1.5px] {dragging === 'resize' ? 'border-transparent' : 'border-ring'}"
320
+ style={screenFrameStyle(frame.screen)}
321
+ data-canvas-frame
322
+ data-dragging={dragging}
323
+ >
324
+ {#if dragging === 'resize'}
325
+ <!-- The outline of a selection that is being stretched: dashes of 4 px with 4 px between. -->
326
+ <svg
327
+ class="pointer-events-none absolute -inset-[1.5px] overflow-visible"
328
+ width={frame.screen.width}
329
+ height={frame.screen.height}
330
+ data-canvas-dashed-outline
331
+ >
332
+ <rect
333
+ class="fill-none stroke-ring"
334
+ x="0.75"
335
+ y="0.75"
336
+ width={Math.max(0, frame.screen.width - 1.5)}
337
+ height={Math.max(0, frame.screen.height - 1.5)}
338
+ stroke-width="1.5"
339
+ stroke-dasharray="4 4"
340
+ />
341
+ </svg>
342
+ {/if}
343
+ {#each shownHandles as handle (handle)}
344
+ {#if layer === 'above-widgets'}
345
+ <!-- A target a finger can hit, around the 8 px square that is drawn. -->
346
+ <span
347
+ class="pointer-events-auto absolute flex size-6 -translate-x-1/2 -translate-y-1/2 touch-none items-center justify-center"
348
+ style="{handleStyle(handle)}cursor:{handleCursor(handle)};"
349
+ data-canvas-handle={handle}
350
+ role="presentation"
351
+ onpointerdown={passPressToHost}
352
+ onpointermove={passMoveToHost}
353
+ onpointerup={passReleaseToHost}
354
+ onpointercancel={passReleaseToHost}
355
+ >
356
+ <span class="size-2 rounded-[2px] border-[1.5px] border-ring bg-background"></span>
357
+ </span>
358
+ {:else}
359
+ <span
360
+ class="absolute size-2 -translate-x-1/2 -translate-y-1/2 rounded-[2px] border-[1.5px] border-ring bg-background"
361
+ style={handleStyle(handle)}
362
+ ></span>
363
+ {/if}
364
+ {/each}
365
+ </div>
366
+ {/if}
367
+
368
+ {#if dotCenter}
369
+ {#if layer === 'above-widgets'}
370
+ <!-- The square a press on the dot lands on, above the live widgets: it hands the press to the host, like the handles. -->
371
+ <span
372
+ class="pointer-events-auto absolute flex touch-none items-center justify-center"
373
+ style="{layerCenteredStyle(dotCenter, DOT_TARGET_SIZE)}cursor:{dragging === 'rotate' ? 'grabbing' : 'grab'};"
374
+ data-canvas-rotation-target
375
+ role="presentation"
376
+ onpointerdown={passPressToHost}
377
+ onpointermove={passMoveToHost}
378
+ onpointerup={passReleaseToHost}
379
+ onpointercancel={passReleaseToHost}
380
+ >
381
+ {@render rotationDot()}
382
+ </span>
383
+ {:else}
384
+ <span class="absolute flex -translate-x-1/2 -translate-y-1/2 items-center justify-center" style={layerPointStyle(dotCenter)}>
385
+ {@render rotationDot()}
386
+ </span>
387
+ {/if}
388
+ {/if}
389
+
390
+ {#if sizeLabel}
391
+ <span
392
+ class="absolute -translate-x-1/2 -translate-y-1/2 whitespace-nowrap rounded-sm bg-inverse px-1.5 py-0.5 text-xs font-medium tabular-nums text-inverse-foreground"
393
+ style={layerPointStyle(sizeLabel)}
394
+ dir="ltr"
395
+ data-canvas-size-label
396
+ >
397
+ {sizeLabel.text}
398
+ </span>
399
+ {/if}
400
+
401
+ {#if frame && readoutText}
402
+ <!-- The figure of the stretch or the turn, in the middle of the selection where the hand is not. -->
403
+ <span
404
+ class="absolute -translate-x-1/2 -translate-y-1/2 whitespace-nowrap rounded-sm bg-inverse px-1.5 py-0.5 text-xs font-medium tabular-nums text-inverse-foreground"
405
+ style={layerPointStyle({ x: frame.screen.centerX, y: frame.screen.centerY })}
406
+ dir="ltr"
407
+ data-canvas-readout
408
+ >
409
+ {readoutText}
410
+ </span>
411
+ {/if}
412
+
413
+ {#if onBoard && state.overlay.virtualCursor}
414
+ {@const arrow = state.overlay.virtualCursor}
415
+ <svg
416
+ class="absolute"
417
+ width={VIRTUAL_CURSOR_SIZE}
418
+ height={VIRTUAL_CURSOR_SIZE}
419
+ viewBox="0 0 24 24"
420
+ style="{layerCenteredStyle(arrow, VIRTUAL_CURSOR_SIZE)}transform:rotate({arrow.angle}deg);"
421
+ data-canvas-virtual-cursor
422
+ >
423
+ <path class="fill-foreground stroke-background" d={VIRTUAL_CURSOR_PATH} stroke-width="1.5" stroke-linejoin="round" />
424
+ </svg>
425
+ {/if}
426
+ </div>
427
+
428
+ {#snippet arrowOutline(arrow: ArrowObject, hovered: boolean)}
429
+ {@const placement = arrowOutlinePlacement(arrow, state.viewport)}
430
+ <!--
431
+ The line of the arrow itself, thin and in the selection colour, over the arrow: the same width at every zoom. A selected arrow is
432
+ drawn with it alone (the handles say the rest). Under the pointer it is fainter and has a pale band round it as well: a dark line
433
+ takes a thin line of its own colour badly, so the band is what shows that the pointer is on it.
434
+ -->
435
+ <svg
436
+ class="pointer-events-none absolute overflow-visible text-ring"
437
+ width="1"
438
+ height="1"
439
+ style={placement.style}
440
+ data-canvas-arrow-outline
441
+ data-hovered={hovered}
442
+ >
443
+ {#if hovered}
444
+ <path
445
+ d={arrow.d}
446
+ transform="scale({placement.scale})"
447
+ fill="none"
448
+ stroke="currentColor"
449
+ stroke-opacity="0.28"
450
+ stroke-width={arrow.strokeWidth * placement.scale + ARROW_HOVER_BAND}
451
+ stroke-linecap="round"
452
+ stroke-linejoin="round"
453
+ vector-effect="non-scaling-stroke"
454
+ data-canvas-arrow-band
455
+ />
456
+ {/if}
457
+ <path
458
+ d={arrow.d}
459
+ transform="scale({placement.scale})"
460
+ fill="none"
461
+ stroke="currentColor"
462
+ stroke-opacity={hovered ? 0.6 : 1}
463
+ stroke-width="1.5"
464
+ stroke-linecap="round"
465
+ stroke-linejoin="round"
466
+ vector-effect="non-scaling-stroke"
467
+ />
468
+ </svg>
469
+ {/snippet}
470
+
471
+ {#snippet rotationDot()}
472
+ <!-- Eight pixels at rest like the other handles; under the pointer it grows into a 24 px disc with the turning arrow. -->
473
+ <span
474
+ class="flex items-center justify-center rounded-full transition-[width,height,background-color,border-color] duration-150 ease-out motion-reduce:transition-none {dotActive
475
+ ? 'size-6 border-0 bg-inverse text-inverse-foreground'
476
+ : 'size-2 border-[1.5px] border-ring bg-background'}"
477
+ data-canvas-rotation-dot
478
+ data-active={dotActive}
479
+ >
480
+ {#if dotActive}
481
+ <svg class="size-3" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
482
+ <path d="M20 11a8 8 0 1 0-2.3 5.7" />
483
+ <path d="M20 4v7h-7" />
484
+ </svg>
485
+ {/if}
486
+ </span>
487
+ {/snippet}
@@ -0,0 +1,17 @@
1
+ import type { EngineState } from '../../engine/state.js';
2
+ import type { CanvasHost } from '../host/CanvasHost.js';
3
+ interface Props {
4
+ state: EngineState;
5
+ host: CanvasHost;
6
+ /** What the host is doing with the pointer now ("move", "resize", "rotate", …), or null. */
7
+ gestureKind: string | null;
8
+ /** Whether the page's advanced tools are on (a widget card's chrome, and the primary widget's ring, depend on it). */
9
+ advancedFeatures?: boolean;
10
+ /** 'board': everything. 'above-widgets': only the frame of the selected widget card, with handles that take the pointer. */
11
+ layer?: 'board' | 'above-widgets';
12
+ /** True when the frame of the selected widget card is drawn in the layer above the live widgets instead. */
13
+ frameElsewhere?: boolean;
14
+ }
15
+ declare const SelectionOverlay: import("svelte").Component<Props, {}, "">;
16
+ type SelectionOverlay = ReturnType<typeof SelectionOverlay>;
17
+ export default SelectionOverlay;
@@ -0,0 +1,76 @@
1
+ <!--
2
+ The field a text is typed in: a plain <textarea> laid exactly over the text object (same box, same turn, same font, same
3
+ padding), inside the world layer, so it scales with the board and the caret is where the letters will be.
4
+
5
+ The text on the board is not drawn while it is edited: this field is the text, and every keystroke is handed to the engine
6
+ (`updateEditingText`), which lays the box out again. Leaving the field ends the edit (an empty text is removed).
7
+ -->
8
+ <script lang="ts">
9
+ import { untrack } from 'svelte';
10
+ import type { TextObject } from '../../engine/core/types.js';
11
+ import { fontShorthand, textDirection } from '../../engine/text/layoutText.js';
12
+ import { useCanvasLanguage } from '../../i18n/language.js';
13
+ import type { CanvasHost } from '../host/CanvasHost.js';
14
+ import { canvasWarn } from '../canvasLogger.js';
15
+ import { boxStyle } from './geometry.js';
16
+
17
+ interface Props {
18
+ shape: TextObject;
19
+ host: CanvasHost;
20
+ }
21
+
22
+ let { shape, host }: Props = $props();
23
+
24
+ const { t } = useCanvasLanguage();
25
+
26
+ /**
27
+ * Fills the field with the text the object has and puts the caret at its end, once, when the field appears. After that
28
+ * the field is the truth and the engine follows it: the text is read untracked so a keystroke does not run this again.
29
+ */
30
+ function startTyping(field: HTMLTextAreaElement): void {
31
+ try {
32
+ field.value = untrack(() => shape.text);
33
+ field.focus({ preventScroll: true });
34
+ field.setSelectionRange(field.value.length, field.value.length);
35
+ } catch (error) {
36
+ canvasWarn('Canvas: could not focus the text field', error);
37
+ }
38
+ }
39
+
40
+ function handleInput(event: Event & { currentTarget: HTMLTextAreaElement }): void {
41
+ host.engine.updateEditingText(event.currentTarget.value);
42
+ }
43
+
44
+ function handleBlur(): void {
45
+ host.engine.endTextEdit();
46
+ }
47
+
48
+ /** The board must not take a press, a drag or a context menu that started in the field. */
49
+ function keepInField(event: Event): void {
50
+ event.stopPropagation();
51
+ }
52
+ </script>
53
+
54
+ <textarea
55
+ {@attach startTyping}
56
+ class="pointer-events-auto absolute m-0 box-border resize-none overflow-visible border-0 outline-none placeholder:text-muted-foreground"
57
+ style="{boxStyle(shape)}opacity:{shape.opacity};padding:{shape.padding}px;background-color:{shape.backgroundColor};color:{shape.color};caret-color:{shape.color};font:{fontShorthand(
58
+ shape
59
+ )};line-height:{shape.lineHeight};text-align:{shape.align};white-space:{shape.autoWidth ? 'pre' : 'pre-wrap'};{shape.underline
60
+ ? 'text-decoration:underline;'
61
+ : ''}"
62
+ data-canvas-text-input
63
+ dir={textDirection(shape.text)}
64
+ wrap={shape.autoWidth ? 'off' : 'soft'}
65
+ spellcheck="false"
66
+ autocomplete="off"
67
+ placeholder={$t('canvas.defaults.textBox')}
68
+ aria-label={$t('canvas.tool.text')}
69
+ oninput={handleInput}
70
+ onblur={handleBlur}
71
+ onpointerdown={keepInField}
72
+ onpointermove={keepInField}
73
+ onpointerup={keepInField}
74
+ oncontextmenu={keepInField}
75
+ ondblclick={keepInField}
76
+ ></textarea>
@@ -0,0 +1,9 @@
1
+ import type { TextObject } from '../../engine/core/types.js';
2
+ import type { CanvasHost } from '../host/CanvasHost.js';
3
+ interface Props {
4
+ shape: TextObject;
5
+ host: CanvasHost;
6
+ }
7
+ declare const TextEditor: import("svelte").Component<Props, {}, "">;
8
+ type TextEditor = ReturnType<typeof TextEditor>;
9
+ export default TextEditor;
@@ -0,0 +1,83 @@
1
+ <!--
2
+ The frame of a selected widget card, drawn in a layer of the page that is above the live widgets.
3
+
4
+ A page that lays a live widget (an iframe) over the card of a widget on the board hides whatever the board draws under it,
5
+ selection frame and handles included. It names an element of its own with `widgetSelectionLayerTarget`, above the iframes,
6
+ and this layer mounts a copy of the selection overlay there: a fixed layer exactly over the board, with the frame of the
7
+ selected card and handles that take the pointer (the board is not under them, so they hand the press to the host).
8
+
9
+ Only the frame is in that layer: the card itself, the board and every other tool stay in the board.
10
+ -->
11
+ <script lang="ts">
12
+ import { onMount } from 'svelte';
13
+ import { Portal } from '@widgetic/design-system/components';
14
+ import type { EngineState } from '../../engine/state.js';
15
+ import type { CanvasHost } from '../host/CanvasHost.js';
16
+ import SelectionOverlay from './SelectionOverlay.svelte';
17
+
18
+ interface Props {
19
+ host: CanvasHost;
20
+ state: EngineState;
21
+ gestureKind: string | null;
22
+ advancedFeatures: boolean;
23
+ /** The id or class of the page's element (or the element itself) that stands above its live widgets. */
24
+ target: string | HTMLElement;
25
+ }
26
+
27
+ // `state` is a prop name of the canvas; here it is renamed, because a local `state` would turn `$state` into a store.
28
+ let { host, state: engineState, gestureKind, advancedFeatures, target }: Props = $props();
29
+
30
+ // Where the board is on the screen, in pixels from the corner of the window: the layer is laid over it there.
31
+ let boardRect = $state({ left: 0, top: 0, width: 0, height: 0 });
32
+ let measureFrame = 0;
33
+
34
+ function measure(): void {
35
+ measureFrame = 0;
36
+ const board = host.boardElement;
37
+ if (!board) return;
38
+ const bounds = board.getBoundingClientRect();
39
+ if (bounds.left !== boardRect.left || bounds.top !== boardRect.top || bounds.width !== boardRect.width || bounds.height !== boardRect.height) {
40
+ boardRect = { left: bounds.left, top: bounds.top, width: bounds.width, height: bounds.height };
41
+ }
42
+ }
43
+
44
+ // rtl-ok: laid over the board where the board is on the screen, measured from the left edge of the window
45
+ const layerStyle = $derived(`left: ${boardRect.left}px; top: ${boardRect.top}px; width: ${boardRect.width}px; height: ${boardRect.height}px; pointer-events: none;`);
46
+
47
+ /** One measurement a frame, however many things asked for it. */
48
+ function scheduleMeasure(): void {
49
+ if (measureFrame) return;
50
+ measureFrame = requestAnimationFrame(measure);
51
+ }
52
+
53
+ // The board moves under the layer when the page scrolls, resizes, or opens a panel beside it, and the frame follows the
54
+ // board through every change of the view, so the position is read again after each.
55
+ $effect(() => {
56
+ void engineState.viewport;
57
+ void engineState.viewSize;
58
+ void engineState.revision;
59
+ scheduleMeasure();
60
+ });
61
+
62
+ onMount(() => {
63
+ const board = host.boardElement;
64
+ const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(scheduleMeasure);
65
+ if (board) observer?.observe(board);
66
+ window.addEventListener('scroll', scheduleMeasure, true);
67
+ window.addEventListener('resize', scheduleMeasure);
68
+ measure();
69
+ return () => {
70
+ observer?.disconnect();
71
+ window.removeEventListener('scroll', scheduleMeasure, true);
72
+ window.removeEventListener('resize', scheduleMeasure);
73
+ if (measureFrame) cancelAnimationFrame(measureFrame);
74
+ measureFrame = 0;
75
+ };
76
+ });
77
+ </script>
78
+
79
+ <Portal {target} style="z-index: 70; pointer-events: none;">
80
+ <div class="canvas-widget-selection-layer pointer-events-none fixed overflow-hidden" dir="ltr" data-canvas-widget-chrome style={layerStyle}>
81
+ <SelectionOverlay state={engineState} {host} {gestureKind} {advancedFeatures} layer="above-widgets" />
82
+ </div>
83
+ </Portal>