zrender-nightly 5.6.1-dev.20241122 → 5.6.1-dev.20241123

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.
package/dist/zrender.js CHANGED
@@ -7337,7 +7337,7 @@
7337
7337
  function registerSSRDataGetter(getter) {
7338
7338
  ssrDataGetter = getter;
7339
7339
  }
7340
- var version = '5.6.1-dev.20241122';
7340
+ var version = '5.6.1-dev.20241123';
7341
7341
 
7342
7342
  var STYLE_MAGIC_KEY = '__zr_style_' + Math.round((Math.random() * 10));
7343
7343
  var DEFAULT_COMMON_STYLE = {
@@ -12551,16 +12551,23 @@
12551
12551
  }
12552
12552
 
12553
12553
  var STYLE_REG = /\{([a-zA-Z0-9_]+)\|([^}]*)\}/g;
12554
- function truncateText(text, containerWidth, font, ellipsis, options) {
12554
+ function truncateText2(out, text, containerWidth, font, ellipsis, options) {
12555
12555
  if (!containerWidth) {
12556
- return '';
12556
+ out.text = '';
12557
+ out.isTruncated = false;
12558
+ return;
12557
12559
  }
12558
12560
  var textLines = (text + '').split('\n');
12559
12561
  options = prepareTruncateOptions(containerWidth, font, ellipsis, options);
12562
+ var isTruncated = false;
12563
+ var truncateOut = {};
12560
12564
  for (var i = 0, len = textLines.length; i < len; i++) {
12561
- textLines[i] = truncateSingleLine(textLines[i], options);
12565
+ truncateSingleLine(truncateOut, textLines[i], options);
12566
+ textLines[i] = truncateOut.textLine;
12567
+ isTruncated = isTruncated || truncateOut.isTruncated;
12562
12568
  }
12563
- return textLines.join('\n');
12569
+ out.text = textLines.join('\n');
12570
+ out.isTruncated = isTruncated;
12564
12571
  }
12565
12572
  function prepareTruncateOptions(containerWidth, font, ellipsis, options) {
12566
12573
  options = options || {};
@@ -12588,16 +12595,20 @@
12588
12595
  preparedOpts.containerWidth = containerWidth;
12589
12596
  return preparedOpts;
12590
12597
  }
12591
- function truncateSingleLine(textLine, options) {
12598
+ function truncateSingleLine(out, textLine, options) {
12592
12599
  var containerWidth = options.containerWidth;
12593
12600
  var font = options.font;
12594
12601
  var contentWidth = options.contentWidth;
12595
12602
  if (!containerWidth) {
12596
- return '';
12603
+ out.textLine = '';
12604
+ out.isTruncated = false;
12605
+ return;
12597
12606
  }
12598
12607
  var lineWidth = getWidth(textLine, font);
12599
12608
  if (lineWidth <= containerWidth) {
12600
- return textLine;
12609
+ out.textLine = textLine;
12610
+ out.isTruncated = false;
12611
+ return;
12601
12612
  }
12602
12613
  for (var j = 0;; j++) {
12603
12614
  if (lineWidth <= contentWidth || j >= options.maxIterations) {
@@ -12615,7 +12626,8 @@
12615
12626
  if (textLine === '') {
12616
12627
  textLine = options.placeholder;
12617
12628
  }
12618
- return textLine;
12629
+ out.textLine = textLine;
12630
+ out.isTruncated = true;
12619
12631
  }
12620
12632
  function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
12621
12633
  var width = 0;
@@ -12636,6 +12648,7 @@
12636
12648
  var lineHeight = retrieve2(style.lineHeight, calculatedLineHeight);
12637
12649
  var bgColorDrawn = !!(style.backgroundColor);
12638
12650
  var truncateLineOverflow = style.lineOverflow === 'truncate';
12651
+ var isTruncated = false;
12639
12652
  var width = style.width;
12640
12653
  var lines;
12641
12654
  if (width != null && (overflow === 'break' || overflow === 'breakAll')) {
@@ -12648,6 +12661,7 @@
12648
12661
  var height = retrieve2(style.height, contentHeight);
12649
12662
  if (contentHeight > height && truncateLineOverflow) {
12650
12663
  var lineCount = Math.floor(height / lineHeight);
12664
+ isTruncated = isTruncated || (lines.length > lineCount);
12651
12665
  lines = lines.slice(0, lineCount);
12652
12666
  }
12653
12667
  if (text && truncate && width != null) {
@@ -12655,8 +12669,11 @@
12655
12669
  minChar: style.truncateMinChar,
12656
12670
  placeholder: style.placeholder
12657
12671
  });
12672
+ var singleOut = {};
12658
12673
  for (var i = 0; i < lines.length; i++) {
12659
- lines[i] = truncateSingleLine(lines[i], options);
12674
+ truncateSingleLine(singleOut, lines[i], options);
12675
+ lines[i] = singleOut.textLine;
12676
+ isTruncated = isTruncated || singleOut.isTruncated;
12660
12677
  }
12661
12678
  }
12662
12679
  var outerHeight = height;
@@ -12685,7 +12702,8 @@
12685
12702
  calculatedLineHeight: calculatedLineHeight,
12686
12703
  contentWidth: contentWidth,
12687
12704
  contentHeight: contentHeight,
12688
- width: width
12705
+ width: width,
12706
+ isTruncated: isTruncated
12689
12707
  };
12690
12708
  }
12691
12709
  var RichTextToken = (function () {
@@ -12711,6 +12729,7 @@
12711
12729
  this.outerWidth = 0;
12712
12730
  this.outerHeight = 0;
12713
12731
  this.lines = [];
12732
+ this.isTruncated = false;
12714
12733
  }
12715
12734
  return RichTextContentBlock;
12716
12735
  }());
@@ -12745,6 +12764,7 @@
12745
12764
  var stlPadding = style.padding;
12746
12765
  var truncate = overflow === 'truncate';
12747
12766
  var truncateLine = style.lineOverflow === 'truncate';
12767
+ var tmpTruncateOut = {};
12748
12768
  function finishLine(line, lineWidth, lineHeight) {
12749
12769
  line.width = lineWidth;
12750
12770
  line.lineHeight = lineHeight;
@@ -12770,6 +12790,7 @@
12770
12790
  token.align = tokenStyle && tokenStyle.align || style.align;
12771
12791
  token.verticalAlign = tokenStyle && tokenStyle.verticalAlign || 'middle';
12772
12792
  if (truncateLine && topHeight != null && calculatedHeight + token.lineHeight > topHeight) {
12793
+ var originalLength = contentBlock.lines.length;
12773
12794
  if (j > 0) {
12774
12795
  line.tokens = line.tokens.slice(0, j);
12775
12796
  finishLine(line, lineWidth, lineHeight);
@@ -12778,6 +12799,7 @@
12778
12799
  else {
12779
12800
  contentBlock.lines = contentBlock.lines.slice(0, i);
12780
12801
  }
12802
+ contentBlock.isTruncated = contentBlock.isTruncated || (contentBlock.lines.length < originalLength);
12781
12803
  break outer;
12782
12804
  }
12783
12805
  var styleTokenWidth = tokenStyle.width;
@@ -12806,7 +12828,9 @@
12806
12828
  token.width = token.contentWidth = 0;
12807
12829
  }
12808
12830
  else {
12809
- token.text = truncateText(token.text, remainTruncWidth - paddingH, font, style.ellipsis, { minChar: style.truncateMinChar });
12831
+ truncateText2(tmpTruncateOut, token.text, remainTruncWidth - paddingH, font, style.ellipsis, { minChar: style.truncateMinChar });
12832
+ token.text = tmpTruncateOut.text;
12833
+ contentBlock.isTruncated = contentBlock.isTruncated || tmpTruncateOut.isTruncated;
12810
12834
  token.width = token.contentWidth = getWidth(token.text, font);
12811
12835
  }
12812
12836
  }
@@ -13203,6 +13227,7 @@
13203
13227
  var textLines = contentBlock.lines;
13204
13228
  var lineHeight = contentBlock.lineHeight;
13205
13229
  var defaultStyle = this._defaultStyle;
13230
+ this.isTruncated = !!contentBlock.isTruncated;
13206
13231
  var baseX = style.x || 0;
13207
13232
  var baseY = style.y || 0;
13208
13233
  var textAlign = style.align || defaultStyle.align || 'left';
@@ -13286,6 +13311,7 @@
13286
13311
  var defaultStyle = this._defaultStyle;
13287
13312
  var textAlign = style.align || defaultStyle.align;
13288
13313
  var verticalAlign = style.verticalAlign || defaultStyle.verticalAlign;
13314
+ this.isTruncated = !!contentBlock.isTruncated;
13289
13315
  var boxX = adjustTextX(baseX, outerWidth, textAlign);
13290
13316
  var boxY = adjustTextY$1(baseY, outerHeight, verticalAlign);
13291
13317
  var xLeft = boxX;