@antv/g-lite 2.2.2 → 2.2.3

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/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * @antv/g-lite
3
3
  * @description A core module for rendering engine implements DOM API.
4
- * @version 2.2.2
5
- * @date 11/7/2024, 7:43:00 AM
4
+ * @version 2.2.3
5
+ * @date 11/14/2024, 8:16:02 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -11468,9 +11468,6 @@ var TextService = /*#__PURE__*/function () {
11468
11468
  };
11469
11469
  }
11470
11470
  }
11471
- }, {
11472
- key: "setGraphemeOnPath",
11473
- value: function setGraphemeOnPath() {}
11474
11471
  }, {
11475
11472
  key: "wordWrap",
11476
11473
  value: function wordWrap(text, parsedStyle, offscreenCanvas) {
@@ -11500,6 +11497,27 @@ var TextService = /*#__PURE__*/function () {
11500
11497
  var ellipsisWidth = Array.from(ellipsis).reduce(function (prev, cur) {
11501
11498
  return prev + calcWidth(cur);
11502
11499
  }, 0);
11500
+ function appendEllipsis(lineIndex) {
11501
+ // If there is not enough space to display the string itself, it is clipped.
11502
+ // @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#values
11503
+ if (ellipsisWidth <= 0 || ellipsisWidth > maxWidth) {
11504
+ return;
11505
+ }
11506
+
11507
+ // Backspace from line's end.
11508
+ var currentLineLength = lines[lineIndex].length;
11509
+ var lastLineWidth = 0;
11510
+ var lastLineIndex = currentLineLength;
11511
+ for (var i = 0; i < currentLineLength; i++) {
11512
+ var width = calcWidth(lines[lineIndex][i]);
11513
+ if (lastLineWidth + width + ellipsisWidth > maxWidth) {
11514
+ lastLineIndex = i;
11515
+ break;
11516
+ }
11517
+ lastLineWidth += width;
11518
+ }
11519
+ lines[lineIndex] = (lines[lineIndex] || '').slice(0, lastLineIndex) + ellipsis;
11520
+ }
11503
11521
  var chars = Array.from(text);
11504
11522
  for (var i = 0; i < chars.length; i++) {
11505
11523
  var _char3 = chars[i];
@@ -11512,6 +11530,9 @@ var TextService = /*#__PURE__*/function () {
11512
11530
  // exceed maxLines, break immediately
11513
11531
  if (currentIndex >= maxLines) {
11514
11532
  parsedStyle.isOverflowing = true;
11533
+ if (i < chars.length - 1) {
11534
+ appendEllipsis(currentIndex - 1);
11535
+ }
11515
11536
  break;
11516
11537
  }
11517
11538
  currentWidth = 0;
@@ -11521,24 +11542,7 @@ var TextService = /*#__PURE__*/function () {
11521
11542
  if (currentWidth > 0 && currentWidth + charWidth > maxWidth) {
11522
11543
  if (currentIndex + 1 >= maxLines) {
11523
11544
  parsedStyle.isOverflowing = true;
11524
-
11525
- // If there is not enough space to display the string itself, it is clipped.
11526
- // @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#values
11527
- if (ellipsisWidth > 0 && ellipsisWidth <= maxWidth) {
11528
- // Backspace from line's end.
11529
- var currentLineLength = lines[currentIndex].length;
11530
- var lastLineWidth = 0;
11531
- var lastLineIndex = currentLineLength;
11532
- for (var _i2 = 0; _i2 < currentLineLength; _i2++) {
11533
- var width = calcWidth(lines[currentIndex][_i2]);
11534
- if (lastLineWidth + width + ellipsisWidth > maxWidth) {
11535
- lastLineIndex = _i2;
11536
- break;
11537
- }
11538
- lastLineWidth += width;
11539
- }
11540
- lines[currentIndex] = (lines[currentIndex] || '').slice(0, lastLineIndex) + ellipsis;
11541
- }
11545
+ appendEllipsis(currentIndex);
11542
11546
  break;
11543
11547
  }
11544
11548
  currentIndex++;