Custom Edge
Edges are more than just paths between points. In yh-flow, you can use the #edge slot to fully control the edge rendering process. This allows you to add complex interactive buttons, real-time status labels, or even dynamic fluid effects to your edges.
Advanced Custom Edge Example
In this example, we add a functional button to the center of the edge. Clicking the button allows you to quickly remove the edge or perform other business operations. The demo uses v-model:edges, keeping the parent component synchronized with the canvas edge list after removal.
Edge with Removal Tool
Mechanics
- Slot Data: The
#edgeslot exposes theedgedata object (including computedlabelXandlabelYcoordinates) and a pre-calculated SVGpathcommand string. - SVG Context: Since you are rendering inside an
<svg>element, you should use<g>(group) tags to wrap your path and UI overlays together. - HTML Overlays (foreignObject): To use standard HTML elements (like
divorbutton) inside the SVG, they must be wrapped in a<foreignObject>with definedwidthandheight. - Event Bubbling: Use
@mousedown.stopor@click.stopon your overlay components to prevent theFlowengine from triggering selection or other edge-level click handlers.