watermark-js-plus 0.7.0 → 0.8.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/docs/components/config.d.ts +70 -0
- package/dist/{core → src/core}/watermark.d.ts +15 -12
- package/dist/{types → src/types}/index.d.ts +39 -25
- package/dist/{utils → src/utils}/index.d.ts +2 -0
- package/dist/src/utils/initialization.d.ts +49 -0
- package/dist/watermark.esm.js +362 -167
- package/dist/watermark.esm.min.js +1 -0
- package/dist/watermark.umd.js +362 -167
- package/dist/watermark.umd.min.js +1 -1
- package/package.json +20 -19
- /package/dist/{core → src/core}/blind.d.ts +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export declare const defaultConfig: {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
rotate: number;
|
|
5
|
+
contentType: string;
|
|
6
|
+
content: string;
|
|
7
|
+
globalAlpha: number;
|
|
8
|
+
zIndex: number;
|
|
9
|
+
mutationObserve: boolean;
|
|
10
|
+
unique: boolean;
|
|
11
|
+
auxiliaryLine: boolean;
|
|
12
|
+
mode: string;
|
|
13
|
+
parent: string;
|
|
14
|
+
backgroundPosition: string;
|
|
15
|
+
backgroundRepeat: string;
|
|
16
|
+
translatePlacement: string;
|
|
17
|
+
translateX: undefined;
|
|
18
|
+
translateY: undefined;
|
|
19
|
+
textType: string;
|
|
20
|
+
textRowMaxWidth: undefined;
|
|
21
|
+
lineHeight: number;
|
|
22
|
+
fontSize: string;
|
|
23
|
+
fontFamily: string;
|
|
24
|
+
fontStyle: string;
|
|
25
|
+
fontVariant: string;
|
|
26
|
+
fontColor: string;
|
|
27
|
+
fontWeight: string;
|
|
28
|
+
textAlign: undefined;
|
|
29
|
+
textBaseline: undefined;
|
|
30
|
+
filter: string;
|
|
31
|
+
richTextWidth: undefined;
|
|
32
|
+
richTextHeight: undefined;
|
|
33
|
+
image: string;
|
|
34
|
+
imageWidth: undefined;
|
|
35
|
+
imageHeight: undefined;
|
|
36
|
+
shadowStyle: {
|
|
37
|
+
shadowBlur: number;
|
|
38
|
+
shadowColor: string;
|
|
39
|
+
shadowOffsetX: number;
|
|
40
|
+
shadowOffsetY: number;
|
|
41
|
+
};
|
|
42
|
+
advancedStyle: {
|
|
43
|
+
type: string;
|
|
44
|
+
params: {
|
|
45
|
+
linear: {};
|
|
46
|
+
radial: {};
|
|
47
|
+
conic: {};
|
|
48
|
+
pattern: {
|
|
49
|
+
image: string;
|
|
50
|
+
repetition: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
colorStops: {
|
|
54
|
+
offset: number;
|
|
55
|
+
color: string;
|
|
56
|
+
}[];
|
|
57
|
+
};
|
|
58
|
+
extraDrawFunc: string;
|
|
59
|
+
onSuccess: string;
|
|
60
|
+
onBeforeDestroy: string;
|
|
61
|
+
onDestroyed: string;
|
|
62
|
+
};
|
|
63
|
+
export declare const basicOptionKeys: string[];
|
|
64
|
+
export declare const positionOptionKeys: string[];
|
|
65
|
+
export declare const richTextOptionKeys: string[];
|
|
66
|
+
export declare const imageOptionKeys: string[];
|
|
67
|
+
export declare const styleOptionKeys: string[];
|
|
68
|
+
export declare const shadowOptionKeys: string[];
|
|
69
|
+
export declare const advancedStyleOptionKeys: string[];
|
|
70
|
+
export declare const extraOptionKeys: string[];
|
|
@@ -1,44 +1,46 @@
|
|
|
1
|
-
import { WatermarkOptions } from '../types';
|
|
1
|
+
import { ChangeOptionsMode, WatermarkOptions } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Watermark class
|
|
4
4
|
*/
|
|
5
5
|
export default class Watermark {
|
|
6
|
-
private
|
|
6
|
+
private options;
|
|
7
7
|
private parentElement;
|
|
8
8
|
private observer?;
|
|
9
9
|
private parentObserve?;
|
|
10
10
|
private watermarkDom?;
|
|
11
11
|
private props?;
|
|
12
|
+
private canvas;
|
|
13
|
+
private recommendOptions;
|
|
12
14
|
/**
|
|
13
15
|
* Watermark constructor
|
|
14
|
-
* @param
|
|
16
|
+
* @param args - watermark args
|
|
15
17
|
*/
|
|
16
|
-
constructor(
|
|
18
|
+
constructor(args?: Partial<WatermarkOptions>);
|
|
17
19
|
/**
|
|
18
20
|
* Create an HD canvas.
|
|
19
21
|
* @param width - width of canvas
|
|
20
22
|
* @param height - height of canvas
|
|
21
23
|
*/
|
|
22
24
|
static createCanvas(width: number, height: number): HTMLCanvasElement;
|
|
23
|
-
changeOptions(
|
|
24
|
-
changeParentElement(parent: Element | string): void;
|
|
25
|
+
changeOptions(args?: Partial<WatermarkOptions>, mode?: ChangeOptionsMode): void;
|
|
25
26
|
/**
|
|
26
27
|
* Creating a watermark.
|
|
27
28
|
*/
|
|
28
29
|
create(): Promise<void>;
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
+
* Delete this watermark.
|
|
31
32
|
*/
|
|
32
33
|
destroy(): void;
|
|
33
|
-
private
|
|
34
|
+
private initConfigData;
|
|
35
|
+
private changeParentElement;
|
|
34
36
|
private validateUnique;
|
|
35
37
|
private validateContent;
|
|
36
38
|
private draw;
|
|
37
39
|
private setStyle;
|
|
38
|
-
createLinearGradient
|
|
39
|
-
createConicGradient
|
|
40
|
-
createRadialGradient
|
|
41
|
-
createPattern
|
|
40
|
+
private createLinearGradient;
|
|
41
|
+
private createConicGradient;
|
|
42
|
+
private createRadialGradient;
|
|
43
|
+
private createPattern;
|
|
42
44
|
private setText;
|
|
43
45
|
private drawText;
|
|
44
46
|
private drawImage;
|
|
@@ -48,4 +50,5 @@ export default class Watermark {
|
|
|
48
50
|
private getDrawImagePosition;
|
|
49
51
|
private checkParentElementType;
|
|
50
52
|
private bindMutationObserve;
|
|
53
|
+
private clearCanvas;
|
|
51
54
|
}
|
|
@@ -5,6 +5,7 @@ export type CreateWatermarkModeType = 'default' | 'blind';
|
|
|
5
5
|
export type DecodeBlindWatermarkModeType = 'canvas' | 'html' | 'svg';
|
|
6
6
|
export type TranslatePlacementType = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'right' | 'middle';
|
|
7
7
|
export type TextType = 'fill' | 'stroke';
|
|
8
|
+
export type ChangeOptionsMode = 'overwrite' | 'append';
|
|
8
9
|
export interface WatermarkDom extends HTMLDivElement {
|
|
9
10
|
__WATERMARK__?: string;
|
|
10
11
|
__WATERMARK__INSTANCE__?: any;
|
|
@@ -13,22 +14,22 @@ export interface WatermarkOptions {
|
|
|
13
14
|
width: number;
|
|
14
15
|
height: number;
|
|
15
16
|
rotate: number;
|
|
17
|
+
auxiliaryLine: boolean;
|
|
18
|
+
globalAlpha: number;
|
|
19
|
+
zIndex: number;
|
|
20
|
+
mutationObserve: boolean;
|
|
21
|
+
unique: boolean;
|
|
22
|
+
mode: CreateWatermarkModeType;
|
|
23
|
+
parent: Element | string;
|
|
24
|
+
backgroundPosition: string;
|
|
25
|
+
backgroundRepeat: string;
|
|
16
26
|
translatePlacement: TranslatePlacementType;
|
|
17
27
|
translateX?: number;
|
|
18
28
|
translateY?: number;
|
|
19
29
|
contentType: ContentTypeType;
|
|
20
30
|
content: string;
|
|
21
31
|
textType: TextType;
|
|
22
|
-
textRowMaxWidth?: number;
|
|
23
|
-
image?: string;
|
|
24
|
-
imageWidth: number;
|
|
25
|
-
imageHeight: number;
|
|
26
|
-
richTextWidth?: number;
|
|
27
|
-
richTextHeight?: number;
|
|
28
32
|
lineHeight: number;
|
|
29
|
-
zIndex: number;
|
|
30
|
-
backgroundPosition: string;
|
|
31
|
-
backgroundRepeat: string;
|
|
32
33
|
fontSize: string;
|
|
33
34
|
fontFamily: string;
|
|
34
35
|
fontStyle: string;
|
|
@@ -38,14 +39,15 @@ export interface WatermarkOptions {
|
|
|
38
39
|
textAlign?: TextAlignType;
|
|
39
40
|
textBaseline?: TextBaselineType;
|
|
40
41
|
filter: string;
|
|
42
|
+
textRowMaxWidth?: number;
|
|
43
|
+
richTextWidth?: number;
|
|
44
|
+
richTextHeight?: number;
|
|
45
|
+
image?: string;
|
|
46
|
+
imageWidth: number;
|
|
47
|
+
imageHeight: number;
|
|
41
48
|
shadowStyle?: Partial<CanvasShadowStyles>;
|
|
42
|
-
globalAlpha: number;
|
|
43
49
|
advancedStyle?: AdvancedStyleType;
|
|
44
50
|
extraDrawFunc?: Function;
|
|
45
|
-
mode: CreateWatermarkModeType;
|
|
46
|
-
mutationObserve: boolean;
|
|
47
|
-
unique: boolean;
|
|
48
|
-
parent: Element | string;
|
|
49
51
|
onSuccess: Function;
|
|
50
52
|
onBeforeDestroy: Function;
|
|
51
53
|
onDestroyed: Function;
|
|
@@ -71,15 +73,27 @@ export interface AdvancedStyleType {
|
|
|
71
73
|
}[];
|
|
72
74
|
}
|
|
73
75
|
export interface AdvancedStyleParamsType {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
linear: Partial<{
|
|
77
|
+
x0: number;
|
|
78
|
+
y0: number;
|
|
79
|
+
x1: number;
|
|
80
|
+
y1: number;
|
|
81
|
+
}>;
|
|
82
|
+
radial: Partial<{
|
|
83
|
+
x0: number;
|
|
84
|
+
y0: number;
|
|
85
|
+
r0: number;
|
|
86
|
+
x1: number;
|
|
87
|
+
y1: number;
|
|
88
|
+
r1: number;
|
|
89
|
+
}>;
|
|
90
|
+
conic: Partial<{
|
|
91
|
+
startAngle: number;
|
|
92
|
+
x: number;
|
|
93
|
+
y: number;
|
|
94
|
+
}>;
|
|
95
|
+
pattern: Partial<{
|
|
96
|
+
image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas;
|
|
97
|
+
repetition: string;
|
|
98
|
+
}>;
|
|
85
99
|
}
|
|
@@ -9,3 +9,5 @@ export declare const createSVGElement: (tagName: string, attrs?: {
|
|
|
9
9
|
export declare const getMultiLineData: (ctx: CanvasRenderingContext2D, text: string, maxWidth: number) => string[];
|
|
10
10
|
export declare const createCustomContentSVG: (ctx: CanvasRenderingContext2D, options: WatermarkOptions) => CustomContentSVGType;
|
|
11
11
|
export declare const convertSVGToImage: (svg: Element) => string;
|
|
12
|
+
export declare const getValue: (v1: any, v2: any) => any;
|
|
13
|
+
export declare const loadImage: (url: string, width?: number | undefined, height?: number | undefined) => Promise<HTMLImageElement>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AdvancedStyleParamsType, WatermarkOptions } from '../types';
|
|
2
|
+
export declare const initialOptions: {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
rotate: number;
|
|
6
|
+
auxiliaryLine: boolean;
|
|
7
|
+
translatePlacement: string;
|
|
8
|
+
contentType: string;
|
|
9
|
+
content: string;
|
|
10
|
+
textType: string;
|
|
11
|
+
imageWidth: number;
|
|
12
|
+
imageHeight: number;
|
|
13
|
+
lineHeight: number;
|
|
14
|
+
zIndex: number;
|
|
15
|
+
backgroundPosition: string;
|
|
16
|
+
backgroundRepeat: string;
|
|
17
|
+
fontSize: string;
|
|
18
|
+
fontFamily: string;
|
|
19
|
+
fontStyle: string;
|
|
20
|
+
fontVariant: string;
|
|
21
|
+
fontColor: string;
|
|
22
|
+
fontWeight: string;
|
|
23
|
+
filter: string;
|
|
24
|
+
globalAlpha: number;
|
|
25
|
+
mode: string;
|
|
26
|
+
mutationObserve: boolean;
|
|
27
|
+
unique: boolean;
|
|
28
|
+
parent: string;
|
|
29
|
+
onSuccess: () => void;
|
|
30
|
+
onBeforeDestroy: () => void;
|
|
31
|
+
onDestroyed: () => void;
|
|
32
|
+
};
|
|
33
|
+
export declare const generateRecommendOptions: (canvas: HTMLCanvasElement, options: WatermarkOptions, args: Partial<WatermarkOptions>) => {
|
|
34
|
+
image: {
|
|
35
|
+
rect: {
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
position: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
textLine: {
|
|
45
|
+
data: string[];
|
|
46
|
+
yOffsetValue: number;
|
|
47
|
+
};
|
|
48
|
+
advancedStyleParams: AdvancedStyleParamsType;
|
|
49
|
+
};
|