Add Mermaid diagram preview#49010
Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Gery Wibowo.
|
Introduce a new `mermaid_preview` crate that renders live previews of Mermaid diagram files (.mmd, .mermaid) using `mermaid-rs-renderer`. Includes keybindings for opening the preview in-place or in a side split on all platforms. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a6a73f6 to
2a347a7
Compare
|
We require contributors to sign our Contributor License Agreement, and we don't have @monkeymars on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Looks like #49064 will be the way this is implemented, so I'll close this one optimistically. |
|
@SomeoneToIgnore #49064 is about markdown support for mermaid blocks, whereas this seems to introduce an Item impl for displaying mermaid graphs; they seem related, but not fully overlapping to me. |
|
Thanks for the pointer to #49064 , but I think this PR addresses a different use case that #49064 doesn't cover. #49064 adds Mermaid rendering inside Markdown files code blocks, whereas this PR introduces a dedicated mermaid_preview crate for previewing standalone .mmd/.mermaid files similar to how svg_preview works for .svg files. Could this be reconsidered or tracked separately? |
|
From what I recall, those bits are meant to be merged together in some form, but sure you can go ahead and ask in the other PR, as that person has the best context of us all. |
|
@monkeymars Hey, thanks for putting this together! The use case is valid, standalone .mmd/.mermaid file preview is something we should support. That said, I'd rather not add a new crate for this. The We can tratify it all, have SVG and Mermaid describe its own file extensions, and rendering logic. That way whole workspace/pane etc boilerplate stays shared. If you're interested in picking this up, happy to help guide the refactor. |
|
That makes a lot of sense! A unified file_preview crate is way cleaner than duplicating the boilerplate. I'd love to pick this up. Would you be able to guide me through the refactor? Happy to start whenever you're ready |
|
Hey @smitbarmase — I've picked up the refactor you suggested! I've opened #49207 which introduces a unified
Would love your feedback on the design of the trait and how the toolbar integration fits in with the rest of the quick action bar. Happy to iterate! |

Summary
mermaid_previewcrate that renders live previews of Mermaid diagram files (.mmd,.mermaid) usingmermaid-rs-rendererFollows the same pattern as
svg_previewandmarkdown_preview.Test plan
.mmdor.mermaidfile and verify the preview keybindings appear in the keymapCmd+Shift+V(macOS) /Ctrl+Shift+V(Linux/Windows) to open an in-place previewCmd+K V/Ctrl+K Vto open a side-by-side preview🤖 Generated with Claude Code