Bump Mermaid to 11.12.0, to match CLI#986
Open
juliasilge wants to merge 4 commits into
Open
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Collaborator
Author
|
I added an extension-level test in ebb071a that will warn us the next time we get out of sync on this. |
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.
Fixes posit-dev/positron#13881
This PR bumps the Mermaid version used by the Diagram preview webview from 9.3.0 to 11.12.0, matching the version already bundled in the Quarto CLI.
How far behind were we?
Soooooooo far! 😱 The Diagram preview was pinned to Mermaid 9.3.0 (late 2022), while the Quarto CLI ships 11.12.0. That is two full major versions behind, plus dozens of minor releases and roughly two and a half years of drift. So a diagram could render correctly in
quarto render/quarto preview(CLI) and then break in the in-editor Diagram preview, purely because the preview was running ancient Mermaid.The user-visible symptom that surfaced this is that the newer node-shape syntax added in Mermaid 11.3.0, e.g.
renders as "undefined" in the preview, because 9.3.0 has no idea what that syntax means.
What changed?
assets/www/diagram/mermaid.min.js: replaced the bundled 9.3.0 build with 11.12.0, copied verbatim from the CLI source (quarto-cli/src/resources/formats/html/mermaid/mermaid.min.js) so the two stay in lockstep. The CLI build appendsglobalThis["mermaid"] = ..., which keepswindow.mermaidavailable to the webview's classic<script>load, so no CSP or script-loading changes were needed.assets/www/diagram/diagram.js: migrated to the Mermaid v10+ async API.await mermaid.parse(src)(parse is now async)const { svg } = await mermaid.render(id, src)then inject the returned markup, replacing the removed callback-stylerender(id, src, cb)mermaid.mermaidAPIaccessor in favor ofmermaid.initialize(...)messagehandler now awaits the render sorender-begin/render-endstill bracket the actual render and a queued state update cannot interrupt an in-flight oneerr.str || err.message || String(err)since v11 errors do not always carry.strHere is what we see afterward:
It's not a perfect match for what you see if you do
quarto previeworquarto render; if more folks use this preview we might want to improve it.FWIW The OJS stdlib pin (
packages/ojs/external-observablehq-stdlib/src/dependencies.js, Mermaid 9.2.2) is a separate code path and is intentionally left untouched here because I don't feel very confident about it.It might be worth thinking about updating this more regularly. 😅