@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.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
|
*/
|
|
@@ -11504,6 +11504,7 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11504
11504
|
var lines = [];
|
|
11505
11505
|
var currentLineIndex = 0;
|
|
11506
11506
|
var currentLineWidth = 0;
|
|
11507
|
+
var prevLineLastCharIndex = 0;
|
|
11507
11508
|
var cache = {};
|
|
11508
11509
|
var calcWidth = function calcWidth(txt) {
|
|
11509
11510
|
return _this2.getFromCache(txt, letterSpacing, cache, context);
|
|
@@ -11515,24 +11516,25 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11515
11516
|
*
|
|
11516
11517
|
* @see https://github.com/antvis/G/issues/1833
|
|
11517
11518
|
*
|
|
11518
|
-
* @param
|
|
11519
|
-
* @param
|
|
11519
|
+
* @param lineTxt - Current line of text
|
|
11520
|
+
* @param txtLastCharIndex - The index of the last character of the current line in the entire text
|
|
11521
|
+
* @param txtStartCharIndex - The index of the start character of the current line in the entire text
|
|
11520
11522
|
*/
|
|
11521
|
-
function findCharIndexClosestWidthThreshold(
|
|
11522
|
-
while (calcWidth(
|
|
11523
|
-
if (self.isNewline(chars[
|
|
11523
|
+
function findCharIndexClosestWidthThreshold(lineTxt, txtLastCharIndex, txtStartCharIndex, widthThreshold) {
|
|
11524
|
+
while (calcWidth(lineTxt) < widthThreshold && txtLastCharIndex < chars.length - 1) {
|
|
11525
|
+
if (self.isNewline(chars[txtLastCharIndex + 1])) {
|
|
11524
11526
|
break;
|
|
11525
11527
|
}
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
+
txtLastCharIndex += 1;
|
|
11529
|
+
lineTxt += chars[txtLastCharIndex];
|
|
11528
11530
|
}
|
|
11529
|
-
while (calcWidth(
|
|
11530
|
-
|
|
11531
|
-
|
|
11531
|
+
while (calcWidth(lineTxt) > widthThreshold && txtLastCharIndex > txtStartCharIndex) {
|
|
11532
|
+
txtLastCharIndex -= 1;
|
|
11533
|
+
lineTxt = lineTxt.slice(0, -1);
|
|
11532
11534
|
}
|
|
11533
11535
|
return {
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
+
lineTxt: lineTxt,
|
|
11537
|
+
txtLastCharIndex: txtLastCharIndex
|
|
11536
11538
|
};
|
|
11537
11539
|
}
|
|
11538
11540
|
function appendEllipsis(lineIndex, textCharIndex) {
|
|
@@ -11545,8 +11547,8 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11545
11547
|
lines[lineIndex] = ellipsis;
|
|
11546
11548
|
return;
|
|
11547
11549
|
}
|
|
11548
|
-
var result = findCharIndexClosestWidthThreshold(lines[lineIndex], textCharIndex, maxWidth - ellipsisWidth);
|
|
11549
|
-
lines[lineIndex] = result.
|
|
11550
|
+
var result = findCharIndexClosestWidthThreshold(lines[lineIndex], textCharIndex, prevLineLastCharIndex + 1, maxWidth - ellipsisWidth);
|
|
11551
|
+
lines[lineIndex] = result.lineTxt + ellipsis;
|
|
11550
11552
|
}
|
|
11551
11553
|
for (var i = 0; i < chars.length; i++) {
|
|
11552
11554
|
var _char2 = chars[i];
|
|
@@ -11562,19 +11564,20 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11562
11564
|
}
|
|
11563
11565
|
break;
|
|
11564
11566
|
}
|
|
11567
|
+
prevLineLastCharIndex = i - 1;
|
|
11565
11568
|
currentLineIndex += 1;
|
|
11566
11569
|
currentLineWidth = 0;
|
|
11567
11570
|
lines[currentLineIndex] = '';
|
|
11568
11571
|
continue;
|
|
11569
11572
|
}
|
|
11570
11573
|
if (currentLineWidth > 0 && currentLineWidth + charWidth > maxWidth) {
|
|
11571
|
-
var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, maxWidth);
|
|
11572
|
-
if (result.
|
|
11573
|
-
lines[currentLineIndex] = result.
|
|
11574
|
-
if (result.
|
|
11574
|
+
var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, prevLineLastCharIndex + 1, maxWidth);
|
|
11575
|
+
if (result.txtLastCharIndex !== i - 1) {
|
|
11576
|
+
lines[currentLineIndex] = result.lineTxt;
|
|
11577
|
+
if (result.txtLastCharIndex === chars.length - 1) {
|
|
11575
11578
|
break;
|
|
11576
11579
|
}
|
|
11577
|
-
i = result.
|
|
11580
|
+
i = result.txtLastCharIndex + 1;
|
|
11578
11581
|
_char2 = chars[i];
|
|
11579
11582
|
prevChar = chars[i - 1];
|
|
11580
11583
|
nextChar = chars[i + 1];
|
|
@@ -11585,6 +11588,7 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11585
11588
|
appendEllipsis(currentLineIndex, i - 1);
|
|
11586
11589
|
break;
|
|
11587
11590
|
}
|
|
11591
|
+
prevLineLastCharIndex = i - 1;
|
|
11588
11592
|
currentLineIndex += 1;
|
|
11589
11593
|
currentLineWidth = 0;
|
|
11590
11594
|
lines[currentLineIndex] = '';
|