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

Replace foreignObject with standard SVG #2688

Open
rgoubet opened this issue Feb 4, 2022 · 4 comments
Open

Replace foreignObject with standard SVG #2688

rgoubet opened this issue Feb 4, 2022 · 4 comments
Labels
Type: Enhancement New feature or request

Comments

@rgoubet
Copy link

rgoubet commented Feb 4, 2022

Is your feature request related to a problem? Please describe.
An SVG file generated by Mermaid cannot be edited using Inkscape (all boxes are black). When inserting an SGV file to an Office document, text does not appear.

Describe the solution you'd like
Instead of using HTML code embedded in foreignObject elements, Mermaid should instead use simple text elements (similar to Graphviz) in order to ensure that the file can be processed by SVG-compatible any application.

Describe alternatives you've considered
An inkscape plugin exists to convert foreignObject elements, but it has approximate results.

Additional context
See also here.

@rgoubet rgoubet added Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request labels Feb 4, 2022
@aloisklink
Copy link
Member

Some diagrams have a htmlLabels: false option that you can use to remove <foreignObject> and use only SVG tags, see #58.

An SVG file generated by Mermaid cannot be edited using Inkscape (all boxes are black). When inserting an SGV file to an Office document, text does not appear.

I'm pretty sure this is also because of CSS issues, see #2102, since mermaid is using some newer CSS features that are not yet supported by Inkscape. Using simpler CSS might fix it.

@aloisklink aloisklink removed the Status: Triage Needs to be verified, categorized, etc label Sep 10, 2022
@rgoubet
Copy link
Author

rgoubet commented Sep 12, 2022

You're right, using this config file generates better results:

{
    "flowchart": {
        "htmlLabels": "false"
    }
}

Office will display it correctly. In Inkscape, it will only after you open the style selector (probably a bug).

@aloisklink
Copy link
Member

It might be possible to make htmlLabels the default setting. Apparently dagre-d3 had some issues with SVG styling, hence why they were using html labels, but that was back in 2015, it might be fixed now #58 (comment).

It's been reported too in mermaid-js/mermaid-cli#103 and https://gitlab.com/inkscape/inbox/-/issues/3268#note_378199615, so there's quite a big demand for it.

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

No branches or pull requests

2 participants