watermark-js-plus 1.6.3 → 1.6.5
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/es/src/core/watermark.js +49 -53
- package/dist/ie/es/node_modules/core-js/internals/array-from.js +11 -3
- package/dist/ie/es/node_modules/core-js/internals/array-set-length.js +39 -0
- package/dist/ie/es/node_modules/core-js/internals/check-correctness-of-iteration.js +2 -0
- package/dist/ie/es/node_modules/core-js/internals/environment-is-ios.js +1 -2
- package/dist/ie/es/node_modules/core-js/internals/function-bind-native.js +1 -1
- package/dist/ie/es/node_modules/core-js/internals/function-name.js +1 -1
- package/dist/ie/es/node_modules/core-js/internals/is-array.js +20 -0
- package/dist/ie/es/node_modules/core-js/internals/iterate.js +8 -3
- package/dist/ie/es/node_modules/core-js/internals/shared-store.js +3 -3
- package/dist/ie/es/node_modules/core-js/internals/to-string-tag-support.js +1 -1
- package/dist/ie/es/node_modules/core-js/modules/es.array.fill.js +1 -1
- package/dist/ie/es/node_modules/core-js/modules/es.array.from.js +1 -1
- package/dist/ie/es/node_modules/core-js/modules/es.array.includes.js +8 -2
- package/dist/ie/es/node_modules/core-js/modules/es.promise.js +1 -1
- package/dist/ie/es/src/core/watermark.js +49 -53
- package/dist/ie/index.cjs.js +135 -69
- package/dist/ie/index.cjs.js.map +1 -1
- package/dist/ie/index.cjs.min.js +1 -1
- package/dist/ie/index.esm.js +135 -69
- package/dist/ie/index.esm.js.map +1 -1
- package/dist/ie/index.esm.min.js +1 -1
- package/dist/ie/index.iife.js +135 -69
- package/dist/ie/index.iife.js.map +1 -1
- package/dist/ie/index.iife.min.js +1 -1
- package/dist/ie/index.umd.js +135 -69
- package/dist/ie/index.umd.js.map +1 -1
- package/dist/ie/index.umd.min.js +1 -1
- package/dist/index.cjs.js +50 -54
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.esm.js +50 -54
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.iife.js +50 -54
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.umd.js +50 -54
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/types/core/watermark.d.ts +3 -2
- package/package.json +57 -51
- /package/dist/ie/es/_virtual/{es.array.fill2.js → es2.array.fill.js} +0 -0
- /package/dist/ie/es/_virtual/{es.array.from2.js → es2.array.from.js} +0 -0
- /package/dist/ie/es/_virtual/{es.array.includes2.js → es2.array.includes.js} +0 -0
- /package/dist/ie/es/_virtual/{es.promise2.js → es2.promise.js} +0 -0
package/dist/ie/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* watermark-js-plus v1.6.
|
|
2
|
+
* watermark-js-plus v1.6.5
|
|
3
3
|
* (c) 2022-2024 Michael Sun
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -77,7 +77,7 @@ function requireFunctionBindNative () {
|
|
|
77
77
|
|
|
78
78
|
functionBindNative = !fails(function () {
|
|
79
79
|
// eslint-disable-next-line es/no-function-prototype-bind -- safe
|
|
80
|
-
var test =
|
|
80
|
+
var test = function () { /* empty */ }.bind();
|
|
81
81
|
// eslint-disable-next-line no-prototype-builtins -- safe
|
|
82
82
|
return typeof test != 'function' || test.hasOwnProperty('prototype');
|
|
83
83
|
});
|
|
@@ -556,10 +556,10 @@ function requireSharedStore () {
|
|
|
556
556
|
var store = sharedStore.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {});
|
|
557
557
|
|
|
558
558
|
(store.versions || (store.versions = [])).push({
|
|
559
|
-
version: '3.
|
|
559
|
+
version: '3.49.0',
|
|
560
560
|
mode: IS_PURE ? 'pure' : 'global',
|
|
561
|
-
copyright: '©
|
|
562
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.
|
|
561
|
+
copyright: '© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.',
|
|
562
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE',
|
|
563
563
|
source: 'https://github.com/zloirock/core-js'
|
|
564
564
|
});
|
|
565
565
|
return sharedStore.exports;
|
|
@@ -912,7 +912,7 @@ function requireFunctionName () {
|
|
|
912
912
|
|
|
913
913
|
var EXISTS = hasOwn(FunctionPrototype, 'name');
|
|
914
914
|
// additional protection from minified / mangled / dropped function names
|
|
915
|
-
var PROPER = EXISTS &&
|
|
915
|
+
var PROPER = EXISTS && function something() { /* empty */ }.name === 'something';
|
|
916
916
|
var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
|
|
917
917
|
|
|
918
918
|
functionName = {
|
|
@@ -1654,7 +1654,7 @@ function requireToStringTagSupport () {
|
|
|
1654
1654
|
|
|
1655
1655
|
var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
1656
1656
|
var test = {};
|
|
1657
|
-
|
|
1657
|
+
// eslint-disable-next-line unicorn/no-immediate-mutation -- ES3 syntax limitation
|
|
1658
1658
|
test[TO_STRING_TAG] = 'z';
|
|
1659
1659
|
|
|
1660
1660
|
toStringTagSupport = String(test) === '[object z]';
|
|
@@ -1776,6 +1776,58 @@ function requireCreateProperty () {
|
|
|
1776
1776
|
return createProperty;
|
|
1777
1777
|
}
|
|
1778
1778
|
|
|
1779
|
+
var isArray;
|
|
1780
|
+
var hasRequiredIsArray;
|
|
1781
|
+
|
|
1782
|
+
function requireIsArray () {
|
|
1783
|
+
if (hasRequiredIsArray) return isArray;
|
|
1784
|
+
hasRequiredIsArray = 1;
|
|
1785
|
+
var classof = requireClassofRaw();
|
|
1786
|
+
|
|
1787
|
+
// `IsArray` abstract operation
|
|
1788
|
+
// https://tc39.es/ecma262/#sec-isarray
|
|
1789
|
+
// eslint-disable-next-line es/no-array-isarray -- safe
|
|
1790
|
+
isArray = Array.isArray || function isArray(argument) {
|
|
1791
|
+
return classof(argument) === 'Array';
|
|
1792
|
+
};
|
|
1793
|
+
return isArray;
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
var arraySetLength;
|
|
1797
|
+
var hasRequiredArraySetLength;
|
|
1798
|
+
|
|
1799
|
+
function requireArraySetLength () {
|
|
1800
|
+
if (hasRequiredArraySetLength) return arraySetLength;
|
|
1801
|
+
hasRequiredArraySetLength = 1;
|
|
1802
|
+
var DESCRIPTORS = requireDescriptors();
|
|
1803
|
+
var isArray = requireIsArray();
|
|
1804
|
+
|
|
1805
|
+
var $TypeError = TypeError;
|
|
1806
|
+
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
1807
|
+
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
1808
|
+
|
|
1809
|
+
// Safari < 13 does not throw an error in this case
|
|
1810
|
+
var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () {
|
|
1811
|
+
// makes no sense without proper strict mode support
|
|
1812
|
+
if (this !== undefined) return true;
|
|
1813
|
+
try {
|
|
1814
|
+
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
1815
|
+
Object.defineProperty([], 'length', { writable: false }).length = 1;
|
|
1816
|
+
} catch (error) {
|
|
1817
|
+
return error instanceof TypeError;
|
|
1818
|
+
}
|
|
1819
|
+
}();
|
|
1820
|
+
|
|
1821
|
+
arraySetLength = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
|
|
1822
|
+
if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
|
|
1823
|
+
throw new $TypeError('Cannot set read only .length');
|
|
1824
|
+
} return O.length = length;
|
|
1825
|
+
} : function (O, length) {
|
|
1826
|
+
return O.length = length;
|
|
1827
|
+
};
|
|
1828
|
+
return arraySetLength;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1779
1831
|
var getIteratorMethod;
|
|
1780
1832
|
var hasRequiredGetIteratorMethod;
|
|
1781
1833
|
|
|
@@ -1834,20 +1886,22 @@ function requireArrayFrom () {
|
|
|
1834
1886
|
var isConstructor = requireIsConstructor();
|
|
1835
1887
|
var lengthOfArrayLike = requireLengthOfArrayLike();
|
|
1836
1888
|
var createProperty = requireCreateProperty();
|
|
1889
|
+
var setArrayLength = requireArraySetLength();
|
|
1837
1890
|
var getIterator = requireGetIterator();
|
|
1838
1891
|
var getIteratorMethod = requireGetIteratorMethod();
|
|
1892
|
+
var iteratorClose = requireIteratorClose();
|
|
1839
1893
|
|
|
1840
1894
|
var $Array = Array;
|
|
1841
1895
|
|
|
1842
1896
|
// `Array.from` method implementation
|
|
1843
1897
|
// https://tc39.es/ecma262/#sec-array.from
|
|
1844
1898
|
arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
|
|
1845
|
-
var O = toObject(arrayLike);
|
|
1846
1899
|
var IS_CONSTRUCTOR = isConstructor(this);
|
|
1847
1900
|
var argumentsLength = arguments.length;
|
|
1848
1901
|
var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
|
|
1849
1902
|
var mapping = mapfn !== undefined;
|
|
1850
1903
|
if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
|
|
1904
|
+
var O = toObject(arrayLike);
|
|
1851
1905
|
var iteratorMethod = getIteratorMethod(O);
|
|
1852
1906
|
var index = 0;
|
|
1853
1907
|
var length, result, step, iterator, next, value;
|
|
@@ -1858,7 +1912,11 @@ function requireArrayFrom () {
|
|
|
1858
1912
|
next = iterator.next;
|
|
1859
1913
|
for (;!(step = call(next, iterator)).done; index++) {
|
|
1860
1914
|
value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
|
|
1861
|
-
|
|
1915
|
+
try {
|
|
1916
|
+
createProperty(result, index, value);
|
|
1917
|
+
} catch (error) {
|
|
1918
|
+
iteratorClose(iterator, 'throw', error);
|
|
1919
|
+
}
|
|
1862
1920
|
}
|
|
1863
1921
|
} else {
|
|
1864
1922
|
length = lengthOfArrayLike(O);
|
|
@@ -1868,7 +1926,7 @@ function requireArrayFrom () {
|
|
|
1868
1926
|
createProperty(result, index, value);
|
|
1869
1927
|
}
|
|
1870
1928
|
}
|
|
1871
|
-
result
|
|
1929
|
+
setArrayLength(result, index);
|
|
1872
1930
|
return result;
|
|
1873
1931
|
};
|
|
1874
1932
|
return arrayFrom;
|
|
@@ -1895,6 +1953,7 @@ function requireCheckCorrectnessOfIteration () {
|
|
|
1895
1953
|
SAFE_CLOSING = true;
|
|
1896
1954
|
}
|
|
1897
1955
|
};
|
|
1956
|
+
// eslint-disable-next-line unicorn/no-immediate-mutation -- ES3 syntax limitation
|
|
1898
1957
|
iteratorWithReturn[ITERATOR] = function () {
|
|
1899
1958
|
return this;
|
|
1900
1959
|
};
|
|
@@ -1909,6 +1968,7 @@ function requireCheckCorrectnessOfIteration () {
|
|
|
1909
1968
|
var ITERATION_SUPPORT = false;
|
|
1910
1969
|
try {
|
|
1911
1970
|
var object = {};
|
|
1971
|
+
// eslint-disable-next-line unicorn/no-immediate-mutation -- ES3 syntax limitation
|
|
1912
1972
|
object[ITERATOR] = function () {
|
|
1913
1973
|
return {
|
|
1914
1974
|
next: function () {
|
|
@@ -2280,8 +2340,7 @@ function requireEnvironmentIsIos () {
|
|
|
2280
2340
|
hasRequiredEnvironmentIsIos = 1;
|
|
2281
2341
|
var userAgent = requireEnvironmentUserAgent();
|
|
2282
2342
|
|
|
2283
|
-
|
|
2284
|
-
environmentIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
|
|
2343
|
+
environmentIsIos = /ipad|iphone|ipod/i.test(userAgent) && /applewebkit/i.test(userAgent);
|
|
2285
2344
|
return environmentIsIos;
|
|
2286
2345
|
}
|
|
2287
2346
|
|
|
@@ -3041,7 +3100,9 @@ function requireIterate () {
|
|
|
3041
3100
|
var iterator, iterFn, index, length, result, next, step;
|
|
3042
3101
|
|
|
3043
3102
|
var stop = function (condition) {
|
|
3044
|
-
|
|
3103
|
+
var $iterator = iterator;
|
|
3104
|
+
iterator = undefined;
|
|
3105
|
+
if ($iterator) iteratorClose($iterator, 'normal');
|
|
3045
3106
|
return new Result(true, condition);
|
|
3046
3107
|
};
|
|
3047
3108
|
|
|
@@ -3071,10 +3132,13 @@ function requireIterate () {
|
|
|
3071
3132
|
|
|
3072
3133
|
next = IS_RECORD ? iterable.next : iterator.next;
|
|
3073
3134
|
while (!(step = call(next, iterator)).done) {
|
|
3135
|
+
// `IteratorValue` errors should propagate without closing the iterator
|
|
3136
|
+
var value = step.value;
|
|
3074
3137
|
try {
|
|
3075
|
-
result = callFn(
|
|
3138
|
+
result = callFn(value);
|
|
3076
3139
|
} catch (error) {
|
|
3077
|
-
iteratorClose(iterator, 'throw', error);
|
|
3140
|
+
if (iterator) iteratorClose(iterator, 'throw', error);
|
|
3141
|
+
else throw error;
|
|
3078
3142
|
}
|
|
3079
3143
|
if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
|
|
3080
3144
|
} return new Result(false);
|
|
@@ -3491,9 +3555,15 @@ function requireEs_array_includes () {
|
|
|
3491
3555
|
return !Array(1).includes();
|
|
3492
3556
|
});
|
|
3493
3557
|
|
|
3558
|
+
// Safari 26.4- bug
|
|
3559
|
+
var BROKEN_ON_SPARSE_WITH_FROM_INDEX = fails(function () {
|
|
3560
|
+
// eslint-disable-next-line no-sparse-arrays, es/no-array-prototype-includes -- detection
|
|
3561
|
+
return [, 1].includes(undefined, 1);
|
|
3562
|
+
});
|
|
3563
|
+
|
|
3494
3564
|
// `Array.prototype.includes` method
|
|
3495
3565
|
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
3496
|
-
$({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
|
|
3566
|
+
$({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE || BROKEN_ON_SPARSE_WITH_FROM_INDEX }, {
|
|
3497
3567
|
includes: function includes(el /* , fromIndex = 0 */) {
|
|
3498
3568
|
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
|
3499
3569
|
}
|
|
@@ -5207,17 +5277,18 @@ var Watermark = /** @class */ (function () {
|
|
|
5207
5277
|
return [2 /*return*/];
|
|
5208
5278
|
}
|
|
5209
5279
|
this.isCreating = true;
|
|
5280
|
+
_h.label = 1;
|
|
5281
|
+
case 1:
|
|
5282
|
+
_h.trys.push([1, , 3, 4]);
|
|
5210
5283
|
if (!this.validateUnique()) {
|
|
5211
|
-
this.isCreating = false;
|
|
5212
5284
|
return [2 /*return*/];
|
|
5213
5285
|
}
|
|
5214
5286
|
if (!this.validateContent()) {
|
|
5215
|
-
this.isCreating = false;
|
|
5216
5287
|
return [2 /*return*/];
|
|
5217
5288
|
}
|
|
5218
5289
|
firstDraw = isUndefined(this.watermarkDom);
|
|
5219
5290
|
return [4 /*yield*/, ((_a = this.watermarkCanvas) === null || _a === void 0 ? void 0 : _a.draw())];
|
|
5220
|
-
case
|
|
5291
|
+
case 2:
|
|
5221
5292
|
_h.sent();
|
|
5222
5293
|
this.layoutCanvas = renderLayout(this.options, (_b = this.watermarkCanvas) === null || _b === void 0 ? void 0 : _b.getCanvas());
|
|
5223
5294
|
image = convertImage(this.layoutCanvas);
|
|
@@ -5227,22 +5298,25 @@ var Watermark = /** @class */ (function () {
|
|
|
5227
5298
|
this.watermarkDom.__WATERMARK__ = 'watermark';
|
|
5228
5299
|
this.watermarkDom.__WATERMARK__INSTANCE__ = this;
|
|
5229
5300
|
parentElementType = this.checkParentElementType();
|
|
5230
|
-
this.watermarkDom.style.cssText = "\n
|
|
5301
|
+
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 ");
|
|
5231
5302
|
backgroundSize = generateBackgroundSize(this.options);
|
|
5232
|
-
watermarkInnerDom.style.cssText = "\n
|
|
5303
|
+
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 ");
|
|
5233
5304
|
this.watermarkDom.appendChild(watermarkInnerDom);
|
|
5234
5305
|
this.parentElement.appendChild(this.watermarkDom);
|
|
5235
5306
|
if (this.options.mutationObserve) {
|
|
5236
5307
|
try {
|
|
5237
|
-
this.
|
|
5308
|
+
this.bindMutationObserver();
|
|
5238
5309
|
}
|
|
5239
5310
|
catch (_j) {
|
|
5240
5311
|
(_e = (_d = this.options).onObserveError) === null || _e === void 0 ? void 0 : _e.call(_d);
|
|
5241
5312
|
}
|
|
5242
5313
|
}
|
|
5243
5314
|
firstDraw && ((_g = (_f = this.options).onSuccess) === null || _g === void 0 ? void 0 : _g.call(_f));
|
|
5315
|
+
return [3 /*break*/, 4];
|
|
5316
|
+
case 3:
|
|
5244
5317
|
this.isCreating = false;
|
|
5245
|
-
return [
|
|
5318
|
+
return [7 /*endfinally*/];
|
|
5319
|
+
case 4: return [2 /*return*/];
|
|
5246
5320
|
}
|
|
5247
5321
|
});
|
|
5248
5322
|
});
|
|
@@ -5265,7 +5339,7 @@ var Watermark = /** @class */ (function () {
|
|
|
5265
5339
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5266
5340
|
(_b = (_a = this.options).onBeforeDestroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
5267
5341
|
(_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
5268
|
-
(_d = this.
|
|
5342
|
+
(_d = this.parentObserver) === null || _d === void 0 ? void 0 : _d.disconnect();
|
|
5269
5343
|
(_f = (_e = this.watermarkDom) === null || _e === void 0 ? void 0 : _e.parentNode) === null || _f === void 0 ? void 0 : _f.removeChild(this.watermarkDom);
|
|
5270
5344
|
(_h = (_g = this.options).onDestroyed) === null || _h === void 0 ? void 0 : _h.call(_g);
|
|
5271
5345
|
};
|
|
@@ -5325,64 +5399,56 @@ var Watermark = /** @class */ (function () {
|
|
|
5325
5399
|
}
|
|
5326
5400
|
return 'custom';
|
|
5327
5401
|
};
|
|
5328
|
-
Watermark.prototype.
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
return
|
|
5332
|
-
|
|
5333
|
-
this.observer = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
|
|
5334
|
-
return __generator(this, function (_a) {
|
|
5335
|
-
switch (_a.label) {
|
|
5402
|
+
Watermark.prototype.recreateOnMutation = function () {
|
|
5403
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5404
|
+
var _b, _c;
|
|
5405
|
+
return __generator(this, function (_d) {
|
|
5406
|
+
switch (_d.label) {
|
|
5336
5407
|
case 0:
|
|
5337
|
-
|
|
5408
|
+
_d.trys.push([0, 2, , 3]);
|
|
5338
5409
|
this.remove();
|
|
5339
5410
|
return [4 /*yield*/, this.create()];
|
|
5340
5411
|
case 1:
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
case 2:
|
|
5412
|
+
_d.sent();
|
|
5413
|
+
return [3 /*break*/, 3];
|
|
5414
|
+
case 2:
|
|
5415
|
+
_d.sent();
|
|
5416
|
+
(_c = (_b = this.options).onObserveError) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
5417
|
+
return [3 /*break*/, 3];
|
|
5418
|
+
case 3: return [2 /*return*/];
|
|
5344
5419
|
}
|
|
5345
5420
|
});
|
|
5346
|
-
});
|
|
5421
|
+
});
|
|
5422
|
+
};
|
|
5423
|
+
Watermark.prototype.bindMutationObserver = function () {
|
|
5424
|
+
var _this = this;
|
|
5425
|
+
if (!this.watermarkDom) {
|
|
5426
|
+
return;
|
|
5427
|
+
}
|
|
5428
|
+
this.observer = new MutationObserver(function (mutationsList) {
|
|
5429
|
+
if (mutationsList.length > 0) {
|
|
5430
|
+
void _this.recreateOnMutation();
|
|
5431
|
+
}
|
|
5432
|
+
});
|
|
5347
5433
|
this.observer.observe(this.watermarkDom, {
|
|
5348
5434
|
attributes: true, // 属性的变动
|
|
5435
|
+
attributeFilter: ['style', 'class', 'hidden', 'id'], // 仅监听会影响水印展示或标识的属性
|
|
5349
5436
|
childList: true, // 子节点的变动(指新增,删除或者更改)
|
|
5350
5437
|
subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
|
|
5351
5438
|
characterData: true, // 节点内容或节点文本的变动。
|
|
5352
5439
|
});
|
|
5353
|
-
this.
|
|
5354
|
-
var
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
if (!((item === null || item === void 0 ? void 0 : item.target) === this.watermarkDom ||
|
|
5365
|
-
((_a = item === null || item === void 0 ? void 0 : item.removedNodes) === null || _a === void 0 ? void 0 : _a[0]) === this.watermarkDom ||
|
|
5366
|
-
(item.type === 'childList' &&
|
|
5367
|
-
item.target === this.parentElement &&
|
|
5368
|
-
item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
|
|
5369
|
-
this.remove();
|
|
5370
|
-
return [4 /*yield*/, this.create()];
|
|
5371
|
-
case 2:
|
|
5372
|
-
_b.sent();
|
|
5373
|
-
_b.label = 3;
|
|
5374
|
-
case 3:
|
|
5375
|
-
_i++;
|
|
5376
|
-
return [3 /*break*/, 1];
|
|
5377
|
-
case 4: return [2 /*return*/];
|
|
5378
|
-
}
|
|
5379
|
-
});
|
|
5380
|
-
}); });
|
|
5381
|
-
this.parentObserve.observe(this.parentElement, {
|
|
5382
|
-
attributes: true, // 属性的变动
|
|
5440
|
+
this.parentObserver = new MutationObserver(function (mutationsList) {
|
|
5441
|
+
var watermarkDom = _this.watermarkDom;
|
|
5442
|
+
if (!watermarkDom) {
|
|
5443
|
+
return;
|
|
5444
|
+
}
|
|
5445
|
+
var watermarkRemoved = mutationsList.some(function (item) { return Array.from(item.removedNodes).includes(watermarkDom); });
|
|
5446
|
+
if (watermarkRemoved) {
|
|
5447
|
+
void _this.recreateOnMutation();
|
|
5448
|
+
}
|
|
5449
|
+
});
|
|
5450
|
+
this.parentObserver.observe(this.parentElement, {
|
|
5383
5451
|
childList: true, // 子节点的变动(指新增,删除或者更改)
|
|
5384
|
-
subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
|
|
5385
|
-
characterData: true, // 节点内容或节点文本的变动。
|
|
5386
5452
|
});
|
|
5387
5453
|
};
|
|
5388
5454
|
return Watermark;
|