synergycodes/ng-diagram/ng-diagram-selection-clipboard
Claude Code and agent skill by synergycodes/ng-diagram
- community
- ext:[{"type":"context","description":"Custom context provider definitions"}]
Checking that the SKILL.md file is still in the repository.
Use when handling ng-diagram selection or clipboard - select/deselect, a properties panel, a context menu, box selection, Ctrl/Cmd multi-select, copy/cut/paste of nodes, groups and edges, or pasted content with a wrong position, edges or ids.
Install
npx vskill@latest install synergycodes/ng-diagram/ng-diagram-selection-clipboardSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Selection, clipboard and context menus
Covers reading and changing the selection, the built-in selection gestures, box selection, properties panels, context menus, and copy/cut/paste. Key bindings are in ng-diagram-shortcuts, touch gestures in ng-diagram-touch, event details in ng-diagram-events, selected-state styling in ng-diagram-styling.
Rules
- Selection lives on the elements (
node.selected,edge.selected). Read it withNgDiagramSelectionService.selection()({ nodes, edges }). Change it withselect,deselect,deselectAll,deleteSelection— not by writingselectedyourself. Every method returns a Promise (since 1.3.0);awaitit when the next line depends on the result. - `select(nodeIds, edgeIds)` replaces the selection. Everything not listed gets deselected. To add, pass the union.
deselect(ids)removes only those ids;select()with no ids clears the selection. - `selection()` is a signal over `nodes()`/`edges()`. It refreshes with change detection, so right after
await select(...)or inside a diagram event handler, read the getters (getModel().getNodes().filter((n) => n.selected)) or the event payload. - Hidden elements (since 1.4.0). Users cannot select them (no click, select-all or box selection), but
select()can, and hiding does not deselect.selection()still lists hidden selected elements;deleteSelection(),copy()/cut(), drag and arrow keys skip them. Filter with!n.computedHiddenwhen you build a selection yourself. - Edit through the model service.
updateNodeData(id, data)replacesdataas a whole, so spread the old data. Never changenode.datain place: an update with the same object reference is ignored. - The clipboard is internal and per diagram.
copy()/cut()store a snapshot in the diagram engine, not in the system clipboard. It is not shared between diagrams, and a new model starts with an empty clipboard.paste(position)takes diagram (flow) coordinates.
Built-in gestures (default bindings)
| Gesture | Result | |
|---|---|---|
| Click a node or edge | Selects only that element (on pointerdown) | |
| Click an element that is already selected | Keeps the whole selection, so a multi-selection can be dragged | |
Ctrl/Cmd+click (multiSelection) | Adds or removes that element | |
| Click empty canvas, or start a pan there | Clears the selection (not while Ctrl/Cmd is held) | |
Shift+drag (boxSelection) | Box selection; replaces the selection and also starts on top of nodes | |
Ctrl/Cmd+A (selectAll) | Selects all visible nodes and edges | |
Delete / Backspace (deleteSelection) | Deletes the visible selection; a deleted group takes its content with it | |
| Right-click | Nothing: select the element in your contextmenu handler |
Ctrl on Windows/Linux, Cmd on macOS. Modifiers match exactly, so Ctrl+Shift+drag is neither box nor multi selection. Rebind in ng-diagram-shortcuts; on touch, box selection is a long press (ng-diagram-touch).
Selection toolbar
Inject NgDiagramSelectionService, NgDiagramClipboardService, NgDiagramModelService and NgDiagramViewportService in any component under the same provideNgDiagram().
To show a floating toolbar only after the user has finished selecting (not on pointerdown or while a selection box grows), react to (selectionGestureEnded) instead of reading selection() live; the recipe is in ng-diagram-events.
Properties panel
For edges use updateEdgeData/updateEdge; for several selected nodes, one updateNodes([...]) call.
Context menu
Menu actions call clipboard.copy(), clipboard.cut(), selectionService.deleteSelection() and clipboard.paste(menu.flow). Place the menu absolutely inside a position: relative wrapper around <ng-diagram>. Read references/context-menu.md for the full wiring (state service, canvas menu, menu component, closing, "can paste" check).
Box selection
An edge is box-selected when both ends are inside: an attached end counts when its node is selected by the box; a free end of a dangling edge counts when its anchor point is inside the box (since 1.4.0). Hidden elements are never box-selected. With realtime: true, selectionChanged fires during the drag each time the box content changes; drive UI from selectionGestureEnded.
Copy, cut and paste
copy() takes:
- the visible selected nodes and all their descendants, including the hidden children of a collapsed group (since 1.4.0);
- the visible selected edges, plus every edge between two copied nodes (since 1.4.0). With
danglingEdges.enabled, an edge with one free end travels with its node.
paste(position, options?) creates:
- new ids from the
computeNodeId/computeEdgeIdconfig functions (seeng-diagram-config). Everything else, includingdata, is copied as it is; groupIdpointing to the pasted copy of the group; a node pasted without its group is ungrouped;- edges: an end whose node was copied connects to the new node. An end whose node was not copied becomes a free end (
source/targetis'', the position is insourcePosition/targetPosition) at its old place, moved with the paste — also whendanglingEdges.enabledisfalse(since 1.4.0). Code that expects two nodes on every edge must handle it; reconnect withattachEdge(seeng-diagram-dangling-edges). An edge whose free end has no known position (never routed) is not pasted. Edges withroutingMode: 'manual'keep their shape (since 1.4.0); - placement: a single visible node with no free edge ends is centered on
position; otherwise the average of the visible nodes' top-left corners and the free edge ends lands onposition, so the content sits about half a node right and down of it. Positions snap whensnapping.shouldSnapDragForNodereturnstrue(since 1.2.0); - selection: the old selection is cleared and the pasted visible content is selected. Pasted hidden content stays unselected (since 1.4.0).
cut() is copy() plus deleteSelection() (it fires selectionRemoved); cutting a collapsed group keeps its hidden children for the paste. A paste fires selectionChanged, clipboardPasted { nodes, edges }, then selectionGestureEnded. paste(position, { waitForMeasurements: true }) (since 1.3.0) resolves after the pasted elements are measured, for example before zoomToFit().
Data is copied as it is, so business ids inside data get duplicated. Fix them after the paste:
Edge cases
- Ctrl/Cmd+V pastes at the last mouse position if the mouse moved in the last 5 seconds, even when the mouse was outside the diagram. Otherwise it pastes 20 px right and down from the copied elements, so repeated pastes stack on the same spot.
- The clipboard holds the snapshot from copy time: later edits to the originals are not pasted, and deleted originals can still be pasted.
copy()with nothing selected empties it. initializeModel()andtoJSON()dropselectedfrom nodes, so a saved node selection does not come back. Callselect()afterdiagramInit.- Pressing a port also selects its node, unless
linking.selectNodeOnPortPressisfalse(since 1.2.0).
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-selection-clipboard/SKILL.md
Popularity
- Repository stars
- 583
- Repository forks
- 41
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
contextCustom context provider definitions
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-selection-clipboard)