From f133efe02529ae804a7b9cdc7e7e9d8fb1086a4e Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Wed, 30 Sep 2026 22:28:13 +0530 Subject: [PATCH] feat(flowchart): alignment + distribution tools (C15) 8 new toolbar buttons (Align L/R/T/B, Center H/V, Distribute H/V) plus a Select All button. Each operation takes the current selection and applies a pure-function transform to the (x, y) positions, then commits each result via store.moveNode(). Architecture: - src/flowchart/flowchart-align.js: pure module with 8 helpers + nodeWidth / nodeHeight utility. UMD wrapper for browser global + CommonJS, same pattern as the other pure modules. - src/renderer/flowchart-bundle.js: pure module inlined so the standalone window doesn't need a separate bundle build; the inlined functions are exposed as window.FlowchartAlign for jsdom tests. - Bundle's _selectedNodeIds Set tracks the alignment selection. Empty by default; populated by Select All or by future canvas-side shift+click (item 1: multi-select). - Each align button no-ops with a status hint if fewer than 2 nodes are selected. Distribute needs 3+. - Each moveNode call creates its own undo snapshot, which is fine for typical 2-10 node selections and lets the user undo a misalignment one node at a time. Tests: 14 new (1376 total) covering all 8 functions plus immutability, no-op for insufficient nodes, and unsorted-input sorting for distribute. Amit Haridas --- src/flowchart-generator.html | 68 +++++++++++ src/flowchart/flowchart-align.js | 134 ++++++++++++++++++++++ src/renderer/flowchart-bundle.js | 190 +++++++++++++++++++++++++++++++ tests/flowchart-align.test.js | 121 ++++++++++++++++++++ 4 files changed, 513 insertions(+) create mode 100644 src/flowchart/flowchart-align.js create mode 100644 tests/flowchart-align.test.js diff --git a/src/flowchart-generator.html b/src/flowchart-generator.html index b06c3ef..1d06087 100644 --- a/src/flowchart-generator.html +++ b/src/flowchart-generator.html @@ -395,6 +395,74 @@ Reset All +

Align (multi-select)

+
+ +
+
+ + + + + + + + +

Export Image