fix: support mermaid v9 by falling back to mermaid.init()#40
Open
Colty1999 wants to merge 2 commits intoLeward:masterfrom
Open
fix: support mermaid v9 by falling back to mermaid.init()#40Colty1999 wants to merge 2 commits intoLeward:masterfrom
Colty1999 wants to merge 2 commits intoLeward:masterfrom
Conversation
Owner
|
Hi @Colty1999 , thanks for the contribution. I am not watching PRs as often as I should, but I'll try to validate this and get it merged. |
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.
Problem
docsify-mermaid@2.0.1callsmermaid.run()which only exists inmermaid v10+. However, mermaid v10 requires ESM imports (
type="module"),which load asynchronously — meaning
window.mermaidis undefined when theplugin tries to use it.
Mermaid v9 loads synchronously via a regular
<script>tag but onlyexposes
mermaid.init(), notmermaid.run().This makes the plugin broken for both versions.
Fix
Fall back to
mermaid.init()whenmermaid.run()is not available,supporting both v9 and v10+.
Changes
src/plugin.js: checktypeof mermaid.run === 'function'beforecalling it; fall back to
mermaid.init()for v9