@antv/g-lite 2.2.13 → 2.2.14
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 +25 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +25 -21
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +4 -4
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/types/services/TextService.d.ts.map +1 -1
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.
|
|
5
|
-
* @date
|
|
4
|
+
* @version 2.2.14
|
|
5
|
+
* @date 1/2/2025, 2:54:20 AM
|
|
6
6
|
* @author AntVis
|
|
7
7
|
* @docs https://g.antv.antgroup.com/
|
|
8
8
|
*/
|
|
@@ -11483,6 +11483,7 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11483
11483
|
var lines = [];
|
|
11484
11484
|
var currentLineIndex = 0;
|
|
11485
11485
|
var currentLineWidth = 0;
|
|
11486
|
+
var prevLineLastCharIndex = 0;
|
|
11486
11487
|
var cache = {};
|
|
11487
11488
|
var calcWidth = function calcWidth(txt) {
|
|
11488
11489
|
return _this2.getFromCache(txt, letterSpacing, cache, context);
|
|
@@ -11494,24 +11495,25 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11494
11495
|
*
|
|
11495
11496
|
* @see https://github.com/antvis/G/issues/1833
|
|
11496
11497
|
*
|
|
11497
|
-
* @param
|
|
11498
|
-
* @param
|
|
11498
|
+
* @param lineTxt - Current line of text
|
|
11499
|
+
* @param txtLastCharIndex - The index of the last character of the current line in the entire text
|
|
11500
|
+
* @param txtStartCharIndex - The index of the start character of the current line in the entire text
|
|
11499
11501
|
*/
|
|
11500
|
-
function findCharIndexClosestWidthThreshold(
|
|
11501
|
-
while (calcWidth(
|
|
11502
|
-
if (self.isNewline(chars[
|
|
11502
|
+
function findCharIndexClosestWidthThreshold(lineTxt, txtLastCharIndex, txtStartCharIndex, widthThreshold) {
|
|
11503
|
+
while (calcWidth(lineTxt) < widthThreshold && txtLastCharIndex < chars.length - 1) {
|
|
11504
|
+
if (self.isNewline(chars[txtLastCharIndex + 1])) {
|
|
11503
11505
|
break;
|
|
11504
11506
|
}
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
+
txtLastCharIndex += 1;
|
|
11508
|
+
lineTxt += chars[txtLastCharIndex];
|
|
11507
11509
|
}
|
|
11508
|
-
while (calcWidth(
|
|
11509
|
-
|
|
11510
|
-
|
|
11510
|
+
while (calcWidth(lineTxt) > widthThreshold && txtLastCharIndex > txtStartCharIndex) {
|
|
11511
|
+
txtLastCharIndex -= 1;
|
|
11512
|
+
lineTxt = lineTxt.slice(0, -1);
|
|
11511
11513
|
}
|
|
11512
11514
|
return {
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
+
lineTxt: lineTxt,
|
|
11516
|
+
txtLastCharIndex: txtLastCharIndex
|
|
11515
11517
|
};
|
|
11516
11518
|
}
|
|
11517
11519
|
function appendEllipsis(lineIndex, textCharIndex) {
|
|
@@ -11524,8 +11526,8 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11524
11526
|
lines[lineIndex] = ellipsis;
|
|
11525
11527
|
return;
|
|
11526
11528
|
}
|
|
11527
|
-
var result = findCharIndexClosestWidthThreshold(lines[lineIndex], textCharIndex, maxWidth - ellipsisWidth);
|
|
11528
|
-
lines[lineIndex] = result.
|
|
11529
|
+
var result = findCharIndexClosestWidthThreshold(lines[lineIndex], textCharIndex, prevLineLastCharIndex + 1, maxWidth - ellipsisWidth);
|
|
11530
|
+
lines[lineIndex] = result.lineTxt + ellipsis;
|
|
11529
11531
|
}
|
|
11530
11532
|
for (var i = 0; i < chars.length; i++) {
|
|
11531
11533
|
var _char2 = chars[i];
|
|
@@ -11541,19 +11543,20 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11541
11543
|
}
|
|
11542
11544
|
break;
|
|
11543
11545
|
}
|
|
11546
|
+
prevLineLastCharIndex = i - 1;
|
|
11544
11547
|
currentLineIndex += 1;
|
|
11545
11548
|
currentLineWidth = 0;
|
|
11546
11549
|
lines[currentLineIndex] = '';
|
|
11547
11550
|
continue;
|
|
11548
11551
|
}
|
|
11549
11552
|
if (currentLineWidth > 0 && currentLineWidth + charWidth > maxWidth) {
|
|
11550
|
-
var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, maxWidth);
|
|
11551
|
-
if (result.
|
|
11552
|
-
lines[currentLineIndex] = result.
|
|
11553
|
-
if (result.
|
|
11553
|
+
var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, prevLineLastCharIndex + 1, maxWidth);
|
|
11554
|
+
if (result.txtLastCharIndex !== i - 1) {
|
|
11555
|
+
lines[currentLineIndex] = result.lineTxt;
|
|
11556
|
+
if (result.txtLastCharIndex === chars.length - 1) {
|
|
11554
11557
|
break;
|
|
11555
11558
|
}
|
|
11556
|
-
i = result.
|
|
11559
|
+
i = result.txtLastCharIndex + 1;
|
|
11557
11560
|
_char2 = chars[i];
|
|
11558
11561
|
prevChar = chars[i - 1];
|
|
11559
11562
|
nextChar = chars[i + 1];
|
|
@@ -11564,6 +11567,7 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11564
11567
|
appendEllipsis(currentLineIndex, i - 1);
|
|
11565
11568
|
break;
|
|
11566
11569
|
}
|
|
11570
|
+
prevLineLastCharIndex = i - 1;
|
|
11567
11571
|
currentLineIndex += 1;
|
|
11568
11572
|
currentLineWidth = 0;
|
|
11569
11573
|
lines[currentLineIndex] = '';
|