process-analytics / bpmn-visualization-js

A TypeScript library for visualizing process execution data on BPMN diagrams
https://process-analytics.github.io/bpmn-visualization-js/
Apache License 2.0
215 stars 29 forks source link

[REFACTOR] try to restore svg labels #320

Open tbouffard opened 4 years ago

tbouffard commented 4 years ago

As of #299, we have switched to html labels as mxGraph 4.1.0 only supports wrapping out of the box with such labels.

As mention in the mxGraph documentation: Enabling HTML labels carries a possible security risk (see the section on security in the manual). This could also cause issue if we want to export the graph in svg (is html in svg foreign object correctly rendered by all svg viewer/editor?), as requested for #133

Using svg labels, wrapping could be done with svg text/tspan

tbouffard commented 4 years ago

With 9484c99a (0.1.5-dev), we see that in case of unsupported foreign object, the label is replaced by [Object] Note

For instance, with Inkscape 1.0 (at least on Ubuntu), the exported svg (see zipped svg master_9484c99a_A.2.0.zip) is rendered as in the following

master_9484c99a_A 2 0_inkscape-1 0_export

mxGraph 4.1.1 implementation notes

The svg exporter used to generate the svg presented here doesn't customize mxSvgCanvas2D foreignObject generation. By default, mxSvgCanvas2D generate a [Object] text label as alternative for viewers that don't support the foreingObject. We could at least use an implementation that display the right text label instead (with the risk of text overflow) See https://github.com/jgraph/mxgraph/blob/v4.1.1/javascript/src/js/util/mxSvgCanvas2D.js#L363

tbouffard commented 4 years ago

draw.io article about issues that may be introduced by html labels: https://www.diagrams.net/doc/faq/svg-export-text-problems (or legacy https://desk.draw.io/support/solutions/articles/16000042487)