watermark-js-plus 1.5.0 → 1.5.2

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 CHANGED
@@ -3,14 +3,26 @@
3
3
  <img width="300" src="https://zhensherlock.github.io/watermark-js-plus/hero-image.png" alt="watermark logo">
4
4
  </a>
5
5
  </p>
6
- <p align="center">
7
- <a href="https://npmjs.com/package/watermark-js-plus"><img src="https://badgen.net/npm/v/watermark-js-plus" alt="npm package"></a>
8
- <img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/zhensherlock/watermark-js-plus/deploy.yml?branch=main">
9
- <img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/watermark-js-plus">
10
- <img alt="npm download week" src="https://img.shields.io/npm/dw/watermark-js-plus">
11
- <img alt="GitHub" src="https://img.shields.io/github/license/zhensherlock/watermark-js-plus">
12
- <a href="https://gitter.im/china-hy/watermark-js-plus?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"><img src="https://badges.gitter.im/china-hy/watermark-js-plus.svg" alt="Join the chat at https://gitter.im/china-hy/watermark-js-plus"></a>
13
- </p>
6
+
7
+ <div align="center">
8
+
9
+ [![][npm-release-shield]][npm-release-link]
10
+ [![][npm-downloads-shield]][npm-downloads-link]
11
+ [![][package-size-shield]][package-size-link]
12
+ [![][codecov-shield]][codecov-link] <br/>
13
+ [![][github-release-date-shield]][github-release-date-link]
14
+ [![][github-action-build-shield]][github-action-build-link]
15
+ [![][github-license-shield]][github-license-link]
16
+ [![][gitter-shield]][gitter-link]
17
+
18
+ [//]: # ( <a href="https://npmjs.com/package/watermark-js-plus"><img src="https://badgen.net/npm/v/watermark-js-plus" alt="npm package"></a>)
19
+ [//]: # ( <img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/zhensherlock/watermark-js-plus/deploy.yml?branch=main">)
20
+ [//]: # ( <img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/watermark-js-plus">)
21
+ [//]: # ( <img alt="npm download week" src="https://img.shields.io/npm/dw/watermark-js-plus">)
22
+ [//]: # ( <img alt="GitHub" src="https://img.shields.io/github/license/zhensherlock/watermark-js-plus">)
23
+ [//]: # ( <a href="https://gitter.im/china-hy/watermark-js-plus?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"><img src="https://badges.gitter.im/china-hy/watermark-js-plus.svg" alt="Join the chat at https://gitter.im/china-hy/watermark-js-plus"></a>)
24
+
25
+ </div>
14
26
 
15
27
  # Watermark
16
28
 
@@ -107,3 +119,20 @@ This project exists thanks to all the people who contribute.
107
119
  ## License
108
120
 
109
121
  [MIT](LICENSE) © MichaelSun
122
+
123
+ [npm-release-link]: https://www.npmjs.com/package/watermark-js-plus
124
+ [npm-release-shield]: https://img.shields.io/npm/v/watermark-js-plus?color=1677FF&labelColor=black&logo=npm&logoColor=white&style=flat-square
125
+ [npm-downloads-link]: https://www.npmjs.com/package/watermark-js-plus
126
+ [npm-downloads-shield]: https://img.shields.io/npm/dw/watermark-js-plus.svg?labelColor=black&style=flat-square&color=1677FF
127
+ [package-size-link]: https://github.com/zhensherlock/watermark-js-plus
128
+ [package-size-shield]: https://img.shields.io/bundlephobia/minzip/watermark-js-plus?color=1677FF&label=build&labelColor=black&logo=rollupdotjs&logoColor=white&style=flat-square
129
+ [codecov-link]: https://codecov.io/gh/zhensherlock/watermark-js-plus
130
+ [codecov-shield]: https://img.shields.io/codecov/c/github/zhensherlock/watermark-js-plus?color=1677FF&labelColor=black&style=flat-square&logo=codecov&logoColor=white
131
+ [github-release-date-link]: https://github.com/zhensherlock/watermark-js-plus/releases
132
+ [github-release-date-shield]: https://img.shields.io/github/release-date/zhensherlock/watermark-js-plus?color=1677FF&labelColor=black&style=flat-square
133
+ [github-action-build-link]: https://github.com/zhensherlock/watermark-js-plus/actions/workflows/deploy.yml
134
+ [github-action-build-shield]: https://img.shields.io/github/actions/workflow/status/zhensherlock/watermark-js-plus/deploy.yml?branch=main&color=1677FF&label=build&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
135
+ [github-license-link]: https://github.com/zhensherlock/watermark-js-plus/blob/main/LICENSE
136
+ [github-license-shield]: https://img.shields.io/github/license/zhensherlock/watermark-js-plus?color=1677FF&labelColor=black&style=flat-square
137
+ [gitter-link]: https://gitter.im/china-hy/watermark-js-plus?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
138
+ [gitter-shield]: https://img.shields.io/gitter/room/china-hy/watermark-js-plus?color=1677FF&labelColor=black&logo=gitter&logoColor=white&style=flat-square
package/dist/index.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * watermark-js-plus v1.5.0
2
+ * watermark-js-plus v1.5.2
3
3
  * (c) 2022-2024 Michael Sun
4
4
  * Released under the MIT License.
5
5
  */
@@ -151,7 +151,8 @@ var getMultiLineData = function (ctx, text, maxWidth) {
151
151
  return result;
152
152
  };
153
153
  var createCustomContentSVG = function (ctx, options) { return __awaiter(void 0, void 0, void 0, function () {
154
- var svgElement, bodyElement, _a, offsetHeight, offsetWidth, width, height, foreignObjectElement;
154
+ var svgElement, bodyElement, rect, rectWidth, rectHeight, width, height, foreignObjectElement;
155
+ var _a;
155
156
  return __generator(this, function (_b) {
156
157
  switch (_b.label) {
157
158
  case 0:
@@ -168,10 +169,12 @@ var createCustomContentSVG = function (ctx, options) { return __awaiter(void 0,
168
169
  case 1:
169
170
  // convert all images to base64
170
171
  _b.sent();
171
- _a = bodyElement.querySelector('.rich-text-content'), offsetHeight = _a.offsetHeight, offsetWidth = _a.offsetWidth;
172
+ rect = (_a = bodyElement.querySelector('.rich-text-content')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
173
+ rectWidth = rect === null || rect === void 0 ? void 0 : rect.width;
174
+ rectHeight = rect === null || rect === void 0 ? void 0 : rect.height;
172
175
  document.body.removeChild(bodyElement);
173
- width = options.richTextWidth || offsetWidth || options.width;
174
- height = options.richTextHeight || offsetHeight || options.height;
176
+ width = options.richTextWidth || rectWidth || options.width;
177
+ height = options.richTextHeight || rectHeight || options.height;
175
178
  svgElement.setAttribute('width', width.toString());
176
179
  svgElement.setAttribute('height', height.toString());
177
180
  foreignObjectElement = createSVGElement('foreignObject', {