feat(flowchart): Open from file button + parse on load (C9)

v4.13.0 — round-trips Mermaid source through the editor:

  - new open-text-file-dialog invoke IPC in main.js opens a system
    Open dialog filtered for .mmd / .mermaid / .md / .markdown / .txt,
    reads the chosen file, returns { path, content } or null on cancel.
  - new openFile() on the flowchart preload bridge.
  - new Open from File button in the standalone window toolbar
    alongside Insert / Save / Reset.
  - On click: confirms overwrite when the current graph is non-empty,
    strips any mermaid fence, parses via the inlined fromMermaid()
    (the inverse of toMermaid), and calls _store.deserialize so the
    canvas redraws. Status bar reports Loaded path.

The fromMermaid() in the bundle is duplicated from
src/flowchart/flowchart-mermaid-parse.js (23 tests in C8 land the
same logic) so the standalone window does not depend on the bundle
rebuild step. Pure module + bundle inline stay in sync logically;
future work could collapse them via a build-time inclusion.

Amit Haridas
This commit is contained in:
Amit Haridas
2026-09-30 21:40:59 +05:30
parent 4123455863
commit 22bc4dcf56
4 changed files with 176 additions and 1 deletions
+7
View File
@@ -384,6 +384,13 @@
>
Save to File
</button>
<button
class="fc-btn"
id="fc-btn-open"
title="Open a .mmd / .md file and load its flowchart"
>
Open from File
</button>
<button class="fc-btn" id="fc-btn-reset" title="Clear all nodes and edges">
Reset All
</button>