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

Add viewBox attribute to SVG #104

Open
sidharthv96 opened this issue May 23, 2024 · 2 comments
Open

Add viewBox attribute to SVG #104

sidharthv96 opened this issue May 23, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@sidharthv96
Copy link
Contributor

Is your feature request related to a problem? Please describe.
As the SVG is lacking viewBox attribute, scaling the output is a bit tricky.

https://github.com/mermaid-js/mermaid-live-editor/blob/cba9a6754dd0a33a0073ec50167efef35289ac72/src/lib/components/View.svelte#L122-L126

Describe the solution you'd like
In addition to height and width, a viewBox property is also added.
Also, if an option to specify an ID for the generated SVG is there, that would make the post-processing easier.

Additional context
mermaid-js/mermaid-live-editor#1457

@sidharthv96 sidharthv96 added the enhancement New feature or request label May 23, 2024
@sidharthv96
Copy link
Contributor Author

Btw, you can try out the feature in https://deploy-preview-1457--mermaidjs.netlify.app

@fskpf
Copy link
Owner

fskpf commented May 26, 2024

I think that the output SVG should mimic the behavior of the input SVG.

So if the input uses a viewBox with percentage width/height, then the output should do the same. Likewise, if the input SVG comes with a defined size, the output should keep this size, without switching to a more "responsive" viewBox.

IMO this would be the expected behavior because the output SVG would behave the same as the input SVG in different contexts.

I'll look into it when there's time to spare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants