fix: blank space on top/bottom when export image/svg#567
fix: blank space on top/bottom when export image/svg#567nhymxu wants to merge 1 commit intomermaid-js:developfrom
Conversation
|
✔️ Deploy Preview for mermaidjs ready! 🔨 Explore the source changes: 8675947 🔍 Inspect the deploy log: https://app.netlify.com/sites/mermaidjs/deploys/61d6bda13e5f9e0007a50605 😎 Browse the preview: https://deploy-preview-567--mermaidjs.netlify.app |
| svg?.setAttribute('width', `${width}px`); // Workaround https://stackoverflow.com/questions/28690643/firefox-error-rendering-an-svg-image-to-html5-canvas-with-drawimage | ||
| if (!svg) { | ||
| svg = document.querySelector('#container svg'); | ||
| svg.removeAttribute('height'); |
There was a problem hiding this comment.
I'm wondering if removing the height attribute would cause any other issues?
There was a problem hiding this comment.
More detail I posted on issue.
When you not have height, browser will re-calculate new height from element inside svg element.
So, diagram will fit inside.
When edit new code, height will back to large number. This code block affect only for save action
You can test with data I put in issue
There was a problem hiding this comment.
Yes, If you have any idea, we can discuss.
My solution only fix for export function. But I think problem from render function first.
There was a problem hiding this comment.
Some VSCode plugin support preview mermaid diagram have same problem, so I think it's from main mermaid.js. Not about live editor
|
This pr is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
|
This pr is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days |








📑 Summary
Remove blank space on top/bottom when export image/svg
Resolves #566
📏 Design Decisions
Before export image, svg. Remove
heightattribute onsvgelement.So browser when re-calculate new fitable height.
📋 Tasks
Make sure you
developbranch