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.esm.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
|
*/
|
|
@@ -30,7 +30,7 @@ function styleInject(css, ref) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
var css_248z = "@keyframes watermark{0%{background-position:0 0}25%{background-position:100% 100%}50%{background-position:
|
|
33
|
+
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%}}";
|
|
34
34
|
styleInject(css_248z);
|
|
35
35
|
|
|
36
36
|
/******************************************************************************
|
|
@@ -47,7 +47,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
47
47
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
48
48
|
PERFORMANCE OF THIS SOFTWARE.
|
|
49
49
|
***************************************************************************** */
|
|
50
|
-
/* global Reflect, Promise */
|
|
50
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
51
51
|
|
|
52
52
|
var extendStatics = function(d, b) {
|
|
53
53
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -86,8 +86,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function __generator(thisArg, body) {
|
|
89
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
90
|
-
return g =
|
|
89
|
+
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);
|
|
90
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
91
91
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
92
92
|
function step(op) {
|
|
93
93
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -111,7 +111,12 @@ function __generator(thisArg, body) {
|
|
|
111
111
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
112
112
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
113
113
|
}
|
|
114
|
-
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
117
|
+
var e = new Error(message);
|
|
118
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
119
|
+
};
|
|
115
120
|
|
|
116
121
|
var convertImage = function (canvas) {
|
|
117
122
|
return canvas.toDataURL('image/png', 1);
|
|
@@ -162,7 +167,7 @@ var createCustomContentSVG = function (ctx, options) { return __awaiter(void 0,
|
|
|
162
167
|
switch (_b.label) {
|
|
163
168
|
case 0:
|
|
164
169
|
svgElement = createSVGElement('svg', {
|
|
165
|
-
xmlns: 'http://www.w3.org/2000/svg'
|
|
170
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
166
171
|
});
|
|
167
172
|
bodyElement = document.createElement('div');
|
|
168
173
|
bodyElement.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
|
|
@@ -184,14 +189,14 @@ var createCustomContentSVG = function (ctx, options) { return __awaiter(void 0,
|
|
|
184
189
|
svgElement.setAttribute('height', height.toString());
|
|
185
190
|
foreignObjectElement = createSVGElement('foreignObject', {
|
|
186
191
|
width: width.toString(),
|
|
187
|
-
height: height.toString()
|
|
192
|
+
height: height.toString(),
|
|
188
193
|
});
|
|
189
194
|
foreignObjectElement.appendChild(bodyElement);
|
|
190
195
|
svgElement.appendChild(foreignObjectElement);
|
|
191
196
|
return [2 /*return*/, {
|
|
192
197
|
element: svgElement,
|
|
193
198
|
width: width,
|
|
194
|
-
height: height
|
|
199
|
+
height: height,
|
|
195
200
|
}];
|
|
196
201
|
}
|
|
197
202
|
});
|
|
@@ -259,7 +264,8 @@ function convertImgToBase64(bodyElement) {
|
|
|
259
264
|
var convertSVGToImage = function (svg) {
|
|
260
265
|
var richContent = svg.outerHTML
|
|
261
266
|
.replace(/<(img|br|input|hr|embed)(.*?)>/g, '<$1$2/>')
|
|
262
|
-
.replace(/\n/g, '')
|
|
267
|
+
.replace(/\n/g, '')
|
|
268
|
+
.replace(/\t/g, '')
|
|
263
269
|
.replace(/#/g, '%23');
|
|
264
270
|
return "data:image/svg+xml;charset=utf-8,".concat(richContent);
|
|
265
271
|
};
|
|
@@ -275,7 +281,7 @@ var loadImage = function (url, width, height) {
|
|
|
275
281
|
if (width === void 0) { width = undefined; }
|
|
276
282
|
if (height === void 0) { height = undefined; }
|
|
277
283
|
var image = new Image();
|
|
278
|
-
image.setAttribute('crossOrigin', '
|
|
284
|
+
image.setAttribute('crossOrigin', 'anonymous');
|
|
279
285
|
!isUndefined(width) && (image.width = width);
|
|
280
286
|
!isUndefined(height) && (image.height = height);
|
|
281
287
|
image.src = url;
|
|
@@ -288,6 +294,25 @@ var loadImage = function (url, width, height) {
|
|
|
288
294
|
var generateMatrix = function (rows, columns, value) {
|
|
289
295
|
return Array.from({ length: rows }, function () { return new Array(columns).fill(value); });
|
|
290
296
|
};
|
|
297
|
+
var generateAnimationStyle = function (movable, backgroundRepeat) {
|
|
298
|
+
if (!movable) {
|
|
299
|
+
return '';
|
|
300
|
+
}
|
|
301
|
+
var horizontalDuration = Math.random() * (8 - 2) + 2;
|
|
302
|
+
var verticalDuration = Math.random() * (4 - 2) + 2;
|
|
303
|
+
switch (backgroundRepeat) {
|
|
304
|
+
case 'repeat':
|
|
305
|
+
return 'animation: 200s linear 0s infinite alternate watermark !important;';
|
|
306
|
+
case 'repeat-x':
|
|
307
|
+
return "animation: ".concat(horizontalDuration, "s ease-in 0s infinite alternate watermark-vertical !important;'");
|
|
308
|
+
case 'repeat-y':
|
|
309
|
+
return "animation: ".concat(verticalDuration, "s ease-out 0s infinite alternate watermark-horizontal !important;'");
|
|
310
|
+
case 'no-repeat':
|
|
311
|
+
return "animation: ".concat(horizontalDuration, "s ease-in 0s infinite alternate watermark-horizontal, ").concat(verticalDuration, "s ease-out 0s infinite alternate watermark-vertical !important;");
|
|
312
|
+
default:
|
|
313
|
+
return '';
|
|
314
|
+
}
|
|
315
|
+
};
|
|
291
316
|
|
|
292
317
|
var initialOptions = {
|
|
293
318
|
width: 300,
|
|
@@ -323,7 +348,7 @@ var initialOptions = {
|
|
|
323
348
|
onSuccess: function () { },
|
|
324
349
|
onBeforeDestroy: function () { },
|
|
325
350
|
onDestroyed: function () { },
|
|
326
|
-
onObserveError: function () { }
|
|
351
|
+
onObserveError: function () { },
|
|
327
352
|
};
|
|
328
353
|
var generateRecommendOptions = function (canvas, options, args) {
|
|
329
354
|
var ctx = canvas.getContext('2d');
|
|
@@ -336,7 +361,7 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
336
361
|
ctx.letterSpacing = options.letterSpacing;
|
|
337
362
|
ctx.wordSpacing = options.wordSpacing;
|
|
338
363
|
if (options === null || options === void 0 ? void 0 : options.rotate) {
|
|
339
|
-
options.rotate = (360 - options.rotate % 360) * (Math.PI / 180);
|
|
364
|
+
options.rotate = (360 - (options.rotate % 360)) * (Math.PI / 180);
|
|
340
365
|
}
|
|
341
366
|
if (isUndefined(args.textRowMaxWidth)) {
|
|
342
367
|
options.textRowMaxWidth = options.width;
|
|
@@ -345,21 +370,21 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
345
370
|
image: {
|
|
346
371
|
rect: {
|
|
347
372
|
width: options.imageWidth,
|
|
348
|
-
height: options.imageHeight
|
|
373
|
+
height: options.imageHeight,
|
|
349
374
|
},
|
|
350
375
|
position: {
|
|
351
376
|
x: 0,
|
|
352
|
-
y: 0
|
|
353
|
-
}
|
|
377
|
+
y: 0,
|
|
378
|
+
},
|
|
354
379
|
},
|
|
355
380
|
textLine: {
|
|
356
381
|
data: [],
|
|
357
|
-
yOffsetValue: 0
|
|
382
|
+
yOffsetValue: 0,
|
|
358
383
|
},
|
|
359
384
|
advancedStyleParams: {
|
|
360
385
|
linear: {
|
|
361
386
|
x0: 0,
|
|
362
|
-
x1: 0
|
|
387
|
+
x1: 0,
|
|
363
388
|
},
|
|
364
389
|
radial: {
|
|
365
390
|
x0: 0,
|
|
@@ -367,15 +392,15 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
367
392
|
r0: 0,
|
|
368
393
|
x1: 0,
|
|
369
394
|
y1: 0,
|
|
370
|
-
r1: 0
|
|
395
|
+
r1: 0,
|
|
371
396
|
},
|
|
372
397
|
conic: {
|
|
373
398
|
x: 0,
|
|
374
399
|
y: 0,
|
|
375
|
-
startAngle: 0
|
|
400
|
+
startAngle: 0,
|
|
376
401
|
},
|
|
377
|
-
pattern: {}
|
|
378
|
-
}
|
|
402
|
+
pattern: {},
|
|
403
|
+
},
|
|
379
404
|
};
|
|
380
405
|
switch (options.contentType) {
|
|
381
406
|
case 'text':
|
|
@@ -425,14 +450,14 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
425
450
|
result.advancedStyleParams.linear.x0 = -options.width / 2;
|
|
426
451
|
result.advancedStyleParams.linear.x1 = options.width / 2;
|
|
427
452
|
// result.advancedStyleParams.radial.x0 = 0
|
|
428
|
-
result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
|
|
453
|
+
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
429
454
|
// result.advancedStyleParams.radial.r0 = 0
|
|
430
455
|
// result.advancedStyleParams.radial.x1 = 0
|
|
431
456
|
// result.advancedStyleParams.radial.y1 = 0
|
|
432
|
-
result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
|
|
457
|
+
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
433
458
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
434
459
|
// result.advancedStyleParams.conic.x = 0
|
|
435
|
-
result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
|
|
460
|
+
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
436
461
|
break;
|
|
437
462
|
case 'top-start':
|
|
438
463
|
translateX = 0;
|
|
@@ -442,13 +467,13 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
442
467
|
result.advancedStyleParams.linear.x0 = 0;
|
|
443
468
|
result.advancedStyleParams.linear.x1 = options.width;
|
|
444
469
|
result.advancedStyleParams.radial.x0 = options.width / 2;
|
|
445
|
-
result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
|
|
470
|
+
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
446
471
|
// result.advancedStyleParams.radial.r0 = 0
|
|
447
472
|
result.advancedStyleParams.radial.x1 = options.width / 2;
|
|
448
|
-
result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
|
|
473
|
+
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
449
474
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
450
475
|
result.advancedStyleParams.conic.x = options.width / 2;
|
|
451
|
-
result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
|
|
476
|
+
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
452
477
|
break;
|
|
453
478
|
case 'top-end':
|
|
454
479
|
translateX = options.width;
|
|
@@ -458,13 +483,13 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
458
483
|
result.advancedStyleParams.linear.x0 = 0;
|
|
459
484
|
result.advancedStyleParams.linear.x1 = -options.width;
|
|
460
485
|
result.advancedStyleParams.radial.x0 = -options.width / 2;
|
|
461
|
-
result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
|
|
486
|
+
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
462
487
|
// result.advancedStyleParams.radial.r0 = 0
|
|
463
488
|
result.advancedStyleParams.radial.x1 = -options.width / 2;
|
|
464
|
-
result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
|
|
489
|
+
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
465
490
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
466
491
|
result.advancedStyleParams.conic.x = -options.width / 2;
|
|
467
|
-
result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
|
|
492
|
+
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
468
493
|
break;
|
|
469
494
|
case 'bottom':
|
|
470
495
|
translateX = options.width / 2;
|
|
@@ -474,13 +499,13 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
474
499
|
result.advancedStyleParams.linear.x0 = -options.width / 2;
|
|
475
500
|
result.advancedStyleParams.linear.x1 = options.width / 2;
|
|
476
501
|
// result.advancedStyleParams.radial.x0 = 0
|
|
477
|
-
result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
|
|
502
|
+
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
478
503
|
// result.advancedStyleParams.radial.r0 = 0
|
|
479
504
|
// result.advancedStyleParams.radial.x1 = 0
|
|
480
|
-
result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
|
|
505
|
+
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
481
506
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
482
507
|
result.advancedStyleParams.conic.x = 0;
|
|
483
|
-
result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
|
|
508
|
+
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
484
509
|
break;
|
|
485
510
|
case 'bottom-start':
|
|
486
511
|
translateX = 0;
|
|
@@ -490,13 +515,13 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
490
515
|
result.advancedStyleParams.linear.x0 = 0;
|
|
491
516
|
result.advancedStyleParams.linear.x1 = options.width;
|
|
492
517
|
result.advancedStyleParams.radial.x0 = options.width / 2;
|
|
493
|
-
result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
|
|
518
|
+
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
494
519
|
// result.advancedStyleParams.radial.r0 = 0
|
|
495
520
|
result.advancedStyleParams.radial.x1 = options.width / 2;
|
|
496
|
-
result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
|
|
521
|
+
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
497
522
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
498
523
|
result.advancedStyleParams.conic.x = options.width / 2;
|
|
499
|
-
result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
|
|
524
|
+
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
500
525
|
break;
|
|
501
526
|
case 'bottom-end':
|
|
502
527
|
translateX = options.width;
|
|
@@ -506,13 +531,13 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
506
531
|
result.advancedStyleParams.linear.x0 = 0;
|
|
507
532
|
result.advancedStyleParams.linear.x1 = -options.width;
|
|
508
533
|
result.advancedStyleParams.radial.x0 = -options.width / 2;
|
|
509
|
-
result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
|
|
534
|
+
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
510
535
|
// result.advancedStyleParams.radial.r0 = 0
|
|
511
536
|
result.advancedStyleParams.radial.x1 = -options.width / 2;
|
|
512
|
-
result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
|
|
537
|
+
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
513
538
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
514
539
|
result.advancedStyleParams.conic.x = -options.width / 2;
|
|
515
|
-
result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
|
|
540
|
+
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
516
541
|
break;
|
|
517
542
|
case 'left':
|
|
518
543
|
translateX = 0;
|
|
@@ -554,12 +579,13 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
554
579
|
if (['text', 'multi-line-text'].includes(options.contentType)) {
|
|
555
580
|
switch (options.textBaseline) {
|
|
556
581
|
case 'middle':
|
|
557
|
-
result.textLine.yOffsetValue = (result.textLine.data.length - 1) * options.lineHeight / 2;
|
|
582
|
+
result.textLine.yOffsetValue = ((result.textLine.data.length - 1) * options.lineHeight) / 2;
|
|
558
583
|
break;
|
|
559
584
|
case 'bottom':
|
|
560
585
|
case 'alphabetic':
|
|
561
586
|
case 'ideographic':
|
|
562
|
-
result.textLine.yOffsetValue =
|
|
587
|
+
result.textLine.yOffsetValue =
|
|
588
|
+
(result.textLine.data.length - 1) * options.lineHeight + (options.lineHeight - parseInt(options.fontSize)) / 2;
|
|
563
589
|
break;
|
|
564
590
|
case 'top':
|
|
565
591
|
case 'hanging':
|
|
@@ -577,11 +603,11 @@ var protection = (function (need) {
|
|
|
577
603
|
if (need) {
|
|
578
604
|
Object.defineProperty(window, 'MutationObserver', {
|
|
579
605
|
writable: false,
|
|
580
|
-
configurable: false
|
|
606
|
+
configurable: false,
|
|
581
607
|
});
|
|
582
608
|
Object.defineProperty(window, 'requestAnimationFrame', {
|
|
583
609
|
writable: false,
|
|
584
|
-
configurable: false
|
|
610
|
+
configurable: false,
|
|
585
611
|
});
|
|
586
612
|
}
|
|
587
613
|
});
|
|
@@ -710,7 +736,7 @@ var WatermarkCanvas = /** @class */ (function () {
|
|
|
710
736
|
};
|
|
711
737
|
WatermarkCanvas.prototype.createLinearGradient = function (ctx) {
|
|
712
738
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
713
|
-
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));
|
|
739
|
+
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));
|
|
714
740
|
(_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) {
|
|
715
741
|
gradient.addColorStop(item.offset, item.color);
|
|
716
742
|
});
|
|
@@ -718,7 +744,7 @@ var WatermarkCanvas = /** @class */ (function () {
|
|
|
718
744
|
};
|
|
719
745
|
WatermarkCanvas.prototype.createConicGradient = function (ctx) {
|
|
720
746
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
721
|
-
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));
|
|
747
|
+
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)));
|
|
722
748
|
(_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) {
|
|
723
749
|
gradient.addColorStop(item.offset, item.color);
|
|
724
750
|
});
|
|
@@ -726,7 +752,7 @@ var WatermarkCanvas = /** @class */ (function () {
|
|
|
726
752
|
};
|
|
727
753
|
WatermarkCanvas.prototype.createRadialGradient = function (ctx) {
|
|
728
754
|
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;
|
|
729
|
-
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));
|
|
755
|
+
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)));
|
|
730
756
|
(_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) {
|
|
731
757
|
gradient.addColorStop(item.offset, item.color);
|
|
732
758
|
});
|
|
@@ -734,7 +760,7 @@ var WatermarkCanvas = /** @class */ (function () {
|
|
|
734
760
|
};
|
|
735
761
|
WatermarkCanvas.prototype.createPattern = function (ctx) {
|
|
736
762
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
737
|
-
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) || '');
|
|
763
|
+
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) || '');
|
|
738
764
|
};
|
|
739
765
|
WatermarkCanvas.prototype.setText = function (ctx, params) {
|
|
740
766
|
var methodName = 'fillText';
|
|
@@ -748,7 +774,7 @@ var WatermarkCanvas = /** @class */ (function () {
|
|
|
748
774
|
text: this.options.content,
|
|
749
775
|
x: 0,
|
|
750
776
|
y: 0 - this.recommendOptions.textLine.yOffsetValue,
|
|
751
|
-
maxWidth: this.options.textRowMaxWidth || this.options.width
|
|
777
|
+
maxWidth: this.options.textRowMaxWidth || this.options.width,
|
|
752
778
|
});
|
|
753
779
|
resolve(ctx.canvas);
|
|
754
780
|
};
|
|
@@ -782,7 +808,12 @@ var WatermarkCanvas = /** @class */ (function () {
|
|
|
782
808
|
var lines = this.recommendOptions.textLine.data;
|
|
783
809
|
var yOffsetValue = this.recommendOptions.textLine.yOffsetValue;
|
|
784
810
|
lines.forEach(function (text, index) {
|
|
785
|
-
_this.setText(ctx, {
|
|
811
|
+
_this.setText(ctx, {
|
|
812
|
+
text: text,
|
|
813
|
+
x: 0,
|
|
814
|
+
y: _this.options.lineHeight * index - yOffsetValue,
|
|
815
|
+
maxWidth: _this.options.textRowMaxWidth || _this.options.width,
|
|
816
|
+
});
|
|
786
817
|
});
|
|
787
818
|
resolve(ctx.canvas);
|
|
788
819
|
};
|
|
@@ -809,10 +840,10 @@ var WatermarkCanvas = /** @class */ (function () {
|
|
|
809
840
|
var rect = { width: this.options.imageWidth || 0, height: this.options.imageHeight || 0 };
|
|
810
841
|
switch (true) {
|
|
811
842
|
case rect.width !== 0 && rect.height === 0:
|
|
812
|
-
rect.height = rect.width * image.height / image.width;
|
|
843
|
+
rect.height = (rect.width * image.height) / image.width;
|
|
813
844
|
break;
|
|
814
845
|
case rect.width === 0 && rect.height !== 0:
|
|
815
|
-
rect.width = rect.height * image.width / image.height;
|
|
846
|
+
rect.width = (rect.height * image.width) / image.height;
|
|
816
847
|
break;
|
|
817
848
|
case rect.width === 0 && rect.height === 0:
|
|
818
849
|
rect.width = image.width;
|
|
@@ -825,7 +856,7 @@ var WatermarkCanvas = /** @class */ (function () {
|
|
|
825
856
|
var _a, _b;
|
|
826
857
|
var result = {
|
|
827
858
|
x: -imageWidth / 2,
|
|
828
|
-
y: -imageHeight / 2
|
|
859
|
+
y: -imageHeight / 2,
|
|
829
860
|
};
|
|
830
861
|
switch (this.options.translatePlacement) {
|
|
831
862
|
case 'top':
|
|
@@ -882,7 +913,7 @@ var GridLayout = /** @class */ (function () {
|
|
|
882
913
|
}
|
|
883
914
|
GridLayout.prototype.draw = function () {
|
|
884
915
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
885
|
-
var layoutCanvas = WatermarkCanvas.createCanvas(((_a = this.options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.width) ||
|
|
916
|
+
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);
|
|
886
917
|
var layoutContext = layoutCanvas.getContext('2d');
|
|
887
918
|
if ((_c = this.options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.backgroundImage) {
|
|
888
919
|
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);
|
|
@@ -911,21 +942,14 @@ var renderLayout = function (options, partialCanvas) {
|
|
|
911
942
|
var generateBackgroundSize = function (options) {
|
|
912
943
|
var _a, _b, _c;
|
|
913
944
|
switch (options.layout) {
|
|
914
|
-
case 'grid':
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
options.width * cols + gap[0] * cols,
|
|
921
|
-
options.height * rows + gap[1] * rows
|
|
922
|
-
];
|
|
923
|
-
}
|
|
945
|
+
case 'grid': {
|
|
946
|
+
var cols = ((_a = options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.cols) || 1;
|
|
947
|
+
var rows = ((_b = options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.rows) || 1;
|
|
948
|
+
var gap = ((_c = options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.gap) || [0, 0];
|
|
949
|
+
return [options.width * cols + gap[0] * cols, options.height * rows + gap[1] * rows];
|
|
950
|
+
}
|
|
924
951
|
default:
|
|
925
|
-
return [
|
|
926
|
-
options.width,
|
|
927
|
-
options.height
|
|
928
|
-
];
|
|
952
|
+
return [options.width, options.height];
|
|
929
953
|
}
|
|
930
954
|
};
|
|
931
955
|
|
|
@@ -1010,14 +1034,14 @@ var Watermark = /** @class */ (function () {
|
|
|
1010
1034
|
parentElementType = this.checkParentElementType();
|
|
1011
1035
|
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 ");
|
|
1012
1036
|
backgroundSize = generateBackgroundSize(this.options);
|
|
1013
|
-
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
|
|
1037
|
+
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 ");
|
|
1014
1038
|
this.watermarkDom.appendChild(watermarkInnerDom);
|
|
1015
1039
|
this.parentElement.appendChild(this.watermarkDom);
|
|
1016
1040
|
if (this.options.mutationObserve) {
|
|
1017
1041
|
try {
|
|
1018
1042
|
this.bindMutationObserve();
|
|
1019
1043
|
}
|
|
1020
|
-
catch (
|
|
1044
|
+
catch (_j) {
|
|
1021
1045
|
(_e = (_d = this.options).onObserveError) === null || _e === void 0 ? void 0 : _e.call(_d);
|
|
1022
1046
|
}
|
|
1023
1047
|
}
|
|
@@ -1149,7 +1173,7 @@ var Watermark = /** @class */ (function () {
|
|
|
1149
1173
|
attributes: true, // 属性的变动
|
|
1150
1174
|
childList: true, // 子节点的变动(指新增,删除或者更改)
|
|
1151
1175
|
subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
|
|
1152
|
-
characterData: true // 节点内容或节点文本的变动。
|
|
1176
|
+
characterData: true, // 节点内容或节点文本的变动。
|
|
1153
1177
|
});
|
|
1154
1178
|
this.parentObserve = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
|
|
1155
1179
|
var _i, mutationsList_1, item;
|
|
@@ -1164,7 +1188,9 @@ var Watermark = /** @class */ (function () {
|
|
|
1164
1188
|
item = mutationsList_1[_i];
|
|
1165
1189
|
if (!((item === null || item === void 0 ? void 0 : item.target) === this.watermarkDom ||
|
|
1166
1190
|
((_a = item === null || item === void 0 ? void 0 : item.removedNodes) === null || _a === void 0 ? void 0 : _a[0]) === this.watermarkDom ||
|
|
1167
|
-
(item.type === 'childList' &&
|
|
1191
|
+
(item.type === 'childList' &&
|
|
1192
|
+
item.target === this.parentElement &&
|
|
1193
|
+
item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
|
|
1168
1194
|
this.remove();
|
|
1169
1195
|
return [4 /*yield*/, this.create()];
|
|
1170
1196
|
case 2:
|
|
@@ -1181,7 +1207,7 @@ var Watermark = /** @class */ (function () {
|
|
|
1181
1207
|
attributes: true, // 属性的变动
|
|
1182
1208
|
childList: true, // 子节点的变动(指新增,删除或者更改)
|
|
1183
1209
|
subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
|
|
1184
|
-
characterData: true // 节点内容或节点文本的变动。
|
|
1210
|
+
characterData: true, // 节点内容或节点文本的变动。
|
|
1185
1211
|
});
|
|
1186
1212
|
};
|
|
1187
1213
|
Watermark.prototype.bindCheckWatermarkElementEvent = function () {
|
|
@@ -1209,7 +1235,7 @@ var BlindWatermark = /** @class */ (function (_super) {
|
|
|
1209
1235
|
if (props === void 0) { props = {}; }
|
|
1210
1236
|
var defaultProps = {
|
|
1211
1237
|
globalAlpha: 0.005,
|
|
1212
|
-
mode: 'blind'
|
|
1238
|
+
mode: 'blind',
|
|
1213
1239
|
};
|
|
1214
1240
|
return _super.call(this, __assign(__assign({}, props), defaultProps)) || this;
|
|
1215
1241
|
}
|
|
@@ -1281,12 +1307,15 @@ var ImageWatermark = /** @class */ (function () {
|
|
|
1281
1307
|
*/
|
|
1282
1308
|
function ImageWatermark(args) {
|
|
1283
1309
|
if (args === void 0) { args = {}; }
|
|
1284
|
-
var _a;
|
|
1310
|
+
var _a, _b;
|
|
1285
1311
|
this.drew = false;
|
|
1286
1312
|
this.props = args;
|
|
1287
1313
|
this.options = __assign(__assign({}, initialOptions), args);
|
|
1314
|
+
if (this.props.crossOrigin) {
|
|
1315
|
+
(_a = this.props.dom) === null || _a === void 0 ? void 0 : _a.setAttribute('crossOrigin', 'anonymous');
|
|
1316
|
+
}
|
|
1288
1317
|
this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
|
|
1289
|
-
this.originalSrc = (
|
|
1318
|
+
this.originalSrc = (_b = this.props.dom) === null || _b === void 0 ? void 0 : _b.src;
|
|
1290
1319
|
this.backgroundImage = this.getBackgroundImage();
|
|
1291
1320
|
}
|
|
1292
1321
|
ImageWatermark.prototype.create = function () {
|