feat(markdown): render Mermaid & PlantUML diagrams in the markdown preview#243
Open
architawr wants to merge 14 commits into
Open
feat(markdown): render Mermaid & PlantUML diagrams in the markdown preview#243architawr wants to merge 14 commits into
architawr wants to merge 14 commits into
Conversation
added 14 commits
May 31, 2026 14:59
…aid loading state, atomic stdin, CRLF + url-scheme hardening, renderLocal tests
…s/plugins to stable module refs Inline components/remarkPlugins literals were recreated every render, giving diagram children unstable component identities; EditorPanel's whole-workspaces subscription re-renders often, so MermaidDiagram/PlantUmlDiagram remounted repeatedly (re-running async render + reloading the <img>). Adds a regression test asserting no remount on parent re-render.
… theme tokens Addresses review on 0-AI-UG#204. Privacy: PlantUML now defaults to a new 'off' mode instead of 'server', so a previewed markdown file never sends ```plantuml block text to a third-party server (plantuml.com) without explicit consent. Server mode (which transmits diagram text) and Local mode (java + jar, on-machine) are both opt-in via Settings -> Diagrams. 'off' renders the source as a plain code block with a hint. Theme: after rebasing onto main, the extracted MarkdownPreview still carried the old hardcoded Tailwind classes (neutral/blue/pink). main (0-AI-UG#208/0-AI-UG#206) migrated the preview to semantic theme tokens (border-strong, text-agent, bg-surface-3, text-secondary, bg-hover-strong) — re-applied those so the preview tracks the active theme. PlantUmlDiagram's fallback/error cards use the same tokens. Adds a regression test pinning the privacy default to 'off'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Renders Mermaid and PlantUML diagrams inside the markdown file preview (the
.mdPreview toggle in the editor), modeled on the well-known VS Code extensions.```mermaid→ rendered client-side as SVG.```plantuml/```puml/```uml→ rendered as an image.How
import()), rendered fully offline, theme-aware (re-renders on theme switch), withsecurityLevel: 'strict'.plantuml-encoder→<img src="{server}/svg/…">. Opt-in because the diagram text is sent to the configured server (defaulthttps://www.plantuml.com/plantuml; point it at a localplantuml-serverfor private/offline rendering).java -jar <plantuml.jar> -tsvg -pipeand returns the SVG, shown as adata:image.<img>, so no CSP change is required (img-srcalready allowshttps:anddata:).MarkdownPreviewwas extracted out of the oversizedEditorPanel.tsxinto a focusedsrc/renderer/panels/markdown/module.Security / CSP
script-src 'self'.eval/new Function, so it runs under the strict prod CSP; output is DOMPurify-sanitized (securityLevel: 'strict'). PlantUML is rendered as an image, not injected markup, and is off unless explicitly enabled. The configured server URL is validated to behttp(s).Testing
spawnbehavior (success / ENOENT / non-zero exit / timeout / non-SVG), and the local data-URL client.tsc --noEmitclean ·vitest557 passed / 3 skipped ·npm run buildsucceeds (re-verified after syncing with latestmain).Notes / scope
plantuml.jaris not bundled; Local mode uses a user-provided jar (brew install plantuml, etc.).