synergycodes/ng-diagram/ng-diagram-edge-relinking
Claude Code and agent skill by synergycodes/ng-diagram
- community
- ext:[{"type":"template","description":"Custom templates for code generation"}]
Checking that the SKILL.md file is still in the repository.
Use when users should reconnect existing ng-diagram edges by dragging their ends - defaultRelinkable or per-edge relinkable, relink handles not showing, validating with reason 'relink', edgeRelinkEnded, or styling relink handles.
Install
npx vskill@latest install synergycodes/ng-diagram/ng-diagram-edge-relinkingSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Edge relinking
Reconnecting the ends of existing edges by dragging handles (since 1.4.0): enabling it, choosing which edges and ends move, validation, events, handle styling and custom templates. Drawing new edges is in ng-diagram-linking. Dropping an end on empty canvas to free it needs ng-diagram-dangling-edges.
Rules
- Relinking is off by default.
linking.defaultRelinkablesets the default for all edges; an edge's ownrelinkableoverrides it. To switch it at runtime callNgDiagramService.updateConfig({ linking: { defaultRelinkable: true } }): the[config]binding is read only when the diagram engine is created. - Handles show only on a selected edge that has a routed path and is drawn by
<ng-diagram-base-edge>, in the default and in custom templates. Draw previews never have handles. There is no public directive for building your own handles. - Lock edges with
relinkable, not with the validator. A validatorfalseonly refuses the port under the pointer, after the user has already grabbed the handle. - A drop on a port the end can take goes through
linking.validateConnectionwithcontext.reason === 'relink',context.edgeandcontext.end. Thesourceortargetargument isnullwhen the other end of the edge is free. - The model does not change during the drag. A reverted relink leaves the edge exactly as it was.
- Keep
zIndex.enabledandzIndex.elevateOnSelectionon (the defaults). Handles are part of the edge, and without elevation a node can cover them.
Effective value (edge.relinkable ?? linking.defaultRelinkable) | Source end | Target end | |
|---|---|---|---|
true | yes | yes | |
'source' | yes | no | |
'target' | no | yes | |
false (default) | no | no |
Enable relinking and choose which ends move
The opposite setup also works: keep defaultRelinkable: false and give only some edges relinkable: true. finalEdgeDataBuilder runs only for drawn edges; loaded, added and pasted edges keep their own relinkable. Partial<LinkingConfig> gives the callbacks their parameter types (see ng-diagram-linking).
Drop outcomes
| Drop | Result | edgeRelinkEnded | |
|---|---|---|---|
| On a port the end can take, validator passes | Reconnected to that node and port | success: true, target, targetPort | |
On empty canvas, with danglingEdges.enabled and shouldKeepOnDrop allowing it | End freed at the drop point (dangling) | success: true, no target | |
| On empty canvas otherwise | Reverted | reason: 'noTarget' | |
| On a port with the wrong direction, or the port of the other end | Reverted, validator not called | reason: 'invalidConnection' | |
Validator returns false | Reverted | reason: 'invalidConnection' | |
| Back on the original port | Nothing changes | reason: 'cancelled' | |
Escape, cancelActiveInteraction(), a second touch gesture, a lost pointer, or the other end's node hidden meanwhile | Reverted | reason: 'cancelled' |
Hidden nodes and ports are not drop targets: a drop over them counts as a drop on empty canvas, so with dangling edges on, the end is freed there. (The EdgeRelinkCancelReason TSDoc and the relinking guide say invalidConnection for hidden targets; the code treats the drop as empty canvas.)
React to relinks
edgeRelinkStartedcarriesedge(a snapshot at gesture start) andend. It fires once the pointer has moved about 5 px; a click on a handle does nothing and fires no events.edgeRelinkEndedalso carriespreviousNode/previousPort(the end was connected) orpreviousPosition(the end was free), anddropPositionin flow coordinates.edgeis the changed edge on success and the unchanged snapshot on failure.- A relink never fires
edgeDrawEndedoredgeDrawn.
Custom edge templates and relinking from code
- Handles sit at the first and last point of the edge you pass to
[edge], so they follow a path computed in your template. isEdgeEndRelinkable(edge, end, defaultRelinkable)(since 1.4.0) returns the effective value for one end.attachEdge(since 1.4.0) checks the node and port like a drop and returnsfalsewhen it refuses. WithoutportIdthe end attaches to the node border (a floating end), which a drag cannot do: drags snap only to ports.
Style the handles
Theme variables (set them on :root or ng-diagram): --ngd-relink-handle-size (default 0.75rem), --ngd-relink-handle-stroke-width (0.1875rem), --ngd-relink-handle-halo-size (0.25rem), --ngd-relink-handle-fill, --ngd-relink-handle-fill-hover, --ngd-relink-handle-fill-drag, --ngd-relink-handle-stroke, --ngd-relink-handle-stroke-hover, --ngd-relink-handle-stroke-drag, --ngd-relink-handle-halo-color-hover, --ngd-relink-handle-halo-color-drag.
Per edge, use the same names with the --edge-relink-handle- prefix on ng-diagram-base-edge. Each state has its own variable, so set the hover and drag colors together with the default ones:
Each handle has an invisible grab area 24 screen pixels wide at every zoom level; hovering it shows the halo.
Edge cases
- While an end is dragged, the original edge is hidden and a preview stands in for it. The preview copies the edge's
type,data,routing, arrowheads and labels, then passes throughlinking.temporaryEdgeDataBuilder, so a builder that forcestypeorroutingalso changes relink previews. - Relinking uses the same
portSnapDistanceand edge panning settings as drawing. - The preview does not copy
routingModeandpoints, so a manual-routing edge previews as an automatic path. After the drop it keeps its waypoints, and only the stored end point moves onto the new port. - An edge whose other end is free (dangling) can be relinked; the validator then gets
nullfor that end.
Symptom → fix
| Symptom | Cause and fix | |
|---|---|---|
| No handles on a selected edge | The effective value is false (set defaultRelinkable or relinkable), the edge has no routed path yet, or the config was changed through the [config] binding after init (use updateConfig). | |
| A raw SVG edge template has no handles | Handles come only from <ng-diagram-base-edge>. Render it in the template. | |
| Handles are hidden under nodes | zIndex.enabled or zIndex.elevateOnSelection is false. Turn them back on. | |
| Users can drag ends of edges that a validator "locks" | The validator only judges where an end may land; it never stops the drag. Use relinkable: false or 'source'/'target'. | |
TypeError on source.id in validateConnection during a relink | The other end is free, so source (or target) is null. Use source?.id. | |
A drop on empty canvas always reverts with noTarget | Dangling edges are off, or shouldKeepOnDrop returned false (ng-diagram-dangling-edges). | |
| The relink preview looks different from the edge | temporaryEdgeDataBuilder overwrites type/routing (keep fields the preview brings, e.g. routing: edge.routing ?? 'bezier'), or the edge uses routingMode: 'manual' (the preview is routed automatically). | |
edgeRelinkEnded.target is a source node | target is the new node of the dragged end; check event.end. | |
| An end cannot be dropped onto a node without ports | Drags snap only to ports. Use attachEdge(edgeId, end, nodeId). |
Verify before you answer
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/ng-diagram-edge-relinking/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
templateCustom templates for code generation
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/synergycodes/ng-diagram/ng-diagram-edge-relinking)