@antv/g-lite 2.2.2 → 2.2.4
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 +29 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +29 -31
- 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/display-objects/DisplayObject.d.ts.map +1 -1
- package/types/services/TextService.d.ts +0 -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 11/
|
|
4
|
+
* @version 2.2.4
|
|
5
|
+
* @date 11/15/2024, 6:16:33 AM
|
|
6
6
|
* @author AntVis
|
|
7
7
|
* @docs https://g.antv.antgroup.com/
|
|
8
8
|
*/
|
|
@@ -11447,9 +11447,6 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11447
11447
|
};
|
|
11448
11448
|
}
|
|
11449
11449
|
}
|
|
11450
|
-
}, {
|
|
11451
|
-
key: "setGraphemeOnPath",
|
|
11452
|
-
value: function setGraphemeOnPath() {}
|
|
11453
11450
|
}, {
|
|
11454
11451
|
key: "wordWrap",
|
|
11455
11452
|
value: function wordWrap(text, parsedStyle, offscreenCanvas) {
|
|
@@ -11479,6 +11476,27 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11479
11476
|
var ellipsisWidth = Array.from(ellipsis).reduce(function (prev, cur) {
|
|
11480
11477
|
return prev + calcWidth(cur);
|
|
11481
11478
|
}, 0);
|
|
11479
|
+
function appendEllipsis(lineIndex) {
|
|
11480
|
+
// If there is not enough space to display the string itself, it is clipped.
|
|
11481
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#values
|
|
11482
|
+
if (ellipsisWidth <= 0 || ellipsisWidth > maxWidth) {
|
|
11483
|
+
return;
|
|
11484
|
+
}
|
|
11485
|
+
|
|
11486
|
+
// Backspace from line's end.
|
|
11487
|
+
var currentLineLength = lines[lineIndex].length;
|
|
11488
|
+
var lastLineWidth = 0;
|
|
11489
|
+
var lastLineIndex = currentLineLength;
|
|
11490
|
+
for (var i = 0; i < currentLineLength; i++) {
|
|
11491
|
+
var width = calcWidth(lines[lineIndex][i]);
|
|
11492
|
+
if (lastLineWidth + width + ellipsisWidth > maxWidth) {
|
|
11493
|
+
lastLineIndex = i;
|
|
11494
|
+
break;
|
|
11495
|
+
}
|
|
11496
|
+
lastLineWidth += width;
|
|
11497
|
+
}
|
|
11498
|
+
lines[lineIndex] = (lines[lineIndex] || '').slice(0, lastLineIndex) + ellipsis;
|
|
11499
|
+
}
|
|
11482
11500
|
var chars = Array.from(text);
|
|
11483
11501
|
for (var i = 0; i < chars.length; i++) {
|
|
11484
11502
|
var _char3 = chars[i];
|
|
@@ -11491,6 +11509,9 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11491
11509
|
// exceed maxLines, break immediately
|
|
11492
11510
|
if (currentIndex >= maxLines) {
|
|
11493
11511
|
parsedStyle.isOverflowing = true;
|
|
11512
|
+
if (i < chars.length - 1) {
|
|
11513
|
+
appendEllipsis(currentIndex - 1);
|
|
11514
|
+
}
|
|
11494
11515
|
break;
|
|
11495
11516
|
}
|
|
11496
11517
|
currentWidth = 0;
|
|
@@ -11500,24 +11521,7 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11500
11521
|
if (currentWidth > 0 && currentWidth + charWidth > maxWidth) {
|
|
11501
11522
|
if (currentIndex + 1 >= maxLines) {
|
|
11502
11523
|
parsedStyle.isOverflowing = true;
|
|
11503
|
-
|
|
11504
|
-
// If there is not enough space to display the string itself, it is clipped.
|
|
11505
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#values
|
|
11506
|
-
if (ellipsisWidth > 0 && ellipsisWidth <= maxWidth) {
|
|
11507
|
-
// Backspace from line's end.
|
|
11508
|
-
var currentLineLength = lines[currentIndex].length;
|
|
11509
|
-
var lastLineWidth = 0;
|
|
11510
|
-
var lastLineIndex = currentLineLength;
|
|
11511
|
-
for (var _i2 = 0; _i2 < currentLineLength; _i2++) {
|
|
11512
|
-
var width = calcWidth(lines[currentIndex][_i2]);
|
|
11513
|
-
if (lastLineWidth + width + ellipsisWidth > maxWidth) {
|
|
11514
|
-
lastLineIndex = _i2;
|
|
11515
|
-
break;
|
|
11516
|
-
}
|
|
11517
|
-
lastLineWidth += width;
|
|
11518
|
-
}
|
|
11519
|
-
lines[currentIndex] = (lines[currentIndex] || '').slice(0, lastLineIndex) + ellipsis;
|
|
11520
|
-
}
|
|
11524
|
+
appendEllipsis(currentIndex);
|
|
11521
11525
|
break;
|
|
11522
11526
|
}
|
|
11523
11527
|
currentIndex++;
|
|
@@ -12456,15 +12460,9 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
12456
12460
|
clonedStyle[attributeName] = customCloneFunc(attributeName, attribute);
|
|
12457
12461
|
}
|
|
12458
12462
|
}
|
|
12459
|
-
var cloned = new this.constructor({
|
|
12460
|
-
// copy id & name
|
|
12461
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
|
|
12462
|
-
id: this.id,
|
|
12463
|
-
name: this.name,
|
|
12464
|
-
className: this.name,
|
|
12465
|
-
interactive: this.interactive,
|
|
12463
|
+
var cloned = new this.constructor(_objectSpread(_objectSpread({}, this.config), {}, {
|
|
12466
12464
|
style: clonedStyle
|
|
12467
|
-
});
|
|
12465
|
+
}));
|
|
12468
12466
|
|
|
12469
12467
|
// apply transform
|
|
12470
12468
|
cloned.setLocalTransform(this.getLocalTransform());
|