@vanduo-oss/vd3-flowchart 1.2.0 → 1.4.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,93 @@
2
2
 
3
3
  All notable changes to `@vanduo-oss/vd3-flowchart` are documented here.
4
4
 
5
+ ## 1.4.0 — 2026-10-03
6
+
7
+ ### Changed
8
+
9
+ - **Behavior change:** with the new default `keyboardShortcuts: 'mindmap'`,
10
+ Enter on a selected node adds a sibling; F2, Space, or typing edits the
11
+ label. While editing, Enter saves (Shift+Enter: new line; textbox nodes keep
12
+ Enter for a new line). Use `keyboardShortcuts: 'basic'` for the 1.3.0 keys.
13
+ - Arrow keys select the nearest node in that direction instead of cycling
14
+ through document order.
15
+ - Selected nodes no longer draw side resize dots; sides resize by dragging the
16
+ edge. Corner handles are squares on a slightly outset frame.
17
+ - Connection handles sit outside each side, appear on hover as well as on
18
+ selection, and no longer shift on hover (the scale transform used the node
19
+ origin).
20
+ - **Document format 1.3.0:** nodes may carry `collapsed: true` (written only
21
+ on collapsed nodes). Every 1.x document through 1.3.0 still loads; packages
22
+ older than 1.4.0 reject 1.3.0 files as a future version.
23
+ - Double-clicking a connection edits its label instead of entering reconnect
24
+ mode (a single click already shows the reconnect endpoints).
25
+ - The `select` event payload adds `nodeIds`; `selection` keeps its shape.
26
+
27
+ ### Added
28
+
29
+ - `keyboardShortcuts` option and Vue prop (`'mindmap' | 'basic'`) with
30
+ `FLOWCHART_KEYBOARD_SHORTCUTS`. Mind-map keys: Tab adds a child, Enter /
31
+ Shift+Enter add a sibling below / above, Tab while editing saves and adds a
32
+ child. All modes: Alt+Arrow nudge (Shift for 1 px), Cmd/Ctrl+D duplicate,
33
+ Cmd/Ctrl + `=` / `-` / `0` zoom, Shift+1 fit, staged Esc, and a `?` overlay
34
+ (also on the toolbar). Shift+Tab is never captured.
35
+ - Clicking a connection handle adds a connected node in that direction and
36
+ opens it for editing; dragging still connects.
37
+ - `insertBranchNode()`, `insertSiblingNode()`, `navigateSelection()`,
38
+ `nudgeNode()`, `duplicateSelection()`, `zoomTo()`, `revealNode()`, and
39
+ `toggleShortcutsHelp()`; `startTextEdit()` accepts `{ initialText }`.
40
+ - Dashed selection frame for circle, diamond, and label nodes.
41
+ - Multi-select: Shift+click toggles, Shift+drag on empty canvas draws a
42
+ marquee, Cmd/Ctrl+A selects all. Groups drag, nudge, copy, cut, paste,
43
+ duplicate (with internal connections), and delete as one undo step each.
44
+ `selectNodes()`, `toggleNodeSelection()`, `getSelectedNodeIds()`,
45
+ `isNodeSelected()`, `nudgeNodes()`.
46
+ - Collapsible branches with a "+N" badge, a "−" toggle on a selected parent,
47
+ and Cmd/Ctrl+/; hidden nodes are skipped by navigation, fit, minimap,
48
+ guides, connection targets, and selection. `setCollapsed()`,
49
+ `toggleCollapsed()`, `getVisibleNodes()`, `isNodeHidden()`.
50
+ - Connection labels from the keyboard: Shift+Arrow selects a node's connection
51
+ on that side (repeat to cycle); Enter, F2, or typing edits inline; arrows
52
+ move to the end nodes. `startEdgeLabelEdit()`, `selectSideEdge()`.
53
+ - Alignment guides while dragging, with Alt to bypass; `snapGuides` option.
54
+ - Minimap with click/drag panning, a toolbar toggle, and the `minimap` option;
55
+ it hides on canvases narrower than 480px. `setMinimapEnabled()`,
56
+ `centerViewOn()`.
57
+ - `autoLayout` option: re-run the current tree or radial layout after
58
+ keyboard or handle insertions, in the same undo step.
59
+
60
+ ### Fixed
61
+
62
+ - A node and its edge from `addChildNode()`, a handle click, or the keyboard
63
+ undo in one step; naming a just-inserted node joins that step. New branch
64
+ edges copy the sibling's or parent's edge style.
65
+ - Deleting a node from the keyboard selects its parent.
66
+ - The palette "Shapes" title no longer wraps mid-word in narrow columns.
67
+ - Inserted sibling connections keep sibling order for tree and radial layouts.
68
+ - The label editor no longer re-selects text that the user has already
69
+ started typing.
70
+
71
+ ## 1.3.0 — 2026-09-17
72
+
73
+ ### Added
74
+
75
+ - Keyboard canvas navigation (arrows, Home/End, Enter to edit) and a native
76
+ **Graph outline** with labelled Edit/Connect controls.
77
+ - `FLOWCHART_DOCUMENT_VERSION` owns saved `version`. Package release stays on
78
+ `VD_FLOWCHART_VERSION`.
79
+
80
+ ### Fixed
81
+
82
+ - Option updates (read-only, grid, history) keep the live editor, camera,
83
+ selection, and applicable history. Parent echoes of emitted documents do
84
+ not loop.
85
+ - Malformed JSON and unsupported future documents throw before the active
86
+ document, selection, or history change. Unversioned input and numeric or
87
+ shortened 1.x versions through 1.2.0 still load.
88
+ - Graph outline refuses self-connection.
89
+ - Node drag translates the moved SVG node and rebuilds only incident edges;
90
+ pointer-up still records history.
91
+
5
92
  ## 1.2.0 — 2026-09-13
6
93
 
7
94
  Extracted from `@vanduo-oss/vd3-cbun@1.4.2` as a standalone package. Component
package/README.md CHANGED
@@ -6,8 +6,9 @@ Vanduo **flowchart** for Vue 3: a node/edge editor with undo/redo, layout
6
6
  modes, and a framework-agnostic core. Extracted 1-to-1 from
7
7
  `@vanduo-oss/vd3-cbun` flowchart **1.2.0**.
8
8
 
9
- **Status: 1.2.0.** `VD_FLOWCHART_VERSION` matches the package version and is
10
- **load-bearing** — `toJSON()` writes it into user documents. Do not reset it.
9
+ **Status: 1.4.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.
11
12
 
12
13
  ## Install
13
14
 
@@ -30,6 +31,7 @@ import {
30
31
  LAYOUT_MODES,
31
32
  FLOWCHART_NODE_TYPES,
32
33
  VD_FLOWCHART_VERSION,
34
+ FLOWCHART_DOCUMENT_VERSION,
33
35
  } from '@vanduo-oss/vd3-flowchart';
34
36
  import '@vanduo-oss/vd3-flowchart/css';
35
37
  ```
@@ -38,7 +40,8 @@ Named exports only — no default export. `VdFlowchart` is the Vue wrapper; the
38
40
  editor class is re-exported as `VdFlowchartCore` (same class name upstream).
39
41
  `computeLayout`, `LAYOUT_MODES`, and the `FLOWCHART_*` tables
40
42
  (`FLOWCHART_NODE_TYPES`, `FLOWCHART_PORTS`, `FLOWCHART_EDGE_MARKERS`,
41
- `FLOWCHART_EDGE_ROUTES`) ship alongside. The core does not import Vue.
43
+ `FLOWCHART_EDGE_ROUTES`, `FLOWCHART_KEYBOARD_SHORTCUTS`) ship alongside. The
44
+ core does not import Vue.
42
45
 
43
46
  `vue` is never bundled — it stays external in both the esm and cjs outputs.
44
47
  The build emits `dist/meta.json` and **fails** if any input leaves `src/` or
@@ -47,10 +50,55 @@ if anything but `vue` is externalized. The package declares
47
50
 
48
51
  ## Version policy
49
52
 
50
- `package.json` version **is** `VD_FLOWCHART_VERSION` (`1.2.0`). Bump both
51
- together, and only when the serialized document format changes. This continues
52
- the old-line `@vanduo-oss/flowchart` lineage (never reset to `1.0.0`). Do not
53
- reuse the retired npm name `@vanduo-oss/flowchart`.
53
+ `package.json` version **is** `VD_FLOWCHART_VERSION` (`1.4.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.
54
102
 
55
103
  ## Theming
56
104
 
@@ -60,10 +108,13 @@ package dependency; any provider of the tokens works.
60
108
 
61
109
  ```js
62
110
  import '@vanduo-oss/vd3/css';
63
- // …or the tokens-only layer:
111
+ // Same component styles without bundled icon fonts:
64
112
  import '@vanduo-oss/vd3/css/core';
65
113
  ```
66
114
 
115
+ `@vanduo-oss/vd3/css/core` is **not** tokens-only. Token JSON is
116
+ `@vanduo-oss/vd3/tokens.json`.
117
+
67
118
  Tokens consumed include `--vd-bg-primary`, `--vd-bg-secondary`,
68
119
  `--vd-text-primary`, `--vd-text-muted`, `--vd-border-color`, and
69
120
  `--vd-color-primary` (via `--vd-flowchart-*` locals).
@@ -83,9 +134,24 @@ Tokens consumed include `--vd-bg-primary`, `--vd-bg-secondary`,
83
134
 
84
135
  | Export | Contents |
85
136
  | --- | --- |
86
- | `@vanduo-oss/vd3-flowchart` | `VdFlowchart` + `VdFlowchartCore`, layout, `FLOWCHART_*`, `VD_FLOWCHART_VERSION` |
137
+ | `@vanduo-oss/vd3-flowchart` | `VdFlowchart` + `VdFlowchartCore`, layout, `FLOWCHART_*`, `VD_FLOWCHART_VERSION`, `FLOWCHART_DOCUMENT_VERSION` |
87
138
  | `@vanduo-oss/vd3-flowchart/css` | Stylesheet (`dist/vd3-flowchart.css`) |
88
139
 
140
+ ## Tested interaction envelope
141
+
142
+ Observed on a Mac mini (Apple M4, 10 cores, 24 GB, macOS 26.6.2) with
143
+ Chromium 153 at 1440×1000, no CPU throttling. Two warmups and ten samples per
144
+ synchronous operation; drag used 24 pointer steps. Times include forced layout
145
+ and exclude compositor paint. These are observations, not supported-size
146
+ guarantees.
147
+
148
+ - Graph label edit: 25 / 100 / 250 / 500 nodes → 2.9 / 11.2 / 29.9 / 57 ms.
149
+ - Graph undo + redo: 3.6 / 14 / 34.5 / 69.8 ms.
150
+ - Graph tree/grid layout: 2.9 / 11.1 / 28.4 / 58.9 ms.
151
+ - 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.
152
+
153
+ Raw JSON: `vd3-docs/reviews/2026-09-16/performance-results.json`.
154
+
89
155
  ## Development
90
156
 
91
157
  ```sh
package/SKILL.md CHANGED
@@ -1,47 +1,60 @@
1
1
  ---
2
2
  name: vanduo-vd3-flowchart
3
- description: Use when adding Vanduo Vue 3 flowchart with @vanduo-oss/vd3-flowchart — node/edge editor, undo/redo, layout modes, and a framework-agnostic core. Covers install, CSS, theming, and the load-bearing VD_FLOWCHART_VERSION 1.2.0.
3
+ description: Integrate @vanduo-oss/vd3-flowchart into Vue 3 apps with controlled documents, editing, layouts, undo, and JSON persistence.
4
4
  ---
5
5
 
6
- # @vanduo-oss/vd3-flowchart
7
-
8
- Standalone Vue 3 flowchart package. `vue >=3.3.0` is a required peer. The root
9
- import re-exports the Vue wrapper AND the framework-agnostic core
10
- (`VdFlowchartCore`). `VD_FLOWCHART_VERSION` is `1.2.0` and matches
11
- `package.json`.
12
-
13
- ## Install
14
-
15
- ```sh
16
- pnpm add @vanduo-oss/vd3-flowchart
17
- ```
18
-
19
- Nothing registers globally. For correct theming, provide the Vanduo `--vd-*`
20
- design tokens (see [Theming](#theming)).
21
-
22
- ## Flowchart
23
-
24
- ```js
25
- import { VdFlowchart, VdFlowchartCore } from '@vanduo-oss/vd3-flowchart';
26
- import '@vanduo-oss/vd3-flowchart/css';
27
- ```
28
-
29
- `VdFlowchart` is the Vue 3 wrapper; the framework-agnostic editor core is the
30
- same class name upstream, so it is re-exported as `VdFlowchartCore`. The entry
31
- also re-exports `computeLayout`, `LAYOUT_MODES`, and the `FLOWCHART_*` constant
32
- tables (`FLOWCHART_NODE_TYPES`, `FLOWCHART_PORTS`, `FLOWCHART_EDGE_MARKERS`,
33
- `FLOWCHART_EDGE_ROUTES`) plus `VD_FLOWCHART_VERSION`. CSS ships at
34
- `@vanduo-oss/vd3-flowchart/css`. `VD_FLOWCHART_VERSION` is `1.2.0` — it
35
- continues the old-line lineage (never reset to `1.0.0`) because the value is
36
- serialized into user documents via `toJSON().version`; resetting it would
37
- mislabel documents saved by the old line.
38
-
39
- ## Theming
40
-
41
- Flowchart uses `--vd-*` tokens (via `--vd-flowchart-*` locals) with built-in
42
- fallbacks. vd3 is not a package dependency.
43
-
44
- ```js
45
- import '@vanduo-oss/vd3/css';
46
- import '@vanduo-oss/vd3/css/core';
47
- ```
6
+ # Vanduo flowchart
7
+
8
+ Install `@vanduo-oss/vd3-flowchart` alongside Vue. Import `VdFlowchart` and
9
+ `@vanduo-oss/vd3-flowchart/css`; no global registration is needed. Styles have
10
+ token fallbacks. In a VD3 app, share the base stylesheet already imported at
11
+ app entry; choose `/css` or `/css/core`, not both.
12
+
13
+ Start from [the complete editor recipe](recipes/editor.vue). It includes two
14
+ nodes, an edge, a controlled `data` prop, change events, read-only state, and undo.
15
+ Give the editor a definite height. Set `auto-fit` for its first measurable layout.
16
+
17
+ ## State and persistence
18
+
19
+ Local edits emit `change` with `{ reason, document }`. Feeding `document` back
20
+ into `data` is safe. External replacements are silent and undoable; identical
21
+ echoes preserve selection/history. Ordinary option changes keep the live editor.
22
+ Disabling history clears it; reenabling starts from the current document.
23
+
24
+ Save `event.document` or `getInstance().toJSON()`. Core `load()` emits by default;
25
+ catch validation errors so a failed import can be reported to the user. Unknown
26
+ future versions and malformed JSON are rejected before changing current work.
27
+ `FLOWCHART_DOCUMENT_VERSION` describes saved JSON; `VD_FLOWCHART_VERSION`
28
+ describes the package release. Do not replace document versions with app versions.
29
+
30
+ ## Keyboard
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.
42
+
43
+ ## Canvas options
44
+
45
+ `snapGuides` (default true) snaps drags to alignment guides; `minimap`
46
+ (default true) shows the overview; `autoLayout` (default false) re-runs the
47
+ current tree or radial layout after insertions. Saved JSON uses document
48
+ format 1.3.0, which adds `collapsed: true` on collapsed nodes only.
49
+
50
+ ## Verification
51
+
52
+ Add a node, toggle read-only, and confirm the edit remains. Undo/redo, save/reload,
53
+ and echo a change back through `data`. With only the keyboard, build a small map
54
+ with Tab, typing, and Enter, move with arrows, and use Graph outline to read
55
+ relationships and connect nodes. Check the consumer's screen reader.
56
+
57
+ Use [Vue declarations](dist/vue.d.ts) for component props/events/exposed methods
58
+ and [core declarations](dist/core.d.ts) for document types and editor methods.
59
+ Core `VdFlowchartCore` requires a browser element and explicit `destroy()`;
60
+ the Vue wrapper mounts and cleans it up automatically.
package/dist/core.d.ts CHANGED
@@ -11,6 +11,11 @@ export type FlowchartEdgeRoute = 'curve' | 'straight' | 'orthogonal';
11
11
  export type FlowchartEdgeKind = 'line' | 'arrow';
12
12
  export type FlowchartDirection = 'right' | 'left' | 'up' | 'down';
13
13
  export type LayoutMode = 'tree' | 'radial' | 'grid';
14
+ /**
15
+ * `'mindmap'` (default): Tab adds a child, Enter adds a sibling, F2/Space or
16
+ * typing edits. `'basic'`: Enter edits and Tab moves focus as usual.
17
+ */
18
+ export type FlowchartKeyboardShortcuts = 'mindmap' | 'basic';
14
19
 
15
20
  export interface FlowchartViewport {
16
21
  x: number;
@@ -27,6 +32,8 @@ export interface FlowchartNode {
27
32
  height: number;
28
33
  text: string;
29
34
  data: Record<string, unknown>;
35
+ /** Present (and true) only on collapsed nodes; document format 1.3.0. */
36
+ collapsed?: true;
30
37
  }
31
38
 
32
39
  export interface FlowchartEndpoint {
@@ -79,6 +86,7 @@ export interface FlowchartNodeInput {
79
86
  height?: number;
80
87
  text?: string;
81
88
  data?: Record<string, unknown>;
89
+ collapsed?: boolean;
82
90
  /** Place relative to another node instead of at the viewport center. */
83
91
  relativeTo?: string | FlowchartRelativeTo;
84
92
  }
@@ -111,6 +119,27 @@ export interface AddChildNodeOptions extends FlowchartNodeInput {
111
119
  edge?: FlowchartEdgeInput;
112
120
  }
113
121
 
122
+ export interface InsertBranchNodeOptions {
123
+ /** Side of the parent to grow on; defaults to the branch's growth direction. */
124
+ direction?: FlowchartDirection;
125
+ /** Sibling to stack next to; defaults to the last sibling on that side. */
126
+ anchorId?: string;
127
+ /** Place before `anchorId` instead of after it. */
128
+ before?: boolean;
129
+ /** Open the label editor on the new node. */
130
+ edit?: boolean;
131
+ }
132
+
133
+ export interface InsertSiblingNodeOptions {
134
+ before?: boolean;
135
+ edit?: boolean;
136
+ }
137
+
138
+ export interface StartTextEditOptions {
139
+ /** Replace the label with this text and place the caret at the end. */
140
+ initialText?: string;
141
+ }
142
+
114
143
  export interface LayoutOptions {
115
144
  /** Force a specific root node id; defaults to nodes with no incoming edges. */
116
145
  root?: string;
@@ -134,6 +163,8 @@ export interface MutationOptions {
134
163
  export interface LoadOptions {
135
164
  /** Keep the prior selection if the entity still exists after load. */
136
165
  preserveSelection?: boolean;
166
+ /** Suppress change notification; an identical document is a no-op. Used by Vue data updates. */
167
+ silent?: boolean;
137
168
  }
138
169
 
139
170
  export interface RemoveNodeOptions {
@@ -154,7 +185,10 @@ export interface FlowchartChangeEvent {
154
185
  }
155
186
 
156
187
  export interface FlowchartSelectEvent {
188
+ /** Primary item; keeps its single-item shape when several nodes are selected. */
157
189
  selection: FlowchartSelection | null;
190
+ /** Every selected node id, the primary node included. */
191
+ nodeIds: string[];
158
192
  }
159
193
 
160
194
  export interface FlowchartViewportEvent {
@@ -195,6 +229,14 @@ export interface VdFlowchartOptions {
195
229
  history?: boolean;
196
230
  /** Maximum retained history entries (default 100). */
197
231
  historyLimit?: number;
232
+ /** Keyboard model on the focused canvas (default `'mindmap'`). */
233
+ keyboardShortcuts?: FlowchartKeyboardShortcuts;
234
+ /** Snap dragged nodes to other nodes' edges and centres; Alt bypasses (default true). */
235
+ snapGuides?: boolean;
236
+ /** Show the overview minimap; it hides on canvases narrower than 480px (default true). */
237
+ minimap?: boolean;
238
+ /** Re-run the current tree or radial layout after insertions, in the same undo step (default false). */
239
+ autoLayout?: boolean;
198
240
  }
199
241
 
200
242
  export class VdFlowchart {
@@ -209,6 +251,11 @@ export class VdFlowchart {
209
251
  selectNode(nodeId: string): this;
210
252
  selectEdge(edgeId: string): this;
211
253
  deselect(): this;
254
+ /** Select several nodes; `primary` (default: the last id) drives single-node UI. */
255
+ selectNodes(nodeIds: string[], options?: { primary?: string }): this;
256
+ toggleNodeSelection(nodeId: string): this;
257
+ getSelectedNodeIds(): string[];
258
+ isNodeSelected(nodeId: string): boolean;
212
259
 
213
260
  // Events
214
261
  on<K extends keyof FlowchartEventMap>(
@@ -226,6 +273,27 @@ export class VdFlowchart {
226
273
  parentId: string,
227
274
  options?: AddChildNodeOptions,
228
275
  ): { node: FlowchartNode; edge: FlowchartEdge | null } | null;
276
+ /** Add a connected node on a side of the parent; node and edge undo as one step. */
277
+ insertBranchNode(
278
+ parentId: string,
279
+ options?: InsertBranchNodeOptions,
280
+ ): { node: FlowchartNode; edge: FlowchartEdge | null } | null;
281
+ /** Add a sibling next to a node (a child when the node has no parent). */
282
+ insertSiblingNode(
283
+ nodeId: string,
284
+ options?: InsertSiblingNodeOptions,
285
+ ): { node: FlowchartNode; edge: FlowchartEdge | null } | null;
286
+ duplicateSelection(): FlowchartNode | FlowchartNode[] | null;
287
+ /** Collapse or expand a node's branch; undoable, reason `node:collapse`. */
288
+ setCollapsed(nodeId: string, collapsed: boolean): boolean;
289
+ toggleCollapsed(nodeId: string): boolean;
290
+ /** Nodes not hidden inside a collapsed branch. */
291
+ getVisibleNodes(): FlowchartNode[];
292
+ isNodeHidden(nodeId: string): boolean;
293
+ nudgeNode(nodeId: string, direction: FlowchartDirection, distance: number): FlowchartNode | null;
294
+ nudgeNodes(nodeIds: string[], direction: FlowchartDirection, distance: number): FlowchartNode[];
295
+ /** Select the nearest node in a direction (spatial keyboard navigation). */
296
+ navigateSelection(direction: FlowchartDirection): boolean;
229
297
  updateNode(
230
298
  nodeId: string,
231
299
  patch?: Partial<FlowchartNodeInput>,
@@ -258,6 +326,16 @@ export class VdFlowchart {
258
326
  zoomOut(): this;
259
327
  resetView(): this;
260
328
  fitView(): this;
329
+ /** Zoom around the view centre to an absolute scale (clamped). */
330
+ zoomTo(scale: number): this;
331
+ /** Pan just enough to bring a node into view. */
332
+ revealNode(nodeId: string): void;
333
+ /** Show or hide the minimap. */
334
+ setMinimapEnabled(enabled: boolean): this;
335
+ /** Pan so a world point is at the centre of the view. */
336
+ centerViewOn(worldX: number, worldY: number): this;
337
+ /** Open, close, or toggle the keyboard shortcuts overlay. */
338
+ toggleShortcutsHelp(force?: boolean): this;
261
339
 
262
340
  // Document
263
341
  clear(): this;
@@ -265,10 +343,29 @@ export class VdFlowchart {
265
343
  toJSON(): FlowchartDocument;
266
344
 
267
345
  // Text editing
268
- startTextEdit(nodeId: string): boolean;
346
+ startTextEdit(nodeId: string, options?: StartTextEditOptions): boolean;
347
+ /** Open the inline label editor on a connection. */
348
+ startEdgeLabelEdit(edgeId: string, options?: StartTextEditOptions): boolean;
349
+ /** Select a connection on one side of a node; repeated calls cycle. */
350
+ selectSideEdge(nodeId: string, direction: FlowchartDirection): boolean;
269
351
  stopTextEdit(options?: { commit?: boolean }): void;
270
352
 
271
353
  // Lifecycle
354
+ /** Update editor options without replacing the document, camera or selection. */
355
+ updateOptions(
356
+ options: Pick<
357
+ VdFlowchartOptions,
358
+ | 'readonly'
359
+ | 'gridSize'
360
+ | 'autoFit'
361
+ | 'history'
362
+ | 'historyLimit'
363
+ | 'keyboardShortcuts'
364
+ | 'snapGuides'
365
+ | 'minimap'
366
+ | 'autoLayout'
367
+ >,
368
+ ): this;
272
369
  destroy(): void;
273
370
  }
274
371
 
@@ -282,7 +379,10 @@ export function computeLayout(
282
379
  export const LAYOUT_MODES: readonly LayoutMode[];
283
380
 
284
381
  export const VD_FLOWCHART_VERSION: string;
382
+ /** Schema version used by toJSON(), independent of the package release. */
383
+ export const FLOWCHART_DOCUMENT_VERSION: string;
285
384
  export const FLOWCHART_NODE_TYPES: readonly FlowchartNodeType[];
286
385
  export const FLOWCHART_PORTS: readonly FlowchartPort[];
287
386
  export const FLOWCHART_EDGE_MARKERS: readonly FlowchartEdgeMarker[];
288
387
  export const FLOWCHART_EDGE_ROUTES: readonly FlowchartEdgeRoute[];
388
+ export const FLOWCHART_KEYBOARD_SHORTCUTS: readonly FlowchartKeyboardShortcuts[];