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/README.md
CHANGED
|
@@ -11,6 +11,7 @@ Next generation JavaScript screenshots tool.
|
|
|
11
11
|
<a href="https://github.com/yorickshan/html2canvas-pro/actions/workflows/ci.yml"><img src="https://github.com/yorickshan/html2canvas-pro/actions/workflows/ci.yml/badge.svg?branch=main" alt="build status"></a>
|
|
12
12
|
<a href=https://npm.im/html2canvas-pro><img src="https://badgen.net/npm/v/html2canvas-pro" alt="npm version"></a>
|
|
13
13
|
<a href=http://npm.im/html2canvas-pro><img src="https://badgen.net/npm/dm/html2canvas-pro" alt="npm downloads"></a>
|
|
14
|
+
<a href="https://www.jsdelivr.com/package/npm/html2canvas-pro"><img src="https://data.jsdelivr.com/v1/package/npm/html2canvas-pro/badge" /></a>
|
|
14
15
|
<p>
|
|
15
16
|
<p align="center">
|
|
16
17
|
<a href="https://yorickshan.github.io/html2canvas-pro/">Documentation</a> | <a href="https://yorickshan.github.io/html2canvas-pro/getting-started.html">Getting Started</a>
|
|
@@ -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
|
*/
|
|
@@ -5569,7 +5569,8 @@ var LIST_OWNERS = ['OL', 'UL', 'MENU'];
|
|
|
5569
5569
|
var parseNodeTree = function (context, node, parent, root) {
|
|
5570
5570
|
for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {
|
|
5571
5571
|
nextNode = childNode.nextSibling;
|
|
5572
|
-
|
|
5572
|
+
// Fixes #2238 #1624 - Fix the issue of TextNode content being overlooked in rendering due to being perceived as blank by trim().
|
|
5573
|
+
if (isTextNode(childNode) && childNode.data.length > 0) {
|
|
5573
5574
|
parent.textNodes.push(new TextContainer(context, childNode, parent.styles));
|
|
5574
5575
|
}
|
|
5575
5576
|
else if (isElementNode(childNode)) {
|
|
@@ -7559,7 +7560,15 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
7559
7560
|
CanvasRenderer.prototype.renderTextWithLetterSpacing = function (text, letterSpacing, baseline) {
|
|
7560
7561
|
var _this = this;
|
|
7561
7562
|
if (letterSpacing === 0) {
|
|
7562
|
-
|
|
7563
|
+
// Fixed an issue with characters moving up in non-Firefox.
|
|
7564
|
+
// https://github.com/niklasvh/html2canvas/issues/2107#issuecomment-692462900
|
|
7565
|
+
if (navigator.userAgent.indexOf('Firefox') === -1) {
|
|
7566
|
+
this.ctx.textBaseline = 'ideographic';
|
|
7567
|
+
this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
|
|
7568
|
+
}
|
|
7569
|
+
else {
|
|
7570
|
+
this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline);
|
|
7571
|
+
}
|
|
7563
7572
|
}
|
|
7564
7573
|
else {
|
|
7565
7574
|
var letters = segmentGraphemes(text.text);
|
|
@@ -7585,15 +7594,14 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
7585
7594
|
};
|
|
7586
7595
|
CanvasRenderer.prototype.renderTextNode = function (text, styles) {
|
|
7587
7596
|
return __awaiter(this, void 0, void 0, function () {
|
|
7588
|
-
var
|
|
7597
|
+
var font, paintOrder;
|
|
7589
7598
|
var _this = this;
|
|
7590
|
-
return __generator(this, function (
|
|
7591
|
-
|
|
7599
|
+
return __generator(this, function (_a) {
|
|
7600
|
+
font = this.createFontStyle(styles)[0];
|
|
7592
7601
|
this.ctx.font = font;
|
|
7593
7602
|
this.ctx.direction = styles.direction === 1 /* DIRECTION.RTL */ ? 'rtl' : 'ltr';
|
|
7594
7603
|
this.ctx.textAlign = 'left';
|
|
7595
7604
|
this.ctx.textBaseline = 'alphabetic';
|
|
7596
|
-
_b = this.fontMetrics.getMetrics(fontFamily, fontSize), baseline = _b.baseline, middle = _b.middle;
|
|
7597
7605
|
paintOrder = styles.paintOrder;
|
|
7598
7606
|
text.textBounds.forEach(function (text) {
|
|
7599
7607
|
paintOrder.forEach(function (paintOrderLayer) {
|
|
@@ -7620,20 +7628,18 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
7620
7628
|
}
|
|
7621
7629
|
if (styles.textDecorationLine.length) {
|
|
7622
7630
|
_this.ctx.fillStyle = asString(styles.textDecorationColor || styles.color);
|
|
7631
|
+
var decorationLineHeight_1 = 1;
|
|
7623
7632
|
styles.textDecorationLine.forEach(function (textDecorationLine) {
|
|
7633
|
+
// 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.
|
|
7624
7634
|
switch (textDecorationLine) {
|
|
7625
7635
|
case 1 /* TEXT_DECORATION_LINE.UNDERLINE */:
|
|
7626
|
-
|
|
7627
|
-
// TODO As some browsers display the line as more than 1px if the font-size is big,
|
|
7628
|
-
// need to take that into account both in position and size
|
|
7629
|
-
_this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top + baseline), text.bounds.width, 1);
|
|
7636
|
+
_this.ctx.fillRect(text.bounds.left, text.bounds.top + text.bounds.height - decorationLineHeight_1, text.bounds.width, decorationLineHeight_1);
|
|
7630
7637
|
break;
|
|
7631
7638
|
case 2 /* TEXT_DECORATION_LINE.OVERLINE */:
|
|
7632
|
-
_this.ctx.fillRect(text.bounds.left,
|
|
7639
|
+
_this.ctx.fillRect(text.bounds.left, text.bounds.top, text.bounds.width, decorationLineHeight_1);
|
|
7633
7640
|
break;
|
|
7634
7641
|
case 3 /* TEXT_DECORATION_LINE.LINE_THROUGH */:
|
|
7635
|
-
|
|
7636
|
-
_this.ctx.fillRect(text.bounds.left, Math.ceil(text.bounds.top + middle), text.bounds.width, 1);
|
|
7642
|
+
_this.ctx.fillRect(text.bounds.left, text.bounds.top + (text.bounds.height / 2 - decorationLineHeight_1 / 2), text.bounds.width, decorationLineHeight_1);
|
|
7637
7643
|
break;
|
|
7638
7644
|
}
|
|
7639
7645
|
});
|
|
@@ -7645,7 +7651,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
7645
7651
|
_this.ctx.lineWidth = styles.webkitTextStrokeWidth;
|
|
7646
7652
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7647
7653
|
_this.ctx.lineJoin = !!window.chrome ? 'miter' : 'round';
|
|
7648
|
-
_this.ctx.strokeText(text.text, text.bounds.left, text.bounds.top +
|
|
7654
|
+
_this.ctx.strokeText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
|
|
7649
7655
|
}
|
|
7650
7656
|
_this.ctx.strokeStyle = '';
|
|
7651
7657
|
_this.ctx.lineWidth = 0;
|