html2canvas-pro 2.4.1 → 2.4.3
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.cjs +27 -14
- package/dist/html2canvas-pro.cjs.map +1 -1
- package/dist/html2canvas-pro.esm.js +27 -14
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +27 -14
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +3 -3
- package/dist/lib/css/property-descriptors/font-family.js +16 -1
- package/dist/lib/render/canvas/background-renderer.js +20 -9
- package/package.json +1 -1
package/dist/html2canvas-pro.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* html2canvas-pro 2.4.
|
|
2
|
+
* html2canvas-pro 2.4.3 <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
|
*/
|
|
@@ -5331,10 +5331,15 @@
|
|
|
5331
5331
|
parse: (_context, tokens) => {
|
|
5332
5332
|
const accumulator = [];
|
|
5333
5333
|
const results = [];
|
|
5334
|
+
const quoted = [];
|
|
5335
|
+
let isQuoted = false;
|
|
5334
5336
|
tokens.forEach((token) => {
|
|
5335
5337
|
switch (token.type) {
|
|
5336
5338
|
case 20:
|
|
5339
|
+
accumulator.push(token.value);
|
|
5340
|
+
break;
|
|
5337
5341
|
case 0:
|
|
5342
|
+
isQuoted = true;
|
|
5338
5343
|
accumulator.push(token.value);
|
|
5339
5344
|
break;
|
|
5340
5345
|
case 17:
|
|
@@ -5342,12 +5347,17 @@
|
|
|
5342
5347
|
break;
|
|
5343
5348
|
case 4:
|
|
5344
5349
|
results.push(accumulator.join(" "));
|
|
5350
|
+
quoted.push(isQuoted);
|
|
5351
|
+
isQuoted = false;
|
|
5345
5352
|
accumulator.length = 0;
|
|
5346
5353
|
break;
|
|
5347
5354
|
}
|
|
5348
5355
|
});
|
|
5349
|
-
if (accumulator.length)
|
|
5350
|
-
|
|
5356
|
+
if (accumulator.length) {
|
|
5357
|
+
results.push(accumulator.join(" "));
|
|
5358
|
+
quoted.push(isQuoted);
|
|
5359
|
+
}
|
|
5360
|
+
return results.map((result, index) => quoted[index] || result.indexOf(" ") !== -1 ? `'${result.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\a ").replace(/\r/g, "\\d ").replace(/\f/g, "\\c ")}'` : result);
|
|
5351
5361
|
}
|
|
5352
5362
|
};
|
|
5353
5363
|
//#endregion
|
|
@@ -9736,21 +9746,20 @@
|
|
|
9736
9746
|
}
|
|
9737
9747
|
if (rx > 0 && ry > 0) {
|
|
9738
9748
|
const cacheKey = `rg|${Math.round(x)}x${Math.round(y)}|${Math.round(rx)}x${Math.round(ry)}|${JSON.stringify(backgroundImage.stops)}`;
|
|
9749
|
+
const stops = processColorStops(backgroundImage.stops, rx * 2);
|
|
9750
|
+
const lastStop = stops[stops.length - 1];
|
|
9739
9751
|
let pattern = this.patternCache.get(cacheKey);
|
|
9740
9752
|
if (!pattern) {
|
|
9741
|
-
const
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
offscreen.width = size;
|
|
9745
|
-
offscreen.height = size;
|
|
9753
|
+
const offscreen = (this.canvas.ownerDocument ?? document).createElement("canvas");
|
|
9754
|
+
offscreen.width = Math.ceil(rx * 2);
|
|
9755
|
+
offscreen.height = Math.ceil(ry * 2);
|
|
9746
9756
|
const offCtx = offscreen.getContext("2d");
|
|
9747
9757
|
if (offCtx) {
|
|
9748
|
-
const
|
|
9749
|
-
|
|
9750
|
-
processColorStops(backgroundImage.stops, offRadius * 2).forEach((s) => gradient.addColorStop(s.stop, asString(s.color)));
|
|
9758
|
+
const gradient = offCtx.createRadialGradient(rx, rx, 0, rx, rx, rx);
|
|
9759
|
+
stops.forEach((s) => gradient.addColorStop(s.stop, asString(s.color)));
|
|
9751
9760
|
offCtx.fillStyle = gradient;
|
|
9752
9761
|
if (rx !== ry) offCtx.scale(1, ry / rx);
|
|
9753
|
-
offCtx.fillRect(0, 0,
|
|
9762
|
+
offCtx.fillRect(0, 0, rx * 2, rx * 2);
|
|
9754
9763
|
pattern = this.ctx.createPattern(offscreen, "no-repeat");
|
|
9755
9764
|
this.patternCache.set(cacheKey, pattern);
|
|
9756
9765
|
}
|
|
@@ -9759,9 +9768,13 @@
|
|
|
9759
9768
|
this.path(path);
|
|
9760
9769
|
this.ctx.save();
|
|
9761
9770
|
this.ctx.clip();
|
|
9762
|
-
|
|
9771
|
+
if (lastStop) {
|
|
9772
|
+
this.ctx.fillStyle = asString(lastStop.color);
|
|
9773
|
+
this.ctx.fill();
|
|
9774
|
+
}
|
|
9775
|
+
this.ctx.translate(left + x - rx, top + y - ry);
|
|
9763
9776
|
this.ctx.fillStyle = pattern;
|
|
9764
|
-
this.ctx.fillRect(0, 0,
|
|
9777
|
+
this.ctx.fillRect(0, 0, rx * 2, ry * 2);
|
|
9765
9778
|
this.ctx.restore();
|
|
9766
9779
|
}
|
|
9767
9780
|
}
|