@uipath/apollo-react 4.61.0 → 4.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/components/BaseNode/BaseNode.cjs +23 -42
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +23 -42
- package/dist/canvas/components/BaseNode/BaseNodeConfigContext.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/FormattingToolbar.cjs +29 -8
- package/dist/canvas/components/StickyNoteNode/FormattingToolbar.d.ts +7 -3
- package/dist/canvas/components/StickyNoteNode/FormattingToolbar.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/FormattingToolbar.js +30 -9
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.cjs +105 -20
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.d.ts +5 -2
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.js +106 -21
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.styles.cjs +1 -0
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.styles.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.styles.js +1 -0
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.types.d.ts +15 -0
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.types.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.cjs +10 -2
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.d.ts +2 -0
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.js +6 -1
- package/dist/canvas/stores/animatedViewportManager.cjs +4 -4
- package/dist/canvas/stores/animatedViewportManager.d.ts.map +1 -1
- package/dist/canvas/stores/animatedViewportManager.js +4 -4
- package/package.json +1 -1
|
@@ -57,7 +57,7 @@ const getContainerWidth = (shape, width)=>{
|
|
|
57
57
|
if (width && width !== external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE && width !== external_constants_cjs_namespaceObject.DEFAULT_RECTANGLE_NODE_WIDTH) return width;
|
|
58
58
|
return defaultWidth;
|
|
59
59
|
};
|
|
60
|
-
const
|
|
60
|
+
const getIntrinsicHeight = (hasFooter, footerVariant)=>{
|
|
61
61
|
if (hasFooter) switch(footerVariant){
|
|
62
62
|
case 'button':
|
|
63
63
|
return external_constants_cjs_namespaceObject.NODE_HEIGHT_FOOTER_BUTTON;
|
|
@@ -65,22 +65,17 @@ const getContainerHeight = (height, hasFooter, footerVariant)=>{
|
|
|
65
65
|
return external_constants_cjs_namespaceObject.NODE_HEIGHT_FOOTER_SINGLE;
|
|
66
66
|
case 'double':
|
|
67
67
|
return external_constants_cjs_namespaceObject.NODE_HEIGHT_FOOTER_DOUBLE;
|
|
68
|
-
default:
|
|
69
|
-
return 'auto';
|
|
70
68
|
}
|
|
71
|
-
return
|
|
69
|
+
return external_constants_cjs_namespaceObject.NODE_HEIGHT_DEFAULT;
|
|
72
70
|
};
|
|
73
71
|
const BaseNodeComponent = (props)=>{
|
|
74
|
-
const { type, data, selected, id, dragging, width,
|
|
72
|
+
const { type, data, selected, id, dragging, width, parentId } = props;
|
|
75
73
|
const { onHandleAction: onHandleActionProp, onHandleMouseEnter: onHandleMouseEnterProp, onHandleMouseLeave: onHandleMouseLeaveProp, onActionNeeded, shouldShowAddButtonFn: shouldShowAddButtonFnProp, shouldShowButtonHandleNotchesFn: shouldShowButtonHandleNotchesFnProp, toolbarConfig: toolbarConfigProp, handleConfigurations: handleConfigurationsProp, adornments: adornmentsProp, suggestionType, disabled, executionStatusOverride, labelTooltip, labelBackgroundColor, footerVariant, footerComponent, subLabelComponent, iconComponent } = (0, external_BaseNodeConfigContext_cjs_namespaceObject.useBaseNodeOverrideConfig)();
|
|
76
74
|
const updateNodeInternals = (0, react_cjs_namespaceObject.useUpdateNodeInternals)();
|
|
77
|
-
const { updateNodeData, updateNode } = (0, react_cjs_namespaceObject.useReactFlow)();
|
|
75
|
+
const { updateNodeData, updateNode, getNode } = (0, react_cjs_namespaceObject.useReactFlow)();
|
|
78
76
|
const containerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
79
77
|
const [isHovered, setIsHovered] = (0, external_react_namespaceObject.useState)(false);
|
|
80
78
|
const [isFocused, setIsFocused] = (0, external_react_namespaceObject.useState)(false);
|
|
81
|
-
const syncedHeightRef = (0, external_react_namespaceObject.useRef)(void 0);
|
|
82
|
-
const baseHeightRef = (0, external_react_namespaceObject.useRef)(external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE);
|
|
83
|
-
if (height && height !== syncedHeightRef.current) baseHeightRef.current = height;
|
|
84
79
|
const executionState = (0, external_hooks_index_cjs_namespaceObject.useNodeExecutionState)(id);
|
|
85
80
|
const validationState = (0, external_hooks_index_cjs_namespaceObject.useElementValidationStatus)(id);
|
|
86
81
|
const nodeTypeRegistry = (0, index_cjs_namespaceObject.useNodeTypeRegistry)();
|
|
@@ -191,36 +186,23 @@ const BaseNodeComponent = (props)=>{
|
|
|
191
186
|
const leftHandles = handleConfigurations.filter((config)=>config.position === react_cjs_namespaceObject.Position.Left && false !== config.visible).reduce((count, config)=>count + config.handles.filter((h)=>false !== h.visible).length, 0);
|
|
192
187
|
const rightHandles = handleConfigurations.filter((config)=>config.position === react_cjs_namespaceObject.Position.Right && false !== config.visible).reduce((count, config)=>count + config.handles.filter((h)=>false !== h.visible).length, 0);
|
|
193
188
|
const leftRightHandles = Math.max(leftHandles, rightHandles);
|
|
194
|
-
const
|
|
195
|
-
return Math.max(
|
|
189
|
+
const handleFloor = (2 * leftRightHandles + 2) * external_constants_cjs_namespaceObject.GRID_SPACING;
|
|
190
|
+
return Math.max(getIntrinsicHeight(!!footerComponent, footerVariant), handleFloor);
|
|
196
191
|
}, [
|
|
197
192
|
handleConfigurations,
|
|
198
|
-
|
|
193
|
+
footerComponent,
|
|
194
|
+
footerVariant
|
|
199
195
|
]);
|
|
200
196
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
197
|
+
if (getNode(id)?.height !== computedHeight) updateNode(id, {
|
|
198
|
+
height: computedHeight
|
|
199
|
+
});
|
|
201
200
|
updateNodeInternals(id);
|
|
202
201
|
}, [
|
|
203
202
|
handleConfigurations,
|
|
204
|
-
id,
|
|
205
|
-
updateNodeInternals
|
|
206
|
-
]);
|
|
207
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
208
|
-
if (void 0 !== computedHeight && computedHeight !== height) {
|
|
209
|
-
syncedHeightRef.current = computedHeight;
|
|
210
|
-
const frameId = requestAnimationFrame(()=>{
|
|
211
|
-
updateNode(id, {
|
|
212
|
-
height: computedHeight
|
|
213
|
-
});
|
|
214
|
-
updateNodeInternals(id);
|
|
215
|
-
});
|
|
216
|
-
return ()=>{
|
|
217
|
-
cancelAnimationFrame(frameId);
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
}, [
|
|
221
203
|
computedHeight,
|
|
222
|
-
height,
|
|
223
204
|
id,
|
|
205
|
+
getNode,
|
|
224
206
|
updateNode,
|
|
225
207
|
updateNodeInternals
|
|
226
208
|
]);
|
|
@@ -232,7 +214,6 @@ const BaseNodeComponent = (props)=>{
|
|
|
232
214
|
const displayIconBackground = isDarkMode ? display.iconBackgroundDark ?? display.iconBackground : display.iconBackground;
|
|
233
215
|
const displayLabelTooltip = labelTooltip;
|
|
234
216
|
const displayLabelBackgroundColor = labelBackgroundColor;
|
|
235
|
-
const displayFooterVariant = footerVariant;
|
|
236
217
|
const displaySubLabel = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
237
218
|
if (void 0 !== subLabelComponent) return subLabelComponent;
|
|
238
219
|
return display.subLabel;
|
|
@@ -243,9 +224,9 @@ const BaseNodeComponent = (props)=>{
|
|
|
243
224
|
const displayFooter = footerComponent;
|
|
244
225
|
const hasFooter = !!displayFooter;
|
|
245
226
|
const containerWidth = getContainerWidth(displayShape, width);
|
|
246
|
-
const containerHeight =
|
|
227
|
+
const containerHeight = computedHeight;
|
|
247
228
|
const nodeVars = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
248
|
-
const numH =
|
|
229
|
+
const numH = containerHeight;
|
|
249
230
|
const getRadius = (basis, ratio)=>'circle' === displayShape ? '50%' : hasFooter ? `${external_constants_cjs_namespaceObject.GRID_SPACING}px` : `${basis * ratio}px`;
|
|
250
231
|
const radiusBasis = Math.min(containerWidth, numH);
|
|
251
232
|
const nodeRadius = getRadius(radiusBasis, external_constants_cjs_namespaceObject.NODE_CONTAINER_RADIUS_RATIO);
|
|
@@ -259,7 +240,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
259
240
|
const innerH = keepSquare ? innerBasis - gap : effectiveH - gap;
|
|
260
241
|
return {
|
|
261
242
|
'--node-w': `${containerWidth}px`,
|
|
262
|
-
'--node-h':
|
|
243
|
+
'--node-h': `${containerHeight}px`,
|
|
263
244
|
'--node-radius': nodeRadius,
|
|
264
245
|
'--node-gap': `${(gap - 2 * external_constants_cjs_namespaceObject.NODE_BORDER_SIZE) / 2}px`,
|
|
265
246
|
'--inner-w': `${innerW}px`,
|
|
@@ -391,8 +372,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
391
372
|
hovered: isHovered,
|
|
392
373
|
showAddButton: 'design' === mode && !multipleNodesSelected && !isConnecting && !dragging,
|
|
393
374
|
showNotches,
|
|
394
|
-
nodeWidth:
|
|
395
|
-
nodeHeight:
|
|
375
|
+
nodeWidth: containerWidth,
|
|
376
|
+
nodeHeight: computedHeight,
|
|
396
377
|
shouldShowAddButtonFn,
|
|
397
378
|
portalActions: !!parentId
|
|
398
379
|
});
|
|
@@ -413,8 +394,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
413
394
|
id: handle.id,
|
|
414
395
|
defaultPosition: defaultPosition,
|
|
415
396
|
handleType: handleVisualType,
|
|
416
|
-
nodeWidth:
|
|
417
|
-
nodeHeight:
|
|
397
|
+
nodeWidth: containerWidth,
|
|
398
|
+
nodeHeight: computedHeight,
|
|
418
399
|
label: handle.label,
|
|
419
400
|
showButton: shouldShowButton,
|
|
420
401
|
selected: selected,
|
|
@@ -429,8 +410,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
429
410
|
useSmartHandles,
|
|
430
411
|
handleConfigurations,
|
|
431
412
|
shouldShowHandles,
|
|
432
|
-
|
|
433
|
-
|
|
413
|
+
containerWidth,
|
|
414
|
+
computedHeight,
|
|
434
415
|
mode,
|
|
435
416
|
selected,
|
|
436
417
|
showNotches,
|
|
@@ -560,8 +541,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
560
541
|
]
|
|
561
542
|
});
|
|
562
543
|
if (useSmartHandles) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SmartHandle_cjs_namespaceObject.SmartHandleProvider, {
|
|
563
|
-
nodeWidth:
|
|
564
|
-
nodeHeight:
|
|
544
|
+
nodeWidth: containerWidth,
|
|
545
|
+
nodeHeight: computedHeight,
|
|
565
546
|
children: nodeContent
|
|
566
547
|
});
|
|
567
548
|
return nodeContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/BaseNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AA4ChF,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/BaseNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AA4ChF,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,kBAAkB,CAAC;AAkrB1B,eAAO,MAAM,QAAQ,8CAhpBa,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,6CAgpBmB,CAAC"}
|
|
@@ -29,7 +29,7 @@ const getContainerWidth = (shape, width)=>{
|
|
|
29
29
|
if (width && width !== DEFAULT_NODE_SIZE && width !== DEFAULT_RECTANGLE_NODE_WIDTH) return width;
|
|
30
30
|
return defaultWidth;
|
|
31
31
|
};
|
|
32
|
-
const
|
|
32
|
+
const getIntrinsicHeight = (hasFooter, footerVariant)=>{
|
|
33
33
|
if (hasFooter) switch(footerVariant){
|
|
34
34
|
case 'button':
|
|
35
35
|
return NODE_HEIGHT_FOOTER_BUTTON;
|
|
@@ -37,22 +37,17 @@ const getContainerHeight = (height, hasFooter, footerVariant)=>{
|
|
|
37
37
|
return NODE_HEIGHT_FOOTER_SINGLE;
|
|
38
38
|
case 'double':
|
|
39
39
|
return NODE_HEIGHT_FOOTER_DOUBLE;
|
|
40
|
-
default:
|
|
41
|
-
return 'auto';
|
|
42
40
|
}
|
|
43
|
-
return
|
|
41
|
+
return NODE_HEIGHT_DEFAULT;
|
|
44
42
|
};
|
|
45
43
|
const BaseNodeComponent = (props)=>{
|
|
46
|
-
const { type, data, selected, id, dragging, width,
|
|
44
|
+
const { type, data, selected, id, dragging, width, parentId } = props;
|
|
47
45
|
const { onHandleAction: onHandleActionProp, onHandleMouseEnter: onHandleMouseEnterProp, onHandleMouseLeave: onHandleMouseLeaveProp, onActionNeeded, shouldShowAddButtonFn: shouldShowAddButtonFnProp, shouldShowButtonHandleNotchesFn: shouldShowButtonHandleNotchesFnProp, toolbarConfig: toolbarConfigProp, handleConfigurations: handleConfigurationsProp, adornments: adornmentsProp, suggestionType, disabled, executionStatusOverride, labelTooltip, labelBackgroundColor, footerVariant, footerComponent, subLabelComponent, iconComponent } = useBaseNodeOverrideConfig();
|
|
48
46
|
const updateNodeInternals = useUpdateNodeInternals();
|
|
49
|
-
const { updateNodeData, updateNode } = useReactFlow();
|
|
47
|
+
const { updateNodeData, updateNode, getNode } = useReactFlow();
|
|
50
48
|
const containerRef = useRef(null);
|
|
51
49
|
const [isHovered, setIsHovered] = useState(false);
|
|
52
50
|
const [isFocused, setIsFocused] = useState(false);
|
|
53
|
-
const syncedHeightRef = useRef(void 0);
|
|
54
|
-
const baseHeightRef = useRef(DEFAULT_NODE_SIZE);
|
|
55
|
-
if (height && height !== syncedHeightRef.current) baseHeightRef.current = height;
|
|
56
51
|
const executionState = useNodeExecutionState(id);
|
|
57
52
|
const validationState = useElementValidationStatus(id);
|
|
58
53
|
const nodeTypeRegistry = useNodeTypeRegistry();
|
|
@@ -163,36 +158,23 @@ const BaseNodeComponent = (props)=>{
|
|
|
163
158
|
const leftHandles = handleConfigurations.filter((config)=>config.position === Position.Left && false !== config.visible).reduce((count, config)=>count + config.handles.filter((h)=>false !== h.visible).length, 0);
|
|
164
159
|
const rightHandles = handleConfigurations.filter((config)=>config.position === Position.Right && false !== config.visible).reduce((count, config)=>count + config.handles.filter((h)=>false !== h.visible).length, 0);
|
|
165
160
|
const leftRightHandles = Math.max(leftHandles, rightHandles);
|
|
166
|
-
const
|
|
167
|
-
return Math.max(
|
|
161
|
+
const handleFloor = (2 * leftRightHandles + 2) * GRID_SPACING;
|
|
162
|
+
return Math.max(getIntrinsicHeight(!!footerComponent, footerVariant), handleFloor);
|
|
168
163
|
}, [
|
|
169
164
|
handleConfigurations,
|
|
170
|
-
|
|
165
|
+
footerComponent,
|
|
166
|
+
footerVariant
|
|
171
167
|
]);
|
|
172
168
|
useEffect(()=>{
|
|
169
|
+
if (getNode(id)?.height !== computedHeight) updateNode(id, {
|
|
170
|
+
height: computedHeight
|
|
171
|
+
});
|
|
173
172
|
updateNodeInternals(id);
|
|
174
173
|
}, [
|
|
175
174
|
handleConfigurations,
|
|
176
|
-
id,
|
|
177
|
-
updateNodeInternals
|
|
178
|
-
]);
|
|
179
|
-
useEffect(()=>{
|
|
180
|
-
if (void 0 !== computedHeight && computedHeight !== height) {
|
|
181
|
-
syncedHeightRef.current = computedHeight;
|
|
182
|
-
const frameId = requestAnimationFrame(()=>{
|
|
183
|
-
updateNode(id, {
|
|
184
|
-
height: computedHeight
|
|
185
|
-
});
|
|
186
|
-
updateNodeInternals(id);
|
|
187
|
-
});
|
|
188
|
-
return ()=>{
|
|
189
|
-
cancelAnimationFrame(frameId);
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
}, [
|
|
193
175
|
computedHeight,
|
|
194
|
-
height,
|
|
195
176
|
id,
|
|
177
|
+
getNode,
|
|
196
178
|
updateNode,
|
|
197
179
|
updateNodeInternals
|
|
198
180
|
]);
|
|
@@ -204,7 +186,6 @@ const BaseNodeComponent = (props)=>{
|
|
|
204
186
|
const displayIconBackground = isDarkMode ? display.iconBackgroundDark ?? display.iconBackground : display.iconBackground;
|
|
205
187
|
const displayLabelTooltip = labelTooltip;
|
|
206
188
|
const displayLabelBackgroundColor = labelBackgroundColor;
|
|
207
|
-
const displayFooterVariant = footerVariant;
|
|
208
189
|
const displaySubLabel = useMemo(()=>{
|
|
209
190
|
if (void 0 !== subLabelComponent) return subLabelComponent;
|
|
210
191
|
return display.subLabel;
|
|
@@ -215,9 +196,9 @@ const BaseNodeComponent = (props)=>{
|
|
|
215
196
|
const displayFooter = footerComponent;
|
|
216
197
|
const hasFooter = !!displayFooter;
|
|
217
198
|
const containerWidth = getContainerWidth(displayShape, width);
|
|
218
|
-
const containerHeight =
|
|
199
|
+
const containerHeight = computedHeight;
|
|
219
200
|
const nodeVars = useMemo(()=>{
|
|
220
|
-
const numH =
|
|
201
|
+
const numH = containerHeight;
|
|
221
202
|
const getRadius = (basis, ratio)=>'circle' === displayShape ? '50%' : hasFooter ? `${GRID_SPACING}px` : `${basis * ratio}px`;
|
|
222
203
|
const radiusBasis = Math.min(containerWidth, numH);
|
|
223
204
|
const nodeRadius = getRadius(radiusBasis, NODE_CONTAINER_RADIUS_RATIO);
|
|
@@ -231,7 +212,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
231
212
|
const innerH = keepSquare ? innerBasis - gap : effectiveH - gap;
|
|
232
213
|
return {
|
|
233
214
|
'--node-w': `${containerWidth}px`,
|
|
234
|
-
'--node-h':
|
|
215
|
+
'--node-h': `${containerHeight}px`,
|
|
235
216
|
'--node-radius': nodeRadius,
|
|
236
217
|
'--node-gap': `${(gap - 2 * NODE_BORDER_SIZE) / 2}px`,
|
|
237
218
|
'--inner-w': `${innerW}px`,
|
|
@@ -363,8 +344,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
363
344
|
hovered: isHovered,
|
|
364
345
|
showAddButton: 'design' === mode && !multipleNodesSelected && !isConnecting && !dragging,
|
|
365
346
|
showNotches,
|
|
366
|
-
nodeWidth:
|
|
367
|
-
nodeHeight:
|
|
347
|
+
nodeWidth: containerWidth,
|
|
348
|
+
nodeHeight: computedHeight,
|
|
368
349
|
shouldShowAddButtonFn,
|
|
369
350
|
portalActions: !!parentId
|
|
370
351
|
});
|
|
@@ -385,8 +366,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
385
366
|
id: handle.id,
|
|
386
367
|
defaultPosition: defaultPosition,
|
|
387
368
|
handleType: handleVisualType,
|
|
388
|
-
nodeWidth:
|
|
389
|
-
nodeHeight:
|
|
369
|
+
nodeWidth: containerWidth,
|
|
370
|
+
nodeHeight: computedHeight,
|
|
390
371
|
label: handle.label,
|
|
391
372
|
showButton: shouldShowButton,
|
|
392
373
|
selected: selected,
|
|
@@ -401,8 +382,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
401
382
|
useSmartHandles,
|
|
402
383
|
handleConfigurations,
|
|
403
384
|
shouldShowHandles,
|
|
404
|
-
|
|
405
|
-
|
|
385
|
+
containerWidth,
|
|
386
|
+
computedHeight,
|
|
406
387
|
mode,
|
|
407
388
|
selected,
|
|
408
389
|
showNotches,
|
|
@@ -532,8 +513,8 @@ const BaseNodeComponent = (props)=>{
|
|
|
532
513
|
]
|
|
533
514
|
});
|
|
534
515
|
if (useSmartHandles) return /*#__PURE__*/ jsx(SmartHandleProvider, {
|
|
535
|
-
nodeWidth:
|
|
536
|
-
nodeHeight:
|
|
516
|
+
nodeWidth: containerWidth,
|
|
517
|
+
nodeHeight: computedHeight,
|
|
537
518
|
children: nodeContent
|
|
538
519
|
});
|
|
539
520
|
return nodeContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseNodeConfigContext.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/BaseNodeConfigContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AActE,MAAM,WAAW,sBAAsB;IAErC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAEpD,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEvD,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACvD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,aAAa,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC;IACzF,+BAA+B,CAAC,EAAE,CAAC,IAAI,EAAE;QACvC,YAAY,EAAE,OAAO,CAAC;QACtB,UAAU,EAAE,OAAO,CAAC;QACpB,SAAS,EAAE,OAAO,CAAC;KACpB,KAAK,OAAO,CAAC;IAGd,aAAa,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzC,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7C,UAAU,CAAC,EAAE,cAAc,CAAC;IAG5B,cAAc,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB,CAAC,EAAE,mBAAmB,CAAC;IAG9C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseNodeConfigContext.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/BaseNodeConfigContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AActE,MAAM,WAAW,sBAAsB;IAErC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAEpD,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEvD,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACvD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,aAAa,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC;IACzF,+BAA+B,CAAC,EAAE,CAAC,IAAI,EAAE;QACvC,YAAY,EAAE,OAAO,CAAC;QACtB,UAAU,EAAE,OAAO,CAAC;QACpB,SAAS,EAAE,OAAO,CAAC;KACpB,KAAK,OAAO,CAAC;IAGd,aAAa,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzC,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7C,UAAU,CAAC,EAAE,cAAc,CAAC;IAG5B,cAAc,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB,CAAC,EAAE,mBAAmB,CAAC;IAG9C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC,iBAAiB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACpC,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACjC;AAMD,eAAO,MAAM,8BAA8B,kDAAyC,CAAC;AAMrF,wBAAgB,yBAAyB,IAAI,sBAAsB,CAElE"}
|
|
@@ -34,19 +34,14 @@ const external_CanvasTooltip_cjs_namespaceObject = require("../CanvasTooltip.cjs
|
|
|
34
34
|
const external_markdown_formatting_index_cjs_namespaceObject = require("./markdown-formatting/index.cjs");
|
|
35
35
|
const external_StickyNoteNode_styles_cjs_namespaceObject = require("./StickyNoteNode.styles.cjs");
|
|
36
36
|
const external_StickyNoteNode_utils_cjs_namespaceObject = require("./StickyNoteNode.utils.cjs");
|
|
37
|
-
const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, onFormat })=>{
|
|
37
|
+
const FormattingToolbarComponent = ({ containerRef, textAreaRef, borderColor, activeFormats, onFormat, onBlur, actions = [], onAction })=>{
|
|
38
38
|
const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
|
|
39
39
|
const mod = (0, external_StickyNoteNode_utils_cjs_namespaceObject.getModifierKey)();
|
|
40
40
|
const shift = (0, external_StickyNoteNode_utils_cjs_namespaceObject.isMac)() ? '⇧' : '+Shift+';
|
|
41
41
|
const applyFormat = (0, external_react_namespaceObject.useCallback)((formatFn)=>{
|
|
42
42
|
const textarea = textAreaRef.current;
|
|
43
43
|
if (!textarea) return;
|
|
44
|
-
|
|
45
|
-
value: textarea.value,
|
|
46
|
-
selectionStart: textarea.selectionStart,
|
|
47
|
-
selectionEnd: textarea.selectionEnd
|
|
48
|
-
};
|
|
49
|
-
onFormat(formatFn(input));
|
|
44
|
+
onFormat(formatFn((0, external_StickyNoteNode_utils_cjs_namespaceObject.readTextSelection)(textarea)));
|
|
50
45
|
textarea.focus();
|
|
51
46
|
}, [
|
|
52
47
|
textAreaRef,
|
|
@@ -101,10 +96,12 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
101
96
|
message: 'Text formatting'
|
|
102
97
|
});
|
|
103
98
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingToolbarContainer, {
|
|
99
|
+
ref: containerRef,
|
|
104
100
|
role: "toolbar",
|
|
105
101
|
"aria-label": toolbarLabel,
|
|
106
102
|
borderColor: borderColor,
|
|
107
103
|
onMouseDown: (e)=>e.preventDefault(),
|
|
104
|
+
onBlur: onBlur,
|
|
108
105
|
className: "nodrag nowheel",
|
|
109
106
|
children: [
|
|
110
107
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
|
|
@@ -112,9 +109,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
112
109
|
placement: "top",
|
|
113
110
|
delay: true,
|
|
114
111
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
112
|
+
type: "button",
|
|
115
113
|
isActive: activeFormats.bold,
|
|
116
114
|
onClick: handleBold,
|
|
117
115
|
"aria-label": boldLabel,
|
|
116
|
+
"aria-pressed": activeFormats.bold,
|
|
118
117
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
|
|
119
118
|
icon: "bold",
|
|
120
119
|
size: 14
|
|
@@ -126,9 +125,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
126
125
|
placement: "top",
|
|
127
126
|
delay: true,
|
|
128
127
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
128
|
+
type: "button",
|
|
129
129
|
isActive: activeFormats.italic,
|
|
130
130
|
onClick: handleItalic,
|
|
131
131
|
"aria-label": italicLabel,
|
|
132
|
+
"aria-pressed": activeFormats.italic,
|
|
132
133
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
|
|
133
134
|
icon: "italic",
|
|
134
135
|
size: 14
|
|
@@ -140,9 +141,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
140
141
|
placement: "top",
|
|
141
142
|
delay: true,
|
|
142
143
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
144
|
+
type: "button",
|
|
143
145
|
isActive: activeFormats.strikethrough,
|
|
144
146
|
onClick: handleStrikethrough,
|
|
145
147
|
"aria-label": strikethroughLabel,
|
|
148
|
+
"aria-pressed": activeFormats.strikethrough,
|
|
146
149
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
|
|
147
150
|
icon: "strikethrough",
|
|
148
151
|
size: 14
|
|
@@ -155,9 +158,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
155
158
|
placement: "top",
|
|
156
159
|
delay: true,
|
|
157
160
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
161
|
+
type: "button",
|
|
158
162
|
isActive: activeFormats.bulletList,
|
|
159
163
|
onClick: handleBulletList,
|
|
160
164
|
"aria-label": bulletListLabel,
|
|
165
|
+
"aria-pressed": activeFormats.bulletList,
|
|
161
166
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
|
|
162
167
|
icon: "list",
|
|
163
168
|
size: 14
|
|
@@ -169,15 +174,31 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
169
174
|
placement: "top",
|
|
170
175
|
delay: true,
|
|
171
176
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
177
|
+
type: "button",
|
|
172
178
|
isActive: activeFormats.numberedList,
|
|
173
179
|
onClick: handleNumberedList,
|
|
174
180
|
"aria-label": numberedListLabel,
|
|
181
|
+
"aria-pressed": activeFormats.numberedList,
|
|
175
182
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
|
|
176
183
|
icon: "list-ordered",
|
|
177
184
|
size: 14
|
|
178
185
|
})
|
|
179
186
|
})
|
|
180
|
-
})
|
|
187
|
+
}),
|
|
188
|
+
actions.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.ToolbarSeparator, {}),
|
|
189
|
+
actions.map((action)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
|
|
190
|
+
content: action.label,
|
|
191
|
+
placement: "top",
|
|
192
|
+
delay: true,
|
|
193
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
|
|
194
|
+
type: "button",
|
|
195
|
+
isActive: false,
|
|
196
|
+
disabled: action.disabled || !onAction,
|
|
197
|
+
onClick: (event)=>onAction?.(action, event.currentTarget.getBoundingClientRect()),
|
|
198
|
+
"aria-label": action.label,
|
|
199
|
+
children: action.icon
|
|
200
|
+
})
|
|
201
|
+
}, action.id))
|
|
181
202
|
]
|
|
182
203
|
});
|
|
183
204
|
};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { type RefObject } from 'react';
|
|
1
|
+
import { type FocusEvent, type RefObject } from 'react';
|
|
2
2
|
import type { ActiveFormats } from './markdown-formatting';
|
|
3
|
-
import type { TextSelection } from './StickyNoteNode.types';
|
|
3
|
+
import type { StickyNoteFormattingAction, TextSelection } from './StickyNoteNode.types';
|
|
4
4
|
interface FormattingToolbarProps {
|
|
5
|
+
containerRef?: RefObject<HTMLDivElement | null>;
|
|
5
6
|
textAreaRef: RefObject<HTMLTextAreaElement | null>;
|
|
6
7
|
borderColor: string;
|
|
7
8
|
activeFormats: ActiveFormats;
|
|
8
9
|
onFormat: (result: TextSelection) => void;
|
|
10
|
+
onBlur?: (event: FocusEvent<HTMLDivElement>) => void;
|
|
11
|
+
actions?: readonly StickyNoteFormattingAction[];
|
|
12
|
+
onAction?: (action: StickyNoteFormattingAction, anchorRect: DOMRectReadOnly) => void;
|
|
9
13
|
}
|
|
10
|
-
export declare const FormattingToolbar: import("react").MemoExoticComponent<({ textAreaRef, borderColor, activeFormats, onFormat, }: FormattingToolbarProps) => import("react/jsx-runtime").JSX.Element>;
|
|
14
|
+
export declare const FormattingToolbar: import("react").MemoExoticComponent<({ containerRef, textAreaRef, borderColor, activeFormats, onFormat, onBlur, actions, onAction, }: FormattingToolbarProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11
15
|
export {};
|
|
12
16
|
//# sourceMappingURL=FormattingToolbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormattingToolbar.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/FormattingToolbar.tsx"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,SAAS,EAAe,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FormattingToolbar.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/FormattingToolbar.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAQ,KAAK,SAAS,EAAe,MAAM,OAAO,CAAC;AAG3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAa3D,OAAO,KAAK,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGxF,UAAU,sBAAsB;IAC9B,YAAY,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAChD,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC1C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACrD,OAAO,CAAC,EAAE,SAAS,0BAA0B,EAAE,CAAC;IAChD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,0BAA0B,EAAE,UAAU,EAAE,eAAe,KAAK,IAAI,CAAC;CACtF;AAqJD,eAAO,MAAM,iBAAiB,wIA1I3B,sBAAsB,6CA0IwC,CAAC"}
|
|
@@ -5,20 +5,15 @@ import { useSafeLingui } from "../../../i18n/index.js";
|
|
|
5
5
|
import { CanvasTooltip } from "../CanvasTooltip.js";
|
|
6
6
|
import { toggleBold, toggleBulletList, toggleItalic, toggleNumberedList, toggleStrikethrough } from "./markdown-formatting/index.js";
|
|
7
7
|
import { FormattingButton, FormattingToolbarContainer, ToolbarSeparator } from "./StickyNoteNode.styles.js";
|
|
8
|
-
import { getModifierKey, isMac } from "./StickyNoteNode.utils.js";
|
|
9
|
-
const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, onFormat })=>{
|
|
8
|
+
import { getModifierKey, isMac, readTextSelection } from "./StickyNoteNode.utils.js";
|
|
9
|
+
const FormattingToolbarComponent = ({ containerRef, textAreaRef, borderColor, activeFormats, onFormat, onBlur, actions = [], onAction })=>{
|
|
10
10
|
const { _ } = useSafeLingui();
|
|
11
11
|
const mod = getModifierKey();
|
|
12
12
|
const shift = isMac() ? '⇧' : '+Shift+';
|
|
13
13
|
const applyFormat = useCallback((formatFn)=>{
|
|
14
14
|
const textarea = textAreaRef.current;
|
|
15
15
|
if (!textarea) return;
|
|
16
|
-
|
|
17
|
-
value: textarea.value,
|
|
18
|
-
selectionStart: textarea.selectionStart,
|
|
19
|
-
selectionEnd: textarea.selectionEnd
|
|
20
|
-
};
|
|
21
|
-
onFormat(formatFn(input));
|
|
16
|
+
onFormat(formatFn(readTextSelection(textarea)));
|
|
22
17
|
textarea.focus();
|
|
23
18
|
}, [
|
|
24
19
|
textAreaRef,
|
|
@@ -73,10 +68,12 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
73
68
|
message: 'Text formatting'
|
|
74
69
|
});
|
|
75
70
|
return /*#__PURE__*/ jsxs(FormattingToolbarContainer, {
|
|
71
|
+
ref: containerRef,
|
|
76
72
|
role: "toolbar",
|
|
77
73
|
"aria-label": toolbarLabel,
|
|
78
74
|
borderColor: borderColor,
|
|
79
75
|
onMouseDown: (e)=>e.preventDefault(),
|
|
76
|
+
onBlur: onBlur,
|
|
80
77
|
className: "nodrag nowheel",
|
|
81
78
|
children: [
|
|
82
79
|
/*#__PURE__*/ jsx(CanvasTooltip, {
|
|
@@ -84,9 +81,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
84
81
|
placement: "top",
|
|
85
82
|
delay: true,
|
|
86
83
|
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
84
|
+
type: "button",
|
|
87
85
|
isActive: activeFormats.bold,
|
|
88
86
|
onClick: handleBold,
|
|
89
87
|
"aria-label": boldLabel,
|
|
88
|
+
"aria-pressed": activeFormats.bold,
|
|
90
89
|
children: /*#__PURE__*/ jsx(CanvasIcon, {
|
|
91
90
|
icon: "bold",
|
|
92
91
|
size: 14
|
|
@@ -98,9 +97,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
98
97
|
placement: "top",
|
|
99
98
|
delay: true,
|
|
100
99
|
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
100
|
+
type: "button",
|
|
101
101
|
isActive: activeFormats.italic,
|
|
102
102
|
onClick: handleItalic,
|
|
103
103
|
"aria-label": italicLabel,
|
|
104
|
+
"aria-pressed": activeFormats.italic,
|
|
104
105
|
children: /*#__PURE__*/ jsx(CanvasIcon, {
|
|
105
106
|
icon: "italic",
|
|
106
107
|
size: 14
|
|
@@ -112,9 +113,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
112
113
|
placement: "top",
|
|
113
114
|
delay: true,
|
|
114
115
|
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
116
|
+
type: "button",
|
|
115
117
|
isActive: activeFormats.strikethrough,
|
|
116
118
|
onClick: handleStrikethrough,
|
|
117
119
|
"aria-label": strikethroughLabel,
|
|
120
|
+
"aria-pressed": activeFormats.strikethrough,
|
|
118
121
|
children: /*#__PURE__*/ jsx(CanvasIcon, {
|
|
119
122
|
icon: "strikethrough",
|
|
120
123
|
size: 14
|
|
@@ -127,9 +130,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
127
130
|
placement: "top",
|
|
128
131
|
delay: true,
|
|
129
132
|
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
133
|
+
type: "button",
|
|
130
134
|
isActive: activeFormats.bulletList,
|
|
131
135
|
onClick: handleBulletList,
|
|
132
136
|
"aria-label": bulletListLabel,
|
|
137
|
+
"aria-pressed": activeFormats.bulletList,
|
|
133
138
|
children: /*#__PURE__*/ jsx(CanvasIcon, {
|
|
134
139
|
icon: "list",
|
|
135
140
|
size: 14
|
|
@@ -141,15 +146,31 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
|
|
|
141
146
|
placement: "top",
|
|
142
147
|
delay: true,
|
|
143
148
|
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
149
|
+
type: "button",
|
|
144
150
|
isActive: activeFormats.numberedList,
|
|
145
151
|
onClick: handleNumberedList,
|
|
146
152
|
"aria-label": numberedListLabel,
|
|
153
|
+
"aria-pressed": activeFormats.numberedList,
|
|
147
154
|
children: /*#__PURE__*/ jsx(CanvasIcon, {
|
|
148
155
|
icon: "list-ordered",
|
|
149
156
|
size: 14
|
|
150
157
|
})
|
|
151
158
|
})
|
|
152
|
-
})
|
|
159
|
+
}),
|
|
160
|
+
actions.length > 0 && /*#__PURE__*/ jsx(ToolbarSeparator, {}),
|
|
161
|
+
actions.map((action)=>/*#__PURE__*/ jsx(CanvasTooltip, {
|
|
162
|
+
content: action.label,
|
|
163
|
+
placement: "top",
|
|
164
|
+
delay: true,
|
|
165
|
+
children: /*#__PURE__*/ jsx(FormattingButton, {
|
|
166
|
+
type: "button",
|
|
167
|
+
isActive: false,
|
|
168
|
+
disabled: action.disabled || !onAction,
|
|
169
|
+
onClick: (event)=>onAction?.(action, event.currentTarget.getBoundingClientRect()),
|
|
170
|
+
"aria-label": action.label,
|
|
171
|
+
children: action.icon
|
|
172
|
+
})
|
|
173
|
+
}, action.id))
|
|
153
174
|
]
|
|
154
175
|
});
|
|
155
176
|
};
|
|
@@ -63,7 +63,7 @@ const external_useMarkdownShortcuts_cjs_namespaceObject = require("./useMarkdown
|
|
|
63
63
|
const external_useScrollCapture_cjs_namespaceObject = require("./useScrollCapture.cjs");
|
|
64
64
|
const minWidth = 8 * external_constants_cjs_namespaceObject.GRID_SPACING;
|
|
65
65
|
const minHeight = 8 * external_constants_cjs_namespaceObject.GRID_SPACING;
|
|
66
|
-
const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false, readOnly = false, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd })=>{
|
|
66
|
+
const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false, readOnly = false, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, formattingActions, markdownComponents: customMarkdownComponents })=>{
|
|
67
67
|
const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
|
|
68
68
|
const { updateNodeData, deleteElements } = (0, react_cjs_namespaceObject.useReactFlow)();
|
|
69
69
|
const { multipleNodesSelected } = (0, SelectionStateContext_cjs_namespaceObject.useSelectionState)();
|
|
@@ -71,7 +71,9 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
71
71
|
const [isResizing, setIsResizing] = (0, external_react_namespaceObject.useState)(false);
|
|
72
72
|
const [isColorPickerOpen, setIsColorPickerOpen] = (0, external_react_namespaceObject.useState)(false);
|
|
73
73
|
const [localContent, setLocalContent] = (0, external_react_namespaceObject.useState)(data.content || '');
|
|
74
|
+
const latestContentRef = (0, external_react_namespaceObject.useRef)(localContent);
|
|
74
75
|
const textAreaRef = (0, external_react_namespaceObject.useRef)(null);
|
|
76
|
+
const formattingToolbarRef = (0, external_react_namespaceObject.useRef)(null);
|
|
75
77
|
const skipBlurRef = (0, external_react_namespaceObject.useRef)(null);
|
|
76
78
|
const { ref: markdownRef, scrollCaptureProps } = (0, external_useScrollCapture_cjs_namespaceObject.useScrollCapture)();
|
|
77
79
|
const colorButtonRef = (0, external_react_namespaceObject.useRef)(null);
|
|
@@ -85,10 +87,15 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
85
87
|
const colorKey = data.color || 'yellow';
|
|
86
88
|
const color = external_StickyNoteNode_types_cjs_namespaceObject.STICKY_NOTE_COLORS[colorKey] ?? external_StickyNoteNode_types_cjs_namespaceObject.STICKY_NOTE_COLORS.yellow;
|
|
87
89
|
const colorWithAlpha = (0, external_StickyNoteNode_types_cjs_namespaceObject.withAlpha)(color);
|
|
90
|
+
const updateLocalContent = (0, external_react_namespaceObject.useCallback)((content)=>{
|
|
91
|
+
latestContentRef.current = content;
|
|
92
|
+
setLocalContent(content);
|
|
93
|
+
}, []);
|
|
88
94
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
89
|
-
|
|
95
|
+
updateLocalContent(data.content || '');
|
|
90
96
|
}, [
|
|
91
|
-
data.content
|
|
97
|
+
data.content,
|
|
98
|
+
updateLocalContent
|
|
92
99
|
]);
|
|
93
100
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
94
101
|
if (isEditing && textAreaRef.current) {
|
|
@@ -116,11 +123,12 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
116
123
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
117
124
|
if (readOnly) {
|
|
118
125
|
setIsEditing(false);
|
|
119
|
-
|
|
126
|
+
updateLocalContent(data.content || '');
|
|
120
127
|
}
|
|
121
128
|
}, [
|
|
122
129
|
readOnly,
|
|
123
|
-
data.content
|
|
130
|
+
data.content,
|
|
131
|
+
updateLocalContent
|
|
124
132
|
]);
|
|
125
133
|
const handleDoubleClick = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
126
134
|
if (readOnly || isEditing) return;
|
|
@@ -135,7 +143,9 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
135
143
|
isEditing,
|
|
136
144
|
readOnly
|
|
137
145
|
]);
|
|
138
|
-
const handleBlur = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
146
|
+
const handleBlur = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
147
|
+
const nextTarget = event.relatedTarget;
|
|
148
|
+
if (nextTarget instanceof Node && (textAreaRef.current?.contains(nextTarget) || formattingToolbarRef.current?.contains(nextTarget))) return;
|
|
139
149
|
setIsEditing(false);
|
|
140
150
|
if (readOnly) return;
|
|
141
151
|
const content = textAreaRef.current?.value ?? localContent;
|
|
@@ -159,10 +169,12 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
159
169
|
]);
|
|
160
170
|
const handleChange = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
161
171
|
skipBlurRef.current = null;
|
|
162
|
-
|
|
163
|
-
}, [
|
|
172
|
+
updateLocalContent(e.target.value);
|
|
173
|
+
}, [
|
|
174
|
+
updateLocalContent
|
|
175
|
+
]);
|
|
164
176
|
const handleFormat = (0, external_react_namespaceObject.useCallback)((result)=>{
|
|
165
|
-
|
|
177
|
+
updateLocalContent(result.value);
|
|
166
178
|
setActiveFormats((0, external_markdown_formatting_index_cjs_namespaceObject.detectActiveFormats)(result));
|
|
167
179
|
requestAnimationFrame(()=>{
|
|
168
180
|
if (textAreaRef.current) {
|
|
@@ -170,7 +182,68 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
170
182
|
textAreaRef.current.selectionEnd = result.selectionEnd;
|
|
171
183
|
}
|
|
172
184
|
});
|
|
173
|
-
}, [
|
|
185
|
+
}, [
|
|
186
|
+
updateLocalContent
|
|
187
|
+
]);
|
|
188
|
+
const handleFormattingAction = (0, external_react_namespaceObject.useCallback)((action, anchorRect)=>{
|
|
189
|
+
const textarea = textAreaRef.current;
|
|
190
|
+
if (!textarea) return;
|
|
191
|
+
const selection = (0, external_StickyNoteNode_utils_cjs_namespaceObject.readTextSelection)(textarea);
|
|
192
|
+
skipBlurRef.current = selection.value;
|
|
193
|
+
let completed = false;
|
|
194
|
+
const restoreSelection = (next)=>{
|
|
195
|
+
setIsEditing(true);
|
|
196
|
+
requestAnimationFrame(()=>{
|
|
197
|
+
const currentTextarea = textAreaRef.current;
|
|
198
|
+
if (!currentTextarea) return;
|
|
199
|
+
const length = next.value.length;
|
|
200
|
+
currentTextarea.focus();
|
|
201
|
+
currentTextarea.selectionStart = Math.max(0, Math.min(length, next.selectionStart));
|
|
202
|
+
currentTextarea.selectionEnd = Math.max(0, Math.min(length, next.selectionEnd));
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
const complete = (next, shouldPersist)=>{
|
|
206
|
+
if (completed) return;
|
|
207
|
+
completed = true;
|
|
208
|
+
skipBlurRef.current = shouldPersist ? next.value : null;
|
|
209
|
+
setActiveFormats((0, external_markdown_formatting_index_cjs_namespaceObject.detectActiveFormats)(next));
|
|
210
|
+
if (shouldPersist) {
|
|
211
|
+
updateLocalContent(next.value);
|
|
212
|
+
onContentChange?.(next.value);
|
|
213
|
+
updateNodeData(id, {
|
|
214
|
+
content: next.value
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
restoreSelection(next);
|
|
218
|
+
};
|
|
219
|
+
try {
|
|
220
|
+
action.onAction({
|
|
221
|
+
selection,
|
|
222
|
+
anchorRect,
|
|
223
|
+
currentValue: ()=>textAreaRef.current?.value ?? latestContentRef.current,
|
|
224
|
+
commit: (next)=>complete(next, true),
|
|
225
|
+
resume: ()=>{
|
|
226
|
+
const currentValue = textAreaRef.current?.value ?? latestContentRef.current;
|
|
227
|
+
complete({
|
|
228
|
+
...selection,
|
|
229
|
+
value: currentValue
|
|
230
|
+
}, false);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
} catch (error) {
|
|
234
|
+
if (!completed) {
|
|
235
|
+
completed = true;
|
|
236
|
+
skipBlurRef.current = null;
|
|
237
|
+
restoreSelection(selection);
|
|
238
|
+
}
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
}, [
|
|
242
|
+
id,
|
|
243
|
+
onContentChange,
|
|
244
|
+
updateLocalContent,
|
|
245
|
+
updateNodeData
|
|
246
|
+
]);
|
|
174
247
|
const updateActiveFormats = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
175
248
|
if (!textAreaRef.current) return;
|
|
176
249
|
const next = (0, external_markdown_formatting_index_cjs_namespaceObject.detectActiveFormats)({
|
|
@@ -185,7 +258,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
185
258
|
if ('Escape' === e.key) {
|
|
186
259
|
skipBlurRef.current = textAreaRef.current?.value ?? localContent;
|
|
187
260
|
setIsEditing(false);
|
|
188
|
-
|
|
261
|
+
updateLocalContent(data.content || '');
|
|
189
262
|
textAreaRef.current?.blur();
|
|
190
263
|
return;
|
|
191
264
|
}
|
|
@@ -209,7 +282,8 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
209
282
|
data.content,
|
|
210
283
|
localContent,
|
|
211
284
|
shortcutKeyDown,
|
|
212
|
-
handleFormat
|
|
285
|
+
handleFormat,
|
|
286
|
+
updateLocalContent
|
|
213
287
|
]);
|
|
214
288
|
const handleResizeStart = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
215
289
|
if (isEditing) {
|
|
@@ -283,8 +357,8 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
283
357
|
id,
|
|
284
358
|
deleteElements
|
|
285
359
|
]);
|
|
286
|
-
const
|
|
287
|
-
a: ({ href, children, ...props })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
|
|
360
|
+
const builtInMarkdownComponents = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
361
|
+
a: ({ node: _node, href, children, ...props })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
|
|
288
362
|
...props,
|
|
289
363
|
href: href,
|
|
290
364
|
target: "_blank",
|
|
@@ -298,6 +372,13 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
298
372
|
children: children
|
|
299
373
|
})
|
|
300
374
|
}), []);
|
|
375
|
+
const markdownComponents = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
376
|
+
...customMarkdownComponents,
|
|
377
|
+
...builtInMarkdownComponents
|
|
378
|
+
}), [
|
|
379
|
+
builtInMarkdownComponents,
|
|
380
|
+
customMarkdownComponents
|
|
381
|
+
]);
|
|
301
382
|
const toolbarConfig = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
302
383
|
const actions = [
|
|
303
384
|
{
|
|
@@ -453,12 +534,6 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
453
534
|
}),
|
|
454
535
|
isEditing ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
455
536
|
children: [
|
|
456
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FormattingToolbar_cjs_namespaceObject.FormattingToolbar, {
|
|
457
|
-
textAreaRef: textAreaRef,
|
|
458
|
-
borderColor: color,
|
|
459
|
-
activeFormats: activeFormats,
|
|
460
|
-
onFormat: handleFormat
|
|
461
|
-
}),
|
|
462
537
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.StickyNoteTextArea, {
|
|
463
538
|
ref: textAreaRef,
|
|
464
539
|
value: localContent,
|
|
@@ -470,6 +545,16 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
470
545
|
placeholder: placeholder,
|
|
471
546
|
isEditing: isEditing,
|
|
472
547
|
className: "nodrag nowheel"
|
|
548
|
+
}),
|
|
549
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FormattingToolbar_cjs_namespaceObject.FormattingToolbar, {
|
|
550
|
+
containerRef: formattingToolbarRef,
|
|
551
|
+
textAreaRef: textAreaRef,
|
|
552
|
+
borderColor: color,
|
|
553
|
+
activeFormats: activeFormats,
|
|
554
|
+
onFormat: handleFormat,
|
|
555
|
+
onBlur: handleBlur,
|
|
556
|
+
actions: formattingActions,
|
|
557
|
+
onAction: handleFormattingAction
|
|
473
558
|
})
|
|
474
559
|
]
|
|
475
560
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.StickyNoteMarkdown, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { NodeProps } from '../../xyflow/react.ts';
|
|
2
|
-
import
|
|
2
|
+
import { type Components } from 'react-markdown';
|
|
3
|
+
import type { StickyNoteColor, StickyNoteData, StickyNoteFormattingAction } from './StickyNoteNode.types';
|
|
3
4
|
export interface StickyNoteNodeProps extends NodeProps {
|
|
4
5
|
data: StickyNoteData;
|
|
5
6
|
placeholder?: string;
|
|
@@ -10,6 +11,8 @@ export interface StickyNoteNodeProps extends NodeProps {
|
|
|
10
11
|
onResize?: (width: number, height: number) => void;
|
|
11
12
|
onResizeStart?: () => void;
|
|
12
13
|
onResizeEnd?: () => void;
|
|
14
|
+
formattingActions?: readonly StickyNoteFormattingAction[];
|
|
15
|
+
markdownComponents?: Omit<Components, 'a'>;
|
|
13
16
|
}
|
|
14
|
-
export declare const StickyNoteNode: import("react").MemoExoticComponent<({ id, data, selected, dragging, placeholder, renderPlaceholderOnSelect, readOnly, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, }: StickyNoteNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
17
|
+
export declare const StickyNoteNode: import("react").MemoExoticComponent<({ id, data, selected, dragging, placeholder, renderPlaceholderOnSelect, readOnly, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, formattingActions, markdownComponents: customMarkdownComponents, }: StickyNoteNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
15
18
|
//# sourceMappingURL=StickyNoteNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StickyNoteNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"StickyNoteNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAM1E,OAAsB,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA8BhE,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,0BAA0B,EAE3B,MAAM,wBAAwB,CAAC;AAMhC,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,iBAAiB,CAAC,EAAE,SAAS,0BAA0B,EAAE,CAAC;IAC1D,kBAAkB,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;CAC5C;AA0iBD,eAAO,MAAM,cAAc,mQAthBxB,mBAAmB,6CAshBwE,CAAC"}
|
|
@@ -18,12 +18,12 @@ import { FormattingToolbar } from "./FormattingToolbar.js";
|
|
|
18
18
|
import { activeFormatsEqual, continueListOnEnter, detectActiveFormats } from "./markdown-formatting/index.js";
|
|
19
19
|
import { BottomCornerIndicators, ColorOption, ColorPickerPanel, RESIZE_CONTROL_Z_INDEX, ResizeHandle, StickyNoteContainer, StickyNoteMarkdown, StickyNoteTextArea, StickyNoteWrapper, TopCornerIndicators, stickyNoteGlobalStyles } from "./StickyNoteNode.styles.js";
|
|
20
20
|
import { STICKY_NOTE_COLORS, withAlpha } from "./StickyNoteNode.types.js";
|
|
21
|
-
import { preserveNewlines } from "./StickyNoteNode.utils.js";
|
|
21
|
+
import { preserveNewlines, readTextSelection } from "./StickyNoteNode.utils.js";
|
|
22
22
|
import { useMarkdownShortcuts } from "./useMarkdownShortcuts.js";
|
|
23
23
|
import { useScrollCapture } from "./useScrollCapture.js";
|
|
24
24
|
const minWidth = 8 * GRID_SPACING;
|
|
25
25
|
const minHeight = 8 * GRID_SPACING;
|
|
26
|
-
const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false, readOnly = false, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd })=>{
|
|
26
|
+
const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false, readOnly = false, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, formattingActions, markdownComponents: customMarkdownComponents })=>{
|
|
27
27
|
const { _ } = useSafeLingui();
|
|
28
28
|
const { updateNodeData, deleteElements } = useReactFlow();
|
|
29
29
|
const { multipleNodesSelected } = useSelectionState();
|
|
@@ -31,7 +31,9 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
31
31
|
const [isResizing, setIsResizing] = useState(false);
|
|
32
32
|
const [isColorPickerOpen, setIsColorPickerOpen] = useState(false);
|
|
33
33
|
const [localContent, setLocalContent] = useState(data.content || '');
|
|
34
|
+
const latestContentRef = useRef(localContent);
|
|
34
35
|
const textAreaRef = useRef(null);
|
|
36
|
+
const formattingToolbarRef = useRef(null);
|
|
35
37
|
const skipBlurRef = useRef(null);
|
|
36
38
|
const { ref: markdownRef, scrollCaptureProps } = useScrollCapture();
|
|
37
39
|
const colorButtonRef = useRef(null);
|
|
@@ -45,10 +47,15 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
45
47
|
const colorKey = data.color || 'yellow';
|
|
46
48
|
const color = STICKY_NOTE_COLORS[colorKey] ?? STICKY_NOTE_COLORS.yellow;
|
|
47
49
|
const colorWithAlpha = withAlpha(color);
|
|
50
|
+
const updateLocalContent = useCallback((content)=>{
|
|
51
|
+
latestContentRef.current = content;
|
|
52
|
+
setLocalContent(content);
|
|
53
|
+
}, []);
|
|
48
54
|
useEffect(()=>{
|
|
49
|
-
|
|
55
|
+
updateLocalContent(data.content || '');
|
|
50
56
|
}, [
|
|
51
|
-
data.content
|
|
57
|
+
data.content,
|
|
58
|
+
updateLocalContent
|
|
52
59
|
]);
|
|
53
60
|
useEffect(()=>{
|
|
54
61
|
if (isEditing && textAreaRef.current) {
|
|
@@ -76,11 +83,12 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
76
83
|
useEffect(()=>{
|
|
77
84
|
if (readOnly) {
|
|
78
85
|
setIsEditing(false);
|
|
79
|
-
|
|
86
|
+
updateLocalContent(data.content || '');
|
|
80
87
|
}
|
|
81
88
|
}, [
|
|
82
89
|
readOnly,
|
|
83
|
-
data.content
|
|
90
|
+
data.content,
|
|
91
|
+
updateLocalContent
|
|
84
92
|
]);
|
|
85
93
|
const handleDoubleClick = useCallback(()=>{
|
|
86
94
|
if (readOnly || isEditing) return;
|
|
@@ -95,7 +103,9 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
95
103
|
isEditing,
|
|
96
104
|
readOnly
|
|
97
105
|
]);
|
|
98
|
-
const handleBlur = useCallback(()=>{
|
|
106
|
+
const handleBlur = useCallback((event)=>{
|
|
107
|
+
const nextTarget = event.relatedTarget;
|
|
108
|
+
if (nextTarget instanceof Node && (textAreaRef.current?.contains(nextTarget) || formattingToolbarRef.current?.contains(nextTarget))) return;
|
|
99
109
|
setIsEditing(false);
|
|
100
110
|
if (readOnly) return;
|
|
101
111
|
const content = textAreaRef.current?.value ?? localContent;
|
|
@@ -119,10 +129,12 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
119
129
|
]);
|
|
120
130
|
const handleChange = useCallback((e)=>{
|
|
121
131
|
skipBlurRef.current = null;
|
|
122
|
-
|
|
123
|
-
}, [
|
|
132
|
+
updateLocalContent(e.target.value);
|
|
133
|
+
}, [
|
|
134
|
+
updateLocalContent
|
|
135
|
+
]);
|
|
124
136
|
const handleFormat = useCallback((result)=>{
|
|
125
|
-
|
|
137
|
+
updateLocalContent(result.value);
|
|
126
138
|
setActiveFormats(detectActiveFormats(result));
|
|
127
139
|
requestAnimationFrame(()=>{
|
|
128
140
|
if (textAreaRef.current) {
|
|
@@ -130,7 +142,68 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
130
142
|
textAreaRef.current.selectionEnd = result.selectionEnd;
|
|
131
143
|
}
|
|
132
144
|
});
|
|
133
|
-
}, [
|
|
145
|
+
}, [
|
|
146
|
+
updateLocalContent
|
|
147
|
+
]);
|
|
148
|
+
const handleFormattingAction = useCallback((action, anchorRect)=>{
|
|
149
|
+
const textarea = textAreaRef.current;
|
|
150
|
+
if (!textarea) return;
|
|
151
|
+
const selection = readTextSelection(textarea);
|
|
152
|
+
skipBlurRef.current = selection.value;
|
|
153
|
+
let completed = false;
|
|
154
|
+
const restoreSelection = (next)=>{
|
|
155
|
+
setIsEditing(true);
|
|
156
|
+
requestAnimationFrame(()=>{
|
|
157
|
+
const currentTextarea = textAreaRef.current;
|
|
158
|
+
if (!currentTextarea) return;
|
|
159
|
+
const length = next.value.length;
|
|
160
|
+
currentTextarea.focus();
|
|
161
|
+
currentTextarea.selectionStart = Math.max(0, Math.min(length, next.selectionStart));
|
|
162
|
+
currentTextarea.selectionEnd = Math.max(0, Math.min(length, next.selectionEnd));
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
const complete = (next, shouldPersist)=>{
|
|
166
|
+
if (completed) return;
|
|
167
|
+
completed = true;
|
|
168
|
+
skipBlurRef.current = shouldPersist ? next.value : null;
|
|
169
|
+
setActiveFormats(detectActiveFormats(next));
|
|
170
|
+
if (shouldPersist) {
|
|
171
|
+
updateLocalContent(next.value);
|
|
172
|
+
onContentChange?.(next.value);
|
|
173
|
+
updateNodeData(id, {
|
|
174
|
+
content: next.value
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
restoreSelection(next);
|
|
178
|
+
};
|
|
179
|
+
try {
|
|
180
|
+
action.onAction({
|
|
181
|
+
selection,
|
|
182
|
+
anchorRect,
|
|
183
|
+
currentValue: ()=>textAreaRef.current?.value ?? latestContentRef.current,
|
|
184
|
+
commit: (next)=>complete(next, true),
|
|
185
|
+
resume: ()=>{
|
|
186
|
+
const currentValue = textAreaRef.current?.value ?? latestContentRef.current;
|
|
187
|
+
complete({
|
|
188
|
+
...selection,
|
|
189
|
+
value: currentValue
|
|
190
|
+
}, false);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
} catch (error) {
|
|
194
|
+
if (!completed) {
|
|
195
|
+
completed = true;
|
|
196
|
+
skipBlurRef.current = null;
|
|
197
|
+
restoreSelection(selection);
|
|
198
|
+
}
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
}, [
|
|
202
|
+
id,
|
|
203
|
+
onContentChange,
|
|
204
|
+
updateLocalContent,
|
|
205
|
+
updateNodeData
|
|
206
|
+
]);
|
|
134
207
|
const updateActiveFormats = useCallback(()=>{
|
|
135
208
|
if (!textAreaRef.current) return;
|
|
136
209
|
const next = detectActiveFormats({
|
|
@@ -145,7 +218,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
145
218
|
if ('Escape' === e.key) {
|
|
146
219
|
skipBlurRef.current = textAreaRef.current?.value ?? localContent;
|
|
147
220
|
setIsEditing(false);
|
|
148
|
-
|
|
221
|
+
updateLocalContent(data.content || '');
|
|
149
222
|
textAreaRef.current?.blur();
|
|
150
223
|
return;
|
|
151
224
|
}
|
|
@@ -169,7 +242,8 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
169
242
|
data.content,
|
|
170
243
|
localContent,
|
|
171
244
|
shortcutKeyDown,
|
|
172
|
-
handleFormat
|
|
245
|
+
handleFormat,
|
|
246
|
+
updateLocalContent
|
|
173
247
|
]);
|
|
174
248
|
const handleResizeStart = useCallback(()=>{
|
|
175
249
|
if (isEditing) {
|
|
@@ -243,8 +317,8 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
243
317
|
id,
|
|
244
318
|
deleteElements
|
|
245
319
|
]);
|
|
246
|
-
const
|
|
247
|
-
a: ({ href, children, ...props })=>/*#__PURE__*/ jsx("a", {
|
|
320
|
+
const builtInMarkdownComponents = useMemo(()=>({
|
|
321
|
+
a: ({ node: _node, href, children, ...props })=>/*#__PURE__*/ jsx("a", {
|
|
248
322
|
...props,
|
|
249
323
|
href: href,
|
|
250
324
|
target: "_blank",
|
|
@@ -258,6 +332,13 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
258
332
|
children: children
|
|
259
333
|
})
|
|
260
334
|
}), []);
|
|
335
|
+
const markdownComponents = useMemo(()=>({
|
|
336
|
+
...customMarkdownComponents,
|
|
337
|
+
...builtInMarkdownComponents
|
|
338
|
+
}), [
|
|
339
|
+
builtInMarkdownComponents,
|
|
340
|
+
customMarkdownComponents
|
|
341
|
+
]);
|
|
261
342
|
const toolbarConfig = useMemo(()=>{
|
|
262
343
|
const actions = [
|
|
263
344
|
{
|
|
@@ -413,12 +494,6 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
413
494
|
}),
|
|
414
495
|
isEditing ? /*#__PURE__*/ jsxs(Fragment, {
|
|
415
496
|
children: [
|
|
416
|
-
/*#__PURE__*/ jsx(FormattingToolbar, {
|
|
417
|
-
textAreaRef: textAreaRef,
|
|
418
|
-
borderColor: color,
|
|
419
|
-
activeFormats: activeFormats,
|
|
420
|
-
onFormat: handleFormat
|
|
421
|
-
}),
|
|
422
497
|
/*#__PURE__*/ jsx(StickyNoteTextArea, {
|
|
423
498
|
ref: textAreaRef,
|
|
424
499
|
value: localContent,
|
|
@@ -430,6 +505,16 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
430
505
|
placeholder: placeholder,
|
|
431
506
|
isEditing: isEditing,
|
|
432
507
|
className: "nodrag nowheel"
|
|
508
|
+
}),
|
|
509
|
+
/*#__PURE__*/ jsx(FormattingToolbar, {
|
|
510
|
+
containerRef: formattingToolbarRef,
|
|
511
|
+
textAreaRef: textAreaRef,
|
|
512
|
+
borderColor: color,
|
|
513
|
+
activeFormats: activeFormats,
|
|
514
|
+
onFormat: handleFormat,
|
|
515
|
+
onBlur: handleBlur,
|
|
516
|
+
actions: formattingActions,
|
|
517
|
+
onAction: handleFormattingAction
|
|
433
518
|
})
|
|
434
519
|
]
|
|
435
520
|
}) : /*#__PURE__*/ jsx(StickyNoteMarkdown, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StickyNoteNode.styles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,8BAA8B,MAAM,CAAC;AA4BlD,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,sBAAsB,2CAOlC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;yGAI7B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;iBACjB,MAAM;qBACF,MAAM;eACZ,OAAO;eACP,OAAO;iBACL,OAAO;yGAuBrB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;eAAgC,OAAO;2HAsBrE,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;yGA8H9B,CAAC;AAEF,eAAO,MAAM,YAAY;;;;eAA2B,OAAO;aAAW,MAAM;yGAW3E,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;cAA0B,OAAO;yGA+BhE,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;cAA0B,OAAO;yGA+BnE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;UAa5B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;WAA0B,MAAM;gBAAc,OAAO;qHAkB5E,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;iBAA6B,MAAM;
|
|
1
|
+
{"version":3,"file":"StickyNoteNode.styles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,8BAA8B,MAAM,CAAC;AA4BlD,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,sBAAsB,2CAOlC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;yGAI7B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;iBACjB,MAAM;qBACF,MAAM;eACZ,OAAO;eACP,OAAO;iBACL,OAAO;yGAuBrB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;eAAgC,OAAO;2HAsBrE,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;yGA8H9B,CAAC;AAEF,eAAO,MAAM,YAAY;;;;eAA2B,OAAO;aAAW,MAAM;yGAW3E,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;cAA0B,OAAO;yGA+BhE,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;cAA0B,OAAO;yGA+BnE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;UAa5B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;WAA0B,MAAM;gBAAc,OAAO;qHAkB5E,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;iBAA6B,MAAM;yGASzE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;cAA6B,OAAO;qHAoBhE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;yGAK5B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
export declare const STICKY_NOTE_COLORS: {
|
|
2
3
|
readonly blue: "#42A1FF";
|
|
3
4
|
readonly green: "#6EB84A";
|
|
@@ -17,5 +18,19 @@ export type TextSelection = {
|
|
|
17
18
|
selectionStart: number;
|
|
18
19
|
selectionEnd: number;
|
|
19
20
|
};
|
|
21
|
+
export interface StickyNoteEditorActionContext {
|
|
22
|
+
selection: TextSelection;
|
|
23
|
+
anchorRect: DOMRectReadOnly;
|
|
24
|
+
currentValue(): string;
|
|
25
|
+
commit(next: TextSelection): void;
|
|
26
|
+
resume(): void;
|
|
27
|
+
}
|
|
28
|
+
export interface StickyNoteFormattingAction {
|
|
29
|
+
id: string;
|
|
30
|
+
icon: ReactNode;
|
|
31
|
+
label: string;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
onAction(context: StickyNoteEditorActionContext): void;
|
|
34
|
+
}
|
|
20
35
|
export type FormattingAction = 'bold' | 'italic' | 'strikethrough' | 'bulletList' | 'numberedList';
|
|
21
36
|
//# sourceMappingURL=StickyNoteNode.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StickyNoteNode.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StickyNoteNode.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAE9D,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAWD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,MAA6B,GAAG,MAAM,CAyBnF;AAGD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAGF,MAAM,WAAW,6BAA6B;IAE5C,SAAS,EAAE,aAAa,CAAC;IAEzB,UAAU,EAAE,eAAe,CAAC;IAE5B,YAAY,IAAI,MAAM,CAAC;IAEvB,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAElC,MAAM,IAAI,IAAI,CAAC;CAChB;AAGD,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,OAAO,EAAE,6BAA6B,GAAG,IAAI,CAAC;CACxD;AAGD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,GAAG,YAAY,GAAG,cAAc,CAAC"}
|
|
@@ -26,8 +26,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
getModifierKey: ()=>getModifierKey,
|
|
28
28
|
isMac: ()=>isMac,
|
|
29
|
-
preserveNewlines: ()=>preserveNewlines
|
|
29
|
+
preserveNewlines: ()=>preserveNewlines,
|
|
30
|
+
readTextSelection: ()=>readTextSelection
|
|
30
31
|
});
|
|
32
|
+
const readTextSelection = (textarea)=>({
|
|
33
|
+
value: textarea.value,
|
|
34
|
+
selectionStart: textarea.selectionStart,
|
|
35
|
+
selectionEnd: textarea.selectionEnd
|
|
36
|
+
});
|
|
31
37
|
const preserveNewlines = (markdown)=>{
|
|
32
38
|
const codeBlocks = [];
|
|
33
39
|
let result = markdown.replace(/```[\s\S]*?```/g, (m)=>{
|
|
@@ -46,10 +52,12 @@ const getModifierKey = ()=>isMac() ? '⌘' : 'Ctrl';
|
|
|
46
52
|
exports.getModifierKey = __webpack_exports__.getModifierKey;
|
|
47
53
|
exports.isMac = __webpack_exports__.isMac;
|
|
48
54
|
exports.preserveNewlines = __webpack_exports__.preserveNewlines;
|
|
55
|
+
exports.readTextSelection = __webpack_exports__.readTextSelection;
|
|
49
56
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
50
57
|
"getModifierKey",
|
|
51
58
|
"isMac",
|
|
52
|
-
"preserveNewlines"
|
|
59
|
+
"preserveNewlines",
|
|
60
|
+
"readTextSelection"
|
|
53
61
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
54
62
|
Object.defineProperty(exports, '__esModule', {
|
|
55
63
|
value: true
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { TextSelection } from './StickyNoteNode.types';
|
|
2
|
+
export declare const readTextSelection: (textarea: HTMLTextAreaElement) => TextSelection;
|
|
1
3
|
export declare const preserveNewlines: (markdown: string) => string;
|
|
2
4
|
export declare const isMac: () => boolean;
|
|
3
5
|
export declare const getModifierKey: () => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StickyNoteNode.utils.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StickyNoteNode.utils.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,eAAO,MAAM,iBAAiB,GAAI,UAAU,mBAAmB,KAAG,aAIhE,CAAC;AAIH,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,KAAG,MAqBnD,CAAC;AAOF,eAAO,MAAM,KAAK,QAAO,OAExB,CAAC;AAOF,eAAO,MAAM,cAAc,QAAO,MAEjC,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
const readTextSelection = (textarea)=>({
|
|
2
|
+
value: textarea.value,
|
|
3
|
+
selectionStart: textarea.selectionStart,
|
|
4
|
+
selectionEnd: textarea.selectionEnd
|
|
5
|
+
});
|
|
1
6
|
const preserveNewlines = (markdown)=>{
|
|
2
7
|
const codeBlocks = [];
|
|
3
8
|
let result = markdown.replace(/```[\s\S]*?```/g, (m)=>{
|
|
@@ -13,4 +18,4 @@ const preserveNewlines = (markdown)=>{
|
|
|
13
18
|
};
|
|
14
19
|
const isMac = ()=>"u" > typeof navigator && navigator.platform.includes('Mac');
|
|
15
20
|
const getModifierKey = ()=>isMac() ? '⌘' : 'Ctrl';
|
|
16
|
-
export { getModifierKey, isMac, preserveNewlines };
|
|
21
|
+
export { getModifierKey, isMac, preserveNewlines, readTextSelection };
|
|
@@ -144,8 +144,8 @@ class AnimatedViewportManager {
|
|
|
144
144
|
const nodeBounds = {
|
|
145
145
|
x: node.position.x,
|
|
146
146
|
y: node.position.y,
|
|
147
|
-
width: node.width || 200,
|
|
148
|
-
height: node.height || 100
|
|
147
|
+
width: node.measured?.width || node.width || 200,
|
|
148
|
+
height: node.measured?.height || node.height || 100
|
|
149
149
|
};
|
|
150
150
|
const nodeFocusViewport = (0, transitions_cjs_namespaceObject.calculateNodeFocusViewport)(nodeBounds, canvasSize, transitions_cjs_namespaceObject.ANIMATION_CONSTANTS.NODE_FOCUS_PADDING);
|
|
151
151
|
const fromViewport = this.getCurrentViewport();
|
|
@@ -206,8 +206,8 @@ class AnimatedViewportManager {
|
|
|
206
206
|
return {
|
|
207
207
|
x: node.position.x,
|
|
208
208
|
y: node.position.y,
|
|
209
|
-
width: node.width || 200,
|
|
210
|
-
height: node.height || 100
|
|
209
|
+
width: node.measured?.width || node.width || 200,
|
|
210
|
+
height: node.measured?.height || node.height || 100
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
cancelTransition() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animatedViewportManager.d.ts","sourceRoot":"","sources":["../../../src/canvas/stores/animatedViewportManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAOL,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;AAK9B,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAK5E,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,UAAU,CAAC,EAAE,QAAQ,CAAC;CACvB;AAMD,cAAM,uBAAuB;IAC3B,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,eAAe,CAKrB;IACF,OAAO,CAAC,mBAAmB,CAAC,CAAS;IAGrC,OAAO,CAAC,iBAAiB,CAAC,CAAiC;IAC3D,OAAO,CAAC,kBAAkB,CAAC,CAAmC;IAC9D,OAAO,CAAC,oBAAoB,CAAC,CAAiC;IAE9D,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAIvD,oBAAoB,IAAI,iBAAiB,GAAG,IAAI;IAIhD,kBAAkB,CAAC,QAAQ,EAAE,QAAQ;IAIrC,kBAAkB,IAAI,QAAQ;IAU9B,kBAAkB,IAAI,eAAe;IAOrC,eAAe,IAAI,OAAO;IAO1B,sBAAsB,CAAC,SAAS,EAAE;QAChC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;QACzC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;QAC5C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;KAC7C;IASD,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,eAAe;IA6BvB,OAAO,CAAC,kBAAkB;IAmB1B,OAAO,CAAC,sBAAsB;IAUxB,iBAAiB,CACrB,cAAc,EAAE,QAAQ,EACxB,QAAQ,CAAC,EAAE,MAAM,EACjB,IAAI,GAAE,cAA2B,GAChC,OAAO,CAAC,IAAI,CAAC;IAiDV,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"animatedViewportManager.d.ts","sourceRoot":"","sources":["../../../src/canvas/stores/animatedViewportManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAOL,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;AAK9B,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAK5E,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,UAAU,CAAC,EAAE,QAAQ,CAAC;CACvB;AAMD,cAAM,uBAAuB;IAC3B,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,eAAe,CAKrB;IACF,OAAO,CAAC,mBAAmB,CAAC,CAAS;IAGrC,OAAO,CAAC,iBAAiB,CAAC,CAAiC;IAC3D,OAAO,CAAC,kBAAkB,CAAC,CAAmC;IAC9D,OAAO,CAAC,oBAAoB,CAAC,CAAiC;IAE9D,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAIvD,oBAAoB,IAAI,iBAAiB,GAAG,IAAI;IAIhD,kBAAkB,CAAC,QAAQ,EAAE,QAAQ;IAIrC,kBAAkB,IAAI,QAAQ;IAU9B,kBAAkB,IAAI,eAAe;IAOrC,eAAe,IAAI,OAAO;IAO1B,sBAAsB,CAAC,SAAS,EAAE;QAChC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;QACzC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;QAC5C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;KAC7C;IASD,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,eAAe;IA6BvB,OAAO,CAAC,kBAAkB;IAmB1B,OAAO,CAAC,sBAAsB;IAUxB,iBAAiB,CACrB,cAAc,EAAE,QAAQ,EACxB,QAAQ,CAAC,EAAE,MAAM,EACjB,IAAI,GAAE,cAA2B,GAChC,OAAO,CAAC,IAAI,CAAC;IAiDV,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAgExC,gBAAgB,CAAC,cAAc,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC/D,oBAAoB,CAAC,QAAQ,EAAE,QAAQ;IAUvC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAoBhD,gBAAgB;IAUhB,OAAO;CAKR;AAGD,eAAO,MAAM,uBAAuB,yBAAgC,CAAC"}
|
|
@@ -116,8 +116,8 @@ class AnimatedViewportManager {
|
|
|
116
116
|
const nodeBounds = {
|
|
117
117
|
x: node.position.x,
|
|
118
118
|
y: node.position.y,
|
|
119
|
-
width: node.width || 200,
|
|
120
|
-
height: node.height || 100
|
|
119
|
+
width: node.measured?.width || node.width || 200,
|
|
120
|
+
height: node.measured?.height || node.height || 100
|
|
121
121
|
};
|
|
122
122
|
const nodeFocusViewport = calculateNodeFocusViewport(nodeBounds, canvasSize, ANIMATION_CONSTANTS.NODE_FOCUS_PADDING);
|
|
123
123
|
const fromViewport = this.getCurrentViewport();
|
|
@@ -178,8 +178,8 @@ class AnimatedViewportManager {
|
|
|
178
178
|
return {
|
|
179
179
|
x: node.position.x,
|
|
180
180
|
y: node.position.y,
|
|
181
|
-
width: node.width || 200,
|
|
182
|
-
height: node.height || 100
|
|
181
|
+
width: node.measured?.width || node.width || 200,
|
|
182
|
+
height: node.measured?.height || node.height || 100
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
cancelTransition() {
|