html2canvas-pro 2.4.0 → 2.4.1

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.
@@ -1,8 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SVGElementContainer = void 0;
3
+ exports.SVGElementContainer = exports.serializeWithoutBoxOffsets = void 0;
4
4
  const element_container_1 = require("../element-container");
5
5
  const bounds_1 = require("../../css/layout/bounds");
6
+ const BOX_OFFSET_PROPERTIES = [
7
+ 'position',
8
+ 'inset',
9
+ 'top',
10
+ 'right',
11
+ 'bottom',
12
+ 'left',
13
+ 'inset-inline',
14
+ 'inset-inline-start',
15
+ 'inset-inline-end',
16
+ 'inset-block',
17
+ 'inset-block-start',
18
+ 'inset-block-end',
19
+ 'margin',
20
+ 'margin-top',
21
+ 'margin-right',
22
+ 'margin-bottom',
23
+ 'margin-left',
24
+ 'margin-inline',
25
+ 'margin-inline-start',
26
+ 'margin-inline-end',
27
+ 'margin-block',
28
+ 'margin-block-start',
29
+ 'margin-block-end'
30
+ ];
31
+ const serializeWithoutBoxOffsets = (serializer, img) => {
32
+ const style = img.getAttribute('style');
33
+ BOX_OFFSET_PROPERTIES.forEach((property) => img.style.removeProperty(property));
34
+ const serialized = serializer.serializeToString(img);
35
+ if (style === null) {
36
+ img.removeAttribute('style');
37
+ }
38
+ else {
39
+ img.setAttribute('style', style);
40
+ }
41
+ return serialized;
42
+ };
43
+ exports.serializeWithoutBoxOffsets = serializeWithoutBoxOffsets;
6
44
  class SVGElementContainer extends element_container_1.ElementContainer {
7
45
  constructor(context, img) {
8
46
  super(context, img);
@@ -10,7 +48,7 @@ class SVGElementContainer extends element_container_1.ElementContainer {
10
48
  const bounds = (0, bounds_1.parseBounds)(context, img);
11
49
  img.setAttribute('width', `${bounds.width}px`);
12
50
  img.setAttribute('height', `${bounds.height}px`);
13
- this.svg = `data:image/svg+xml,${encodeURIComponent(s.serializeToString(img))}`;
51
+ this.svg = `data:image/svg+xml,${encodeURIComponent((0, exports.serializeWithoutBoxOffsets)(s, img))}`;
14
52
  this.intrinsicWidth = img.width.baseVal.value;
15
53
  this.intrinsicHeight = img.height.baseVal.value;
16
54
  this.context.cache.addImage(this.svg);
@@ -1,5 +1,6 @@
1
1
  import { ElementContainer } from '../element-container';
2
2
  import { Context } from '../../core/context';
3
+ export declare const serializeWithoutBoxOffsets: (serializer: XMLSerializer, img: SVGSVGElement) => string;
3
4
  export declare class SVGElementContainer extends ElementContainer {
4
5
  svg: string;
5
6
  intrinsicWidth: number;
package/package.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "default": "./dist/html2canvas-pro.esm.js"
20
20
  }
21
21
  },
22
- "version": "2.4.0",
22
+ "version": "2.4.1",
23
23
  "author": {
24
24
  "name": "yorickshan",
25
25
  "email": "yorickshan@gmail.com",