html2canvas-pro 1.5.11 → 1.5.12
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/html2canvas-pro.esm.js +83 -12
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +83 -12
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +2 -2
- package/dist/lib/css/index.js +3 -1
- package/dist/lib/css/index.js.map +1 -1
- package/dist/lib/css/property-descriptors/rotate.js +28 -0
- package/dist/lib/css/property-descriptors/rotate.js.map +1 -0
- package/dist/lib/css/property-descriptors/transform.js +25 -4
- package/dist/lib/css/property-descriptors/transform.js.map +1 -1
- package/dist/lib/dom/document-cloner.js +17 -6
- package/dist/lib/dom/document-cloner.js.map +1 -1
- package/dist/lib/dom/element-container.js +4 -0
- package/dist/lib/dom/element-container.js.map +1 -1
- package/dist/lib/render/stacking-context.js +11 -0
- package/dist/lib/render/stacking-context.js.map +1 -1
- package/dist/types/css/index.d.ts +2 -0
- package/dist/types/css/property-descriptors/rotate.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* html2canvas-pro 1.5.
|
|
2
|
+
* html2canvas-pro 1.5.12 <https://yorickshan.github.io/html2canvas-pro/>
|
|
3
3
|
* Copyright (c) 2024-present yorickshan and html2canvas-pro contributors
|
|
4
4
|
* Released under MIT License
|
|
5
5
|
*/
|
|
@@ -3971,24 +3971,44 @@ var transform$1 = {
|
|
|
3971
3971
|
if (typeof transformFunction === 'undefined') {
|
|
3972
3972
|
throw new Error("Attempting to parse an unsupported transform function \"".concat(token.name, "\""));
|
|
3973
3973
|
}
|
|
3974
|
-
return transformFunction(token.values);
|
|
3974
|
+
return transformFunction(_context, token.values);
|
|
3975
3975
|
}
|
|
3976
3976
|
return null;
|
|
3977
3977
|
}
|
|
3978
3978
|
};
|
|
3979
|
-
var matrix = function (args) {
|
|
3979
|
+
var matrix = function (_context, args) {
|
|
3980
3980
|
var values = args.filter(function (arg) { return arg.type === 17 /* TokenType.NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
|
|
3981
3981
|
return values.length === 6 ? values : null;
|
|
3982
3982
|
};
|
|
3983
3983
|
// doesn't support 3D transforms at the moment
|
|
3984
|
-
var matrix3d = function (args) {
|
|
3984
|
+
var matrix3d = function (_context, args) {
|
|
3985
3985
|
var values = args.filter(function (arg) { return arg.type === 17 /* TokenType.NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
|
|
3986
3986
|
var a1 = values[0], b1 = values[1]; values[2]; values[3]; var a2 = values[4], b2 = values[5]; values[6]; values[7]; values[8]; values[9]; values[10]; values[11]; var a4 = values[12], b4 = values[13]; values[14]; values[15];
|
|
3987
3987
|
return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
|
|
3988
3988
|
};
|
|
3989
|
+
var rotate$1 = function (context, args) {
|
|
3990
|
+
if (args.length !== 1) {
|
|
3991
|
+
return null;
|
|
3992
|
+
}
|
|
3993
|
+
var arg = args[0];
|
|
3994
|
+
var radians = 0;
|
|
3995
|
+
if (arg.type === 17 /* TokenType.NUMBER_TOKEN */ && arg.number === 0) {
|
|
3996
|
+
radians = 0;
|
|
3997
|
+
}
|
|
3998
|
+
else if (arg.type === 15 /* TokenType.DIMENSION_TOKEN */) {
|
|
3999
|
+
radians = angle.parse(context, arg);
|
|
4000
|
+
}
|
|
4001
|
+
else {
|
|
4002
|
+
return null;
|
|
4003
|
+
}
|
|
4004
|
+
var cos = Math.cos(radians);
|
|
4005
|
+
var sin = Math.sin(radians);
|
|
4006
|
+
return [cos, sin, -sin, cos, 0, 0];
|
|
4007
|
+
};
|
|
3989
4008
|
var SUPPORTED_TRANSFORM_FUNCTIONS = {
|
|
3990
4009
|
matrix: matrix,
|
|
3991
|
-
matrix3d: matrix3d
|
|
4010
|
+
matrix3d: matrix3d,
|
|
4011
|
+
rotate: rotate$1
|
|
3992
4012
|
};
|
|
3993
4013
|
|
|
3994
4014
|
var DEFAULT_VALUE = {
|
|
@@ -4011,6 +4031,30 @@ var transformOrigin = {
|
|
|
4011
4031
|
}
|
|
4012
4032
|
};
|
|
4013
4033
|
|
|
4034
|
+
var rotate = {
|
|
4035
|
+
name: 'rotate',
|
|
4036
|
+
initialValue: 'none',
|
|
4037
|
+
prefix: false,
|
|
4038
|
+
type: 0 /* PropertyDescriptorParsingType.VALUE */,
|
|
4039
|
+
parse: function (_context, token) {
|
|
4040
|
+
if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
|
|
4041
|
+
return null;
|
|
4042
|
+
}
|
|
4043
|
+
if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
|
|
4044
|
+
if (token.number === 0) {
|
|
4045
|
+
return 0;
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
if (token.type === 15 /* TokenType.DIMENSION_TOKEN */) {
|
|
4049
|
+
// Parse angle and convert to degrees for storage
|
|
4050
|
+
var radians = angle.parse(_context, token);
|
|
4051
|
+
// Store as degrees for consistency
|
|
4052
|
+
return (radians * 180) / Math.PI;
|
|
4053
|
+
}
|
|
4054
|
+
return null;
|
|
4055
|
+
}
|
|
4056
|
+
};
|
|
4057
|
+
|
|
4014
4058
|
var visibility = {
|
|
4015
4059
|
name: 'visible',
|
|
4016
4060
|
initialValue: 'none',
|
|
@@ -4523,6 +4567,7 @@ var CSSParsedDeclaration = /** @class */ (function () {
|
|
|
4523
4567
|
this.textTransform = parse(context, textTransform, declaration.textTransform);
|
|
4524
4568
|
this.transform = parse(context, transform$1, declaration.transform);
|
|
4525
4569
|
this.transformOrigin = parse(context, transformOrigin, declaration.transformOrigin);
|
|
4570
|
+
this.rotate = parse(context, rotate, declaration.rotate);
|
|
4526
4571
|
this.visibility = parse(context, visibility, declaration.visibility);
|
|
4527
4572
|
this.webkitTextStrokeColor = parse(context, webkitTextStrokeColor, declaration.webkitTextStrokeColor);
|
|
4528
4573
|
this.webkitTextStrokeWidth = parse(context, webkitTextStrokeWidth, declaration.webkitTextStrokeWidth);
|
|
@@ -4537,7 +4582,7 @@ var CSSParsedDeclaration = /** @class */ (function () {
|
|
|
4537
4582
|
return isTransparent(this.backgroundColor);
|
|
4538
4583
|
};
|
|
4539
4584
|
CSSParsedDeclaration.prototype.isTransformed = function () {
|
|
4540
|
-
return this.transform !== null;
|
|
4585
|
+
return this.transform !== null || this.rotate !== null;
|
|
4541
4586
|
};
|
|
4542
4587
|
CSSParsedDeclaration.prototype.isPositioned = function () {
|
|
4543
4588
|
return this.position !== 0 /* POSITION.STATIC */;
|
|
@@ -4648,6 +4693,10 @@ var ElementContainer = /** @class */ (function () {
|
|
|
4648
4693
|
// getBoundingClientRect takes transforms into account
|
|
4649
4694
|
element.style.transform = 'none';
|
|
4650
4695
|
}
|
|
4696
|
+
if (this.styles.rotate !== null) {
|
|
4697
|
+
// Handle rotate property similarly to transform
|
|
4698
|
+
element.style.rotate = 'none';
|
|
4699
|
+
}
|
|
4651
4700
|
}
|
|
4652
4701
|
this.bounds = parseBounds(this.context, element);
|
|
4653
4702
|
if (isDebugging(element, 4 /* DebuggerType.RENDER */)) {
|
|
@@ -6112,16 +6161,27 @@ var DocumentCloner = /** @class */ (function () {
|
|
|
6112
6161
|
}
|
|
6113
6162
|
});
|
|
6114
6163
|
}); });
|
|
6115
|
-
var adoptedNode = documentClone.adoptNode(this.documentElement);
|
|
6116
6164
|
/**
|
|
6117
6165
|
* The baseURI of the document will be lost after documentClone.open().
|
|
6118
|
-
* We
|
|
6166
|
+
* We save it before open() to preserve the original base URI for resource resolution.
|
|
6119
6167
|
* */
|
|
6120
|
-
|
|
6168
|
+
var baseUri = documentClone.baseURI;
|
|
6121
6169
|
documentClone.open();
|
|
6122
6170
|
documentClone.write("".concat(serializeDoctype(document.doctype), "<html></html>"));
|
|
6123
6171
|
// Chrome scrolls the parent document for some reason after the write to the cloned window???
|
|
6124
6172
|
restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
|
|
6173
|
+
/**
|
|
6174
|
+
* Note: adoptNode() should be called AFTER documentClone.open() and close()
|
|
6175
|
+
*
|
|
6176
|
+
* In Chrome, calling adoptNode() before or during open/write may cause
|
|
6177
|
+
* styles with uppercase characters in class names (e.g. ".MyClass") to not apply correctly.
|
|
6178
|
+
*
|
|
6179
|
+
* Fix:
|
|
6180
|
+
* - Make sure adoptNode() is called after documentClone.open() and close()
|
|
6181
|
+
* - This allows Chrome to properly match and apply all CSS rules including mixed-case class selectors.
|
|
6182
|
+
* */
|
|
6183
|
+
var adoptedNode = documentClone.adoptNode(this.documentElement);
|
|
6184
|
+
addBase(adoptedNode, baseUri);
|
|
6125
6185
|
documentClone.replaceChild(adoptedNode, documentClone.documentElement);
|
|
6126
6186
|
documentClone.close();
|
|
6127
6187
|
return iframeLoad;
|
|
@@ -6530,10 +6590,10 @@ var createStyles = function (body, styles) {
|
|
|
6530
6590
|
body.appendChild(style);
|
|
6531
6591
|
}
|
|
6532
6592
|
};
|
|
6533
|
-
var addBase = function (targetELement,
|
|
6593
|
+
var addBase = function (targetELement, baseUri) {
|
|
6534
6594
|
var _a;
|
|
6535
|
-
var baseNode =
|
|
6536
|
-
baseNode.href =
|
|
6595
|
+
var baseNode = targetELement.ownerDocument.createElement('base');
|
|
6596
|
+
baseNode.href = baseUri;
|
|
6537
6597
|
var headEle = targetELement.getElementsByTagName('head').item(0);
|
|
6538
6598
|
headEle === null || headEle === void 0 ? void 0 : headEle.insertBefore(baseNode, (_a = headEle === null || headEle === void 0 ? void 0 : headEle.firstChild) !== null && _a !== void 0 ? _a : null);
|
|
6539
6599
|
};
|
|
@@ -7001,6 +7061,17 @@ var ElementPaint = /** @class */ (function () {
|
|
|
7001
7061
|
if (this.container.styles.opacity < 1) {
|
|
7002
7062
|
this.effects.push(new OpacityEffect(this.container.styles.opacity));
|
|
7003
7063
|
}
|
|
7064
|
+
if (this.container.styles.rotate !== null) {
|
|
7065
|
+
var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
|
|
7066
|
+
var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
|
|
7067
|
+
// Apply rotate property if present
|
|
7068
|
+
var angle = this.container.styles.rotate;
|
|
7069
|
+
var rad = (angle * Math.PI) / 180;
|
|
7070
|
+
var cos = Math.cos(rad);
|
|
7071
|
+
var sin = Math.sin(rad);
|
|
7072
|
+
var rotateMatrix = [cos, sin, -sin, cos, 0, 0];
|
|
7073
|
+
this.effects.push(new TransformEffect(offsetX, offsetY, rotateMatrix));
|
|
7074
|
+
}
|
|
7004
7075
|
if (this.container.styles.transform !== null) {
|
|
7005
7076
|
var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
|
|
7006
7077
|
var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
|