watermark-js-plus 1.5.8 → 1.6.0
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/ie/index.cjs.js +107 -78
- package/dist/ie/index.cjs.js.map +1 -1
- package/dist/ie/index.cjs.min.js +1 -1
- package/dist/ie/index.esm.js +107 -78
- package/dist/ie/index.esm.js.map +1 -1
- package/dist/ie/index.esm.min.js +1 -1
- package/dist/ie/index.iife.js +107 -78
- package/dist/ie/index.iife.js.map +1 -1
- package/dist/ie/index.iife.min.js +1 -1
- package/dist/ie/index.umd.js +107 -78
- package/dist/ie/index.umd.js.map +1 -1
- package/dist/ie/index.umd.min.js +1 -1
- package/dist/index.cjs.js +105 -76
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.esm.js +105 -76
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.iife.js +105 -76
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.umd.js +105 -76
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/types/{src/types → types}/index.d.ts +1 -0
- package/dist/{ie/types/src → types}/utils/index.d.ts +1 -0
- package/package.json +45 -32
- package/dist/ie/types/src/types/index.d.ts +0 -128
- package/dist/ie/types/tests/core/blind.test.d.ts +0 -1
- package/dist/ie/types/tests/core/image.test.d.ts +0 -1
- package/dist/ie/types/tests/core/watermark.test.d.ts +0 -1
- package/dist/ie/types/tests/utils/index.d.ts +0 -2
- package/dist/ie/types/tests/utils/index.test.d.ts +0 -1
- package/dist/types/src/core/blind.d.ts +0 -19
- package/dist/types/src/core/canvas.d.ts +0 -51
- package/dist/types/src/core/image.d.ts +0 -22
- package/dist/types/src/core/layout/grid.d.ts +0 -14
- package/dist/types/src/core/layout/index.d.ts +0 -4
- package/dist/types/src/core/watermark.d.ts +0 -48
- package/dist/types/src/index.d.ts +0 -5
- package/dist/types/src/index.ie.d.ts +0 -7
- package/dist/types/src/style/index.d.ts +0 -1
- package/dist/types/src/utils/index.d.ts +0 -14
- package/dist/types/src/utils/initialization.d.ts +0 -19
- package/dist/types/src/utils/protection.d.ts +0 -2
- package/dist/types/tests/core/blind.test.d.ts +0 -1
- package/dist/types/tests/core/image.test.d.ts +0 -1
- package/dist/types/tests/core/watermark.test.d.ts +0 -1
- package/dist/types/tests/utils/index.d.ts +0 -2
- package/dist/types/tests/utils/index.test.d.ts +0 -1
- /package/dist/{ie/types/src → types}/core/blind.d.ts +0 -0
- /package/dist/{ie/types/src → types}/core/canvas.d.ts +0 -0
- /package/dist/{ie/types/src → types}/core/image.d.ts +0 -0
- /package/dist/{ie/types/src → types}/core/layout/grid.d.ts +0 -0
- /package/dist/{ie/types/src → types}/core/layout/index.d.ts +0 -0
- /package/dist/{ie/types/src → types}/core/watermark.d.ts +0 -0
- /package/dist/{ie/types/src → types}/index.d.ts +0 -0
- /package/dist/{ie/types/src → types}/index.ie.d.ts +0 -0
- /package/dist/{ie/types/src → types}/style/index.d.ts +0 -0
- /package/dist/{ie/types/src → types}/utils/initialization.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/polyfill.d.ts +0 -0
- /package/dist/{ie/types/src → types}/utils/protection.d.ts +0 -0
package/dist/index.iife.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* watermark-js-plus v1.
|
|
2
|
+
* watermark-js-plus v1.6.0
|
|
3
3
|
* (c) 2022-2024 Michael Sun
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -33,7 +33,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
var css_248z = "@keyframes watermark{0%{background-position:0 0}25%{background-position:100% 100%}50%{background-position:
|
|
36
|
+
var css_248z = "@keyframes watermark{0%{background-position:0 0}25%{background-position:100% 100%}50%{background-position:100% 0}75%{background-position:0 100%}to{background-position:0 0}}@keyframes watermark-horizontal{0%{background-position-x:0}to{background-position-x:100%}}@keyframes watermark-vertical{0%{background-position-y:0}to{background-position-y:100%}}";
|
|
37
37
|
styleInject(css_248z);
|
|
38
38
|
|
|
39
39
|
/******************************************************************************
|
|
@@ -50,7 +50,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
50
50
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
51
51
|
PERFORMANCE OF THIS SOFTWARE.
|
|
52
52
|
***************************************************************************** */
|
|
53
|
-
/* global Reflect, Promise */
|
|
53
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
54
54
|
|
|
55
55
|
var extendStatics = function(d, b) {
|
|
56
56
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -89,8 +89,8 @@ var WatermarkPlus = (function (exports) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function __generator(thisArg, body) {
|
|
92
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
93
|
-
return g =
|
|
92
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
93
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
94
94
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
95
95
|
function step(op) {
|
|
96
96
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -114,7 +114,12 @@ var WatermarkPlus = (function (exports) {
|
|
|
114
114
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
115
115
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
116
116
|
}
|
|
117
|
-
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
120
|
+
var e = new Error(message);
|
|
121
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
122
|
+
};
|
|
118
123
|
|
|
119
124
|
var convertImage = function (canvas) {
|
|
120
125
|
return canvas.toDataURL('image/png', 1);
|
|
@@ -165,7 +170,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
165
170
|
switch (_b.label) {
|
|
166
171
|
case 0:
|
|
167
172
|
svgElement = createSVGElement('svg', {
|
|
168
|
-
xmlns: 'http://www.w3.org/2000/svg'
|
|
173
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
169
174
|
});
|
|
170
175
|
bodyElement = document.createElement('div');
|
|
171
176
|
bodyElement.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
|
|
@@ -187,14 +192,14 @@ var WatermarkPlus = (function (exports) {
|
|
|
187
192
|
svgElement.setAttribute('height', height.toString());
|
|
188
193
|
foreignObjectElement = createSVGElement('foreignObject', {
|
|
189
194
|
width: width.toString(),
|
|
190
|
-
height: height.toString()
|
|
195
|
+
height: height.toString(),
|
|
191
196
|
});
|
|
192
197
|
foreignObjectElement.appendChild(bodyElement);
|
|
193
198
|
svgElement.appendChild(foreignObjectElement);
|
|
194
199
|
return [2 /*return*/, {
|
|
195
200
|
element: svgElement,
|
|
196
201
|
width: width,
|
|
197
|
-
height: height
|
|
202
|
+
height: height,
|
|
198
203
|
}];
|
|
199
204
|
}
|
|
200
205
|
});
|
|
@@ -262,7 +267,8 @@ var WatermarkPlus = (function (exports) {
|
|
|
262
267
|
var convertSVGToImage = function (svg) {
|
|
263
268
|
var richContent = svg.outerHTML
|
|
264
269
|
.replace(/<(img|br|input|hr|embed)(.*?)>/g, '<$1$2/>')
|
|
265
|
-
.replace(/\n/g, '')
|
|
270
|
+
.replace(/\n/g, '')
|
|
271
|
+
.replace(/\t/g, '')
|
|
266
272
|
.replace(/#/g, '%23');
|
|
267
273
|
return "data:image/svg+xml;charset=utf-8,".concat(richContent);
|
|
268
274
|
};
|
|
@@ -278,7 +284,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
278
284
|
if (width === void 0) { width = undefined; }
|
|
279
285
|
if (height === void 0) { height = undefined; }
|
|
280
286
|
var image = new Image();
|
|
281
|
-
image.setAttribute('crossOrigin', '
|
|
287
|
+
image.setAttribute('crossOrigin', 'anonymous');
|
|
282
288
|
!isUndefined(width) && (image.width = width);
|
|
283
289
|
!isUndefined(height) && (image.height = height);
|
|
284
290
|
image.src = url;
|
|
@@ -291,6 +297,25 @@ var WatermarkPlus = (function (exports) {
|
|
|
291
297
|
var generateMatrix = function (rows, columns, value) {
|
|
292
298
|
return Array.from({ length: rows }, function () { return new Array(columns).fill(value); });
|
|
293
299
|
};
|
|
300
|
+
var generateAnimationStyle = function (movable, backgroundRepeat) {
|
|
301
|
+
if (!movable) {
|
|
302
|
+
return '';
|
|
303
|
+
}
|
|
304
|
+
var horizontalDuration = Math.random() * (8 - 2) + 2;
|
|
305
|
+
var verticalDuration = Math.random() * (4 - 2) + 2;
|
|
306
|
+
switch (backgroundRepeat) {
|
|
307
|
+
case 'repeat':
|
|
308
|
+
return 'animation: 200s linear 0s infinite alternate watermark !important;';
|
|
309
|
+
case 'repeat-x':
|
|
310
|
+
return "animation: ".concat(horizontalDuration, "s ease-in 0s infinite alternate watermark-vertical !important;'");
|
|
311
|
+
case 'repeat-y':
|
|
312
|
+
return "animation: ".concat(verticalDuration, "s ease-out 0s infinite alternate watermark-horizontal !important;'");
|
|
313
|
+
case 'no-repeat':
|
|
314
|
+
return "animation: ".concat(horizontalDuration, "s ease-in 0s infinite alternate watermark-horizontal, ").concat(verticalDuration, "s ease-out 0s infinite alternate watermark-vertical !important;");
|
|
315
|
+
default:
|
|
316
|
+
return '';
|
|
317
|
+
}
|
|
318
|
+
};
|
|
294
319
|
|
|
295
320
|
var initialOptions = {
|
|
296
321
|
width: 300,
|
|
@@ -326,7 +351,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
326
351
|
onSuccess: function () { },
|
|
327
352
|
onBeforeDestroy: function () { },
|
|
328
353
|
onDestroyed: function () { },
|
|
329
|
-
onObserveError: function () { }
|
|
354
|
+
onObserveError: function () { },
|
|
330
355
|
};
|
|
331
356
|
var generateRecommendOptions = function (canvas, options, args) {
|
|
332
357
|
var ctx = canvas.getContext('2d');
|
|
@@ -339,7 +364,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
339
364
|
ctx.letterSpacing = options.letterSpacing;
|
|
340
365
|
ctx.wordSpacing = options.wordSpacing;
|
|
341
366
|
if (options === null || options === void 0 ? void 0 : options.rotate) {
|
|
342
|
-
options.rotate = (360 - options.rotate % 360) * (Math.PI / 180);
|
|
367
|
+
options.rotate = (360 - (options.rotate % 360)) * (Math.PI / 180);
|
|
343
368
|
}
|
|
344
369
|
if (isUndefined(args.textRowMaxWidth)) {
|
|
345
370
|
options.textRowMaxWidth = options.width;
|
|
@@ -348,21 +373,21 @@ var WatermarkPlus = (function (exports) {
|
|
|
348
373
|
image: {
|
|
349
374
|
rect: {
|
|
350
375
|
width: options.imageWidth,
|
|
351
|
-
height: options.imageHeight
|
|
376
|
+
height: options.imageHeight,
|
|
352
377
|
},
|
|
353
378
|
position: {
|
|
354
379
|
x: 0,
|
|
355
|
-
y: 0
|
|
356
|
-
}
|
|
380
|
+
y: 0,
|
|
381
|
+
},
|
|
357
382
|
},
|
|
358
383
|
textLine: {
|
|
359
384
|
data: [],
|
|
360
|
-
yOffsetValue: 0
|
|
385
|
+
yOffsetValue: 0,
|
|
361
386
|
},
|
|
362
387
|
advancedStyleParams: {
|
|
363
388
|
linear: {
|
|
364
389
|
x0: 0,
|
|
365
|
-
x1: 0
|
|
390
|
+
x1: 0,
|
|
366
391
|
},
|
|
367
392
|
radial: {
|
|
368
393
|
x0: 0,
|
|
@@ -370,15 +395,15 @@ var WatermarkPlus = (function (exports) {
|
|
|
370
395
|
r0: 0,
|
|
371
396
|
x1: 0,
|
|
372
397
|
y1: 0,
|
|
373
|
-
r1: 0
|
|
398
|
+
r1: 0,
|
|
374
399
|
},
|
|
375
400
|
conic: {
|
|
376
401
|
x: 0,
|
|
377
402
|
y: 0,
|
|
378
|
-
startAngle: 0
|
|
403
|
+
startAngle: 0,
|
|
379
404
|
},
|
|
380
|
-
pattern: {}
|
|
381
|
-
}
|
|
405
|
+
pattern: {},
|
|
406
|
+
},
|
|
382
407
|
};
|
|
383
408
|
switch (options.contentType) {
|
|
384
409
|
case 'text':
|
|
@@ -428,14 +453,14 @@ var WatermarkPlus = (function (exports) {
|
|
|
428
453
|
result.advancedStyleParams.linear.x0 = -options.width / 2;
|
|
429
454
|
result.advancedStyleParams.linear.x1 = options.width / 2;
|
|
430
455
|
// result.advancedStyleParams.radial.x0 = 0
|
|
431
|
-
result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
|
|
456
|
+
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
432
457
|
// result.advancedStyleParams.radial.r0 = 0
|
|
433
458
|
// result.advancedStyleParams.radial.x1 = 0
|
|
434
459
|
// result.advancedStyleParams.radial.y1 = 0
|
|
435
|
-
result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
|
|
460
|
+
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
436
461
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
437
462
|
// result.advancedStyleParams.conic.x = 0
|
|
438
|
-
result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
|
|
463
|
+
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
439
464
|
break;
|
|
440
465
|
case 'top-start':
|
|
441
466
|
translateX = 0;
|
|
@@ -445,13 +470,13 @@ var WatermarkPlus = (function (exports) {
|
|
|
445
470
|
result.advancedStyleParams.linear.x0 = 0;
|
|
446
471
|
result.advancedStyleParams.linear.x1 = options.width;
|
|
447
472
|
result.advancedStyleParams.radial.x0 = options.width / 2;
|
|
448
|
-
result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
|
|
473
|
+
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
449
474
|
// result.advancedStyleParams.radial.r0 = 0
|
|
450
475
|
result.advancedStyleParams.radial.x1 = options.width / 2;
|
|
451
|
-
result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
|
|
476
|
+
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
452
477
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
453
478
|
result.advancedStyleParams.conic.x = options.width / 2;
|
|
454
|
-
result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
|
|
479
|
+
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
455
480
|
break;
|
|
456
481
|
case 'top-end':
|
|
457
482
|
translateX = options.width;
|
|
@@ -461,13 +486,13 @@ var WatermarkPlus = (function (exports) {
|
|
|
461
486
|
result.advancedStyleParams.linear.x0 = 0;
|
|
462
487
|
result.advancedStyleParams.linear.x1 = -options.width;
|
|
463
488
|
result.advancedStyleParams.radial.x0 = -options.width / 2;
|
|
464
|
-
result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
|
|
489
|
+
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
465
490
|
// result.advancedStyleParams.radial.r0 = 0
|
|
466
491
|
result.advancedStyleParams.radial.x1 = -options.width / 2;
|
|
467
|
-
result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
|
|
492
|
+
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
468
493
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
469
494
|
result.advancedStyleParams.conic.x = -options.width / 2;
|
|
470
|
-
result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
|
|
495
|
+
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
471
496
|
break;
|
|
472
497
|
case 'bottom':
|
|
473
498
|
translateX = options.width / 2;
|
|
@@ -477,13 +502,13 @@ var WatermarkPlus = (function (exports) {
|
|
|
477
502
|
result.advancedStyleParams.linear.x0 = -options.width / 2;
|
|
478
503
|
result.advancedStyleParams.linear.x1 = options.width / 2;
|
|
479
504
|
// result.advancedStyleParams.radial.x0 = 0
|
|
480
|
-
result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
|
|
505
|
+
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
481
506
|
// result.advancedStyleParams.radial.r0 = 0
|
|
482
507
|
// result.advancedStyleParams.radial.x1 = 0
|
|
483
|
-
result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
|
|
508
|
+
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
484
509
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
485
510
|
result.advancedStyleParams.conic.x = 0;
|
|
486
|
-
result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
|
|
511
|
+
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
487
512
|
break;
|
|
488
513
|
case 'bottom-start':
|
|
489
514
|
translateX = 0;
|
|
@@ -493,13 +518,13 @@ var WatermarkPlus = (function (exports) {
|
|
|
493
518
|
result.advancedStyleParams.linear.x0 = 0;
|
|
494
519
|
result.advancedStyleParams.linear.x1 = options.width;
|
|
495
520
|
result.advancedStyleParams.radial.x0 = options.width / 2;
|
|
496
|
-
result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
|
|
521
|
+
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
497
522
|
// result.advancedStyleParams.radial.r0 = 0
|
|
498
523
|
result.advancedStyleParams.radial.x1 = options.width / 2;
|
|
499
|
-
result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
|
|
524
|
+
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
500
525
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
501
526
|
result.advancedStyleParams.conic.x = options.width / 2;
|
|
502
|
-
result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
|
|
527
|
+
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
503
528
|
break;
|
|
504
529
|
case 'bottom-end':
|
|
505
530
|
translateX = options.width;
|
|
@@ -509,13 +534,13 @@ var WatermarkPlus = (function (exports) {
|
|
|
509
534
|
result.advancedStyleParams.linear.x0 = 0;
|
|
510
535
|
result.advancedStyleParams.linear.x1 = -options.width;
|
|
511
536
|
result.advancedStyleParams.radial.x0 = -options.width / 2;
|
|
512
|
-
result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
|
|
537
|
+
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
513
538
|
// result.advancedStyleParams.radial.r0 = 0
|
|
514
539
|
result.advancedStyleParams.radial.x1 = -options.width / 2;
|
|
515
|
-
result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
|
|
540
|
+
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
516
541
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
517
542
|
result.advancedStyleParams.conic.x = -options.width / 2;
|
|
518
|
-
result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
|
|
543
|
+
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
519
544
|
break;
|
|
520
545
|
case 'left':
|
|
521
546
|
translateX = 0;
|
|
@@ -557,12 +582,13 @@ var WatermarkPlus = (function (exports) {
|
|
|
557
582
|
if (['text', 'multi-line-text'].includes(options.contentType)) {
|
|
558
583
|
switch (options.textBaseline) {
|
|
559
584
|
case 'middle':
|
|
560
|
-
result.textLine.yOffsetValue = (result.textLine.data.length - 1) * options.lineHeight / 2;
|
|
585
|
+
result.textLine.yOffsetValue = ((result.textLine.data.length - 1) * options.lineHeight) / 2;
|
|
561
586
|
break;
|
|
562
587
|
case 'bottom':
|
|
563
588
|
case 'alphabetic':
|
|
564
589
|
case 'ideographic':
|
|
565
|
-
result.textLine.yOffsetValue =
|
|
590
|
+
result.textLine.yOffsetValue =
|
|
591
|
+
(result.textLine.data.length - 1) * options.lineHeight + (options.lineHeight - parseInt(options.fontSize)) / 2;
|
|
566
592
|
break;
|
|
567
593
|
case 'top':
|
|
568
594
|
case 'hanging':
|
|
@@ -580,11 +606,11 @@ var WatermarkPlus = (function (exports) {
|
|
|
580
606
|
if (need) {
|
|
581
607
|
Object.defineProperty(window, 'MutationObserver', {
|
|
582
608
|
writable: false,
|
|
583
|
-
configurable: false
|
|
609
|
+
configurable: false,
|
|
584
610
|
});
|
|
585
611
|
Object.defineProperty(window, 'requestAnimationFrame', {
|
|
586
612
|
writable: false,
|
|
587
|
-
configurable: false
|
|
613
|
+
configurable: false,
|
|
588
614
|
});
|
|
589
615
|
}
|
|
590
616
|
});
|
|
@@ -713,7 +739,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
713
739
|
};
|
|
714
740
|
WatermarkCanvas.prototype.createLinearGradient = function (ctx) {
|
|
715
741
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
716
|
-
var gradient = ctx.createLinearGradient(getValue((_c = (_b = (_a = this.options.advancedStyle) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.linear) === null || _c === void 0 ? void 0 : _c.x0, this.recommendOptions.advancedStyleParams.linear.x0), getValue((_f = (_e = (_d = this.options.advancedStyle) === null || _d === void 0 ? void 0 : _d.params) === null || _e === void 0 ? void 0 : _e.linear) === null || _f === void 0 ? void 0 : _f.y0, 0), getValue((_j = (_h = (_g = this.options.advancedStyle) === null || _g === void 0 ? void 0 : _g.params) === null || _h === void 0 ? void 0 : _h.linear) === null || _j === void 0 ? void 0 : _j.x1, this.recommendOptions.advancedStyleParams.linear.x1), getValue((_m = (_l = (_k = this.options.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.linear) === null || _m === void 0 ? void 0 : _m.y1, 0));
|
|
742
|
+
var gradient = ctx.createLinearGradient((getValue((_c = (_b = (_a = this.options.advancedStyle) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.linear) === null || _c === void 0 ? void 0 : _c.x0, this.recommendOptions.advancedStyleParams.linear.x0)), getValue((_f = (_e = (_d = this.options.advancedStyle) === null || _d === void 0 ? void 0 : _d.params) === null || _e === void 0 ? void 0 : _e.linear) === null || _f === void 0 ? void 0 : _f.y0, 0), (getValue((_j = (_h = (_g = this.options.advancedStyle) === null || _g === void 0 ? void 0 : _g.params) === null || _h === void 0 ? void 0 : _h.linear) === null || _j === void 0 ? void 0 : _j.x1, this.recommendOptions.advancedStyleParams.linear.x1)), getValue((_m = (_l = (_k = this.options.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.linear) === null || _m === void 0 ? void 0 : _m.y1, 0));
|
|
717
743
|
(_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.colorStops) === null || _q === void 0 ? void 0 : _q.forEach(function (item) {
|
|
718
744
|
gradient.addColorStop(item.offset, item.color);
|
|
719
745
|
});
|
|
@@ -721,7 +747,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
721
747
|
};
|
|
722
748
|
WatermarkCanvas.prototype.createConicGradient = function (ctx) {
|
|
723
749
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
724
|
-
var gradient = ctx.createConicGradient(getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.conic) === null || _d === void 0 ? void 0 : _d.startAngle, 0), getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.conic) === null || _h === void 0 ? void 0 : _h.x, this.recommendOptions.advancedStyleParams.conic.x), getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.conic) === null || _m === void 0 ? void 0 : _m.y, this.recommendOptions.advancedStyleParams.conic.y));
|
|
750
|
+
var gradient = ctx.createConicGradient(getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.conic) === null || _d === void 0 ? void 0 : _d.startAngle, 0), (getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.conic) === null || _h === void 0 ? void 0 : _h.x, this.recommendOptions.advancedStyleParams.conic.x)), (getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.conic) === null || _m === void 0 ? void 0 : _m.y, this.recommendOptions.advancedStyleParams.conic.y)));
|
|
725
751
|
(_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.colorStops) === null || _q === void 0 ? void 0 : _q.forEach(function (item) {
|
|
726
752
|
gradient.addColorStop(item.offset, item.color);
|
|
727
753
|
});
|
|
@@ -729,7 +755,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
729
755
|
};
|
|
730
756
|
WatermarkCanvas.prototype.createRadialGradient = function (ctx) {
|
|
731
757
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
732
|
-
var gradient = ctx.createRadialGradient(getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.radial) === null || _d === void 0 ? void 0 : _d.x0, this.recommendOptions.advancedStyleParams.radial.x0), getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.radial) === null || _h === void 0 ? void 0 : _h.y0, this.recommendOptions.advancedStyleParams.radial.y0), getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.radial) === null || _m === void 0 ? void 0 : _m.r0, this.recommendOptions.advancedStyleParams.radial.r0), getValue((_r = (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.params) === null || _q === void 0 ? void 0 : _q.radial) === null || _r === void 0 ? void 0 : _r.x1, this.recommendOptions.advancedStyleParams.radial.x1), getValue((_v = (_u = (_t = (_s = this.options) === null || _s === void 0 ? void 0 : _s.advancedStyle) === null || _t === void 0 ? void 0 : _t.params) === null || _u === void 0 ? void 0 : _u.radial) === null || _v === void 0 ? void 0 : _v.y1, this.recommendOptions.advancedStyleParams.radial.y1), getValue((_z = (_y = (_x = (_w = this.options) === null || _w === void 0 ? void 0 : _w.advancedStyle) === null || _x === void 0 ? void 0 : _x.params) === null || _y === void 0 ? void 0 : _y.radial) === null || _z === void 0 ? void 0 : _z.r1, this.recommendOptions.advancedStyleParams.radial.r1));
|
|
758
|
+
var gradient = ctx.createRadialGradient((getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.radial) === null || _d === void 0 ? void 0 : _d.x0, this.recommendOptions.advancedStyleParams.radial.x0)), (getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.radial) === null || _h === void 0 ? void 0 : _h.y0, this.recommendOptions.advancedStyleParams.radial.y0)), (getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.radial) === null || _m === void 0 ? void 0 : _m.r0, this.recommendOptions.advancedStyleParams.radial.r0)), (getValue((_r = (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.params) === null || _q === void 0 ? void 0 : _q.radial) === null || _r === void 0 ? void 0 : _r.x1, this.recommendOptions.advancedStyleParams.radial.x1)), (getValue((_v = (_u = (_t = (_s = this.options) === null || _s === void 0 ? void 0 : _s.advancedStyle) === null || _t === void 0 ? void 0 : _t.params) === null || _u === void 0 ? void 0 : _u.radial) === null || _v === void 0 ? void 0 : _v.y1, this.recommendOptions.advancedStyleParams.radial.y1)), (getValue((_z = (_y = (_x = (_w = this.options) === null || _w === void 0 ? void 0 : _w.advancedStyle) === null || _x === void 0 ? void 0 : _x.params) === null || _y === void 0 ? void 0 : _y.radial) === null || _z === void 0 ? void 0 : _z.r1, this.recommendOptions.advancedStyleParams.radial.r1)));
|
|
733
759
|
(_2 = (_1 = (_0 = this.options) === null || _0 === void 0 ? void 0 : _0.advancedStyle) === null || _1 === void 0 ? void 0 : _1.colorStops) === null || _2 === void 0 ? void 0 : _2.forEach(function (item) {
|
|
734
760
|
gradient.addColorStop(item.offset, item.color);
|
|
735
761
|
});
|
|
@@ -737,7 +763,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
737
763
|
};
|
|
738
764
|
WatermarkCanvas.prototype.createPattern = function (ctx) {
|
|
739
765
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
740
|
-
return ctx.createPattern((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.pattern) === null || _d === void 0 ? void 0 : _d.image, ((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.pattern) === null || _h === void 0 ? void 0 : _h.repetition) || '');
|
|
766
|
+
return ctx.createPattern(((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.pattern) === null || _d === void 0 ? void 0 : _d.image), ((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.pattern) === null || _h === void 0 ? void 0 : _h.repetition) || '');
|
|
741
767
|
};
|
|
742
768
|
WatermarkCanvas.prototype.setText = function (ctx, params) {
|
|
743
769
|
var methodName = 'fillText';
|
|
@@ -751,7 +777,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
751
777
|
text: this.options.content,
|
|
752
778
|
x: 0,
|
|
753
779
|
y: 0 - this.recommendOptions.textLine.yOffsetValue,
|
|
754
|
-
maxWidth: this.options.textRowMaxWidth || this.options.width
|
|
780
|
+
maxWidth: this.options.textRowMaxWidth || this.options.width,
|
|
755
781
|
});
|
|
756
782
|
resolve(ctx.canvas);
|
|
757
783
|
};
|
|
@@ -785,7 +811,12 @@ var WatermarkPlus = (function (exports) {
|
|
|
785
811
|
var lines = this.recommendOptions.textLine.data;
|
|
786
812
|
var yOffsetValue = this.recommendOptions.textLine.yOffsetValue;
|
|
787
813
|
lines.forEach(function (text, index) {
|
|
788
|
-
_this.setText(ctx, {
|
|
814
|
+
_this.setText(ctx, {
|
|
815
|
+
text: text,
|
|
816
|
+
x: 0,
|
|
817
|
+
y: _this.options.lineHeight * index - yOffsetValue,
|
|
818
|
+
maxWidth: _this.options.textRowMaxWidth || _this.options.width,
|
|
819
|
+
});
|
|
789
820
|
});
|
|
790
821
|
resolve(ctx.canvas);
|
|
791
822
|
};
|
|
@@ -812,10 +843,10 @@ var WatermarkPlus = (function (exports) {
|
|
|
812
843
|
var rect = { width: this.options.imageWidth || 0, height: this.options.imageHeight || 0 };
|
|
813
844
|
switch (true) {
|
|
814
845
|
case rect.width !== 0 && rect.height === 0:
|
|
815
|
-
rect.height = rect.width * image.height / image.width;
|
|
846
|
+
rect.height = (rect.width * image.height) / image.width;
|
|
816
847
|
break;
|
|
817
848
|
case rect.width === 0 && rect.height !== 0:
|
|
818
|
-
rect.width = rect.height * image.width / image.height;
|
|
849
|
+
rect.width = (rect.height * image.width) / image.height;
|
|
819
850
|
break;
|
|
820
851
|
case rect.width === 0 && rect.height === 0:
|
|
821
852
|
rect.width = image.width;
|
|
@@ -828,7 +859,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
828
859
|
var _a, _b;
|
|
829
860
|
var result = {
|
|
830
861
|
x: -imageWidth / 2,
|
|
831
|
-
y: -imageHeight / 2
|
|
862
|
+
y: -imageHeight / 2,
|
|
832
863
|
};
|
|
833
864
|
switch (this.options.translatePlacement) {
|
|
834
865
|
case 'top':
|
|
@@ -885,7 +916,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
885
916
|
}
|
|
886
917
|
GridLayout.prototype.draw = function () {
|
|
887
918
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
888
|
-
var layoutCanvas = WatermarkCanvas.createCanvas(((_a = this.options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.width) ||
|
|
919
|
+
var layoutCanvas = WatermarkCanvas.createCanvas(((_a = this.options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.width) || this.partialWidth * this.cols + this.gap[0] * this.cols, ((_b = this.options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.height) || this.partialHeight * this.rows + this.gap[1] * this.rows);
|
|
889
920
|
var layoutContext = layoutCanvas.getContext('2d');
|
|
890
921
|
if ((_c = this.options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.backgroundImage) {
|
|
891
922
|
layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.drawImage((_d = this.options.gridLayoutOptions) === null || _d === void 0 ? void 0 : _d.backgroundImage, 0, 0, (_e = this.options.gridLayoutOptions) === null || _e === void 0 ? void 0 : _e.width, (_f = this.options.gridLayoutOptions) === null || _f === void 0 ? void 0 : _f.height);
|
|
@@ -914,21 +945,14 @@ var WatermarkPlus = (function (exports) {
|
|
|
914
945
|
var generateBackgroundSize = function (options) {
|
|
915
946
|
var _a, _b, _c;
|
|
916
947
|
switch (options.layout) {
|
|
917
|
-
case 'grid':
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
options.width * cols + gap[0] * cols,
|
|
924
|
-
options.height * rows + gap[1] * rows
|
|
925
|
-
];
|
|
926
|
-
}
|
|
948
|
+
case 'grid': {
|
|
949
|
+
var cols = ((_a = options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.cols) || 1;
|
|
950
|
+
var rows = ((_b = options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.rows) || 1;
|
|
951
|
+
var gap = ((_c = options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.gap) || [0, 0];
|
|
952
|
+
return [options.width * cols + gap[0] * cols, options.height * rows + gap[1] * rows];
|
|
953
|
+
}
|
|
927
954
|
default:
|
|
928
|
-
return [
|
|
929
|
-
options.width,
|
|
930
|
-
options.height
|
|
931
|
-
];
|
|
955
|
+
return [options.width, options.height];
|
|
932
956
|
}
|
|
933
957
|
};
|
|
934
958
|
|
|
@@ -1013,14 +1037,14 @@ var WatermarkPlus = (function (exports) {
|
|
|
1013
1037
|
parentElementType = this.checkParentElementType();
|
|
1014
1038
|
this.watermarkDom.style.cssText = "\n z-index:".concat(this.options.zIndex, "!important;display:block!important;visibility:visible!important;transform:none!important;scale:none!important;\n ").concat(parentElementType === 'custom' ? 'top:0!important;bottom:0!important;left:0!important;right:0!important;height:100%!important;pointer-events:none!important;position:absolute!important;' : 'position:relative!important;', "\n ");
|
|
1015
1039
|
backgroundSize = generateBackgroundSize(this.options);
|
|
1016
|
-
watermarkInnerDom.style.cssText = "\n display:block!important;visibility:visible!important;pointer-events:none;top:0;bottom:0;left:0;right:0;transform:none!important;scale:none!important;\n position:".concat(parentElementType === 'root' ? 'fixed' : 'absolute', "!important;-webkit-print-color-adjust:exact!important;width:100%!important;height:100%!important;\n z-index:").concat(this.options.zIndex, "!important;background-image:url(").concat(image, ")!important;background-repeat:").concat(this.options.backgroundRepeat, "!important;\n background-size:").concat(backgroundSize[0], "px ").concat(backgroundSize[1], "px!important;background-position:").concat(this.options.backgroundPosition, ";\n ").concat(this.options.movable
|
|
1040
|
+
watermarkInnerDom.style.cssText = "\n display:block!important;visibility:visible!important;pointer-events:none;top:0;bottom:0;left:0;right:0;transform:none!important;scale:none!important;\n position:".concat(parentElementType === 'root' ? 'fixed' : 'absolute', "!important;-webkit-print-color-adjust:exact!important;width:100%!important;height:100%!important;\n z-index:").concat(this.options.zIndex, "!important;background-image:url(").concat(image, ")!important;background-repeat:").concat(this.options.backgroundRepeat, "!important;\n background-size:").concat(backgroundSize[0], "px ").concat(backgroundSize[1], "px!important;background-position:").concat(this.options.backgroundPosition, ";\n ").concat(generateAnimationStyle(this.options.movable, this.options.backgroundRepeat), "\n ");
|
|
1017
1041
|
this.watermarkDom.appendChild(watermarkInnerDom);
|
|
1018
1042
|
this.parentElement.appendChild(this.watermarkDom);
|
|
1019
1043
|
if (this.options.mutationObserve) {
|
|
1020
1044
|
try {
|
|
1021
1045
|
this.bindMutationObserve();
|
|
1022
1046
|
}
|
|
1023
|
-
catch (
|
|
1047
|
+
catch (_j) {
|
|
1024
1048
|
(_e = (_d = this.options).onObserveError) === null || _e === void 0 ? void 0 : _e.call(_d);
|
|
1025
1049
|
}
|
|
1026
1050
|
}
|
|
@@ -1152,7 +1176,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
1152
1176
|
attributes: true, // 属性的变动
|
|
1153
1177
|
childList: true, // 子节点的变动(指新增,删除或者更改)
|
|
1154
1178
|
subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
|
|
1155
|
-
characterData: true // 节点内容或节点文本的变动。
|
|
1179
|
+
characterData: true, // 节点内容或节点文本的变动。
|
|
1156
1180
|
});
|
|
1157
1181
|
this.parentObserve = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
|
|
1158
1182
|
var _i, mutationsList_1, item;
|
|
@@ -1167,7 +1191,9 @@ var WatermarkPlus = (function (exports) {
|
|
|
1167
1191
|
item = mutationsList_1[_i];
|
|
1168
1192
|
if (!((item === null || item === void 0 ? void 0 : item.target) === this.watermarkDom ||
|
|
1169
1193
|
((_a = item === null || item === void 0 ? void 0 : item.removedNodes) === null || _a === void 0 ? void 0 : _a[0]) === this.watermarkDom ||
|
|
1170
|
-
(item.type === 'childList' &&
|
|
1194
|
+
(item.type === 'childList' &&
|
|
1195
|
+
item.target === this.parentElement &&
|
|
1196
|
+
item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
|
|
1171
1197
|
this.remove();
|
|
1172
1198
|
return [4 /*yield*/, this.create()];
|
|
1173
1199
|
case 2:
|
|
@@ -1184,7 +1210,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
1184
1210
|
attributes: true, // 属性的变动
|
|
1185
1211
|
childList: true, // 子节点的变动(指新增,删除或者更改)
|
|
1186
1212
|
subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
|
|
1187
|
-
characterData: true // 节点内容或节点文本的变动。
|
|
1213
|
+
characterData: true, // 节点内容或节点文本的变动。
|
|
1188
1214
|
});
|
|
1189
1215
|
};
|
|
1190
1216
|
Watermark.prototype.bindCheckWatermarkElementEvent = function () {
|
|
@@ -1212,7 +1238,7 @@ var WatermarkPlus = (function (exports) {
|
|
|
1212
1238
|
if (props === void 0) { props = {}; }
|
|
1213
1239
|
var defaultProps = {
|
|
1214
1240
|
globalAlpha: 0.005,
|
|
1215
|
-
mode: 'blind'
|
|
1241
|
+
mode: 'blind',
|
|
1216
1242
|
};
|
|
1217
1243
|
return _super.call(this, __assign(__assign({}, props), defaultProps)) || this;
|
|
1218
1244
|
}
|
|
@@ -1284,12 +1310,15 @@ var WatermarkPlus = (function (exports) {
|
|
|
1284
1310
|
*/
|
|
1285
1311
|
function ImageWatermark(args) {
|
|
1286
1312
|
if (args === void 0) { args = {}; }
|
|
1287
|
-
var _a;
|
|
1313
|
+
var _a, _b;
|
|
1288
1314
|
this.drew = false;
|
|
1289
1315
|
this.props = args;
|
|
1290
1316
|
this.options = __assign(__assign({}, initialOptions), args);
|
|
1317
|
+
if (this.props.crossOrigin) {
|
|
1318
|
+
(_a = this.props.dom) === null || _a === void 0 ? void 0 : _a.setAttribute('crossOrigin', 'anonymous');
|
|
1319
|
+
}
|
|
1291
1320
|
this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
|
|
1292
|
-
this.originalSrc = (
|
|
1321
|
+
this.originalSrc = (_b = this.props.dom) === null || _b === void 0 ? void 0 : _b.src;
|
|
1293
1322
|
this.backgroundImage = this.getBackgroundImage();
|
|
1294
1323
|
}
|
|
1295
1324
|
ImageWatermark.prototype.create = function () {
|