@joint/core 4.0.3 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.0.3 (2024-05-14) - JavaScript diagramming library
1
+ /*! JointJS v4.0.4 (2024-05-31) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
@@ -17407,6 +17407,8 @@ var joint = (function (exports) {
17407
17407
  return (attrs.text !== undefined);
17408
17408
  }
17409
17409
 
17410
+ var FONT_ATTRIBUTES = ['font-weight', 'font-family', 'font-size', 'letter-spacing', 'text-transform'];
17411
+
17410
17412
  var textAttributesNS = {
17411
17413
 
17412
17414
  'line-height': {
@@ -17522,18 +17524,28 @@ var joint = (function (exports) {
17522
17524
  var text = value.text;
17523
17525
  if (text === undefined) { text = attrs.text; }
17524
17526
  if (text !== undefined) {
17527
+
17525
17528
  var breakTextFn = value.breakText || breakText;
17526
17529
  var computedStyles = getComputedStyle(node);
17530
+ var wrapFontAttributes = {};
17531
+ // The font size attributes must be set on the node
17532
+ // to get the correct text wrapping.
17533
+ // TODO: set the native SVG attributes before special attributes
17534
+ for (var i = 0; i < FONT_ATTRIBUTES.length; i++) {
17535
+ var name = FONT_ATTRIBUTES[i];
17536
+ if (name in attrs) {
17537
+ node.setAttribute(name, attrs[name]);
17538
+ }
17539
+ // Note: computedStyles is a live object
17540
+ // i.e. the properties are evaluated when accessed.
17541
+ wrapFontAttributes[name] = computedStyles[name];
17542
+ }
17527
17543
 
17528
- wrappedText = breakTextFn('' + text, size, {
17529
- 'font-weight': computedStyles.fontWeight,
17530
- 'font-family': computedStyles.fontFamily,
17531
- 'text-transform': computedStyles.textTransform,
17532
- 'font-size': computedStyles.fontSize,
17533
- 'letter-spacing': computedStyles.letterSpacing,
17534
- // The `line-height` attribute in SVG is JoinJS specific.
17535
- 'lineHeight': attrs['line-height'],
17536
- }, {
17544
+ // The `line-height` attribute in SVG is JoinJS specific.
17545
+ // TODO: change the `lineHeight` to breakText option.
17546
+ wrapFontAttributes.lineHeight = attrs['line-height'];
17547
+
17548
+ wrappedText = breakTextFn('' + text, size, wrapFontAttributes, {
17537
17549
  // Provide an existing SVG Document here
17538
17550
  // instead of creating a temporary one over again.
17539
17551
  svgDocument: this.paper.svg,
@@ -17547,7 +17559,11 @@ var joint = (function (exports) {
17547
17559
  wrappedText = '';
17548
17560
  }
17549
17561
  textAttributesNS.text.set.call(this, wrappedText, refBBox, node, attrs);
17550
- }
17562
+ },
17563
+ // We expose the font attributes list to allow
17564
+ // the user to take other custom font attributes into account
17565
+ // when wrapping the text.
17566
+ FONT_ATTRIBUTES: FONT_ATTRIBUTES
17551
17567
  },
17552
17568
 
17553
17569
  'title': {
@@ -21614,6 +21630,11 @@ var joint = (function (exports) {
21614
21630
  svgforeignobject: function() {
21615
21631
  return !!document.createElementNS &&
21616
21632
  /SVGForeignObject/.test(({}).toString.call(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')));
21633
+ },
21634
+
21635
+ // works for iOS browsers too
21636
+ isSafari: function() {
21637
+ return /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
21617
21638
  }
21618
21639
  },
21619
21640
 
@@ -32482,6 +32503,11 @@ var joint = (function (exports) {
32482
32503
  this.updateHighlighters(true);
32483
32504
  this.updateTools(opt);
32484
32505
  flags = this.removeFlag(flags, [Flags$2.RENDER, Flags$2.UPDATE, Flags$2.LABELS, Flags$2.TOOLS, Flags$2.CONNECTOR]);
32506
+
32507
+ if (env.test('isSafari')) {
32508
+ this.__fixSafariBug268376();
32509
+ }
32510
+
32485
32511
  return flags;
32486
32512
  }
32487
32513
 
@@ -32535,6 +32561,20 @@ var joint = (function (exports) {
32535
32561
  return flags;
32536
32562
  },
32537
32563
 
32564
+ __fixSafariBug268376: function() {
32565
+ // Safari has a bug where any change after the first render is not reflected in the DOM.
32566
+ // https://bugs.webkit.org/show_bug.cgi?id=268376
32567
+ var ref = this;
32568
+ var el = ref.el;
32569
+ var childNodes = Array.from(el.childNodes);
32570
+ var fragment = document.createDocumentFragment();
32571
+ for (var i = 0, n = childNodes.length; i < n; i++) {
32572
+ el.removeChild(childNodes[i]);
32573
+ fragment.appendChild(childNodes[i]);
32574
+ }
32575
+ el.appendChild(fragment);
32576
+ },
32577
+
32538
32578
  requestConnectionUpdate: function(opt) {
32539
32579
  this.requestUpdate(this.getFlag(Flags$2.UPDATE), opt);
32540
32580
  },
@@ -39945,7 +39985,7 @@ var joint = (function (exports) {
39945
39985
  Control: Control
39946
39986
  });
39947
39987
 
39948
- var version = "4.0.3";
39988
+ var version = "4.0.4";
39949
39989
 
39950
39990
  var Vectorizer = V;
39951
39991
  var layout = { PortLabel: PortLabel, Port: Port };