Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework mermaid integration to support off-DOM rendering #4364

Merged
merged 1 commit into from Sep 25, 2023

Conversation

knolleary
Copy link
Member

This is a rework of how we integrate mermaid into the editor.

As reported in #4323, if we try to render a mermaid diagram in an element that isn't currently visible, it results in an error. This is an "expected" behaviour of using mermaid.init/run.

In this PR, I've updated to the latest mermaid and modified how we drive it. We now do the work to call mermaid.render with the diagram text to get the svg back and insert it ourselves.

The downside is we have to do the error handling ourselves - so instead of the mermaid 'bomb' image, it now displays the error in text. It isn't as pretty, but to be honest, it feels more useful to know what the error was rather than just the fact there was an error.

I've also updated the internal APIs so nothing should be calling the global mermaid directly - we take care of that.

Whilst I was at it, I also fixed #4358 as it the help sidebar wasn't making the call to render mermaid.

@knolleary knolleary linked an issue Sep 22, 2023 that may be closed by this pull request
@knolleary knolleary merged commit 680d5b8 into master Sep 25, 2023
4 checks passed
@knolleary knolleary deleted the 4323-redo-mermaid-integration branch November 20, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant