@antv/g-lite 2.2.11 → 2.2.13

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.esm.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.11
5
- * @date 12/26/2024, 8:33:47 AM
4
+ * @version 2.2.13
5
+ * @date 12/27/2024, 4:20:45 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -11463,6 +11463,7 @@ var TextService = /*#__PURE__*/function () {
11463
11463
  key: "wordWrap",
11464
11464
  value: function wordWrap(text, parsedStyle, offscreenCanvas) {
11465
11465
  var _this2 = this;
11466
+ var self = this;
11466
11467
  var _parsedStyle$wordWrap2 = parsedStyle.wordWrapWidth,
11467
11468
  wordWrapWidth = _parsedStyle$wordWrap2 === void 0 ? 0 : _parsedStyle$wordWrap2,
11468
11469
  _parsedStyle$letterSp2 = parsedStyle.letterSpacing,
@@ -11498,10 +11499,13 @@ var TextService = /*#__PURE__*/function () {
11498
11499
  */
11499
11500
  function findCharIndexClosestWidthThreshold(txt, textCharIndex, widthThreshold) {
11500
11501
  while (calcWidth(txt) < widthThreshold && textCharIndex < chars.length - 1) {
11502
+ if (self.isNewline(chars[textCharIndex + 1])) {
11503
+ break;
11504
+ }
11501
11505
  textCharIndex += 1;
11502
11506
  txt += chars[textCharIndex];
11503
11507
  }
11504
- while (calcWidth(txt) > widthThreshold) {
11508
+ while (calcWidth(txt) > widthThreshold && textCharIndex > 0) {
11505
11509
  textCharIndex -= 1;
11506
11510
  txt = txt.slice(0, -1);
11507
11511
  }
@@ -11533,7 +11537,7 @@ var TextService = /*#__PURE__*/function () {
11533
11537
  if (currentLineIndex + 1 >= maxLines) {
11534
11538
  parsedStyle.isOverflowing = true;
11535
11539
  if (i < chars.length - 1) {
11536
- appendEllipsis(currentLineIndex, i);
11540
+ appendEllipsis(currentLineIndex, i - 1);
11537
11541
  }
11538
11542
  break;
11539
11543
  }
@@ -11543,13 +11547,13 @@ var TextService = /*#__PURE__*/function () {
11543
11547
  continue;
11544
11548
  }
11545
11549
  if (currentLineWidth > 0 && currentLineWidth + charWidth > maxWidth) {
11546
- var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i, maxWidth);
11547
- if (result.textCharIndex !== i) {
11550
+ var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, maxWidth);
11551
+ if (result.textCharIndex !== i - 1) {
11548
11552
  lines[currentLineIndex] = result.txt;
11549
11553
  if (result.textCharIndex === chars.length - 1) {
11550
11554
  break;
11551
11555
  }
11552
- i = result.textCharIndex;
11556
+ i = result.textCharIndex + 1;
11553
11557
  _char2 = chars[i];
11554
11558
  prevChar = chars[i - 1];
11555
11559
  nextChar = chars[i + 1];
@@ -11557,7 +11561,7 @@ var TextService = /*#__PURE__*/function () {
11557
11561
  }
11558
11562
  if (currentLineIndex + 1 >= maxLines) {
11559
11563
  parsedStyle.isOverflowing = true;
11560
- appendEllipsis(currentLineIndex, i);
11564
+ appendEllipsis(currentLineIndex, i - 1);
11561
11565
  break;
11562
11566
  }
11563
11567
  currentLineIndex += 1;