synergycodes/ng-diagram/ng-diagram-ports
Claude Code and agent skill by synergycodes/ng-diagram
- community
Checking that the SKILL.md file is still in the repository.
Use when adding ports to ng-diagram nodes (<ng-diagram-port>), edges will not connect or attach at the wrong spot, port positions are stale (invalidateMeasurements), ports must be hidden or removed, or port styling and hover.
Install
npx vskill@latest install synergycodes/ng-diagram/ng-diagram-portsSKILL.md
Ports
Declaring ports in node templates, how they are placed and measured, custom port content, hiding and removing ports, and port styling. Drawing and validating connections is in ng-diagram-linking; node templates in ng-diagram-custom-nodes.
Rules
- Ports live in templates, not in the model. Each
<ng-diagram-port>registers itself, and the library writes the read-onlynode.measuredPorts(id,type,side,nodeId, measuredpositionandsizerelative to the node). Never writemeasuredPorts. Edges point at a port withsourcePort/targetPortplus the node id, so a portidmust be unique within its node only (every default node hasport-leftandport-right). - Inputs:
id(required),type(required:'source' | 'target' | 'both'),side(required:'top' | 'right' | 'bottom' | 'left'),originPoint(default'center'),hidden(since 1.4.0). ImportNgDiagramPortComponent. - `type` sets the direction. A
sourceport can only start a link, atargetport can only receive one,bothcan do both. Other rules belong inlinking.validateConnection(seeng-diagram-linking). - `side` does three jobs. It places the port (middle of the left/right edge, center of the top/bottom edge of its nearest positioned ancestor), it picks the edge anchor (the middle of the port's border on that side; on rotated nodes the side turns in 90° steps), and it sets the direction in which the routed edge leaves. When you move a port with CSS, keep
sidematching where it ends up. - Positions are measured, not computed. Ports are measured again automatically when the port or its node is resized, when the node rotates, and when
sideororiginPointchange. A pure position change (class toggle,top/leftbinding, reordering a port list) is invisible toResizeObserver: callinvalidateMeasurements. - Hide ports with `[hidden]`, not CSS — and only after they were rendered once. A port hidden from its first render is never measured, so its edges are not drawn. Removing a port (
@if,@for) also needs care: edges that still name it stop following the node.
Ports in a node template
Custom content and placement
- Projected content turns off the default circle: the port takes the size of its content and gets the class
custom-content.--ngd-port-sizeaffects only the default circle. originPointchooses which point of the port sits on the side position:topLeft,topCenter,topRight,centerLeft,center,centerRight,bottomLeft,bottomCenter,bottomRight. The custom-ports example page lists names likeleftTop— those do not exist.- Fine-tune placement with an inline
top/leftstyle, as the docs custom-ports example does. An inlinetransformreplaces the translation thatoriginPointapplies, so include it yourself (for exampletransform: translate(-50%, -50%) translateY(4px)).
Ports per row (dynamic port list)
- Adding a port registers and measures it; a growing row list resizes the node, which re-measures all its ports.
- Track
@foritems by a stable id. A port reads itsidwhen it registers, so give a new id through a new port element, not by changing the binding.
Re-measuring ports
invalidateMeasurements(options?)(since 1.2.3) re-measures nodes, ports and edge labels:{ nodes: [{ nodeId }] }re-measures a node and all its ports,{ edges: [{ edgeId }] }the labels of an edge, no argument the whole diagram.- Since 1.3.0 it returns a
Promisethat resolves when the re-measurements have settled, someasuredPortsis fresh on the next line (before 1.3.0 it returnedvoid). Ignoring the promise is fine. - Do not
awaitit inside a transaction (it resolves before the geometry lands) or inside a middleware (the update pipeline is not re-entrant, the await deadlocks). Fire-and-forget is safe there. - Since 1.3.0 an empty
transaction(..., { waitForMeasurements: true })no longer works as a "wait for measurements" barrier. AwaitinvalidateMeasurementsitself.
Ports visible only in edit mode (since 1.4.0)
- Measure before you hide. A port that is
[hidden]from its first render is never measured, and an edge whose port has no geometry is not drawn. That is why the recipe shows the ports during initialization and hides them in(diagramInit). Ports of nodes added later while hidden (or first rendered later by virtualization) have no geometry until they are shown once. - A plain
hiddenattribute (no binding) also means hidden. - A hidden port stays in the DOM with
display: noneand keeps its last measured geometry inmeasuredPorts. It cannot start or receive a link (also throughstartLinking), and the linking preview does not snap to it. - Edges connected to a hidden port stay visible at the port's last measured position. To hide them too, set their own
hiddenflag (seeng-diagram-visibility). - Hidden ports never block initialization or
waitForMeasurements, and are measured again when shown. - The port component sets its own inline
display, so a CSSdisplay: nonerule onng-diagram-portdoes not hide it. Hiding the port's wrapper with CSS is invisible to the library: a port hidden that way at load makes initialization wait for the measurement timeouts (2 to 4 s), and the linking preview can still snap to it.
Removing a port and its edges
Removing a port (@if, @for) deletes it from measuredPorts. An edge that still has that id in sourcePort/targetPort is not routed any more: it keeps its last path and does not follow the node. (The Conditional Visibility docs page says such edges connect to the node instead; 1.4.0 does not do that.) Remove or reconnect such edges in the same step:
To keep an edge and attach that end to the node border instead (a floating end), clear the port: updateEdge(edgeId, { sourcePort: undefined }) (or targetPort). With dangling edges enabled you can also detach the end (see ng-diagram-dangling-edges).
Styling
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-ports/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
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-ports)