@bian-womp/spark-workbench 0.3.21 → 0.3.22
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/lib/cjs/index.cjs +39 -13
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/misc/SelectionBoundOverlay.d.ts.map +1 -1
- package/lib/cjs/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/lib/esm/index.js +39 -13
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/misc/SelectionBoundOverlay.d.ts.map +1 -1
- package/lib/esm/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionBoundOverlay.d.ts","sourceRoot":"","sources":["../../../../src/misc/SelectionBoundOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SelectionBoundOverlay.d.ts","sourceRoot":"","sources":["../../../../src/misc/SelectionBoundOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEnE,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC3C,SAAS,EAAE;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAChD,UAAU,EAAE,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;IACjD,YAAY,EAAE,MAAM,CAAC;CACtB,CAgGA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkbenchCanvas.d.ts","sourceRoot":"","sources":["../../../../src/misc/WorkbenchCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,EA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const SelectionBoundOverlay = ({ selection, rfInstance, viewportTick }) => {
|
|
5797
|
+
const overlayRef = useRef(null);
|
|
5798
|
+
const [parentRect, setParentRect] = useState(null);
|
|
5799
|
+
useEffect(() => {
|
|
5800
|
+
if (!overlayRef.current)
|
|
5801
|
+
return;
|
|
5802
|
+
const parent = overlayRef.current.parentElement;
|
|
5803
|
+
if (!parent)
|
|
5804
|
+
return;
|
|
5805
|
+
const updateRect = () => {
|
|
5806
|
+
setParentRect(parent.getBoundingClientRect());
|
|
5807
|
+
};
|
|
5808
|
+
updateRect();
|
|
5809
|
+
const resizeObserver = new ResizeObserver(updateRect);
|
|
5810
|
+
resizeObserver.observe(parent);
|
|
5811
|
+
const scrollHandler = () => updateRect();
|
|
5812
|
+
window.addEventListener("scroll", scrollHandler, true);
|
|
5813
|
+
return () => {
|
|
5814
|
+
resizeObserver.disconnect();
|
|
5815
|
+
window.removeEventListener("scroll", scrollHandler, true);
|
|
5816
|
+
};
|
|
5817
|
+
}, [viewportTick]);
|
|
5797
5818
|
const selectionBounds = useMemo(() => {
|
|
5798
5819
|
if (typeof document === "undefined" ||
|
|
5799
5820
|
!rfInstance ||
|
|
5821
|
+
!parentRect ||
|
|
5800
5822
|
selection.nodes.length < 2) {
|
|
5801
5823
|
return null;
|
|
5802
5824
|
}
|
|
@@ -5806,31 +5828,35 @@ const SelectionBoundOverlay = ({ selection, rfInstance, viewportTick }) => {
|
|
|
5806
5828
|
if (!el)
|
|
5807
5829
|
continue;
|
|
5808
5830
|
const rect = el.getBoundingClientRect();
|
|
5831
|
+
const relativeLeft = rect.left - parentRect.left;
|
|
5832
|
+
const relativeTop = rect.top - parentRect.top;
|
|
5833
|
+
const relativeRight = rect.right - parentRect.left;
|
|
5834
|
+
const relativeBottom = rect.bottom - parentRect.top;
|
|
5809
5835
|
if (!bounds) {
|
|
5810
5836
|
bounds = {
|
|
5811
|
-
left:
|
|
5812
|
-
top:
|
|
5813
|
-
right:
|
|
5814
|
-
bottom:
|
|
5837
|
+
left: relativeLeft,
|
|
5838
|
+
top: relativeTop,
|
|
5839
|
+
right: relativeRight,
|
|
5840
|
+
bottom: relativeBottom,
|
|
5815
5841
|
};
|
|
5816
5842
|
}
|
|
5817
5843
|
else {
|
|
5818
|
-
bounds.left = Math.min(bounds.left,
|
|
5819
|
-
bounds.top = Math.min(bounds.top,
|
|
5820
|
-
bounds.right = Math.max(bounds.right,
|
|
5821
|
-
bounds.bottom = Math.max(bounds.bottom,
|
|
5844
|
+
bounds.left = Math.min(bounds.left, relativeLeft);
|
|
5845
|
+
bounds.top = Math.min(bounds.top, relativeTop);
|
|
5846
|
+
bounds.right = Math.max(bounds.right, relativeRight);
|
|
5847
|
+
bounds.bottom = Math.max(bounds.bottom, relativeBottom);
|
|
5822
5848
|
}
|
|
5823
5849
|
}
|
|
5824
5850
|
return bounds;
|
|
5825
|
-
}, [selection.nodes, rfInstance, viewportTick]);
|
|
5851
|
+
}, [selection.nodes, rfInstance, viewportTick, parentRect]);
|
|
5826
5852
|
if (!selectionBounds || selection.nodes.length < 2) {
|
|
5827
|
-
return
|
|
5853
|
+
return jsx("div", { ref: overlayRef, style: { display: "none" } });
|
|
5828
5854
|
}
|
|
5829
5855
|
const { left, top, right, bottom } = selectionBounds;
|
|
5830
5856
|
const width = right - left;
|
|
5831
5857
|
const height = bottom - top;
|
|
5832
|
-
return (jsx("div", { style: {
|
|
5833
|
-
position: "
|
|
5858
|
+
return (jsx("div", { ref: overlayRef, style: {
|
|
5859
|
+
position: "absolute",
|
|
5834
5860
|
left: `${left}px`,
|
|
5835
5861
|
top: `${top}px`,
|
|
5836
5862
|
width: `${width}px`,
|
|
@@ -6493,7 +6519,7 @@ const WorkbenchCanvasComponent = React.forwardRef((props, ref) => {
|
|
|
6493
6519
|
return () => off();
|
|
6494
6520
|
}, [wb]);
|
|
6495
6521
|
const { onInit: userOnInit, ...restReactFlowProps } = reactFlowProps || {};
|
|
6496
|
-
return (jsxs("div", { className: "w-full h-full", onContextMenu: onContextMenu, children: [jsxs(ReactFlowProvider, { children: [jsxs(ReactFlow, { ...restReactFlowProps, nodes: throttled.nodes, edges: throttled.edges, nodeTypes: nodeTypes, edgeTypes: edgeTypes, connectionLineComponent: connectionLineRenderer, selectionOnDrag: true, onInit: (inst) => {
|
|
6522
|
+
return (jsxs("div", { className: "w-full h-full relative overflow-hidden", onContextMenu: onContextMenu, children: [jsxs(ReactFlowProvider, { children: [jsxs(ReactFlow, { ...restReactFlowProps, nodes: throttled.nodes, edges: throttled.edges, nodeTypes: nodeTypes, edgeTypes: edgeTypes, connectionLineComponent: connectionLineRenderer, selectionOnDrag: true, onInit: (inst) => {
|
|
6497
6523
|
rfInstanceRef.current = inst;
|
|
6498
6524
|
const savedViewport = wb.getViewport();
|
|
6499
6525
|
if (savedViewport) {
|