Edge Renderer
EdgeLabelTemplate draws HTML at each edge's label point, in a layer that is not zoomed - React Flow's EdgeLabelRenderer. Here every edge gets its label as HTML with a button that removes the edge; the labels stay the same size at any zoom.
to B
to C
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry it
- Click the × on an edge's label to remove that edge.
- Scroll to zoom: the edges and nodes grow and shrink, the HTML labels keep their size and stay on their edges.
- Drag a node: each label follows its edge's midpoint.
- Drag from a node's bottom dot to another node's top dot: the new edge gets a × of its own, with no text since it has no label.
- Reset edges puts the two starting edges back.
How it works
EdgeLabelTemplateis aRenderFragment<BlowEdgeContext>rendered once per edge, centred on the edge's label point (LabelX,LabelY) in an overlay that is positioned but not scaled, so the HTML keeps a constant screen size.- While it is set it replaces the built-in SVG labels, which is why the template draws
ctx.Edge.Labelitself. The edge path, its arrowhead and its selection are still drawn by the canvas. - Anything in the label that takes a press carries the
nopanclass (andnodrag), the canvas'sNoPanClassandNoDragClass;BlowEdgeToolbaris a ready-made container that does the same. - The button removes the edge from the
Edgeslist the canvas was given; Reset edges hands it a new list.