When we draw a line on draw.io it provides a feature to shape the line by providing a handle in the middle that can be dragged to adjust the shape of the line. When that handle is dragged two straight lines are created and two more handles appear in the middle of those lines that can also be stretched and so on. When we bring those handles back to their original position the lines began to merge back and handles start disappearing. And all this happens very smoothly. I want to achieve a similar feat in my application and I've built it based on reactflow library. Is it possible to achieve that in reactflow?
I asked for help from chat gpt and it suggested to proceed with something like this-
import React from 'react';
import { Flow, Controls, Position, ReactFlowProvider } from 'react-flow-renderer';
const CustomEdgeHandle = ({ id, position }) => (
<div
id={id}
style={{
position: 'absolute',
background: 'red',
width: 10,
height: 10,
borderRadius: '50%',
transform: `translate(${position.x - 5}px, ${position.y - 5}px)`,
cursor: 'pointer',
}}
/>
);
const CustomEdge = ({ id, sourceX, sourceY, targetX, targetY, ...rest }) => {
const midpoint = {
x: (sourceX + targetX) / 2,
y: (sourceY + targetY) / 2,
};
return (
<>
<div
style={{
position: 'absolute',
transform: `translate(${midpoint.x}px, ${midpoint.y}px)`,
}}
>
<CustomEdgeHandle id={`handle-${id}`} position={midpoint} />
</div>
<div
style={{
position: 'absolute',
pointerEvents: 'none',
}}
>
<div
style={{
position: 'absolute',
border: '1px solid #ddd',
background: '#fff',
transform: `translate(${sourceX}px, ${sourceY}px)`,
width: Math.abs(targetX - sourceX),
height: Math.abs(targetY - sourceY),
}}
/>
</div>
</>
);
};
const CustomFlow = () => {
const elements = [
{ id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 100, y: 100 } },
{ id: '2', type: 'output', data: { label: 'Node 2' }, position: { x: 300, y: 100 } },
{ id: 'e1-2', source: '1', target: '2', animated: true, arrowHeadType: 'arrowclosed',
type: 'customEdge' },
];
const nodeTypes = {
customEdge: CustomEdge,
};
return (
<ReactFlowProvider>
<div style={{ height: '400px', border: '1px solid #ddd' }}>
<Flow elements={elements} nodeTypes={nodeTypes} />
<Controls />
</div>
</ReactFlowProvider>
);
};
export default CustomFlow;


I am unable to comment, you might be looking for slpines: https://github.com/linwe2012/Spline