diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 0915a456..60a8451f 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -22,6 +22,7 @@ export { getNodePositionWithOrigin, } from './utils/graph'; export { applyNodeChanges, applyEdgeChanges } from './utils/changes'; +export { createNodeInternals } from './store/utils'; export { getMarkerEnd } from './components/Edges/utils'; export { default as ReactFlowProvider } from './components/ReactFlowProvider'; export { default as Panel } from './components/Panel'; diff --git a/packages/node-resizer/src/ResizeControl.tsx b/packages/node-resizer/src/ResizeControl.tsx index b57f021a..832cd647 100644 --- a/packages/node-resizer/src/ResizeControl.tsx +++ b/packages/node-resizer/src/ResizeControl.tsx @@ -8,6 +8,8 @@ import { NodeChange, NodePositionChange, NodeDimensionChange, + applyNodeChanges, + createNodeInternals, } from '@reactflow/core'; import type { Dimensions, Node, XYPosition } from '@reactflow/core'; @@ -56,7 +58,7 @@ function ResizeControl({ nodeElementRef.current = document.querySelector(`.react-flow__node[data-id="${nodeId}"]`) as HTMLDivElement; }) .on('drag', (event: ResizeDragEvent) => { - const { updateNodePositions, nodeInternals, onNodesChange } = store.getState(); + const { updateNodePositions, nodeInternals, onNodesChange, hasDefaultNodes, nodeOrigin } = store.getState(); const pointerPos = getPointerPosition(event); const nodeEl = nodeElementRef.current; const node = nodeInternals.get(nodeId); @@ -109,6 +111,12 @@ function ResizeControl({ } if (changes.length) { + if (hasDefaultNodes) { + const nodes = applyNodeChanges(changes, Array.from(nodeInternals.values())); + const nextNodeInternals = createNodeInternals(nodes, nodeInternals, nodeOrigin); + store.setState({ nodeInternals: nextNodeInternals }); + } + onNodesChange?.(changes); } }