html2canvas-pro 1.5.6 → 1.5.8
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/README.md +1 -0
- package/dist/html2canvas-pro.esm.js +21 -15
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +21 -15
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +2 -2
- package/dist/lib/dom/node-parser.js +2 -1
- package/dist/lib/dom/node-parser.js.map +1 -1
- package/dist/lib/render/canvas/canvas-renderer.js +18 -13
- package/dist/lib/render/canvas/canvas-renderer.js.map +1 -1
- package/package.json +1 -1
package/dist/html2canvas-pro.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
*
|
|
2
|
+
* html2canvas-pro 1.5.8 <https://yorickshan.github.io/html2canvas-pro/>
|
|
3
3
|
* Copyright (c) 2024 yorickshan <https://github.com/yorickshan>
|
|
4
4
|
* Released under MIT License
|
|
5
5
|
*/
|
|
@@ -5575,7 +5575,8 @@
|
|
|
5575
5575
|
var parseNodeTree = function (context, node, parent, root) {
|
|
5576
5576
|
for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {
|
|
5577
5577
|
nextNode = childNode.nextSibling;
|
|
5578
|
-
|
|
5578
|
+
// Fixes #2238 #1624 - Fix the issue of TextNode content being overlooked in rendering due to being perceived as blank by trim().
|
|
5579
|
+
if (isTextNode(childNode) && childNode.data.length > 0) {
|
|
5579
5580
|
parent.textNodes.push(new TextContainer(context, childNode, parent.styles));
|
|
5580
5581
|
}
|
|
5581
5582
|
else if (isElementNode(childNode)) {
|
|
@@ -7565,7 +7566,15 @@
|
|
|
7565
7566
|
CanvasRenderer.prototype.renderTextWithLetterSpacing = function (text, letterSpacing, baseline) {
|
|
7566
7567
|
var _this = this;
|
|
7567
7568
|
if (letterSpacing === 0) {
|
|
7568
|
-
|
|
7569
|
+
// Fixed an issue with characters moving up in non-Firefox.
|
|
7570
|
+
// https://github.com/niklasvh/html2canvas/issues/2107#issuecomment-692462900
|
|
7571
|
+
if (navigator.userAgent.indexOf('Firefox') === -1) {
|
|
7572
|
+
this.ctx.textBaseline = 'ideographic';
|
|
7573
|
+
this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
|
|
7574
|
+
}
|
|
7575
|
+
else {
|
|
7576
|
+
this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline);
|
|
7577
|
+
}
|
|
7569
7578
|
}
|
|
7570
7579
|
else {
|
|
7571
7580
|
var letters = segmentGraphemes(text.text);
|
|
@@ -7591,15 +7600,14 @@
|
|
|
7591
7600
|
};
|
|
7592
7601
|
CanvasRenderer.prototype.renderTextNode = function (text, styles) {
|
|
7593
7602
|
return __awaiter(this, void 0, void 0, function () {
|
|
7594
|
-
var
|
|
7603
|
+
var font, paintOrder;
|
|
7595
7604
|
var _this = this;
|
|
7596
|
-
return __generator(this, function (
|
|
7597
|
-
|
|
7605
|
+
return __generator(this, function (_a) {
|
|
7606
|
+
font = this.createFontStyle(styles)[0];
|
|
7598
7607
|
this.ctx.font = font;
|
|
7599
7608
|
this.ctx.direction = styles.direction === 1 /* DIRECTION.RTL */ ? 'rtl' : 'ltr';
|
|
7600
7609
|
this.ctx.textAlign = 'left';
|
|
7601
7610
|
this.ctx.textBaseline = 'alphabetic';
|
|
7602
|
-
_b = this.fontMetrics.getMetrics(fontFamily, fontSize), baseline = _b.baseline, middle = _b.middle;
|
|
7603
7611
|
paintOrder = styles.paintOrder;
|
|
7604
7612
|
text.textBounds.forEach(function (text) {
|
|
7605
7613
|
paintOrder.forEach(function (paintOrderLayer) {
|
|
@@ -7626,20 +7634,18 @@
|
|
|
7626
7634
|
}
|
|
7627
7635
|
if (styles.textDecorationLine.length) {
|
|
7628
7636
|
_this.ctx.fillStyle = asString(styles.textDecorationColor || styles.color);
|
|
7637
|
+
var decorationLineHeight_1 = 1;
|
|
7629
7638
|
styles.textDecorationLine.forEach(function (textDecorationLine) {
|
|
7639
|
+
// Fix the issue where textDecorationLine exhibits x-axis positioning errors on high-resolution devices due to varying devicePixelRatio, corrected by using relative values of element heights.
|
|
7630
7640
|
switch (textDecorationLine) {
|
|
7631
7641
|
case 1 /* TEXT_DECORATION_LINE.UNDERLINE */:
|
|
7632
|
-
|
|
7633
|
-
// TODO As some browsers display the line as more than 1px if the font-size is big,
|
|
7634
|
-
// need to take that into account both in position and size
|
|
7635
|
-
_this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top + baseline), text.bounds.width, 1);
|
|
7642
|
+
_this.ctx.fillRect(text.bounds.left, text.bounds.top + text.bounds.height - decorationLineHeight_1, text.bounds.width, decorationLineHeight_1);
|
|
7636
7643
|
break;
|
|
7637
7644
|
case 2 /* TEXT_DECORATION_LINE.OVERLINE */:
|
|
7638
|
-
_this.ctx.fillRect(text.bounds.left,
|
|
7645
|
+
_this.ctx.fillRect(text.bounds.left, text.bounds.top, text.bounds.width, decorationLineHeight_1);
|
|
7639
7646
|
break;
|
|
7640
7647
|
case 3 /* TEXT_DECORATION_LINE.LINE_THROUGH */:
|
|
7641
|
-
|
|
7642
|
-
_this.ctx.fillRect(text.bounds.left, Math.ceil(text.bounds.top + middle), text.bounds.width, 1);
|
|
7648
|
+
_this.ctx.fillRect(text.bounds.left, text.bounds.top + (text.bounds.height / 2 - decorationLineHeight_1 / 2), text.bounds.width, decorationLineHeight_1);
|
|
7643
7649
|
break;
|
|
7644
7650
|
}
|
|
7645
7651
|
});
|
|
@@ -7651,7 +7657,7 @@
|
|
|
7651
7657
|
_this.ctx.lineWidth = styles.webkitTextStrokeWidth;
|
|
7652
7658
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7653
7659
|
_this.ctx.lineJoin = !!window.chrome ? 'miter' : 'round';
|
|
7654
|
-
_this.ctx.strokeText(text.text, text.bounds.left, text.bounds.top +
|
|
7660
|
+
_this.ctx.strokeText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
|
|
7655
7661
|
}
|
|
7656
7662
|
_this.ctx.strokeStyle = '';
|
|
7657
7663
|
_this.ctx.lineWidth = 0;
|