@vanduo-oss/vd3-flowchart 1.3.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,72 @@
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
+
5
71
  ## 1.3.0 — 2026-09-17
6
72
 
7
73
  ### Added
package/README.md CHANGED
@@ -6,8 +6,8 @@ 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.3.0.** `VD_FLOWCHART_VERSION` tracks the package release.
10
- `FLOWCHART_DOCUMENT_VERSION` (currently `1.2.0`) is the value `toJSON()`
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
11
  writes. Do not reset either independently without a compatibility plan.
12
12
 
13
13
  ## Install
@@ -40,7 +40,8 @@ Named exports only — no default export. `VdFlowchart` is the Vue wrapper; the
40
40
  editor class is re-exported as `VdFlowchartCore` (same class name upstream).
41
41
  `computeLayout`, `LAYOUT_MODES`, and the `FLOWCHART_*` tables
42
42
  (`FLOWCHART_NODE_TYPES`, `FLOWCHART_PORTS`, `FLOWCHART_EDGE_MARKERS`,
43
- `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.
44
45
 
45
46
  `vue` is never bundled — it stays external in both the esm and cjs outputs.
46
47
  The build emits `dist/meta.json` and **fails** if any input leaves `src/` or
@@ -49,15 +50,56 @@ if anything but `vue` is externalized. The package declares
49
50
 
50
51
  ## Version policy
51
52
 
52
- `package.json` version **is** `VD_FLOWCHART_VERSION` (`1.3.0`). Bump those
53
+ `package.json` version **is** `VD_FLOWCHART_VERSION` (`1.4.0`). Bump those
53
54
  together for a package release. Keep `FLOWCHART_DOCUMENT_VERSION` unchanged
54
55
  unless the serialized schema changes; add fixtures and explicit compatibility
55
- rules for a format change. Unversioned 1.x documents through 1.2.0 still load.
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.
56
59
  Malformed JSON and unsupported future versions throw before the active
57
60
  document, selection, or history change. This continues the old-line
58
61
  `@vanduo-oss/flowchart` lineage (never reset to `1.0.0`). Do not reuse the
59
62
  retired npm name `@vanduo-oss/flowchart`.
60
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
+
61
103
  ## Theming
62
104
 
63
105
  Flowchart chrome renders against Vanduo `--vd-*` design tokens — the same
package/SKILL.md CHANGED
@@ -27,12 +27,32 @@ future versions and malformed JSON are rejected before changing current work.
27
27
  `FLOWCHART_DOCUMENT_VERSION` describes saved JSON; `VD_FLOWCHART_VERSION`
28
28
  describes the package release. Do not replace document versions with app versions.
29
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
+
30
50
  ## Verification
31
51
 
32
52
  Add a node, toggle read-only, and confirm the edit remains. Undo/redo, save/reload,
33
- and echo a change back through `data`. With only the keyboard, select nodes using
34
- canvas arrows, edit with Enter, save with Ctrl/Cmd+Enter, and use Graph outline
35
- to read relationships and connect nodes. Check the consumer's screen reader.
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.
36
56
 
37
57
  Use [Vue declarations](dist/vue.d.ts) for component props/events/exposed methods
38
58
  and [core declarations](dist/core.d.ts) for document types and editor methods.
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;
@@ -156,7 +185,10 @@ export interface FlowchartChangeEvent {
156
185
  }
157
186
 
158
187
  export interface FlowchartSelectEvent {
188
+ /** Primary item; keeps its single-item shape when several nodes are selected. */
159
189
  selection: FlowchartSelection | null;
190
+ /** Every selected node id, the primary node included. */
191
+ nodeIds: string[];
160
192
  }
161
193
 
162
194
  export interface FlowchartViewportEvent {
@@ -197,6 +229,14 @@ export interface VdFlowchartOptions {
197
229
  history?: boolean;
198
230
  /** Maximum retained history entries (default 100). */
199
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;
200
240
  }
201
241
 
202
242
  export class VdFlowchart {
@@ -211,6 +251,11 @@ export class VdFlowchart {
211
251
  selectNode(nodeId: string): this;
212
252
  selectEdge(edgeId: string): this;
213
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;
214
259
 
215
260
  // Events
216
261
  on<K extends keyof FlowchartEventMap>(
@@ -228,6 +273,27 @@ export class VdFlowchart {
228
273
  parentId: string,
229
274
  options?: AddChildNodeOptions,
230
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;
231
297
  updateNode(
232
298
  nodeId: string,
233
299
  patch?: Partial<FlowchartNodeInput>,
@@ -260,6 +326,16 @@ export class VdFlowchart {
260
326
  zoomOut(): this;
261
327
  resetView(): this;
262
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;
263
339
 
264
340
  // Document
265
341
  clear(): this;
@@ -267,7 +343,11 @@ export class VdFlowchart {
267
343
  toJSON(): FlowchartDocument;
268
344
 
269
345
  // Text editing
270
- 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;
271
351
  stopTextEdit(options?: { commit?: boolean }): void;
272
352
 
273
353
  // Lifecycle
@@ -275,7 +355,15 @@ export class VdFlowchart {
275
355
  updateOptions(
276
356
  options: Pick<
277
357
  VdFlowchartOptions,
278
- 'readonly' | 'gridSize' | 'autoFit' | 'history' | 'historyLimit'
358
+ | 'readonly'
359
+ | 'gridSize'
360
+ | 'autoFit'
361
+ | 'history'
362
+ | 'historyLimit'
363
+ | 'keyboardShortcuts'
364
+ | 'snapGuides'
365
+ | 'minimap'
366
+ | 'autoLayout'
279
367
  >,
280
368
  ): this;
281
369
  destroy(): void;
@@ -297,3 +385,4 @@ export const FLOWCHART_NODE_TYPES: readonly FlowchartNodeType[];
297
385
  export const FLOWCHART_PORTS: readonly FlowchartPort[];
298
386
  export const FLOWCHART_EDGE_MARKERS: readonly FlowchartEdgeMarker[];
299
387
  export const FLOWCHART_EDGE_ROUTES: readonly FlowchartEdgeRoute[];
388
+ export const FLOWCHART_KEYBOARD_SHORTCUTS: readonly FlowchartKeyboardShortcuts[];