Add Mermaid rendering to Markdown - #1929
Conversation
|
The Mermaid integration point is sound. Astryx 0.2.0 does not ship a Mermaid or generic diagram renderer, and The security path looks reasonable too: I think the viewer should still be revised before merge.
A simpler component boundary would look like this: flowchart TD
A["Astryx Markdown<br/>components.code"] --> B{"Settled Mermaid fence?"}
B -- No --> C["Astryx CodeBlock"]
B -- Yes --> D{"Within automatic render budget?"}
D -- No --> E["Source + explicit Render action"]
D -- Yes --> F["Inline Mermaid<br/>fit-to-width"]
F --> G["View source disclosure"]
F --> H["Expand"]
H --> I["Astryx Dialog<br/>variant=fullscreen"]
I --> J["Astryx Toolbar + IconButton"]
I --> K["Zoom, reset, and pan"]
This keeps Mermaid-specific rendering local while letting Astryx own code presentation, toolbar behavior, modal semantics, focus, Escape, and scroll locking. Inline diagrams stay quiet: fit-to-width, View source, and Expand. The complete zoom and pan controls only appear where they have enough room to be useful.
中文建议底层接法可以保留:继续用 |
Astro-Han
left a comment
There was a problem hiding this comment.
Re-reviewed the latest head. The previous viewer feedback is addressed: fullscreen now uses the Astryx fullscreen Dialog and Toolbar, fitted diagrams preserve vertical touch scrolling, narrow containers retain the Expand action, successful renders keep a source disclosure, automatic rendering has count/source budgets with an explicit Render fallback, and the hostile-input regression fixture locks down the SVG boundary. CI is fully green. Approving for merge.
One non-blocking P2 follow-up: applyMermaidRenderBudget only recognizes fences that begin after up to three spaces. Astryx also parses Mermaid fences inside Markdown containers such as blockquotes and lists, but those retain prefixes like > during the raw-source scan. As a result, four blockquoted Mermaid fences all remain automatic instead of the fourth becoming deferred, bypassing the per-Markdown three-diagram and total-source budgets.
Please consider enforcing the budget against the parsed code blocks, or extending the scanner to handle Markdown container prefixes, with blockquote/list regression cases. The existing per-diagram hard limit and serialized render queue keep this from blocking the otherwise complete integration.
What changed
mermaidfenced code blocks as diagrams in the shared Markdown surfaceWhy
The Astryx Markdown pipeline previously treated Mermaid fences as ordinary code blocks. This adds the missing product integration while keeping assistant-authored diagram input behind explicit rendering and security boundaries.
Safety and performance
securityLevel: strict, HTML labels are disabled, and bind functions are never attachedValidation
npm --workspace @maka/ui run typechecknpm --workspace @maka/ui test(238 tests)npm --workspace @maka/desktop run build:with-depsgit diff --check