Forum Feature requests

Support for foreign objects in SVG?

Richard B. Kreckel
I've seen a few feature requests for SVG foreign object support in Prince, but they're all many years old. Also, there's an item on the roadmap.

May I ask what the status regarding this feature is? I'm asking because this is becoming more and more common, for instance in diagrams.net they seem to be using it often (see https://desk.draw.io/support/solutions/articles/16000042487).
mikeday
We will take another look at this feature.
Richard B. Kreckel
Any news yet on foreign objects? (Sorry for being a nuisance.)
mikeday
Not yet, it requires a bit of a rethink of the way we handle things!
rsands
+1, we have hit a stumbling block without foreignObject. Reason for foreignObject is the limited abilities of <text> and dealing with multiline.

We place divs inside of the foreignObject. Any ideas for a potential workaround? Would it involve us lifting the <divs> outside of the <svg> and positioning absolute?
mikeday
Yes, for multiline text it is simplest to use HTML outside of the SVG for now.
depth42
I wanted to add a vote for HTML foreign objects inside SVG, too.
yyang
Foreign objects are essential to mermaid diagrams. Hope this feature could be implemented in the near future.
mikeday
It's been a journey but the Prince pre-release builds now include support for the SVG foreignObject element, allowing the use of HTML in SVG diagrams! :D
yyang
It's working great for what I've tested so far. Finally I don't have to use `"simpleLabels": true` in draw.io. Thanks a lot for this wonderful achievement!

A related issue is that some SVGs (like this one) use CSS features like "color-scheme:light dark" and "light-dark(#fff,var(--ge-dark-color, #121212))", and they have to be manually patched. Hope these features can be supported, too.