leafer-x-watermark 3.1.0 → 3.2.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.d.mts +4 -1
- package/dist/index.mjs +11 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -17,6 +17,7 @@ declare module '@leafer-ui/interface' {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
type ITileContentParser = (content: string) => object | null;
|
|
20
21
|
interface ITileGap {
|
|
21
22
|
x?: number;
|
|
22
23
|
y?: number;
|
|
@@ -48,6 +49,7 @@ interface IProcessDataType extends IRectData {
|
|
|
48
49
|
}
|
|
49
50
|
interface IWatermark extends IWatermarkAttrData, IUI {
|
|
50
51
|
__: IProcessDataType;
|
|
52
|
+
tileContentParser?: ITileContentParser;
|
|
51
53
|
}
|
|
52
54
|
interface IWatermarkInputData extends IWatermarkAttrData, IRectInputData {
|
|
53
55
|
}
|
|
@@ -91,6 +93,7 @@ declare abstract class ProcessorDataBase extends RectData implements IProcessDat
|
|
|
91
93
|
|
|
92
94
|
declare abstract class WatermarkBase<TConstructorData = IWatermarkInputData> extends Rect<TConstructorData> implements IWatermark {
|
|
93
95
|
__: ProcessorDataBase;
|
|
96
|
+
tileContentParser?: ITileContentParser;
|
|
94
97
|
constructor(data?: TConstructorData);
|
|
95
98
|
syncParentSize(e?: PropertyEvent): void;
|
|
96
99
|
destroy(): void;
|
|
@@ -150,4 +153,4 @@ declare function installStaggerPattern(): void;
|
|
|
150
153
|
declare function processStaggerData(paint: any): INormalizedStagger | null;
|
|
151
154
|
|
|
152
155
|
export { WatermarkAsync, WatermarkSync, WatermarkURL, installStaggerPattern, normalizeStagger, processStaggerData };
|
|
153
|
-
export type { INormalizedStagger, IProcessDataType, IStagger, IStaggerData, IStaggerType, ITileGap, IWatermark, IWatermarkAttrData, IWatermarkInputData };
|
|
156
|
+
export type { INormalizedStagger, IProcessDataType, IStagger, IStaggerData, IStaggerType, ITileContentParser, ITileGap, IWatermark, IWatermarkAttrData, IWatermarkInputData };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { Debug, RectData, isObject, UICreator, Rect, PropertyEvent, dataProcessor, boundsType, registerUI, Plugin, Creator, MatrixHelper, MathHelper, PaintImage, Platform } from '@leafer-ui/core';
|
|
2
2
|
|
|
3
3
|
const console = Debug.get("leafer-x-watermark");
|
|
4
|
+
function defaultTileContentParser(content) {
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(content);
|
|
7
|
+
} catch (e) {
|
|
8
|
+
console.error("Invalid tileContent JSON:", e);
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
4
12
|
class ProcessorDataBase extends RectData {
|
|
5
13
|
_cachedUrl;
|
|
6
14
|
_cachedBounds;
|
|
@@ -104,12 +112,8 @@ class ProcessorDataBase extends RectData {
|
|
|
104
112
|
this.__leaf.fill = void 0;
|
|
105
113
|
return null;
|
|
106
114
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
} catch (e) {
|
|
110
|
-
console.error("Invalid tileContent JSON:", e);
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
115
|
+
const parser = this.__leaf.tileContentParser || defaultTileContentParser;
|
|
116
|
+
return parser(_tileContent);
|
|
113
117
|
}
|
|
114
118
|
updateLeafDimensions(bounds) {
|
|
115
119
|
const leaf = this.__leaf;
|
|
@@ -127,6 +131,7 @@ class ProcessorDataBase extends RectData {
|
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
class WatermarkBase extends Rect {
|
|
134
|
+
tileContentParser;
|
|
130
135
|
constructor(data) {
|
|
131
136
|
super(data);
|
|
132
137
|
this.syncParentSize = this.syncParentSize.bind(this);
|