@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.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
|
*/
|
|
@@ -11468,9 +11468,6 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11468
11468
|
};
|
|
11469
11469
|
}
|
|
11470
11470
|
}
|
|
11471
|
-
}, {
|
|
11472
|
-
key: "setGraphemeOnPath",
|
|
11473
|
-
value: function setGraphemeOnPath() {}
|
|
11474
11471
|
}, {
|
|
11475
11472
|
key: "wordWrap",
|
|
11476
11473
|
value: function wordWrap(text, parsedStyle, offscreenCanvas) {
|
|
@@ -11500,6 +11497,27 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11500
11497
|
var ellipsisWidth = Array.from(ellipsis).reduce(function (prev, cur) {
|
|
11501
11498
|
return prev + calcWidth(cur);
|
|
11502
11499
|
}, 0);
|
|
11500
|
+
function appendEllipsis(lineIndex) {
|
|
11501
|
+
// If there is not enough space to display the string itself, it is clipped.
|
|
11502
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#values
|
|
11503
|
+
if (ellipsisWidth <= 0 || ellipsisWidth > maxWidth) {
|
|
11504
|
+
return;
|
|
11505
|
+
}
|
|
11506
|
+
|
|
11507
|
+
// Backspace from line's end.
|
|
11508
|
+
var currentLineLength = lines[lineIndex].length;
|
|
11509
|
+
var lastLineWidth = 0;
|
|
11510
|
+
var lastLineIndex = currentLineLength;
|
|
11511
|
+
for (var i = 0; i < currentLineLength; i++) {
|
|
11512
|
+
var width = calcWidth(lines[lineIndex][i]);
|
|
11513
|
+
if (lastLineWidth + width + ellipsisWidth > maxWidth) {
|
|
11514
|
+
lastLineIndex = i;
|
|
11515
|
+
break;
|
|
11516
|
+
}
|
|
11517
|
+
lastLineWidth += width;
|
|
11518
|
+
}
|
|
11519
|
+
lines[lineIndex] = (lines[lineIndex] || '').slice(0, lastLineIndex) + ellipsis;
|
|
11520
|
+
}
|
|
11503
11521
|
var chars = Array.from(text);
|
|
11504
11522
|
for (var i = 0; i < chars.length; i++) {
|
|
11505
11523
|
var _char3 = chars[i];
|
|
@@ -11512,6 +11530,9 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11512
11530
|
// exceed maxLines, break immediately
|
|
11513
11531
|
if (currentIndex >= maxLines) {
|
|
11514
11532
|
parsedStyle.isOverflowing = true;
|
|
11533
|
+
if (i < chars.length - 1) {
|
|
11534
|
+
appendEllipsis(currentIndex - 1);
|
|
11535
|
+
}
|
|
11515
11536
|
break;
|
|
11516
11537
|
}
|
|
11517
11538
|
currentWidth = 0;
|
|
@@ -11521,24 +11542,7 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11521
11542
|
if (currentWidth > 0 && currentWidth + charWidth > maxWidth) {
|
|
11522
11543
|
if (currentIndex + 1 >= maxLines) {
|
|
11523
11544
|
parsedStyle.isOverflowing = true;
|
|
11524
|
-
|
|
11525
|
-
// If there is not enough space to display the string itself, it is clipped.
|
|
11526
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#values
|
|
11527
|
-
if (ellipsisWidth > 0 && ellipsisWidth <= maxWidth) {
|
|
11528
|
-
// Backspace from line's end.
|
|
11529
|
-
var currentLineLength = lines[currentIndex].length;
|
|
11530
|
-
var lastLineWidth = 0;
|
|
11531
|
-
var lastLineIndex = currentLineLength;
|
|
11532
|
-
for (var _i2 = 0; _i2 < currentLineLength; _i2++) {
|
|
11533
|
-
var width = calcWidth(lines[currentIndex][_i2]);
|
|
11534
|
-
if (lastLineWidth + width + ellipsisWidth > maxWidth) {
|
|
11535
|
-
lastLineIndex = _i2;
|
|
11536
|
-
break;
|
|
11537
|
-
}
|
|
11538
|
-
lastLineWidth += width;
|
|
11539
|
-
}
|
|
11540
|
-
lines[currentIndex] = (lines[currentIndex] || '').slice(0, lastLineIndex) + ellipsis;
|
|
11541
|
-
}
|
|
11545
|
+
appendEllipsis(currentIndex);
|
|
11542
11546
|
break;
|
|
11543
11547
|
}
|
|
11544
11548
|
currentIndex++;
|
|
@@ -12477,15 +12481,9 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
12477
12481
|
clonedStyle[attributeName] = customCloneFunc(attributeName, attribute);
|
|
12478
12482
|
}
|
|
12479
12483
|
}
|
|
12480
|
-
var cloned = new this.constructor({
|
|
12481
|
-
// copy id & name
|
|
12482
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
|
|
12483
|
-
id: this.id,
|
|
12484
|
-
name: this.name,
|
|
12485
|
-
className: this.name,
|
|
12486
|
-
interactive: this.interactive,
|
|
12484
|
+
var cloned = new this.constructor(_objectSpread(_objectSpread({}, this.config), {}, {
|
|
12487
12485
|
style: clonedStyle
|
|
12488
|
-
});
|
|
12486
|
+
}));
|
|
12489
12487
|
|
|
12490
12488
|
// apply transform
|
|
12491
12489
|
cloned.setLocalTransform(this.getLocalTransform());
|