-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Incorrect bounding box for htmlLabels with images in Mermaid v10.2.0 #4455
Comments
Hi, I'm the one who wrote PR #4268. Sorry about this issue.
the image is not cropped anymore. So
I am not sure how big of an issue that is? |
Mermaid v10.2.0 changed some behavior for htmlLabels with embedded SVG images. The `width=100%` is now set in the node CSS, which normally scales the images to the width of the text, but for this SVG, it seems to crop it. See mermaid-js/mermaid#4455. Setting a well-defined `viewBox` attribute to our SVG fixes this. Co-authored-by: Laura Valentine Tscharner <[email protected]>
No worries! The image rendering improvements in PR #4268 seem really useful. To be honest, this might be my fault, I'm not an expert on SVGs, but from some quick googling, it sounds like SVGs without a In fact, adding a I'm going to close this issue, since it sounds like missing a
@Valentine14th, do you mind if I submit the change you've recommended to the mermaid-cli project and credit you as a Co-author? I've tested the change, and adding a |
@aloisklink Of course go ahead! Thank you! |
Mermaid v10.2.0 changed some behavior for htmlLabels with embedded SVG images. The `width=100%` is now set in the node CSS, which normally scales the images to the width of the text, but for this SVG, it seems to crop it. See mermaid-js/mermaid#4455. Setting a well-defined `viewBox` attribute to our SVG fixes this. Co-authored-by: Laura Valentine Tscharner <[email protected]>
Description
Images in flowcharts used to work fine in Mermaid v10.1.0 or before, but in Mermaid v10.2.0, the boxes are now smaller, and longer automatically expand to fit the entire image.
This was caught by
mermaid-cli
's automated visual regression tests, see mermaid-js/mermaid-cli#541 (review)Steps to reproduce
Copy in the code sample below in Mermaid v10.1.0 and v10.2.0 (or commit d132d26 and 9bb0cef).
However, they both do not work with the mermaid.live editor. So you may find it easier to add the following patch to the
demos/flowchart.html
file:Screenshots
Working in Mermaid v10.1.0
SVG (may miss fontawesome fonts when rendered on GitHub)
PNG
Broken in Mermaid v10.2.0
SVG (may miss fontawesome fonts when rendered on GitHub)
PNG
Code Sample
Setup
Additional Context
I've done a diff on the output SVGs, after passing the SVGs through an XML prettier to make it a bit prettier:
It looks like the change was in PR #4268, or commit 9bb0cef.
Edit: I've done some testing and confirmed that commit 9bb0cef is the one that changed this behavior.
The text was updated successfully, but these errors were encountered: