I am working on a unique "flow-builder" project and I need to achieve this specific result: https://i.sstatic.net/6TTuS.png
At the moment, my current edge looks like this: https://i.sstatic.net/9ydzx.png
The text on the edge is currently aligned with the edge itself, however, I need it to align differently as shown in the first image
Since I am new to path/textPath, I am struggling to figure this out. Here is the code snippet for my "Edge" component:
import React from 'react';
import { getSmoothStepPath, getMarkerEnd } from 'react-flow-renderer';
export default function DefaultEdge({
id,
sourceX,
sourceY,
targetX,
targetY,
sourcePosition,
targetPosition,
style = {},
data,
arrowHeadType,
markerEndId,
}) {
const edgePath = getSmoothStepPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition });
const markerEnd = getMarkerEnd(arrowHeadType, markerEndId);
return (
<>
<path id={id} style={style} className="react-flow__edge-path" d={edgePath} markerEnd={markerEnd} />
<text>
<textPath href={`#${id}`} style={{ fontSize: '12px' }} startOffset="90%" textAnchor="middle" >
{data?.text || 'default text'}
</textPath>
</text>
</>
);
}