clientIO / joint

A proven SVG-based JavaScript diagramming library powering exceptional UIs
https://jointjs.com
Mozilla Public License 2.0
4.45k stars 841 forks source link

fix(attributes): text-wrap takes external CSS into account #2542

Closed kumilingus closed 2 months ago

kumilingus commented 3 months ago

Description

The text-wrap attribute takes external CSS and inherited styles into account when computing the line breaks (previously only explicit inline attributes were considered).

The text-wrap worked properly only when the font attributes were set explicitly.

<text font-size="12">A text to wrap</text>

This PR adds support for external CSS:

<style>
  text { font-size: 12px; }
</style>

...

<text>A text to wrap</text>

Note: Thanks to https://github.com/clientIO/joint/pull/2459, all font attributes are evaluated and set before text-wrap, so it is safe to use the getComputedStyle() method.

Fixes https://github.com/clientIO/joint/issues/2295.