watermark-js-plus 1.3.39 → 1.4.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/index.cjs.js +22 -24
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.esm.js +22 -24
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.iife.js +22 -24
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.umd.js +22 -24
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/types/docs/components/config.d.ts +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/package.json +7 -7
package/dist/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* watermark-js-plus v1.
|
|
2
|
+
* watermark-js-plus v1.4.0
|
|
3
3
|
* (c) 2022-2023 Michael Sun
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -197,6 +197,7 @@ var initialOptions = {
|
|
|
197
197
|
fontColor: '#000',
|
|
198
198
|
fontWeight: 'normal',
|
|
199
199
|
filter: 'none',
|
|
200
|
+
letterSpacing: '0px',
|
|
200
201
|
globalAlpha: 0.5,
|
|
201
202
|
mode: 'default',
|
|
202
203
|
mutationObserve: true,
|
|
@@ -214,6 +215,8 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
214
215
|
}
|
|
215
216
|
ctx.font = "".concat(options.fontStyle, " ").concat(options.fontVariant, " ").concat(options.fontWeight, " ").concat(options.fontSize, " ").concat(options.fontFamily);
|
|
216
217
|
ctx.filter = options.filter;
|
|
218
|
+
// @ts-ignore
|
|
219
|
+
ctx.letterSpacing = options.letterSpacing;
|
|
217
220
|
if (options === null || options === void 0 ? void 0 : options.rotate) {
|
|
218
221
|
options.rotate = (360 - options.rotate % 360) * (Math.PI / 180);
|
|
219
222
|
}
|
|
@@ -863,7 +866,7 @@ var Watermark = /** @class */ (function () {
|
|
|
863
866
|
this.watermarkDom.__WATERMARK__ = 'watermark';
|
|
864
867
|
this.watermarkDom.__WATERMARK__INSTANCE__ = this;
|
|
865
868
|
parentElementType = this.checkParentElementType();
|
|
866
|
-
this.watermarkDom.style.cssText = "\n z-index:
|
|
869
|
+
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 ");
|
|
867
870
|
backgroundSize = generateBackgroundSize(this.options);
|
|
868
871
|
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 ? 'animation: 200s ease 0s infinite normal none running watermark !important;' : '', "\n ");
|
|
869
872
|
this.watermarkDom.append(watermarkInnerDom);
|
|
@@ -1068,47 +1071,42 @@ var BlindWatermark = /** @class */ (function (_super) {
|
|
|
1068
1071
|
*/
|
|
1069
1072
|
function BlindWatermark(props) {
|
|
1070
1073
|
if (props === void 0) { props = {}; }
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
+
var defaultProps = {
|
|
1075
|
+
globalAlpha: 0.005,
|
|
1076
|
+
mode: 'blind'
|
|
1077
|
+
};
|
|
1078
|
+
return _super.call(this, __assign(__assign({}, props), defaultProps)) || this;
|
|
1074
1079
|
}
|
|
1075
1080
|
/**
|
|
1076
1081
|
* Decode blind watermark.
|
|
1077
1082
|
* @param props - decode options
|
|
1078
1083
|
*/
|
|
1079
1084
|
BlindWatermark.decode = function (props) {
|
|
1080
|
-
var
|
|
1081
|
-
|
|
1082
|
-
fillColor: '#000',
|
|
1083
|
-
compositeOperation: 'color-burn',
|
|
1084
|
-
mode: 'canvas',
|
|
1085
|
-
compositeTimes: 3
|
|
1086
|
-
}, props);
|
|
1087
|
-
if (!options.url) {
|
|
1085
|
+
var _a = props.url, url = _a === void 0 ? '' : _a, _b = props.fillColor, fillColor = _b === void 0 ? '#000' : _b, _c = props.compositeOperation, compositeOperation = _c === void 0 ? 'color-burn' : _c, _d = props.mode, mode = _d === void 0 ? 'canvas' : _d, _e = props.compositeTimes, compositeTimes = _e === void 0 ? 3 : _e, onSuccess = props.onSuccess;
|
|
1086
|
+
if (!url) {
|
|
1088
1087
|
return;
|
|
1089
1088
|
}
|
|
1090
|
-
if (
|
|
1089
|
+
if (mode === 'canvas') {
|
|
1091
1090
|
var img_1 = new Image();
|
|
1092
|
-
img_1.src =
|
|
1093
|
-
img_1.
|
|
1094
|
-
var _a;
|
|
1091
|
+
img_1.src = url;
|
|
1092
|
+
img_1.addEventListener('load', function () {
|
|
1095
1093
|
var width = img_1.width, height = img_1.height;
|
|
1096
1094
|
var canvas = WatermarkCanvas.createCanvas(width, height);
|
|
1097
1095
|
var ctx = canvas.getContext('2d');
|
|
1098
|
-
if (ctx
|
|
1096
|
+
if (!ctx) {
|
|
1099
1097
|
throw new Error('get context error');
|
|
1100
1098
|
}
|
|
1101
1099
|
ctx.drawImage(img_1, 0, 0, width, height);
|
|
1102
|
-
ctx.globalCompositeOperation =
|
|
1103
|
-
ctx.fillStyle =
|
|
1104
|
-
for (var i = 0; i <
|
|
1100
|
+
ctx.globalCompositeOperation = compositeOperation;
|
|
1101
|
+
ctx.fillStyle = fillColor;
|
|
1102
|
+
for (var i = 0; i < compositeTimes; i++) {
|
|
1105
1103
|
ctx.fillRect(0, 0, width, height);
|
|
1106
1104
|
}
|
|
1107
1105
|
var resultImage = convertImage(canvas);
|
|
1108
|
-
if (
|
|
1109
|
-
|
|
1106
|
+
if (isFunction(onSuccess)) {
|
|
1107
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(resultImage);
|
|
1110
1108
|
}
|
|
1111
|
-
};
|
|
1109
|
+
});
|
|
1112
1110
|
}
|
|
1113
1111
|
};
|
|
1114
1112
|
return BlindWatermark;
|