@twick/2d 0.15.20 → 0.15.21
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.cjs +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -9339,7 +9339,11 @@ var TxtLeaf = class extends Shape {
|
|
|
9339
9339
|
}
|
|
9340
9340
|
const fontOffset = context.measureText("").fontBoundingBoxAscent;
|
|
9341
9341
|
const parentRect = this.element.getBoundingClientRect();
|
|
9342
|
-
const
|
|
9342
|
+
const fullRange = document.createRange();
|
|
9343
|
+
fullRange.selectNodeContents(this.element);
|
|
9344
|
+
const fullRect = fullRange.getBoundingClientRect();
|
|
9345
|
+
const centerX = (fullRect.left + fullRect.right) / 2;
|
|
9346
|
+
const centerY = (fullRect.top + fullRect.bottom) / 2;
|
|
9343
9347
|
const range = document.createRange();
|
|
9344
9348
|
let line = "";
|
|
9345
9349
|
const lineRect = new import_core57.BBox();
|
|
@@ -9349,8 +9353,8 @@ var TxtLeaf = class extends Shape {
|
|
|
9349
9353
|
}
|
|
9350
9354
|
range.selectNodeContents(childNode);
|
|
9351
9355
|
const rangeRect = range.getBoundingClientRect();
|
|
9352
|
-
const x =
|
|
9353
|
-
const y =
|
|
9356
|
+
const x = rangeRect.left - centerX;
|
|
9357
|
+
const y = rangeRect.top - centerY + fontOffset;
|
|
9354
9358
|
if (lineRect.y === y) {
|
|
9355
9359
|
lineRect.width += rangeRect.width;
|
|
9356
9360
|
line += childNode.textContent;
|