feat(edges): render edge labels as HTML with labelHtml - #82
Open
webard wants to merge 1 commit into
Open
Conversation
Edge labels are written with `textContent`, so anything but plain text shows as the tags themselves — a label that wants a line break, an icon or a piece of emphasis has no way to ask for one, and `white-space: pre-wrap` on `.flow-edge-label` only reaches newlines that were typed. `labelHtml: true` on an edge switches its labels to `innerHTML`. It covers all three positions (`label`, `labelStart`, `labelEnd`), because they are one decision about one edge, and defaults to off, so nothing renders differently until an edge asks. The value is trusted the way any framework trusts HTML it is handed; the type's docstring and the labels page both say to sanitise user input first. Both branches skip a write when the DOM already holds the string, so the label block still costs nothing on the effect re-runs that don't change it.
webard
force-pushed
the
feat/edge-label-html
branch
from
August 10, 2026 11:03
2772411 to
3ccb459
Compare
This was referenced Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
An edge can now ask for its labels to be rendered as HTML:
Why
ensureLabelwrites label text withtextContent, so anything but plain text shows as the tags themselves. A label that wants a line break, a small icon, or a piece of emphasis has no way to ask for one —white-space: pre-wrapon.flow-edge-labelonly reaches newlines that were actually typed, and the label div is already an HTML element, so the capability is there, just not reachable.Where this came from: a workflow editor where the line between two nodes carries the reason the branch exists ("over the credit limit / and no manager on shift"). Two short lines read far better than one long one, and the editor writes those labels itself.
Shape
labelHtml?: booleanonFlowEdge, default off — nothing renders differently until an edge asks.label,labelStart,labelEnd): one decision about one edge, not three flags.innerHTMLunchanged and is trusted the way any framework trusts HTML it is handed. The docstring on the type and the labels page both say to sanitise user input first.Tests
Three cases in
src/plugin/directives/flow-edge.test.ts(the existingmountEdgesharness, with the container marked as the viewport so labels have somewhere to land):labelHtml: truerenders real elements;labelStart/labelEndtoo.The two HTML cases fail against
devwithout the source change.npm run test— 187 files, 3035 tests, all passing.dist/is not rebuilt here — source and docs only, so the diff stays reviewable. I had pushed a rebuild commit and have since dropped it (force-push); the build is yours to cut at release time.Not included
No version bump, no
CHANGELOG.mdentry, nodist/rebuild, no new dependencies — the changelog has no Unreleased section and releases are cut by the maintainer, so I left that to the release commit. Happy to add an entry if you'd rather have it in the PR.