From 5f846d1e5fd4a27af6c3daf39414bc2968aa5e08 Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Mon, 14 Sep 2026 23:50:25 +0530 Subject: [PATCH] refactor(flowchart): standalone window (Cmd+Alt+F) replaces sidebar panel; v4.9.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Five fix rounds (v4.9.1 → v4.9.5) couldn't make the sidebar flowchart panel feel right — at 280 px sidebar with canvas + preview cramped to ~175 px each, plus the editor-container hide/show dance the maximize/restore toggle required, the panel kept presenting as cramped and unreliable at runtime. Strategy pivot: the flowchart editor now lives in its own BrowserWindow, matching the ASCII Art Generator pattern. - src/flowchart-generator.html — new standalone HTML with header, toolbar (Insert at Cursor / Reset), canvas host, and preview host. Stylesheet hrefs are src/-relative (no ../). Forced light surface via background/color !important rules — mirrors the v4.9.5 CSS fix. - src/renderer/flowchart-controller.js — pure browser IIFE. Hydrates from /flowchart-session.json once on mount, persists on every mutation with 500 ms debounce. Insert at Cursor wraps the generated Mermaid source in a fenced ```mermaid block and sends it through the existing insert-content IPC. - src/main.js — openFlowchartGenerator() launches the standalone BrowserWindow (1100×720, contextIsolation:true, nodeIntegration:false). Tools menu entry 'Flowchart Generator' with Cmd/Ctrl+Alt+F. - src/preload.js — new window.electronAPI.flowchart.* namespace with getUserDataPath/readFile/writeFile/insertAtCursor, reusing the existing thin text-file IPC handlers. - The four pure modules (flowchart-shapes.js, flowchart-mermaid.js, flowchart-store.js, flowchart-canvas.js) gained a tiny UMD wrapper so they work both as CommonJS (legacy sidebar) and as browser globals (standalone window). No behavioural change to the 73 flowchart unit tests in tests/flowchart-*.test.js. - src/renderer.js — sidebar registerPanel('flowchart', ...) and the commandPalette entry are now commented out. Legacy panel file (src/sidebar/flowchart-panel.js) preserved for rollback. Tests: - tests/flowchart-controller.test.js — 10 new tests covering stylesheet paths (no ../ escape), bootstrap wiring (getUserDataPath once, reads flowchart-session.json), hydration from a saved session, Insert-at-Cursor fenced block format, Reset (with and without confirm), and two regression tests that src/renderer.js no longer has a live sidebar registration. All 1122 tests pass; lint + format clean. Amit Haridas --- README.md | 2 +- UPDATES.md | 16 ++ package.json | 2 +- src/flowchart-generator.html | 210 ++++++++++++++++++++++ src/flowchart/flowchart-canvas.js | 21 ++- src/flowchart/flowchart-mermaid.js | 14 +- src/flowchart/flowchart-shapes.js | 32 +++- src/flowchart/flowchart-store.js | 14 +- src/main.js | 45 +++++ src/preload.js | 16 ++ src/renderer.js | 32 +++- src/renderer/flowchart-controller.js | 249 +++++++++++++++++++++++++++ tests/flowchart-controller.test.js | 216 +++++++++++++++++++++++ 13 files changed, 848 insertions(+), 21 deletions(-) create mode 100644 src/flowchart-generator.html create mode 100644 src/renderer/flowchart-controller.js create mode 100644 tests/flowchart-controller.test.js diff --git a/README.md b/README.md index 01b7141..66ce67e 100644 --- a/README.md +++ b/README.md @@ -257,4 +257,4 @@ Amit Haridas (amit.wh@gmail.com) ## Version -v4.9.5 +v4.9.6 diff --git a/UPDATES.md b/UPDATES.md index 4be42af..e0840a2 100644 --- a/UPDATES.md +++ b/UPDATES.md @@ -1,5 +1,21 @@ # PanConverter - Updates & Changelog +## Version 4.9.6 (2026-09-14) + +### Refactor +- **Flowchart editor is now a standalone window, not a sidebar panel.** Five fix rounds (v4.9.1 → v4.9.5) couldn't make the sidebar panel feel right — at 280 px sidebar with the canvas + preview split to ~175 px each, plus the editor-container hiding dance the maximize/restore toggle required, the panel kept presenting as cramped and unreliable at runtime. Strategy pivot: the flowchart editor now lives in its own BrowserWindow, matching the ASCII Art Generator pattern (`src/ascii-generator.html` + `src/renderer/ascii-controller.js`). + - New `src/flowchart-generator.html` — standalone HTML with its own header, toolbar (Insert at Cursor / Reset), canvas host, and preview host (text-only — the canvas on the left IS the visual preview). All stylesheet `href`s are `src/`-relative — no `../` escape (lesson learned from v4.9.2). Forced light surface (`background: #fafafa !important; color: #1f2328 !important`) on the canvas + preview regardless of the project's body theme, mirroring the v4.9.5 CSS fix that traded theme consistency for guaranteed visibility. + - New `src/renderer/flowchart-controller.js` — pure browser IIFE. Wires the canvas + preview, hydrates from `/flowchart-session.json` once on mount, persists on every store mutation with a 500 ms debounce. Insert at Cursor wraps the generated `flowchart TD` source in a fenced ```` ```mermaid ```` block and sends it through the existing `insert-content` IPC channel — same one the renderer.js sidebar panel used. Keyboard shortcuts (Ctrl/Cmd+Z / Ctrl/Cmd+Shift+Z / Delete / Backspace) handled at document level. + - New `openFlowchartGenerator()` in `src/main.js` — `BrowserWindow` (1100×720, parent: mainWindow, `contextIsolation: true, nodeIntegration: false`) launched by an `ipcMain.on('open-flowchart-generator')` listener. Tools menu now has a "Flowchart Generator" entry with accelerator `CmdOrCtrl+Alt+F`. + - New `window.electronAPI.flowchart.*` namespace in `src/preload.js` — `getUserDataPath` / `readFile` / `writeFile` / `insertAtCursor`. Reuses the existing thin IPC handlers (`get-user-data-path`, `read-text-file`, `write-text-file`) which already sandbox writes to ``. + - The four pure modules (`flowchart-shapes.js`, `flowchart-mermaid.js`, `flowchart-store.js`, `flowchart-canvas.js`) gained a tiny UMD wrapper so they work both as CommonJS (the legacy sidebar panel still loads them via `require()`) and as browser globals (the standalone window loads them via ` + + + + + + diff --git a/src/flowchart/flowchart-canvas.js b/src/flowchart/flowchart-canvas.js index 8decc5c..7944a0f 100644 --- a/src/flowchart/flowchart-canvas.js +++ b/src/flowchart/flowchart-canvas.js @@ -13,7 +13,12 @@ 'use strict'; -const { DEFAULT_WIDTH, DEFAULT_HEIGHT, shapeSvg, SHAPE_KINDS } = require('./flowchart-shapes'); +// v4.9.6 — CommonJS sibling import when running under Node (the renderer.js +// sidebar panel still uses require()), browser global fallback when loaded as +// a