watermark-js-plus 1.6.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/node_modules/tslib/tslib.es6.js +86 -0
- package/dist/es/src/core/blind.js +82 -0
- package/dist/es/src/core/canvas.js +292 -0
- package/dist/es/src/core/image.js +63 -0
- package/dist/es/src/core/layout/grid.js +36 -0
- package/dist/es/src/core/layout/index.js +25 -0
- package/dist/es/src/core/watermark.js +248 -0
- package/dist/es/src/index.js +3 -0
- package/dist/es/src/utils/index.js +199 -0
- package/dist/es/src/utils/initialization.js +284 -0
- package/dist/es/src/utils/protection.js +13 -0
- package/dist/es/style.css +1 -0
- package/dist/ie/es/_virtual/_commonjsHelpers.js +3 -0
- package/dist/ie/es/_virtual/es.array.fill.js +3 -0
- package/dist/ie/es/_virtual/es.array.fill2.js +3 -0
- package/dist/ie/es/_virtual/es.array.from.js +3 -0
- package/dist/ie/es/_virtual/es.array.from2.js +3 -0
- package/dist/ie/es/_virtual/es.array.includes.js +3 -0
- package/dist/ie/es/_virtual/es.array.includes2.js +3 -0
- package/dist/ie/es/_virtual/es.promise.all.js +3 -0
- package/dist/ie/es/_virtual/es.promise.catch.js +3 -0
- package/dist/ie/es/_virtual/es.promise.constructor.js +3 -0
- package/dist/ie/es/_virtual/es.promise.js +3 -0
- package/dist/ie/es/_virtual/es.promise.race.js +3 -0
- package/dist/ie/es/_virtual/es.promise.reject.js +3 -0
- package/dist/ie/es/_virtual/es.promise.resolve.js +3 -0
- package/dist/ie/es/_virtual/es.promise2.js +3 -0
- package/dist/ie/es/_virtual/make-built-in.js +3 -0
- package/dist/ie/es/_virtual/new-promise-capability.js +3 -0
- package/dist/ie/es/_virtual/object-define-properties.js +3 -0
- package/dist/ie/es/_virtual/object-define-property.js +3 -0
- package/dist/ie/es/_virtual/object-get-own-property-descriptor.js +3 -0
- package/dist/ie/es/_virtual/object-get-own-property-names.js +3 -0
- package/dist/ie/es/_virtual/object-get-own-property-symbols.js +3 -0
- package/dist/ie/es/_virtual/object-property-is-enumerable.js +3 -0
- package/dist/ie/es/_virtual/shared-store.js +3 -0
- package/dist/ie/es/node_modules/core-js/internals/a-callable.js +23 -0
- package/dist/ie/es/node_modules/core-js/internals/a-constructor.js +23 -0
- package/dist/ie/es/node_modules/core-js/internals/a-possible-prototype.js +21 -0
- package/dist/ie/es/node_modules/core-js/internals/add-to-unscopables.js +34 -0
- package/dist/ie/es/node_modules/core-js/internals/an-instance.js +20 -0
- package/dist/ie/es/node_modules/core-js/internals/an-object.js +22 -0
- package/dist/ie/es/node_modules/core-js/internals/array-fill.js +30 -0
- package/dist/ie/es/node_modules/core-js/internals/array-from.js +66 -0
- package/dist/ie/es/node_modules/core-js/internals/array-includes.js +47 -0
- package/dist/ie/es/node_modules/core-js/internals/array-slice.js +15 -0
- package/dist/ie/es/node_modules/core-js/internals/call-with-safe-iteration-closing.js +24 -0
- package/dist/ie/es/node_modules/core-js/internals/check-correctness-of-iteration.js +52 -0
- package/dist/ie/es/node_modules/core-js/internals/classof-raw.js +20 -0
- package/dist/ie/es/node_modules/core-js/internals/classof.js +44 -0
- package/dist/ie/es/node_modules/core-js/internals/copy-constructor-properties.js +31 -0
- package/dist/ie/es/node_modules/core-js/internals/create-non-enumerable-property.js +24 -0
- package/dist/ie/es/node_modules/core-js/internals/create-property-descriptor.js +18 -0
- package/dist/ie/es/node_modules/core-js/internals/create-property.js +22 -0
- package/dist/ie/es/node_modules/core-js/internals/define-built-in-accessor.js +21 -0
- package/dist/ie/es/node_modules/core-js/internals/define-built-in.js +42 -0
- package/dist/ie/es/node_modules/core-js/internals/define-global-property.js +24 -0
- package/dist/ie/es/node_modules/core-js/internals/descriptors.js +19 -0
- package/dist/ie/es/node_modules/core-js/internals/document-create-element.js +23 -0
- package/dist/ie/es/node_modules/core-js/internals/enum-bug-keys.js +20 -0
- package/dist/ie/es/node_modules/core-js/internals/environment-is-ios-pebble.js +15 -0
- package/dist/ie/es/node_modules/core-js/internals/environment-is-ios.js +16 -0
- package/dist/ie/es/node_modules/core-js/internals/environment-is-node.js +15 -0
- package/dist/ie/es/node_modules/core-js/internals/environment-is-webos-webkit.js +15 -0
- package/dist/ie/es/node_modules/core-js/internals/environment-user-agent.js +18 -0
- package/dist/ie/es/node_modules/core-js/internals/environment-v8-version.js +40 -0
- package/dist/ie/es/node_modules/core-js/internals/environment.js +34 -0
- package/dist/ie/es/node_modules/core-js/internals/export.js +72 -0
- package/dist/ie/es/node_modules/core-js/internals/fails.js +17 -0
- package/dist/ie/es/node_modules/core-js/internals/function-apply.js +22 -0
- package/dist/ie/es/node_modules/core-js/internals/function-bind-context.js +27 -0
- package/dist/ie/es/node_modules/core-js/internals/function-bind-native.js +20 -0
- package/dist/ie/es/node_modules/core-js/internals/function-call.js +19 -0
- package/dist/ie/es/node_modules/core-js/internals/function-name.js +30 -0
- package/dist/ie/es/node_modules/core-js/internals/function-uncurry-this-accessor.js +22 -0
- package/dist/ie/es/node_modules/core-js/internals/function-uncurry-this-clause.js +22 -0
- package/dist/ie/es/node_modules/core-js/internals/function-uncurry-this.js +24 -0
- package/dist/ie/es/node_modules/core-js/internals/get-built-in.js +23 -0
- package/dist/ie/es/node_modules/core-js/internals/get-iterator-method.js +29 -0
- package/dist/ie/es/node_modules/core-js/internals/get-iterator.js +29 -0
- package/dist/ie/es/node_modules/core-js/internals/get-method.js +22 -0
- package/dist/ie/es/node_modules/core-js/internals/global-this.js +27 -0
- package/dist/ie/es/node_modules/core-js/internals/has-own-property.js +24 -0
- package/dist/ie/es/node_modules/core-js/internals/hidden-keys.js +11 -0
- package/dist/ie/es/node_modules/core-js/internals/host-report-errors.js +16 -0
- package/dist/ie/es/node_modules/core-js/internals/html.js +15 -0
- package/dist/ie/es/node_modules/core-js/internals/ie8-dom-define.js +25 -0
- package/dist/ie/es/node_modules/core-js/internals/indexed-object.js +29 -0
- package/dist/ie/es/node_modules/core-js/internals/inspect-source.js +28 -0
- package/dist/ie/es/node_modules/core-js/internals/internal-state.js +89 -0
- package/dist/ie/es/node_modules/core-js/internals/is-array-iterator-method.js +23 -0
- package/dist/ie/es/node_modules/core-js/internals/is-callable.js +21 -0
- package/dist/ie/es/node_modules/core-js/internals/is-constructor.js +68 -0
- package/dist/ie/es/node_modules/core-js/internals/is-forced.js +35 -0
- package/dist/ie/es/node_modules/core-js/internals/is-null-or-undefined.js +15 -0
- package/dist/ie/es/node_modules/core-js/internals/is-object.js +17 -0
- package/dist/ie/es/node_modules/core-js/internals/is-possible-prototype.js +17 -0
- package/dist/ie/es/node_modules/core-js/internals/is-pure.js +11 -0
- package/dist/ie/es/node_modules/core-js/internals/is-symbol.js +28 -0
- package/dist/ie/es/node_modules/core-js/internals/iterate.js +89 -0
- package/dist/ie/es/node_modules/core-js/internals/iterator-close.js +37 -0
- package/dist/ie/es/node_modules/core-js/internals/iterators.js +11 -0
- package/dist/ie/es/node_modules/core-js/internals/length-of-array-like.js +19 -0
- package/dist/ie/es/node_modules/core-js/internals/make-built-in.js +73 -0
- package/dist/ie/es/node_modules/core-js/internals/math-trunc.js +20 -0
- package/dist/ie/es/node_modules/core-js/internals/microtask.js +98 -0
- package/dist/ie/es/node_modules/core-js/internals/new-promise-capability.js +32 -0
- package/dist/ie/es/node_modules/core-js/internals/object-create.js +102 -0
- package/dist/ie/es/node_modules/core-js/internals/object-define-properties.js +37 -0
- package/dist/ie/es/node_modules/core-js/internals/object-define-property.js +59 -0
- package/dist/ie/es/node_modules/core-js/internals/object-get-own-property-descriptor.js +41 -0
- package/dist/ie/es/node_modules/core-js/internals/object-get-own-property-names.js +24 -0
- package/dist/ie/es/node_modules/core-js/internals/object-get-own-property-symbols.js +13 -0
- package/dist/ie/es/node_modules/core-js/internals/object-is-prototype-of.js +15 -0
- package/dist/ie/es/node_modules/core-js/internals/object-keys-internal.js +36 -0
- package/dist/ie/es/node_modules/core-js/internals/object-keys.js +22 -0
- package/dist/ie/es/node_modules/core-js/internals/object-property-is-enumerable.js +24 -0
- package/dist/ie/es/node_modules/core-js/internals/object-set-prototype-of.js +43 -0
- package/dist/ie/es/node_modules/core-js/internals/ordinary-to-primitive.js +29 -0
- package/dist/ie/es/node_modules/core-js/internals/own-keys.js +30 -0
- package/dist/ie/es/node_modules/core-js/internals/perform.js +17 -0
- package/dist/ie/es/node_modules/core-js/internals/promise-constructor-detection.js +66 -0
- package/dist/ie/es/node_modules/core-js/internals/promise-native-constructor.js +15 -0
- package/dist/ie/es/node_modules/core-js/internals/promise-resolve.js +26 -0
- package/dist/ie/es/node_modules/core-js/internals/promise-statics-incorrect-iteration.js +21 -0
- package/dist/ie/es/node_modules/core-js/internals/queue.js +34 -0
- package/dist/ie/es/node_modules/core-js/internals/require-object-coercible.js +22 -0
- package/dist/ie/es/node_modules/core-js/internals/safe-get-built-in.js +25 -0
- package/dist/ie/es/node_modules/core-js/internals/set-species.js +32 -0
- package/dist/ie/es/node_modules/core-js/internals/set-to-string-tag.js +26 -0
- package/dist/ie/es/node_modules/core-js/internals/shared-key.js +21 -0
- package/dist/ie/es/node_modules/core-js/internals/shared-store.js +28 -0
- package/dist/ie/es/node_modules/core-js/internals/shared.js +17 -0
- package/dist/ie/es/node_modules/core-js/internals/species-constructor.js +29 -0
- package/dist/ie/es/node_modules/core-js/internals/symbol-constructor-detection.js +32 -0
- package/dist/ie/es/node_modules/core-js/internals/task.js +139 -0
- package/dist/ie/es/node_modules/core-js/internals/to-absolute-index.js +24 -0
- package/dist/ie/es/node_modules/core-js/internals/to-indexed-object.js +20 -0
- package/dist/ie/es/node_modules/core-js/internals/to-integer-or-infinity.js +21 -0
- package/dist/ie/es/node_modules/core-js/internals/to-length.js +22 -0
- package/dist/ie/es/node_modules/core-js/internals/to-object.js +21 -0
- package/dist/ie/es/node_modules/core-js/internals/to-primitive.js +42 -0
- package/dist/ie/es/node_modules/core-js/internals/to-property-key.js +22 -0
- package/dist/ie/es/node_modules/core-js/internals/to-string-tag-support.js +20 -0
- package/dist/ie/es/node_modules/core-js/internals/try-to-string.js +19 -0
- package/dist/ie/es/node_modules/core-js/internals/uid.js +21 -0
- package/dist/ie/es/node_modules/core-js/internals/use-symbol-as-uid.js +18 -0
- package/dist/ie/es/node_modules/core-js/internals/v8-prototype-define-bug.js +25 -0
- package/dist/ie/es/node_modules/core-js/internals/validate-arguments-length.js +16 -0
- package/dist/ie/es/node_modules/core-js/internals/weak-map-basic-detection.js +19 -0
- package/dist/ie/es/node_modules/core-js/internals/well-known-symbol.js +35 -0
- package/dist/ie/es/node_modules/core-js/modules/es.array.fill.js +26 -0
- package/dist/ie/es/node_modules/core-js/modules/es.array.from.js +28 -0
- package/dist/ie/es/node_modules/core-js/modules/es.array.includes.js +36 -0
- package/dist/ie/es/node_modules/core-js/modules/es.promise.all.js +56 -0
- package/dist/ie/es/node_modules/core-js/modules/es.promise.catch.js +43 -0
- package/dist/ie/es/node_modules/core-js/modules/es.promise.constructor.js +323 -0
- package/dist/ie/es/node_modules/core-js/modules/es.promise.js +24 -0
- package/dist/ie/es/node_modules/core-js/modules/es.promise.race.js +43 -0
- package/dist/ie/es/node_modules/core-js/modules/es.promise.reject.js +28 -0
- package/dist/ie/es/node_modules/core-js/modules/es.promise.resolve.js +34 -0
- package/dist/ie/es/node_modules/tslib/tslib.es6.js +86 -0
- package/dist/ie/es/node_modules/whatwg-fetch/fetch.js +643 -0
- package/dist/ie/es/src/core/blind.js +82 -0
- package/dist/ie/es/src/core/canvas.js +292 -0
- package/dist/ie/es/src/core/image.js +63 -0
- package/dist/ie/es/src/core/layout/grid.js +36 -0
- package/dist/ie/es/src/core/layout/index.js +25 -0
- package/dist/ie/es/src/core/watermark.js +248 -0
- package/dist/ie/es/src/index.ie.js +9 -0
- package/dist/ie/es/src/utils/index.js +199 -0
- package/dist/ie/es/src/utils/initialization.js +284 -0
- package/dist/ie/es/src/utils/polyfill.js +5 -0
- package/dist/ie/es/src/utils/protection.js +13 -0
- package/dist/ie/es/style.css +1 -0
- package/dist/ie/index.cjs.js +3 -37
- package/dist/ie/index.cjs.js.map +1 -1
- package/dist/ie/index.cjs.min.js +1 -1
- package/dist/ie/index.esm.js +3 -37
- package/dist/ie/index.esm.js.map +1 -1
- package/dist/ie/index.esm.min.js +1 -1
- package/dist/ie/index.iife.js +3 -37
- package/dist/ie/index.iife.js.map +1 -1
- package/dist/ie/index.iife.min.js +1 -1
- package/dist/ie/index.umd.js +3 -37
- package/dist/ie/index.umd.js.map +1 -1
- package/dist/ie/index.umd.min.js +1 -1
- package/dist/index.cjs.js +1 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.esm.js +1 -35
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.iife.js +1 -35
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.umd.js +1 -35
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/types/core/watermark.d.ts +0 -4
- package/dist/types/style/index.d.ts +1 -1
- package/package.json +41 -22
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { isUndefined, getMultiLineData } from './index.js';
|
|
2
|
+
|
|
3
|
+
var initialOptions = {
|
|
4
|
+
width: 300,
|
|
5
|
+
height: 300,
|
|
6
|
+
rotate: 45,
|
|
7
|
+
layout: 'default',
|
|
8
|
+
auxiliaryLine: false,
|
|
9
|
+
translatePlacement: 'middle',
|
|
10
|
+
contentType: 'text',
|
|
11
|
+
content: 'hello watermark-js-plus',
|
|
12
|
+
textType: 'fill',
|
|
13
|
+
imageWidth: 0,
|
|
14
|
+
imageHeight: 0,
|
|
15
|
+
lineHeight: 30,
|
|
16
|
+
zIndex: 2147483647,
|
|
17
|
+
backgroundPosition: '0 0',
|
|
18
|
+
backgroundRepeat: 'repeat',
|
|
19
|
+
fontSize: '20px',
|
|
20
|
+
fontFamily: 'sans-serif',
|
|
21
|
+
fontStyle: '',
|
|
22
|
+
fontVariant: '',
|
|
23
|
+
fontColor: '#000',
|
|
24
|
+
fontWeight: 'normal',
|
|
25
|
+
filter: 'none',
|
|
26
|
+
letterSpacing: '0px',
|
|
27
|
+
wordSpacing: '0px',
|
|
28
|
+
globalAlpha: 0.5,
|
|
29
|
+
mode: 'default',
|
|
30
|
+
mutationObserve: true,
|
|
31
|
+
monitorProtection: false,
|
|
32
|
+
movable: false,
|
|
33
|
+
parent: 'body',
|
|
34
|
+
onSuccess: function () { },
|
|
35
|
+
onBeforeDestroy: function () { },
|
|
36
|
+
onDestroyed: function () { },
|
|
37
|
+
onObserveError: function () { },
|
|
38
|
+
};
|
|
39
|
+
var generateRecommendOptions = function (canvas, options, args) {
|
|
40
|
+
var ctx = canvas.getContext('2d');
|
|
41
|
+
if (ctx === null) {
|
|
42
|
+
throw new Error('get context error');
|
|
43
|
+
}
|
|
44
|
+
ctx.font = "".concat(options.fontStyle, " ").concat(options.fontVariant, " ").concat(options.fontWeight, " ").concat(options.fontSize, " ").concat(options.fontFamily);
|
|
45
|
+
ctx.filter = options.filter;
|
|
46
|
+
ctx.letterSpacing = options.letterSpacing;
|
|
47
|
+
ctx.wordSpacing = options.wordSpacing;
|
|
48
|
+
if (options === null || options === void 0 ? void 0 : options.rotate) {
|
|
49
|
+
options.rotate = (360 - (options.rotate % 360)) * (Math.PI / 180);
|
|
50
|
+
}
|
|
51
|
+
if (isUndefined(args.textRowMaxWidth)) {
|
|
52
|
+
options.textRowMaxWidth = options.width;
|
|
53
|
+
}
|
|
54
|
+
var result = {
|
|
55
|
+
image: {
|
|
56
|
+
rect: {
|
|
57
|
+
width: options.imageWidth,
|
|
58
|
+
height: options.imageHeight,
|
|
59
|
+
},
|
|
60
|
+
position: {
|
|
61
|
+
x: 0,
|
|
62
|
+
y: 0,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
textLine: {
|
|
66
|
+
data: [],
|
|
67
|
+
yOffsetValue: 0,
|
|
68
|
+
},
|
|
69
|
+
advancedStyleParams: {
|
|
70
|
+
linear: {
|
|
71
|
+
x0: 0,
|
|
72
|
+
x1: 0,
|
|
73
|
+
},
|
|
74
|
+
radial: {
|
|
75
|
+
x0: 0,
|
|
76
|
+
y0: 0,
|
|
77
|
+
r0: 0,
|
|
78
|
+
x1: 0,
|
|
79
|
+
y1: 0,
|
|
80
|
+
r1: 0,
|
|
81
|
+
},
|
|
82
|
+
conic: {
|
|
83
|
+
x: 0,
|
|
84
|
+
y: 0,
|
|
85
|
+
startAngle: 0,
|
|
86
|
+
},
|
|
87
|
+
pattern: {},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
switch (options.contentType) {
|
|
91
|
+
case 'text':
|
|
92
|
+
result.textLine.data = [options.content];
|
|
93
|
+
break;
|
|
94
|
+
case 'multi-line-text':
|
|
95
|
+
result.textLine.data = getMultiLineData(ctx, options.content, options.textRowMaxWidth);
|
|
96
|
+
break;
|
|
97
|
+
// case 'image':
|
|
98
|
+
// break
|
|
99
|
+
// case 'rich-text':
|
|
100
|
+
// break
|
|
101
|
+
}
|
|
102
|
+
var translateX = options.width / 2;
|
|
103
|
+
var translateY = options.height / 2;
|
|
104
|
+
var textBaseline = 'middle';
|
|
105
|
+
var textAlign = 'center';
|
|
106
|
+
if (!isUndefined(args === null || args === void 0 ? void 0 : args.translateX) && !isUndefined(args === null || args === void 0 ? void 0 : args.translateY)) {
|
|
107
|
+
translateX = args === null || args === void 0 ? void 0 : args.translateX;
|
|
108
|
+
translateY = args === null || args === void 0 ? void 0 : args.translateY;
|
|
109
|
+
textBaseline = 'top';
|
|
110
|
+
textAlign = 'left';
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// default middle
|
|
114
|
+
// translateX = options.width / 2
|
|
115
|
+
// translateY = options.height / 2
|
|
116
|
+
// TextBaselineType = 'middle'
|
|
117
|
+
// textAlign = 'center'
|
|
118
|
+
result.advancedStyleParams.linear.x0 = -options.width / 2;
|
|
119
|
+
result.advancedStyleParams.linear.x1 = options.width / 2;
|
|
120
|
+
// result.advancedStyleParams.radial.x0 = 0
|
|
121
|
+
// result.advancedStyleParams.radial.y0 = 0
|
|
122
|
+
result.advancedStyleParams.radial.r0 = 0;
|
|
123
|
+
// result.advancedStyleParams.radial.x1 = 0
|
|
124
|
+
// result.advancedStyleParams.radial.y1 = 0
|
|
125
|
+
result.advancedStyleParams.radial.r1 = options.width / 2;
|
|
126
|
+
// result.advancedStyleParams.conic.x = 0
|
|
127
|
+
// result.advancedStyleParams.conic.y = 0
|
|
128
|
+
}
|
|
129
|
+
switch (args.translatePlacement) {
|
|
130
|
+
case 'top':
|
|
131
|
+
translateX = options.width / 2;
|
|
132
|
+
translateY = 0;
|
|
133
|
+
textBaseline = 'top';
|
|
134
|
+
// textAlign = 'center'
|
|
135
|
+
result.advancedStyleParams.linear.x0 = -options.width / 2;
|
|
136
|
+
result.advancedStyleParams.linear.x1 = options.width / 2;
|
|
137
|
+
// result.advancedStyleParams.radial.x0 = 0
|
|
138
|
+
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
139
|
+
// result.advancedStyleParams.radial.r0 = 0
|
|
140
|
+
// result.advancedStyleParams.radial.x1 = 0
|
|
141
|
+
// result.advancedStyleParams.radial.y1 = 0
|
|
142
|
+
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
143
|
+
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
144
|
+
// result.advancedStyleParams.conic.x = 0
|
|
145
|
+
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
146
|
+
break;
|
|
147
|
+
case 'top-start':
|
|
148
|
+
translateX = 0;
|
|
149
|
+
translateY = 0;
|
|
150
|
+
textBaseline = 'top';
|
|
151
|
+
textAlign = 'start';
|
|
152
|
+
result.advancedStyleParams.linear.x0 = 0;
|
|
153
|
+
result.advancedStyleParams.linear.x1 = options.width;
|
|
154
|
+
result.advancedStyleParams.radial.x0 = options.width / 2;
|
|
155
|
+
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
156
|
+
// result.advancedStyleParams.radial.r0 = 0
|
|
157
|
+
result.advancedStyleParams.radial.x1 = options.width / 2;
|
|
158
|
+
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
159
|
+
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
160
|
+
result.advancedStyleParams.conic.x = options.width / 2;
|
|
161
|
+
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
162
|
+
break;
|
|
163
|
+
case 'top-end':
|
|
164
|
+
translateX = options.width;
|
|
165
|
+
translateY = 0;
|
|
166
|
+
textBaseline = 'top';
|
|
167
|
+
textAlign = 'end';
|
|
168
|
+
result.advancedStyleParams.linear.x0 = 0;
|
|
169
|
+
result.advancedStyleParams.linear.x1 = -options.width;
|
|
170
|
+
result.advancedStyleParams.radial.x0 = -options.width / 2;
|
|
171
|
+
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
172
|
+
// result.advancedStyleParams.radial.r0 = 0
|
|
173
|
+
result.advancedStyleParams.radial.x1 = -options.width / 2;
|
|
174
|
+
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
175
|
+
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
176
|
+
result.advancedStyleParams.conic.x = -options.width / 2;
|
|
177
|
+
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
178
|
+
break;
|
|
179
|
+
case 'bottom':
|
|
180
|
+
translateX = options.width / 2;
|
|
181
|
+
translateY = options.height;
|
|
182
|
+
textBaseline = 'bottom';
|
|
183
|
+
// textAlign = 'center'
|
|
184
|
+
result.advancedStyleParams.linear.x0 = -options.width / 2;
|
|
185
|
+
result.advancedStyleParams.linear.x1 = options.width / 2;
|
|
186
|
+
// result.advancedStyleParams.radial.x0 = 0
|
|
187
|
+
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
188
|
+
// result.advancedStyleParams.radial.r0 = 0
|
|
189
|
+
// result.advancedStyleParams.radial.x1 = 0
|
|
190
|
+
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
191
|
+
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
192
|
+
result.advancedStyleParams.conic.x = 0;
|
|
193
|
+
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
194
|
+
break;
|
|
195
|
+
case 'bottom-start':
|
|
196
|
+
translateX = 0;
|
|
197
|
+
translateY = options.height;
|
|
198
|
+
textBaseline = 'bottom';
|
|
199
|
+
textAlign = 'start';
|
|
200
|
+
result.advancedStyleParams.linear.x0 = 0;
|
|
201
|
+
result.advancedStyleParams.linear.x1 = options.width;
|
|
202
|
+
result.advancedStyleParams.radial.x0 = options.width / 2;
|
|
203
|
+
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
204
|
+
// result.advancedStyleParams.radial.r0 = 0
|
|
205
|
+
result.advancedStyleParams.radial.x1 = options.width / 2;
|
|
206
|
+
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
207
|
+
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
208
|
+
result.advancedStyleParams.conic.x = options.width / 2;
|
|
209
|
+
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
210
|
+
break;
|
|
211
|
+
case 'bottom-end':
|
|
212
|
+
translateX = options.width;
|
|
213
|
+
translateY = options.height;
|
|
214
|
+
textBaseline = 'bottom';
|
|
215
|
+
textAlign = 'end';
|
|
216
|
+
result.advancedStyleParams.linear.x0 = 0;
|
|
217
|
+
result.advancedStyleParams.linear.x1 = -options.width;
|
|
218
|
+
result.advancedStyleParams.radial.x0 = -options.width / 2;
|
|
219
|
+
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
220
|
+
// result.advancedStyleParams.radial.r0 = 0
|
|
221
|
+
result.advancedStyleParams.radial.x1 = -options.width / 2;
|
|
222
|
+
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
223
|
+
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
224
|
+
result.advancedStyleParams.conic.x = -options.width / 2;
|
|
225
|
+
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
226
|
+
break;
|
|
227
|
+
case 'left':
|
|
228
|
+
translateX = 0;
|
|
229
|
+
translateY = options.height / 2;
|
|
230
|
+
// TextBaselineType = 'middle'
|
|
231
|
+
textAlign = 'start';
|
|
232
|
+
result.advancedStyleParams.linear.x0 = 0;
|
|
233
|
+
result.advancedStyleParams.linear.x1 = options.width;
|
|
234
|
+
result.advancedStyleParams.radial.x0 = options.width / 2;
|
|
235
|
+
// result.advancedStyleParams.radial.y0 = 0
|
|
236
|
+
// result.advancedStyleParams.radial.r0 = 0
|
|
237
|
+
result.advancedStyleParams.radial.x1 = options.width / 2;
|
|
238
|
+
// result.advancedStyleParams.radial.y1 = 0
|
|
239
|
+
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
240
|
+
result.advancedStyleParams.conic.x = options.width / 2;
|
|
241
|
+
result.advancedStyleParams.conic.y = 0;
|
|
242
|
+
break;
|
|
243
|
+
case 'right':
|
|
244
|
+
translateX = options.width;
|
|
245
|
+
translateY = options.height / 2;
|
|
246
|
+
// TextBaselineType = 'middle'
|
|
247
|
+
textAlign = 'end';
|
|
248
|
+
result.advancedStyleParams.linear.x0 = 0;
|
|
249
|
+
result.advancedStyleParams.linear.x1 = -options.width;
|
|
250
|
+
result.advancedStyleParams.radial.x0 = -options.width / 2;
|
|
251
|
+
// result.advancedStyleParams.radial.y0 = 0
|
|
252
|
+
// result.advancedStyleParams.radial.r0 = 0
|
|
253
|
+
result.advancedStyleParams.radial.x1 = -options.width / 2;
|
|
254
|
+
// result.advancedStyleParams.radial.y1 = 0
|
|
255
|
+
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
256
|
+
result.advancedStyleParams.conic.x = -options.width / 2;
|
|
257
|
+
result.advancedStyleParams.conic.y = 0;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
options.translateX = translateX;
|
|
261
|
+
options.translateY = translateY;
|
|
262
|
+
isUndefined(args === null || args === void 0 ? void 0 : args.textBaseline) && (options.textBaseline = textBaseline);
|
|
263
|
+
isUndefined(args === null || args === void 0 ? void 0 : args.textAlign) && (options.textAlign = textAlign);
|
|
264
|
+
if (['text', 'multi-line-text'].includes(options.contentType)) {
|
|
265
|
+
switch (options.textBaseline) {
|
|
266
|
+
case 'middle':
|
|
267
|
+
result.textLine.yOffsetValue = ((result.textLine.data.length - 1) * options.lineHeight) / 2;
|
|
268
|
+
break;
|
|
269
|
+
case 'bottom':
|
|
270
|
+
case 'alphabetic':
|
|
271
|
+
case 'ideographic':
|
|
272
|
+
result.textLine.yOffsetValue =
|
|
273
|
+
(result.textLine.data.length - 1) * options.lineHeight + (options.lineHeight - parseInt(options.fontSize)) / 2;
|
|
274
|
+
break;
|
|
275
|
+
case 'top':
|
|
276
|
+
case 'hanging':
|
|
277
|
+
result.textLine.yOffsetValue = -options.lineHeight / 2 + parseInt(options.fontSize) / 2;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return result;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export { generateRecommendOptions, initialOptions };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var protection = (function (need) {
|
|
2
|
+
if (typeof window === 'undefined') {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
if (need) {
|
|
6
|
+
Object.defineProperty(window, 'MutationObserver', {
|
|
7
|
+
writable: false,
|
|
8
|
+
configurable: false,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { protection as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@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%}}
|
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.2
|
|
3
3
|
* (c) 2022-2024 Michael Sun
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -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.42.0',
|
|
560
560
|
mode: IS_PURE ? 'pure' : 'global',
|
|
561
561
|
copyright: '© 2014-2025 Denis Pushkarev (zloirock.ru)',
|
|
562
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.
|
|
562
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.42.0/LICENSE',
|
|
563
563
|
source: 'https://github.com/zloirock/core-js'
|
|
564
564
|
});
|
|
565
565
|
return sharedStore.exports;
|
|
@@ -4542,7 +4542,6 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
4542
4542
|
}
|
|
4543
4543
|
ctx.font = "".concat(options.fontStyle, " ").concat(options.fontVariant, " ").concat(options.fontWeight, " ").concat(options.fontSize, " ").concat(options.fontFamily);
|
|
4544
4544
|
ctx.filter = options.filter;
|
|
4545
|
-
// @ts-ignore
|
|
4546
4545
|
ctx.letterSpacing = options.letterSpacing;
|
|
4547
4546
|
ctx.wordSpacing = options.wordSpacing;
|
|
4548
4547
|
if (options === null || options === void 0 ? void 0 : options.rotate) {
|
|
@@ -4790,10 +4789,6 @@ var protection = (function (need) {
|
|
|
4790
4789
|
writable: false,
|
|
4791
4790
|
configurable: false,
|
|
4792
4791
|
});
|
|
4793
|
-
Object.defineProperty(window, 'requestAnimationFrame', {
|
|
4794
|
-
writable: false,
|
|
4795
|
-
configurable: false,
|
|
4796
|
-
});
|
|
4797
4792
|
}
|
|
4798
4793
|
});
|
|
4799
4794
|
|
|
@@ -5256,7 +5251,6 @@ var Watermark = /** @class */ (function () {
|
|
|
5256
5251
|
(_b = (_a = this.options).onBeforeDestroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
5257
5252
|
(_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
5258
5253
|
(_d = this.parentObserve) === null || _d === void 0 ? void 0 : _d.disconnect();
|
|
5259
|
-
this.unbindCheckWatermarkElementEvent();
|
|
5260
5254
|
(_f = (_e = this.watermarkDom) === null || _e === void 0 ? void 0 : _e.parentNode) === null || _f === void 0 ? void 0 : _f.removeChild(this.watermarkDom);
|
|
5261
5255
|
(_h = (_g = this.options).onDestroyed) === null || _h === void 0 ? void 0 : _h.call(_g);
|
|
5262
5256
|
};
|
|
@@ -5316,30 +5310,11 @@ var Watermark = /** @class */ (function () {
|
|
|
5316
5310
|
}
|
|
5317
5311
|
return 'custom';
|
|
5318
5312
|
};
|
|
5319
|
-
Watermark.prototype.checkWatermarkElement = function () {
|
|
5320
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
5321
|
-
return __generator(this, function (_a) {
|
|
5322
|
-
switch (_a.label) {
|
|
5323
|
-
case 0:
|
|
5324
|
-
if (!!this.parentElement.contains(this.watermarkDom)) return [3 /*break*/, 2];
|
|
5325
|
-
this.remove();
|
|
5326
|
-
return [4 /*yield*/, this.create()];
|
|
5327
|
-
case 1:
|
|
5328
|
-
_a.sent();
|
|
5329
|
-
_a.label = 2;
|
|
5330
|
-
case 2:
|
|
5331
|
-
this.bindCheckWatermarkElementEvent();
|
|
5332
|
-
return [2 /*return*/];
|
|
5333
|
-
}
|
|
5334
|
-
});
|
|
5335
|
-
});
|
|
5336
|
-
};
|
|
5337
5313
|
Watermark.prototype.bindMutationObserve = function () {
|
|
5338
5314
|
var _this = this;
|
|
5339
5315
|
if (!this.watermarkDom) {
|
|
5340
5316
|
return;
|
|
5341
5317
|
}
|
|
5342
|
-
this.bindCheckWatermarkElementEvent();
|
|
5343
5318
|
this.observer = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
|
|
5344
5319
|
return __generator(this, function (_a) {
|
|
5345
5320
|
switch (_a.label) {
|
|
@@ -5395,15 +5370,6 @@ var Watermark = /** @class */ (function () {
|
|
|
5395
5370
|
characterData: true, // 节点内容或节点文本的变动。
|
|
5396
5371
|
});
|
|
5397
5372
|
};
|
|
5398
|
-
Watermark.prototype.bindCheckWatermarkElementEvent = function () {
|
|
5399
|
-
this.unbindCheckWatermarkElementEvent();
|
|
5400
|
-
this.checkWatermarkElementRequestID = requestAnimationFrame(this.checkWatermarkElement.bind(this));
|
|
5401
|
-
};
|
|
5402
|
-
Watermark.prototype.unbindCheckWatermarkElementEvent = function () {
|
|
5403
|
-
if (!isUndefined(this.checkWatermarkElementRequestID)) {
|
|
5404
|
-
cancelAnimationFrame(this.checkWatermarkElementRequestID);
|
|
5405
|
-
}
|
|
5406
|
-
};
|
|
5407
5373
|
return Watermark;
|
|
5408
5374
|
}());
|
|
5409
5375
|
|