-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix: Correctly render mermaid diagrams in markdown preview tool #4791
Fix: Correctly render mermaid diagrams in markdown preview tool #4791
Conversation
Edit: Fixed the below since I forgot I could just move the
|
This reverts commit 04aaf35. For separate PR.
display: none
…on show view Was originally in the content container component to be shared between the lesson view and markdown preview tool, but the markdown preview tool needs a different connection/action structure to render mermaid diagrams properly. Moving it out of the content container means the diagramming#connect method can be essentially returned to original using the default .mermaid selector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this @MaoShizhong 💪
It's a shame we can't keep the diagramming controller with the content container, but the trade off is worth it. It's a good solution! just one nit from me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀 nice work @MaoShizhong!
Because
We initialise and run mermaid as soon as mermaid diagrams enter the DOM. If they have
display: none
, which they start off with as a child of a hidden parent element in the markdown preview page, they'll be rendered with incorrect SVG values - unable to rerender later as the mermaid text will have already been replaced.This PR
diagramming#render
when switching to rendered preview tab in the markdown preview toolmermaid.init
method with recommended newrun
method as per documentation for v10+Issue
Closes #4783
Additional Information
Pull Request Requirements
keyword: brief description of change
format, using one of the following keywords:Feature
- adds new or amends existing user-facing behaviorChore
- changes that have no user-facing value, refactors, dependency bumps, etcFix
- bug fixesBecause
section summarizes the reason for this PRThis PR
section has a bullet point list describing the changes in this PRIssue
section