@vanduo-oss/vd3-flowchart 1.5.1 → 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 +53 -0
- package/README.md +16 -170
- package/SKILL.md +57 -15
- package/dist/core.d.ts +89 -2
- package/dist/index.cjs +1167 -52
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1167 -52
- package/dist/index.js.map +3 -3
- package/dist/meta.json +16 -12
- package/dist/vd3-flowchart.css +496 -0
- package/dist/vue.d.ts +33 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,59 @@
|
|
|
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
|
+
|
|
5
58
|
## 1.5.1 — 2026-11-01
|
|
6
59
|
|
|
7
60
|
### Fixed
|
package/README.md
CHANGED
|
@@ -4,13 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
[](./LICENSE)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
modes, and a framework-agnostic core. Extracted 1-to-1 from
|
|
9
|
-
`@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`.
|
|
10
8
|
|
|
11
|
-
**Status: 1.
|
|
12
|
-
`FLOWCHART_DOCUMENT_VERSION` (currently `1.3.0`) is the value `toJSON()`
|
|
13
|
-
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).
|
|
14
10
|
|
|
15
11
|
## Install
|
|
16
12
|
|
|
@@ -18,197 +14,47 @@ writes. Do not reset either independently without a compatibility plan.
|
|
|
18
14
|
pnpm add @vanduo-oss/vd3-flowchart
|
|
19
15
|
```
|
|
20
16
|
|
|
21
|
-
`vue >=3.3.0` is a **required** peer dependency (the only runtime dep) — install
|
|
22
|
-
it alongside if your project does not already depend on Vue. For correct
|
|
23
|
-
theming, also provide the Vanduo `--vd-*` design tokens (see
|
|
24
|
-
[Theming](#theming)).
|
|
25
|
-
|
|
26
17
|
## Import
|
|
27
18
|
|
|
28
19
|
```js
|
|
29
20
|
import {
|
|
30
21
|
VdFlowchart,
|
|
31
|
-
VdFlowchartCore,
|
|
32
|
-
computeLayout,
|
|
33
|
-
LAYOUT_MODES,
|
|
34
|
-
FLOWCHART_NODE_TYPES,
|
|
35
22
|
VD_FLOWCHART_VERSION,
|
|
36
23
|
FLOWCHART_DOCUMENT_VERSION,
|
|
37
24
|
} from '@vanduo-oss/vd3-flowchart';
|
|
38
25
|
import '@vanduo-oss/vd3-flowchart/css';
|
|
39
26
|
```
|
|
40
27
|
|
|
41
|
-
Named exports only
|
|
42
|
-
editor class is re-exported as `VdFlowchartCore` (same class name upstream).
|
|
43
|
-
`computeLayout`, `LAYOUT_MODES`, and the `FLOWCHART_*` tables
|
|
44
|
-
(`FLOWCHART_NODE_TYPES`, `FLOWCHART_PORTS`, `FLOWCHART_EDGE_MARKERS`,
|
|
45
|
-
`FLOWCHART_EDGE_ROUTES`, `FLOWCHART_KEYBOARD_SHORTCUTS`) ship alongside. The
|
|
46
|
-
core does not import Vue.
|
|
47
|
-
|
|
48
|
-
`vue` is never bundled — it stays external in both the esm and cjs outputs.
|
|
49
|
-
The build emits `dist/meta.json` and **fails** if any input leaves `src/` or
|
|
50
|
-
if anything but `vue` is externalized. The package declares
|
|
51
|
-
`sideEffects: ["**/*.css"]`.
|
|
52
|
-
|
|
53
|
-
## Version policy
|
|
54
|
-
|
|
55
|
-
`package.json` version **is** `VD_FLOWCHART_VERSION` (`1.5.1`). Bump those
|
|
56
|
-
together for a package release. Keep `FLOWCHART_DOCUMENT_VERSION` unchanged
|
|
57
|
-
unless the serialized schema changes; add fixtures and explicit compatibility
|
|
58
|
-
rules for a format change. Unversioned 1.x documents through 1.3.0 still load;
|
|
59
|
-
1.3.0 added the optional node field `collapsed: true`, written only on
|
|
60
|
-
collapsed nodes.
|
|
61
|
-
Malformed JSON and unsupported future versions throw before the active
|
|
62
|
-
document, selection, or history change. This continues the old-line
|
|
63
|
-
`@vanduo-oss/flowchart` lineage (never reset to `1.0.0`). Do not reuse the
|
|
64
|
-
retired npm name `@vanduo-oss/flowchart`.
|
|
65
|
-
|
|
66
|
-
## Editing and keyboard
|
|
67
|
-
|
|
68
|
-
Hover or select a node to show a connection handle outside each side. Drag a
|
|
69
|
-
handle to connect; click it to add a connected node in that direction. Resize
|
|
70
|
-
from the corner squares or by dragging a side. Dragged nodes snap to other
|
|
71
|
-
nodes' edges and centres (hold Alt to bypass; `snapGuides: false` turns it
|
|
72
|
-
off). Shift+click or Shift+drag on empty canvas selects several nodes, which
|
|
73
|
-
then move, nudge, copy, duplicate, and delete together. A collapsed branch
|
|
74
|
-
shows a "+N" badge; click it or press Cmd/Ctrl+/ to toggle. The minimap in
|
|
75
|
-
the canvas corner pans the view (`minimap: false` or the toolbar toggle hides
|
|
76
|
-
it). Double-click a connection to edit its label. Set `autoLayout: true` to
|
|
77
|
-
re-run the current tree or radial layout after each keyboard or handle
|
|
78
|
-
insertion.
|
|
79
|
-
|
|
80
|
-
With the canvas focused, the default `keyboardShortcuts: 'mindmap'` mode
|
|
81
|
-
follows mind-map tools such as XMind and MindNode:
|
|
82
|
-
|
|
83
|
-
| Keys | Action |
|
|
84
|
-
| --- | --- |
|
|
85
|
-
| Arrow keys | Select the nearest node in that direction |
|
|
86
|
-
| Shift+Arrow | Select a connection on that side (repeat to cycle) |
|
|
87
|
-
| Enter, F2, or typing on a connection | Edit its label |
|
|
88
|
-
| Cmd/Ctrl+A | Select all nodes |
|
|
89
|
-
| Cmd/Ctrl+/ | Collapse or expand the branch |
|
|
90
|
-
| Tab | Add a child node and edit it |
|
|
91
|
-
| Enter / Shift+Enter | Add a sibling below / above and edit it |
|
|
92
|
-
| F2, Space, or typing | Edit the label |
|
|
93
|
-
| Enter / Tab while editing | Save / save and add a child (Shift+Enter: new line) |
|
|
94
|
-
| Alt+Arrow (Shift for 1 px) | Nudge the node by one grid step |
|
|
95
|
-
| Cmd/Ctrl+D | Duplicate the node |
|
|
96
|
-
| Cmd/Ctrl + `=` / `-` / `0`, Shift+1 | Zoom in, out, 100%, fit |
|
|
97
|
-
| Esc | Cancel editing, then the tool, then deselect |
|
|
98
|
-
| Shift+Tab, or Esc then Tab | Leave the canvas |
|
|
99
|
-
| `?` | Show all shortcuts |
|
|
100
|
-
|
|
101
|
-
`keyboardShortcuts: 'basic'` keeps Tab for focus movement; Enter or F2 edits and
|
|
102
|
-
Ctrl/Cmd+Enter saves. A node plus its edge is one undo step, and naming a
|
|
103
|
-
just-inserted node joins that step.
|
|
104
|
-
|
|
105
|
-
## Camera and node bounds
|
|
106
|
-
|
|
107
|
-
`minScale` / `maxScale` default to `0.35` / `3`, and `minNodeSize` /
|
|
108
|
-
`maxNodeSize` default to `56` / `420`. Pass a finite pair to widen either
|
|
109
|
-
range; an invalid pair falls back to those defaults. Junctions stay 28×28.
|
|
110
|
-
`fitNode(id, padding)` frames one visible node. Padding is screen pixels.
|
|
111
|
-
Scale is stored to four decimal places. Nodes smaller than their default size
|
|
112
|
-
scale their text, markers, and routes down with them. The default grid stays
|
|
113
|
-
12,000 units; a wider camera uses a 240,000-unit grid.
|
|
114
|
-
|
|
115
|
-
```js
|
|
116
|
-
new VdFlowchartCore({
|
|
117
|
-
element: '#editor',
|
|
118
|
-
minScale: 0.05,
|
|
119
|
-
maxScale: 20,
|
|
120
|
-
minNodeSize: 6,
|
|
121
|
-
maxNodeSize: 4800,
|
|
122
|
-
});
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
The same four names are Vue props. The document format is unchanged: scale and
|
|
126
|
-
size remain plain numbers.
|
|
127
|
-
|
|
128
|
-
## Theming
|
|
129
|
-
|
|
130
|
-
Flowchart chrome renders against Vanduo `--vd-*` design tokens — the same
|
|
131
|
-
tokens `@vanduo-oss/vd3` defines — with built-in fallbacks. vd3 is not a
|
|
132
|
-
package dependency; any provider of the tokens works.
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
import '@vanduo-oss/vd3/css';
|
|
136
|
-
// Same component styles without bundled icon fonts:
|
|
137
|
-
import '@vanduo-oss/vd3/css/core';
|
|
138
|
-
```
|
|
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.
|
|
139
29
|
|
|
140
|
-
`@vanduo-oss/vd3/css/core` is
|
|
141
|
-
`@vanduo-oss/vd3/tokens.json`.
|
|
142
|
-
|
|
143
|
-
Tokens consumed include `--vd-bg-primary`, `--vd-bg-secondary`,
|
|
144
|
-
`--vd-text-primary`, `--vd-text-muted`, `--vd-border-color`, and
|
|
145
|
-
`--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`.
|
|
146
31
|
|
|
147
32
|
## Security
|
|
148
33
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
-
|
|
153
|
-
|
|
154
|
-
is bundled.
|
|
155
|
-
- **Hardened `.npmrc`:** `ignore-scripts`, `minimum-release-age`, `save-exact`,
|
|
156
|
-
`strict-peer-dependencies`, `trust-policy=no-downgrade`,
|
|
157
|
-
`block-exotic-subdeps`, and an explicit `registry`.
|
|
158
|
-
- **MIT** licensed ([LICENSE](./LICENSE)); toolbar Phosphor paths are inlined
|
|
159
|
-
(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).
|
|
160
39
|
|
|
161
40
|
## Exports
|
|
162
41
|
|
|
163
42
|
| Export | Contents |
|
|
164
43
|
| --- | --- |
|
|
165
|
-
| `@vanduo-oss/vd3-flowchart` | `VdFlowchart
|
|
44
|
+
| `@vanduo-oss/vd3-flowchart` | `VdFlowchart`, `VdFlowchartCore`, layout, `FLOWCHART_*`, `VD_FLOWCHART_VERSION`, `FLOWCHART_DOCUMENT_VERSION` |
|
|
166
45
|
| `@vanduo-oss/vd3-flowchart/css` | Stylesheet (`dist/vd3-flowchart.css`) |
|
|
167
46
|
|
|
168
|
-
## Tested interaction envelope
|
|
169
|
-
|
|
170
|
-
Observed on a Mac mini (Apple M4, 10 cores, 24 GB, macOS 26.6.2) with
|
|
171
|
-
Chromium 153 at 1440×1000, no CPU throttling. Two warmups and ten samples per
|
|
172
|
-
synchronous operation; drag used 24 pointer steps. Times include forced layout
|
|
173
|
-
and exclude compositor paint. These are observations, not supported-size
|
|
174
|
-
guarantees.
|
|
175
|
-
|
|
176
|
-
- Graph label edit: 25 / 100 / 250 / 500 nodes → 2.9 / 11.2 / 29.9 / 57 ms.
|
|
177
|
-
- Graph undo + redo: 3.6 / 14 / 34.5 / 69.8 ms.
|
|
178
|
-
- Graph tree/grid layout: 2.9 / 11.1 / 28.4 / 58.9 ms.
|
|
179
|
-
- 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.
|
|
180
|
-
|
|
181
|
-
Raw JSON: `vd3-docs/reviews/2026-09-16/performance-results.json`.
|
|
182
|
-
|
|
183
47
|
## Development
|
|
184
48
|
|
|
185
|
-
|
|
186
|
-
pnpm install
|
|
187
|
-
pnpm lint # eslint
|
|
188
|
-
pnpm format:check # prettier
|
|
189
|
-
pnpm stylelint # authored CSS
|
|
190
|
-
pnpm test # vitest (jsdom + node)
|
|
191
|
-
pnpm build # esbuild harness → dist/
|
|
192
|
-
pnpm test:types # tsc --noEmit over tests/types (needs dist/)
|
|
193
|
-
pnpm test:e2e # Playwright Chromium (needs dist/)
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
`test:types` and `test:e2e` consume the built `dist/` output, so **run
|
|
197
|
-
`pnpm build` first**. Chromium must be installed once:
|
|
198
|
-
`pnpm exec playwright install chromium`.
|
|
199
|
-
|
|
200
|
-
Node 24 LTS is the supported development and CI runtime; run `nvm use` to select
|
|
201
|
-
it for this repository from `.nvmrc`. The existing `engines.node >=20.19.0`
|
|
202
|
-
range remains a temporary consumer compatibility floor, tested on a best-effort
|
|
203
|
-
basis until the next major release; it is not the recommended development
|
|
204
|
-
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).
|
|
205
50
|
|
|
206
51
|
## Documentation
|
|
207
52
|
|
|
208
|
-
-
|
|
209
|
-
-
|
|
210
|
-
-
|
|
53
|
+
- [vd3.vanduo.dev](https://vd3.vanduo.dev/)
|
|
54
|
+
- [SKILL.md](./SKILL.md)
|
|
55
|
+
- [CHANGELOG.md](./CHANGELOG.md)
|
|
56
|
+
- [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
211
57
|
|
|
212
58
|
## License
|
|
213
59
|
|
|
214
|
-
[MIT](./LICENSE) © Vanduo
|
|
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'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
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.
|
|
55
|
-
`getInstance().fitNode(id, padding)` frames one
|
|
56
|
-
|
|
57
|
-
|
|
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[];
|