@vanduo-oss/vd3-flowchart 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,77 @@
2
2
 
3
3
  All notable changes to `@vanduo-oss/vd3-flowchart` are documented here.
4
4
 
5
+ ## 1.6.0 — 2026-11-08
6
+
7
+ ### Added
8
+
9
+ - **Theme-adaptive coloring for nodes and edges** (`FLOWCHART_COLOR_PRESETS`):
10
+ 12 presets (`default`, `primary`, `secondary`, `success`, `warning`,
11
+ `danger`, `info`, `violet`, `teal`, `orange`, `pink`, `neutral`) driven by
12
+ `--vd-flowchart-palette-*` light/dark CSS variables, plus optional custom CSS
13
+ color overrides (`fill`, `stroke`, `textColor` on nodes; `color` on edges).
14
+ Edge arrowheads and dot markers inherit the edge color automatically.
15
+ - **Coloring UI & API**: Inspector color swatch grid, custom color inputs, and
16
+ reset action; toolbar quick-color palette popover; and programmatic methods
17
+ `setNodeColor()`, `setEdgeColor()`, `setSelectionColor()`, and
18
+ `clearSelectionColor()`.
19
+ - **Layer order ("Arrange")**: `bringToFront()`, `bringForward()`,
20
+ `sendBackward()`, and `sendToBack()` for nodes, multi-selections, and edges,
21
+ with Inspector controls and keyboard shortcuts (`Cmd/Ctrl + ]`,
22
+ `Cmd/Ctrl + [`, `Cmd/Ctrl + Shift + ]`, `Cmd/Ctrl + Shift + [`).
23
+ - **Multi-selection Align & Distribute**: `alignNodes()`
24
+ (`FLOWCHART_NODE_ALIGNMENTS`: `left`, `center`, `right`, `top`, `middle`,
25
+ `bottom`) and `distributeNodes()` (`FLOWCHART_DISTRIBUTE_AXES`: `horizontal`,
26
+ `vertical`), plus batch color, layer order, and lock controls in the
27
+ multi-selection Inspector.
28
+ - **Edge stroke styles** (`FLOWCHART_EDGE_STROKE_STYLES`): `solid`, `dashed`,
29
+ `dotted`, and `animated` (with `prefers-reduced-motion: reduce` support) via
30
+ `edge.strokeStyle` and the Inspector `Style` selector.
31
+ - **Node locking**: `node.locked`, `setNodeLocked()`, `toggleNodeLocked()`,
32
+ `Cmd/Ctrl + L` shortcut, and SVG lock badge. Locked nodes cannot be dragged,
33
+ resized, nudged, inline-edited, or deleted via `deleteSelection()`.
34
+ - **Standalone SVG export**: `exportSvg({ padding, background })` serializes
35
+ the visible diagram into a cropped, self-contained `<svg>` string with
36
+ inlined colors and stripped interactive handles.
37
+ - **Vue template ref methods**: exposed all new coloring, layer order,
38
+ align/distribute, locking, clipboard (`duplicateSelection`, `copySelection`,
39
+ `pasteClipboard`, `pasteSelection`, `cutSelection`), and `exportSvg` methods
40
+ on `VdFlowchart`.
41
+
42
+ ### Fixed
43
+
44
+ - **Arrowhead endpoint retraction**: curved, straight, and orthogonal edge paths
45
+ now retract their endpoint before start/end markers by the marker's overhang
46
+ plus the target shape's outer stroke offset (including diamond miter vertices),
47
+ so arrow tips meet the shape border cleanly instead of poking underneath the
48
+ node fill.
49
+
50
+ ### Compatibility
51
+
52
+ - `FLOWCHART_DOCUMENT_VERSION` stays `1.3.0`. Uncolored, unlocked, solid-stroke
53
+ nodes and edges omit all new optional fields so default documents serialize
54
+ identically to `1.5.1`. `load()` also accepts `data.color`, `data.fill`,
55
+ `data.stroke`, `data.textColor`, `data.locked`, and `data.strokeStyle`
56
+ fallbacks.
57
+
58
+ ## 1.5.1 — 2026-11-01
59
+
60
+ ### Fixed
61
+
62
+ - Inline text editors for shapes use transparent chrome so circles and diamonds
63
+ keep their SVG silhouette while typing. Textbox, edge, and label editors keep
64
+ an opaque panel.
65
+ - Dark theme idle node strokes lean on the accent color so outlines stay visible
66
+ without hover or selection. Hosts may still override `--vd-flowchart-node-stroke`.
67
+ - The diagram canvas no longer draws a full-viewport focus ring. Mindmap Tab that
68
+ opens a new branch editor skips the intermediate canvas focus flash.
69
+ - Tree layout measures node size. Rank and sibling gaps stay clear of the boxes,
70
+ and a decision with one deep branch keeps that branch on the main spine.
71
+ - Facing orthogonal connectors shorten their stubs when two shapes sit closer
72
+ than two full stubs, so the route does not loop around the pair.
73
+ - Tree layout re-picks ports from the flow: diamond side branches leave the side
74
+ ports, and a reverse loop uses the quieter side of the spine.
75
+
5
76
  ## 1.5.0 — 2026-10-25
6
77
 
7
78
  ### Added
package/README.md CHANGED
@@ -1,14 +1,12 @@
1
1
  # @vanduo-oss/vd3-flowchart
2
2
 
3
+ <a href="https://snyk.io/?utm_source=open-source&utm_medium=pg-ptr&utm_campaign=ref-2501-osp&utm_content=pg-cta"><img src="https://raw.githubusercontent.com/vanduo-oss/vd3-flowchart/main/assets/scanned-by-snyk.png" alt="Scanned by Snyk" width="206" height="141"></a>
4
+
3
5
  [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
4
6
 
5
- Vanduo **flowchart** for Vue 3: a node/edge editor with undo/redo, layout
6
- modes, and a framework-agnostic core. Extracted 1-to-1 from
7
- `@vanduo-oss/vd3-cbun` flowchart **1.2.0**.
7
+ A Vue 3 node and edge editor with undo, layout, and a framework-agnostic core. Peer: `vue >=3.3.0`.
8
8
 
9
- **Status: 1.5.0.** `VD_FLOWCHART_VERSION` tracks the package release.
10
- `FLOWCHART_DOCUMENT_VERSION` (currently `1.3.0`) is the value `toJSON()`
11
- writes. Do not reset either independently without a compatibility plan.
9
+ **Status: 1.6.0.** `VD_FLOWCHART_VERSION` is the package release. `FLOWCHART_DOCUMENT_VERSION` is `1.3.0`, the value `toJSON()` writes. Bump those independently only with a compatibility plan. Guides: [vd3.vanduo.dev](https://vd3.vanduo.dev/). Agents: [SKILL.md](./SKILL.md).
12
10
 
13
11
  ## Install
14
12
 
@@ -16,194 +14,47 @@ writes. Do not reset either independently without a compatibility plan.
16
14
  pnpm add @vanduo-oss/vd3-flowchart
17
15
  ```
18
16
 
19
- `vue >=3.3.0` is a **required** peer dependency (the only runtime dep) — install
20
- it alongside if your project does not already depend on Vue. For correct
21
- theming, also provide the Vanduo `--vd-*` design tokens (see
22
- [Theming](#theming)).
23
-
24
17
  ## Import
25
18
 
26
19
  ```js
27
20
  import {
28
21
  VdFlowchart,
29
- VdFlowchartCore,
30
- computeLayout,
31
- LAYOUT_MODES,
32
- FLOWCHART_NODE_TYPES,
33
22
  VD_FLOWCHART_VERSION,
34
23
  FLOWCHART_DOCUMENT_VERSION,
35
24
  } from '@vanduo-oss/vd3-flowchart';
36
25
  import '@vanduo-oss/vd3-flowchart/css';
37
26
  ```
38
27
 
39
- Named exports only — no default export. `VdFlowchart` is the Vue wrapper; the
40
- editor class is re-exported as `VdFlowchartCore` (same class name upstream).
41
- `computeLayout`, `LAYOUT_MODES`, and the `FLOWCHART_*` tables
42
- (`FLOWCHART_NODE_TYPES`, `FLOWCHART_PORTS`, `FLOWCHART_EDGE_MARKERS`,
43
- `FLOWCHART_EDGE_ROUTES`, `FLOWCHART_KEYBOARD_SHORTCUTS`) ship alongside. The
44
- core does not import Vue.
45
-
46
- `vue` is never bundled — it stays external in both the esm and cjs outputs.
47
- The build emits `dist/meta.json` and **fails** if any input leaves `src/` or
48
- if anything but `vue` is externalized. The package declares
49
- `sideEffects: ["**/*.css"]`.
50
-
51
- ## Version policy
52
-
53
- `package.json` version **is** `VD_FLOWCHART_VERSION` (`1.5.0`). Bump those
54
- together for a package release. Keep `FLOWCHART_DOCUMENT_VERSION` unchanged
55
- unless the serialized schema changes; add fixtures and explicit compatibility
56
- rules for a format change. Unversioned 1.x documents through 1.3.0 still load;
57
- 1.3.0 added the optional node field `collapsed: true`, written only on
58
- collapsed nodes.
59
- Malformed JSON and unsupported future versions throw before the active
60
- document, selection, or history change. This continues the old-line
61
- `@vanduo-oss/flowchart` lineage (never reset to `1.0.0`). Do not reuse the
62
- retired npm name `@vanduo-oss/flowchart`.
63
-
64
- ## Editing and keyboard
65
-
66
- Hover or select a node to show a connection handle outside each side. Drag a
67
- handle to connect; click it to add a connected node in that direction. Resize
68
- from the corner squares or by dragging a side. Dragged nodes snap to other
69
- nodes' edges and centres (hold Alt to bypass; `snapGuides: false` turns it
70
- off). Shift+click or Shift+drag on empty canvas selects several nodes, which
71
- then move, nudge, copy, duplicate, and delete together. A collapsed branch
72
- shows a "+N" badge; click it or press Cmd/Ctrl+/ to toggle. The minimap in
73
- the canvas corner pans the view (`minimap: false` or the toolbar toggle hides
74
- it). Double-click a connection to edit its label. Set `autoLayout: true` to
75
- re-run the current tree or radial layout after each keyboard or handle
76
- insertion.
77
-
78
- With the canvas focused, the default `keyboardShortcuts: 'mindmap'` mode
79
- follows mind-map tools such as XMind and MindNode:
80
-
81
- | Keys | Action |
82
- | --- | --- |
83
- | Arrow keys | Select the nearest node in that direction |
84
- | Shift+Arrow | Select a connection on that side (repeat to cycle) |
85
- | Enter, F2, or typing on a connection | Edit its label |
86
- | Cmd/Ctrl+A | Select all nodes |
87
- | Cmd/Ctrl+/ | Collapse or expand the branch |
88
- | Tab | Add a child node and edit it |
89
- | Enter / Shift+Enter | Add a sibling below / above and edit it |
90
- | F2, Space, or typing | Edit the label |
91
- | Enter / Tab while editing | Save / save and add a child (Shift+Enter: new line) |
92
- | Alt+Arrow (Shift for 1 px) | Nudge the node by one grid step |
93
- | Cmd/Ctrl+D | Duplicate the node |
94
- | Cmd/Ctrl + `=` / `-` / `0`, Shift+1 | Zoom in, out, 100%, fit |
95
- | Esc | Cancel editing, then the tool, then deselect |
96
- | Shift+Tab, or Esc then Tab | Leave the canvas |
97
- | `?` | Show all shortcuts |
98
-
99
- `keyboardShortcuts: 'basic'` keeps Tab for focus movement; Enter or F2 edits and
100
- Ctrl/Cmd+Enter saves. A node plus its edge is one undo step, and naming a
101
- just-inserted node joins that step.
102
-
103
- ## Camera and node bounds
104
-
105
- `minScale` / `maxScale` default to `0.35` / `3`, and `minNodeSize` /
106
- `maxNodeSize` default to `56` / `420`. Pass a finite pair to widen either
107
- range; an invalid pair falls back to those defaults. Junctions stay 28×28.
108
- `fitNode(id, padding)` frames one visible node. Padding is screen pixels.
109
- Scale is stored to four decimal places. Nodes smaller than their default size
110
- scale their text, markers, and routes down with them. The default grid stays
111
- 12,000 units; a wider camera uses a 240,000-unit grid.
112
-
113
- ```js
114
- new VdFlowchartCore({
115
- element: '#editor',
116
- minScale: 0.05,
117
- maxScale: 20,
118
- minNodeSize: 6,
119
- maxNodeSize: 4800,
120
- });
121
- ```
122
-
123
- The same four names are Vue props. The document format is unchanged: scale and
124
- size remain plain numbers.
125
-
126
- ## Theming
127
-
128
- Flowchart chrome renders against Vanduo `--vd-*` design tokens — the same
129
- tokens `@vanduo-oss/vd3` defines — with built-in fallbacks. vd3 is not a
130
- package dependency; any provider of the tokens works.
131
-
132
- ```js
133
- import '@vanduo-oss/vd3/css';
134
- // Same component styles without bundled icon fonts:
135
- import '@vanduo-oss/vd3/css/core';
136
- ```
137
-
138
- `@vanduo-oss/vd3/css/core` is **not** tokens-only. Token JSON is
139
- `@vanduo-oss/vd3/tokens.json`.
28
+ Named exports only. `VdFlowchart` is the Vue wrapper. The editor class is `VdFlowchartCore`. `computeLayout`, `LAYOUT_MODES`, and the `FLOWCHART_*` tables ship alongside and do not import Vue. `vue` stays external. The build fails if anything other than `vue` is externalized.
140
29
 
141
- Tokens consumed include `--vd-bg-primary`, `--vd-bg-secondary`,
142
- `--vd-text-primary`, `--vd-text-muted`, `--vd-border-color`, and
143
- `--vd-color-primary` (via `--vd-flowchart-*` locals).
30
+ Chrome uses Vanduo `--vd-*` tokens, with fallbacks. `@vanduo-oss/vd3` is not a dependency. Import `@vanduo-oss/vd3/css` or `@vanduo-oss/vd3/css/core` once when the app already uses vd3. `/css/core` is not tokens-only; token JSON is `@vanduo-oss/vd3/tokens.json`.
144
31
 
145
32
  ## Security
146
33
 
147
- - **No bundled dependencies** — beyond the `vue` peer, nothing is bundled; the
148
- build fails if any other module is externalized or any `node_modules` input
149
- is bundled.
150
- - **Hardened `.npmrc`:** `ignore-scripts`, `minimum-release-age`, `save-exact`,
151
- `strict-peer-dependencies`, `trust-policy=no-downgrade`,
152
- `block-exotic-subdeps`, and an explicit `registry`.
153
- - **MIT** licensed ([LICENSE](./LICENSE)); toolbar Phosphor paths are inlined
154
- (MIT) so the package vendors no third-party runtime modules.
34
+ This repo is monitored with [Snyk](https://snyk.io/?utm_source=open-source&utm_medium=pg-ptr&utm_campaign=ref-2501-osp&utm_content=pg-cta).
35
+
36
+ - Nothing is bundled beyond the `vue` peer. Toolbar Phosphor paths are inlined (MIT).
37
+ - Hardened `.npmrc`: `ignore-scripts`, `minimum-release-age`, `save-exact`, `strict-peer-dependencies`, `trust-policy=no-downgrade`, `block-exotic-subdeps`, and an explicit `registry`.
38
+ - [MIT](./LICENSE).
155
39
 
156
40
  ## Exports
157
41
 
158
42
  | Export | Contents |
159
43
  | --- | --- |
160
- | `@vanduo-oss/vd3-flowchart` | `VdFlowchart` + `VdFlowchartCore`, layout, `FLOWCHART_*`, `VD_FLOWCHART_VERSION`, `FLOWCHART_DOCUMENT_VERSION` |
44
+ | `@vanduo-oss/vd3-flowchart` | `VdFlowchart`, `VdFlowchartCore`, layout, `FLOWCHART_*`, `VD_FLOWCHART_VERSION`, `FLOWCHART_DOCUMENT_VERSION` |
161
45
  | `@vanduo-oss/vd3-flowchart/css` | Stylesheet (`dist/vd3-flowchart.css`) |
162
46
 
163
- ## Tested interaction envelope
164
-
165
- Observed on a Mac mini (Apple M4, 10 cores, 24 GB, macOS 26.6.2) with
166
- Chromium 153 at 1440×1000, no CPU throttling. Two warmups and ten samples per
167
- synchronous operation; drag used 24 pointer steps. Times include forced layout
168
- and exclude compositor paint. These are observations, not supported-size
169
- guarantees.
170
-
171
- - Graph label edit: 25 / 100 / 250 / 500 nodes → 2.9 / 11.2 / 29.9 / 57 ms.
172
- - Graph undo + redo: 3.6 / 14 / 34.5 / 69.8 ms.
173
- - Graph tree/grid layout: 2.9 / 11.1 / 28.4 / 58.9 ms.
174
- - Graph drag (translate the moved node SVG and rebuild only incident edges): 0.2 / 0.3 / 0.2 / 0.3 ms, down from 1.6 / 4.5 / 10.7 / 20.7 ms before that path.
175
-
176
- Raw JSON: `vd3-docs/reviews/2026-09-16/performance-results.json`.
177
-
178
47
  ## Development
179
48
 
180
- ```sh
181
- pnpm install
182
- pnpm lint # eslint
183
- pnpm format:check # prettier
184
- pnpm stylelint # authored CSS
185
- pnpm test # vitest (jsdom + node)
186
- pnpm build # esbuild harness → dist/
187
- pnpm test:types # tsc --noEmit over tests/types (needs dist/)
188
- pnpm test:e2e # Playwright Chromium (needs dist/)
189
- ```
190
-
191
- `test:types` and `test:e2e` consume the built `dist/` output, so **run
192
- `pnpm build` first**. Chromium must be installed once:
193
- `pnpm exec playwright install chromium`.
194
-
195
- Node 24 LTS is the supported development and CI runtime; run `nvm use` to select
196
- it for this repository from `.nvmrc`. The existing `engines.node >=20.19.0`
197
- range remains a temporary consumer compatibility floor, tested on a best-effort
198
- basis until the next major release; it is not the recommended development
199
- runtime.
49
+ Node 26 LTS (`nvm use` from `.nvmrc`) and pnpm >= 10. `engines.node` `>=20.19.0` is the consumer floor. `pnpm release:check` is the pre-publish gate. `pnpm test:types` and `pnpm test:e2e` need `pnpm build` first. See [CONTRIBUTING.md](./CONTRIBUTING.md).
200
50
 
201
51
  ## Documentation
202
52
 
203
- - Agent / LLM reference — [SKILL.md](./SKILL.md)
204
- - Contributing — [CONTRIBUTING.md](./CONTRIBUTING.md)
205
- - Changelog — [CHANGELOG.md](./CHANGELOG.md)
53
+ - [vd3.vanduo.dev](https://vd3.vanduo.dev/)
54
+ - [SKILL.md](./SKILL.md)
55
+ - [CHANGELOG.md](./CHANGELOG.md)
56
+ - [CONTRIBUTING.md](./CONTRIBUTING.md)
206
57
 
207
58
  ## License
208
59
 
209
- [MIT](./LICENSE) © Vanduo Open Source Foundation
60
+ [MIT](./LICENSE) © Vanduo
package/SKILL.md CHANGED
@@ -29,32 +29,74 @@ describes the package release. Do not replace document versions with app version
29
29
 
30
30
  ## Keyboard
31
31
 
32
- `keyboardShortcuts` defaults to `'mindmap'`: with a node selected on the focused
33
- canvas, Tab adds a child, Enter adds a sibling (Shift+Enter above), and F2, Space,
34
- or typing edits the label. While editing, Enter saves and Tab saves and adds a
35
- child. Arrows select the nearest node in that direction; Alt+Arrow nudges.
36
- Shift+Tab, or Esc then Tab, leaves the canvas. `?` lists every shortcut. Use
37
- `'basic'` when Tab must always move focus; Enter then edits and Ctrl/Cmd+Enter
38
- saves. A node plus its edge, and naming a just-inserted node, undo in one step.
39
- Shift+Arrow selects a connection on that side; Enter, F2, or typing edits its
40
- label. Shift+click, Shift+drag, and Cmd/Ctrl+A select several nodes (the
41
- `select` event lists them in `nodeIds`). Cmd/Ctrl+/ collapses a branch.
32
+ `keyboardShortcuts` defaults to `'mindmap'`. With the canvas focused:
33
+
34
+ | Keys | Action |
35
+ | --- | --- |
36
+ | Arrow keys | Select the nearest node in that direction |
37
+ | Shift+Arrow | Select a connection on that side (repeat to cycle) |
38
+ | Enter, F2, or typing on a connection | Edit its label |
39
+ | Cmd/Ctrl+A | Select all nodes |
40
+ | Cmd/Ctrl+/ | Collapse or expand the branch |
41
+ | Tab | Add a child node and edit it |
42
+ | Enter / Shift+Enter | Add a sibling below / above and edit it |
43
+ | F2, Space, or typing | Edit the label |
44
+ | Enter / Tab while editing | Save / save and add a child (Shift+Enter: new line) |
45
+ | Alt+Arrow (Shift for 1 px) | Nudge the node by one grid step |
46
+ | Cmd/Ctrl+D | Duplicate the node |
47
+ | Cmd/Ctrl + `]` / `[` (Shift for front/back) | Bring forward/front, send backward/back |
48
+ | Cmd/Ctrl+L | Lock or unlock the selected node(s) |
49
+ | Cmd/Ctrl + `=` / `-` / `0`, Shift+1 | Zoom in, out, 100%, fit |
50
+ | Esc | Cancel editing, then the tool, then deselect |
51
+ | Shift+Tab, or Esc then Tab | Leave the canvas |
52
+ | `?` | Show all shortcuts |
53
+
54
+ `'basic'` keeps Tab for focus movement. Enter or F2 edits, and Ctrl/Cmd+Enter saves. A node plus its edge, and naming a just-inserted node, undo in one step. Shift+click, Shift+drag, and Cmd/Ctrl+A select several nodes (`select` lists them in `nodeIds`). Hover or select a node to show connection handles. Drag a handle to connect, or click it to add a node in that direction. Resize from the corner squares or a side. Drags snap to other nodes' edges and centres; hold Alt to bypass. Double-click a connection to edit its label. A collapsed branch shows a "+N" badge.
42
55
 
43
56
  ## Canvas options
44
57
 
45
58
  `snapGuides` (default true) snaps drags to alignment guides; `minimap`
46
59
  (default true) shows the overview; `autoLayout` (default false) re-runs the
47
60
  current tree or radial layout after insertions. Saved JSON uses document
48
- format 1.3.0, which adds `collapsed: true` on collapsed nodes only.
61
+ format 1.3.0, which writes optional `collapsed: true`, `color`, `fill`,
62
+ `stroke`, `textColor`, and `locked: true` on nodes and `color`, `strokeStyle`
63
+ on edges only when non-default.
64
+
65
+ ## Coloring, arrange, locking, and export
66
+
67
+ Nodes and edges adapt to light/dark themes by default and accept named presets
68
+ (`FLOWCHART_COLOR_PRESETS`: `'primary'`, `'secondary'`, `'success'`,
69
+ `'warning'`, `'danger'`, `'info'`, `'violet'`, `'teal'`, `'orange'`, `'pink'`,
70
+ `'neutral'`) or custom CSS colors via `setNodeColor()`, `setEdgeColor()`,
71
+ `setSelectionColor()`, and `clearSelectionColor()`. Reorder z-order with
72
+ `bringToFront()`, `bringForward()`, `sendBackward()`, and `sendToBack()`
73
+ (or Cmd/Ctrl + `]` / `[`). Align and distribute multi-selected nodes with
74
+ `alignNodes()` and `distributeNodes()`, lock nodes with `setNodeLocked()` /
75
+ `toggleNodeLocked()` (Cmd/Ctrl+L), and export standalone SVG markup with
76
+ `exportSvg()`.
49
77
 
50
78
  ## Deep zoom
51
79
 
52
80
  `minScale` and `maxScale` default to `0.35` and `3`. `minNodeSize` and
53
81
  `maxNodeSize` default to `56` and `420`. Pass both ends of a pair to opt into
54
- a wider camera or smaller and larger nodes. Junctions stay fixed-size.
55
- `getInstance().fitNode(id, padding)` frames one visible node. A node smaller
56
- than its default size scales its text, markers, and connectors with it. Saved
57
- JSON stays document format 1.3.0.
82
+ a wider camera or smaller and larger nodes. An invalid pair falls back to those
83
+ defaults. Junctions stay 28×28. `getInstance().fitNode(id, padding)` frames one
84
+ visible node; padding is screen pixels. Scale is stored to four decimal places.
85
+ A node smaller than its default size scales its text, markers, and connectors
86
+ with it. The default grid is 12,000 units; a wider camera uses 240,000. The
87
+ same four names are Vue props. Saved JSON stays document format 1.3.0; scale
88
+ and size remain plain numbers.
89
+
90
+ ## Observed interaction cost
91
+
92
+ These are observations, not supported-size guarantees. Measured on a Mac mini
93
+ (Apple M4, macOS 26) with Chromium at 1440×1000, two warmups and ten samples,
94
+ including forced layout and excluding compositor paint. Graph label edit at
95
+ 25 / 100 / 250 / 500 nodes was about 2.9 / 11.2 / 29.9 / 57 ms. Undo+redo was
96
+ about 3.6 / 14 / 34.5 / 69.8 ms. Tree/grid layout was about 2.9 / 11.1 / 28.4 /
97
+ 58.9 ms. Dragging a node (translate that SVG node and rebuild only incident
98
+ edges) stayed under 1 ms. Raw JSON:
99
+ `vd3-docs/reviews/2026-09-16/performance-results.json`.
58
100
 
59
101
  ## Verification
60
102
 
package/dist/core.d.ts CHANGED
@@ -8,9 +8,25 @@ export type FlowchartNodeType =
8
8
  export type FlowchartPort = 'top' | 'right' | 'bottom' | 'left';
9
9
  export type FlowchartEdgeMarker = 'none' | 'arrow' | 'dot';
10
10
  export type FlowchartEdgeRoute = 'curve' | 'straight' | 'orthogonal';
11
+ export type FlowchartEdgeStrokeStyle = 'solid' | 'dashed' | 'dotted' | 'animated';
11
12
  export type FlowchartEdgeKind = 'line' | 'arrow';
12
13
  export type FlowchartDirection = 'right' | 'left' | 'up' | 'down';
13
14
  export type LayoutMode = 'tree' | 'radial' | 'grid';
15
+ export type FlowchartColorPreset =
16
+ | 'default'
17
+ | 'primary'
18
+ | 'secondary'
19
+ | 'success'
20
+ | 'warning'
21
+ | 'danger'
22
+ | 'info'
23
+ | 'violet'
24
+ | 'teal'
25
+ | 'orange'
26
+ | 'pink'
27
+ | 'neutral';
28
+ export type FlowchartNodeAlignment = 'left' | 'center' | 'right' | 'top' | 'middle' | 'bottom';
29
+ export type FlowchartDistributeAxis = 'horizontal' | 'vertical';
14
30
  /**
15
31
  * `'mindmap'` (default): Tab adds a child, Enter adds a sibling, F2/Space or
16
32
  * typing edits. `'basic'`: Enter edits and Tab moves focus as usual.
@@ -34,6 +50,16 @@ export interface FlowchartNode {
34
50
  data: Record<string, unknown>;
35
51
  /** Present (and true) only on collapsed nodes; document format 1.3.0. */
36
52
  collapsed?: true;
53
+ /** Named theme-adaptive color preset (omitted when `'default'`). */
54
+ color?: Exclude<FlowchartColorPreset, 'default'>;
55
+ /** Custom CSS fill override for the node shape. */
56
+ fill?: string;
57
+ /** Custom CSS stroke override for the node shape. */
58
+ stroke?: string;
59
+ /** Custom CSS fill override for the node text label. */
60
+ textColor?: string;
61
+ /** Present (and true) only when the node is locked against drag/resize/delete. */
62
+ locked?: true;
37
63
  }
38
64
 
39
65
  export interface FlowchartEndpoint {
@@ -52,6 +78,24 @@ export interface FlowchartEdge {
52
78
  route: FlowchartEdgeRoute;
53
79
  label: string;
54
80
  data: Record<string, unknown>;
81
+ /** Named preset or custom CSS color (omitted when default). */
82
+ color?: Exclude<FlowchartColorPreset, 'default'> | string;
83
+ /** Stroke pattern style (omitted when `'solid'`). */
84
+ strokeStyle?: Exclude<FlowchartEdgeStrokeStyle, 'solid'>;
85
+ }
86
+
87
+ export interface FlowchartNodeColorPatch {
88
+ color?: FlowchartColorPreset | string | null;
89
+ fill?: string | null;
90
+ stroke?: string | null;
91
+ textColor?: string | null;
92
+ }
93
+
94
+ export interface ExportSvgOptions {
95
+ /** Padding in world units around visible content (default 32). */
96
+ padding?: number;
97
+ /** Optional background color (`'transparent'`, `'theme'`, or CSS color). */
98
+ background?: string;
55
99
  }
56
100
 
57
101
  export interface FlowchartDocument {
@@ -87,6 +131,11 @@ export interface FlowchartNodeInput {
87
131
  text?: string;
88
132
  data?: Record<string, unknown>;
89
133
  collapsed?: boolean;
134
+ color?: FlowchartColorPreset | string | null;
135
+ fill?: string | null;
136
+ stroke?: string | null;
137
+ textColor?: string | null;
138
+ locked?: boolean;
90
139
  /** Place relative to another node instead of at the viewport center. */
91
140
  relativeTo?: string | FlowchartRelativeTo;
92
141
  }
@@ -108,6 +157,8 @@ export interface FlowchartEdgeInput {
108
157
  strokeWidth?: number;
109
158
  route?: FlowchartEdgeRoute;
110
159
  label?: string;
160
+ color?: FlowchartColorPreset | string | null;
161
+ strokeStyle?: FlowchartEdgeStrokeStyle | null;
111
162
  data?: Record<string, unknown>;
112
163
  }
113
164
 
@@ -292,9 +343,33 @@ export class VdFlowchart {
292
343
  options?: InsertSiblingNodeOptions,
293
344
  ): { node: FlowchartNode; edge: FlowchartEdge | null } | null;
294
345
  duplicateSelection(): FlowchartNode | FlowchartNode[] | null;
346
+ copySelection(): boolean;
347
+ pasteClipboard(): boolean;
348
+ pasteSelection(): FlowchartNode | FlowchartNode[] | null;
349
+ cutSelection(): boolean;
295
350
  /** Collapse or expand a node's branch; undoable, reason `node:collapse`. */
296
351
  setCollapsed(nodeId: string, collapsed: boolean): boolean;
297
352
  toggleCollapsed(nodeId: string): boolean;
353
+ /** Set or clear a node's color preset or custom CSS fill/stroke/textColor. */
354
+ setNodeColor(
355
+ nodeId: string,
356
+ colorOrPatch: FlowchartColorPreset | string | FlowchartNodeColorPatch | null,
357
+ ): FlowchartNode | null;
358
+ /** Set or clear an edge's color preset or custom CSS stroke color. */
359
+ setEdgeColor(
360
+ edgeId: string,
361
+ color: FlowchartColorPreset | string | { color?: string | null; stroke?: string | null } | null,
362
+ ): FlowchartEdge | null;
363
+ /** Apply a color preset or custom color patch to the current selection. */
364
+ setSelectionColor(
365
+ colorOrPatch: FlowchartColorPreset | string | FlowchartNodeColorPatch | null,
366
+ ): this;
367
+ /** Reset the current selection's colors back to the theme default. */
368
+ clearSelectionColor(): this;
369
+ /** Lock or unlock one or more nodes against dragging, resizing, inline editing, and deletion. */
370
+ setNodeLocked(nodeId?: string | string[] | boolean, locked?: boolean): boolean;
371
+ /** Toggle locked state on the specified node(s) or current selection. */
372
+ toggleNodeLocked(nodeId?: string | string[]): boolean;
298
373
  /** Nodes not hidden inside a collapsed branch. */
299
374
  getVisibleNodes(): FlowchartNode[];
300
375
  isNodeHidden(nodeId: string): boolean;
@@ -317,9 +392,15 @@ export class VdFlowchart {
317
392
  removeEdge(edgeId: string): boolean;
318
393
  deleteSelection(): boolean;
319
394
 
320
- // Layout
395
+ // Layout & Arrange (Z-Order, Align, Distribute)
321
396
  layout(mode?: LayoutMode, options?: LayoutOptions): this;
322
397
  autoArrange(options?: LayoutOptions): this;
398
+ bringToFront(targetId?: string | string[]): this;
399
+ bringForward(targetId?: string | string[]): this;
400
+ sendBackward(targetId?: string | string[]): this;
401
+ sendToBack(targetId?: string | string[]): this;
402
+ alignNodes(alignment?: FlowchartNodeAlignment, nodeIds?: string[]): this;
403
+ distributeNodes(axis?: FlowchartDistributeAxis, nodeIds?: string[]): this;
323
404
 
324
405
  // History
325
406
  undo(): this;
@@ -347,10 +428,12 @@ export class VdFlowchart {
347
428
  /** Open, close, or toggle the keyboard shortcuts overlay. */
348
429
  toggleShortcutsHelp(force?: boolean): this;
349
430
 
350
- // Document
431
+ // Document & Export
351
432
  clear(): this;
352
433
  load(data: Partial<FlowchartDocument> | string, options?: LoadOptions): this;
353
434
  toJSON(): FlowchartDocument;
435
+ /** Serialize visible scene to a cropped, standalone `<svg>` string. */
436
+ exportSvg(options?: ExportSvgOptions): string;
354
437
 
355
438
  // Text editing
356
439
  startTextEdit(nodeId: string, options?: StartTextEditOptions): boolean;
@@ -399,4 +482,8 @@ export const FLOWCHART_NODE_TYPES: readonly FlowchartNodeType[];
399
482
  export const FLOWCHART_PORTS: readonly FlowchartPort[];
400
483
  export const FLOWCHART_EDGE_MARKERS: readonly FlowchartEdgeMarker[];
401
484
  export const FLOWCHART_EDGE_ROUTES: readonly FlowchartEdgeRoute[];
485
+ export const FLOWCHART_EDGE_STROKE_STYLES: readonly FlowchartEdgeStrokeStyle[];
486
+ export const FLOWCHART_COLOR_PRESETS: readonly FlowchartColorPreset[];
487
+ export const FLOWCHART_NODE_ALIGNMENTS: readonly FlowchartNodeAlignment[];
488
+ export const FLOWCHART_DISTRIBUTE_AXES: readonly FlowchartDistributeAxis[];
402
489
  export const FLOWCHART_KEYBOARD_SHORTCUTS: readonly FlowchartKeyboardShortcuts[];