bpmn-visualization-js
bpmn-visualization-js copied to clipboard
[REFACTOR] try to restore svg labels
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
With 9484c99a (0.1.5-dev), we see that in case of unsupported foreign object, the label is replaced by [Object]
Note
- example given here is the svg export of the A.2.0.bpmn file from BPMN-MIWG
- the svg export is done by implementing a
mxImageExport
backed by amxSvgCanvas2D
(inspired from the draw.io svg exporter implementation)
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
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
- mxSvgCanvas2D.prototype.createAlternateContent
- mxSvgCanvas2D.prototype.getAlternateText
- mxSvgCanvas2D.prototype.foAltText: returns
[Object]
by default
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)