feat(example): Add custom edge example
update(example): fit view on custom node example * node selection to use hooks * dev script to use vue-tsc
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { EdgeProps, getBezierPath, getMarkerEnd } from '../../src';
|
||||
import { FunctionalComponent } from 'vue';
|
||||
|
||||
const CustomEdge: FunctionalComponent<EdgeProps> = ({
|
||||
id,
|
||||
sourceX,
|
||||
sourceY,
|
||||
targetX,
|
||||
targetY,
|
||||
sourcePosition,
|
||||
targetPosition,
|
||||
data,
|
||||
arrowHeadType,
|
||||
markerEndId
|
||||
}) => {
|
||||
const edgePath = getBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition });
|
||||
const markerEnd = getMarkerEnd(arrowHeadType, markerEndId);
|
||||
|
||||
return () => (
|
||||
<>
|
||||
<path id={id} class="react-flow__edge-path" d={edgePath} marker-end={markerEnd} />
|
||||
<text>
|
||||
<textPath href={`#${id}`} style={{ fontSize: '12px' }} startOffset="50%" text-anchor="middle">
|
||||
{data.text}
|
||||
</textPath>
|
||||
</text>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default CustomEdge;
|
||||
Reference in New Issue
Block a user