synergycodes/ng-diagram/ng-diagram-config
Claude Code and agent skill by synergycodes/ng-diagram
- community
Checking that the SKILL.md file is still in the repository.
Use when configuring ng-diagram - [config] vs updateConfig(), a config change that has no effect, NgDiagramConfig/FlowConfig keys and defaults, custom node and edge IDs (computeNodeId), edge panning, or debugMode logging.
Install
npx vskill@latest install synergycodes/ng-diagram/ng-diagram-configSKILL.md
ng-diagram configuration
How [config], NgDiagramService.updateConfig() and the config() signal work, which settings apply at runtime, and common setups: custom IDs, edge panning, viewer mode, debug logging. Read references/config-reference.md for every key with its default and its owning skill.
Rules
- Pass only overrides.
NgDiagramConfigis a deep partial ofFlowConfig; every key you leave out keeps its default. - `[config]` is read when the diagram creates its engine: on first render and whenever you bind a new model. Binding a new config object later does not reach the engine. Exception:
hideWatermarkandwatermarkPositionfollow the binding at any time. - Change settings at runtime with `updateConfig(partial)`. It deep-merges into the running config and updates the
config()signal. A new model creates a new engine from[config], soupdateConfig()changes are lost then: keep[config]in sync if you swap models. - Merging: objects merge key by key, but arrays (
shortcuts) and functions replace the old value, andundefinedvalues are skipped. To reset a key, pass its default value. - Let function options read your own state. Callbacks such as
validateConnection,shouldSnapDragForNodeorcanGrouprun on every use, so a callback that reads your signal needs noupdateConfig()and survives model swaps. - Type callback parameters yourself. In 1.4.0 the deep-partial
NgDiagramConfigtype drops the signature of callbacks that take parameters (linking.validateConnection, both edge data builders,resize.getMinNodeSize,grouping.canGroup, the snapping and rotation callbacks): inline parameters become implicitany(TS7006 understrict), and a wrong signature or return type still compiles. Build the section with its own type (const linking: Partial<LinkingConfig> = { ... }, likewisePartial<SnappingConfig>,Partial<ResizeConfig>,Partial<GroupingConfig>,Partial<NodeRotationConfig>): it types the parameters and checks the signature. Annotating the parameters ((node: Node) => ...) only types the body. Optional callbacks (danglingEdges.*) andcomputeNodeId/computeEdgeIdkeep their types. - `config()` is `{}` until just after the first `diagramInit` (still
{}inside that handler), then the full merged config with all defaults. After a model swap it shows the previous engine's config until the new initialization. Its type is a deep partial: use optional chaining.
Config binding and runtime changes
updateConfig() throws [ngDiagram] Library engine not initialized yet. before <ng-diagram> has created its engine (see ng-diagram-model-init).
Keys that are not re-read at runtime
| Key | Read | Change it later by | |
|---|---|---|---|
virtualization.enabled | Rendering and the pan handler: when the engine is created (zoomToFit, the minimap, port cleanup and [ngDiagramHidden] read it live) | New [config] value plus a new model (below); not updateConfig(). | |
edgeRouting.defaultRouting | When the engine is created | NgDiagramService.setDefaultRouting(name), see ng-diagram-edge-routing. | |
zoom.zoomToFit.onInit | When diagramInit fires | [config] before the next model. | |
hideWatermark, watermarkPosition | From the [config] binding only | Changing the bound object; updateConfig() ignores them. | |
viewportPanningEnabled | Behavior: on every gesture. Grab cursor: when the engine is created | updateConfig() changes the behavior; the grab cursor stays as it was. |
Settings used to compute stored results (routing options, zIndex, snapping sizes) apply to what is computed after the change: existing edges keep their path until they or their nodes change.
Change an init-only key (virtualization)
The new model is a full re-initialization (ng-diagram-model-init). Virtualization itself: ng-diagram-performance.
Custom node and edge IDs
computeNodeIdnames nodes dropped from the palette and every pasted node.computeEdgeIdnames every pasted edge and every edge the user draws. A drawn edge gets its id beforelinking.finalEdgeDataBuilderruns, so the builder can still replace it.- Neither is used by
addNodes,addEdgesorinitializeModel: you pass those ids yourself. - Default:
crypto.randomUUID(), orDate.now()plus a random string wherecrypto.randomUUIDis missing (plainhttp://other than localhost). IDs must stay unique: a plain counter restarts after a reload and collides with saved ids.
Edge panning
Dragging near the border of the diagram pans the viewport, faster the closer the pointer is to the border.
selectionMoving.edgePanningEnabled/edgePanningThreshold/edgePanningForce(defaultstrue,30px,10): while dragging nodes. The threshold is also the margin the viewport keeps around nodes moved with the arrow keys.linking.edgePanningEnabled/edgePanningThreshold/edgePanningForce(same defaults): while drawing or relinking an edge.- Both need
viewportPanningEnabled: true.
Panning and dragging switches
viewportPanningEnabled: false(since 0.9.0): no panning with mouse, touch, wheel or trackpad, no arrow-key panning, no edge panning. Zooming and programmatic moves (moveViewport,setViewport,zoomToFit) still work. Seeng-diagram-viewport.nodeDraggingEnabled: false(since 1.0.0): nodes cannot be dragged or moved with the arrow keys; since 1.4.0 the arrow keys pan the viewport instead. For single nodes usedraggable: false(ng-diagram-custom-nodes). Programmatic moves still work.
Viewer (read-only) settings
These flags remove most editing gestures, but they are not a lock: nodes with their own resizable: true or rotatable: true keep their handles, users can still select, and your code can still change the model. With danglingEdges.enabled, also set danglingEdges: { shouldKeepOnDrop: () => false }: the connection validator is not called for a drop on empty canvas, so such a drop still keeps a dangling edge. To block changes for real, cancel them in a middleware. For a runtime read-only toggle that blocks changes (and how to hide ports in it), see ng-diagram-middleware (Read-only mode). Shortcut names: ng-diagram-shortcuts.
Debug logging
debugMode: true logs every committed model update (an update cancelled by a middleware is not logged) as [ngDiagram] <action types> with { initialState, finalState, history, initialUpdate }, and logs render timings ([ngDiagram] Render: +<added> -<removed> nodes (total: <n>): <ms>ms) when the set of rendered nodes changes. It can be switched at runtime with updateConfig({ debugMode: true }). It does not put the engine on window. It logs full state objects on every update, so keep it off in production.
Edge cases
- Settings read through the
config()signal apply only fromdiagramIniton:background,defaultNode.removePorts,resize.defaultResizable,nodeRotation.defaultRotatable,linking.defaultRelinkable. For example, withdefaultNode: { removePorts: true }the default ports exist during the first initialization and disappear right after it. shortcutsis replaced as a whole: build the list withconfigureShortcuts(...), which merges with the defaults. At runtime pass the live list as the second argument,configureShortcuts(changes, diagram.config().shortcuts as ShortcutDefinition[]), or earlier changes reset to the defaults (ng-diagram-shortcuts).- Every new engine starts from
[config]; middlewares and custom routings registered at runtime are dropped too (ng-diagram-model-init).
Symptom → fix
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-config/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-config)