@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.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
  */
@@ -11484,6 +11484,7 @@ var TextService = /*#__PURE__*/function () {
11484
11484
  key: "wordWrap",
11485
11485
  value: function wordWrap(text, parsedStyle, offscreenCanvas) {
11486
11486
  var _this2 = this;
11487
+ var self = this;
11487
11488
  var _parsedStyle$wordWrap2 = parsedStyle.wordWrapWidth,
11488
11489
  wordWrapWidth = _parsedStyle$wordWrap2 === void 0 ? 0 : _parsedStyle$wordWrap2,
11489
11490
  _parsedStyle$letterSp2 = parsedStyle.letterSpacing,
@@ -11519,10 +11520,13 @@ var TextService = /*#__PURE__*/function () {
11519
11520
  */
11520
11521
  function findCharIndexClosestWidthThreshold(txt, textCharIndex, widthThreshold) {
11521
11522
  while (calcWidth(txt) < widthThreshold && textCharIndex < chars.length - 1) {
11523
+ if (self.isNewline(chars[textCharIndex + 1])) {
11524
+ break;
11525
+ }
11522
11526
  textCharIndex += 1;
11523
11527
  txt += chars[textCharIndex];
11524
11528
  }
11525
- while (calcWidth(txt) > widthThreshold) {
11529
+ while (calcWidth(txt) > widthThreshold && textCharIndex > 0) {
11526
11530
  textCharIndex -= 1;
11527
11531
  txt = txt.slice(0, -1);
11528
11532
  }
@@ -11554,7 +11558,7 @@ var TextService = /*#__PURE__*/function () {
11554
11558
  if (currentLineIndex + 1 >= maxLines) {
11555
11559
  parsedStyle.isOverflowing = true;
11556
11560
  if (i < chars.length - 1) {
11557
- appendEllipsis(currentLineIndex, i);
11561
+ appendEllipsis(currentLineIndex, i - 1);
11558
11562
  }
11559
11563
  break;
11560
11564
  }
@@ -11564,13 +11568,13 @@ var TextService = /*#__PURE__*/function () {
11564
11568
  continue;
11565
11569
  }
11566
11570
  if (currentLineWidth > 0 && currentLineWidth + charWidth > maxWidth) {
11567
- var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i, maxWidth);
11568
- if (result.textCharIndex !== i) {
11571
+ var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, maxWidth);
11572
+ if (result.textCharIndex !== i - 1) {
11569
11573
  lines[currentLineIndex] = result.txt;
11570
11574
  if (result.textCharIndex === chars.length - 1) {
11571
11575
  break;
11572
11576
  }
11573
- i = result.textCharIndex;
11577
+ i = result.textCharIndex + 1;
11574
11578
  _char2 = chars[i];
11575
11579
  prevChar = chars[i - 1];
11576
11580
  nextChar = chars[i + 1];
@@ -11578,7 +11582,7 @@ var TextService = /*#__PURE__*/function () {
11578
11582
  }
11579
11583
  if (currentLineIndex + 1 >= maxLines) {
11580
11584
  parsedStyle.isOverflowing = true;
11581
- appendEllipsis(currentLineIndex, i);
11585
+ appendEllipsis(currentLineIndex, i - 1);
11582
11586
  break;
11583
11587
  }
11584
11588
  currentLineIndex += 1;