@univerjs/watermark 0.16.1 → 0.17.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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +70 -69
- package/lib/index.js +70 -69
- package/lib/types/controllers/watermark.render.controller.spec.d.ts +16 -0
- package/lib/types/facade/f-univer.spec.d.ts +16 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/plugin.d.ts +3 -1
- package/lib/types/services/watermark.service.spec.d.ts +16 -0
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
- /package/lib/types/{controllers/config.schema.d.ts → config/config.d.ts} +0 -0
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var I=Object.defineProperty;var d=(a,e,r)=>e in a?I(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r;var _=(a,e,r)=>d(a,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@univerjs/core"),o=require("@univerjs/engine-render"),p=require("rxjs"),W=["image/png","image/jpeg","image/jpg","image/bmp"],u={content:"",fontSize:16,color:"rgb(0,0,0)",bold:!1,italic:!1,direction:"ltr",x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},R={url:"",width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},E={name:!0,email:!1,phone:!1,uid:!1,fontSize:16,color:"rgb(0,0,0)",bold:!1,italic:!1,direction:"ltr",x:60,y:60,repeat:!0,spacingX:200,spacingY:100,rotate:-30,opacity:.15},k="@univerjs/watermark",A="0.17.0",f={name:k,version:A},h="watermark.config",v={};var y=Object.getOwnPropertyDescriptor,T=(a,e,r,t)=>{for(var i=t>1?void 0:t?y(e,r):e,s=a.length-1,c;s>=0;s--)(c=a[s])&&(i=c(i)||i);return i},C=(a,e)=>(r,t)=>e(r,t,a);exports.WatermarkService=class extends n.Disposable{constructor(r){super();_(this,"_updateConfig$",new p.Subject);_(this,"updateConfig$",this._updateConfig$.asObservable());_(this,"_refresh$",new p.Subject);_(this,"refresh$",this._refresh$.asObservable());this._localStorageService=r}async getWatermarkConfig(){return await this._localStorageService.getItem(o.UNIVER_WATERMARK_STORAGE_KEY)}updateWatermarkConfig(r){this._localStorageService.setItem(o.UNIVER_WATERMARK_STORAGE_KEY,r),this._updateConfig$.next(r)}deleteWatermarkConfig(){this._localStorageService.removeItem(o.UNIVER_WATERMARK_STORAGE_KEY),this._updateConfig$.next(null)}refresh(){this._refresh$.next(Math.random())}dispose(){this._refresh$.complete(),this._updateConfig$.complete()}};exports.WatermarkService=T([C(0,n.Inject(n.ILocalStorageService))],exports.WatermarkService);var M=Object.getOwnPropertyDescriptor,U=(a,e,r,t)=>{for(var i=t>1?void 0:t?M(e,r):e,s=a.length-1,c;s>=0;s--)(c=a[s])&&(i=c(i)||i);return i},l=(a,e)=>(r,t)=>e(r,t,a);let S=class extends n.RxDisposable{constructor(e,r,t,i){super();_(this,"_watermarkLayer");this._context=e,this._watermarkService=r,this._localStorageService=t,this._userManagerService=i,this._watermarkLayer=new o.WatermarkLayer(e.scene,[],o.UNIVER_WATERMARK_LAYER_INDEX),this._initAddRender(),this._initWatermarkUpdate(),this._initWatermarkConfig()}_initAddRender(){const{scene:e}=this._context;e.addLayer(this._watermarkLayer)}async _initWatermarkConfig(){var r;const e=await this._localStorageService.getItem(o.UNIVER_WATERMARK_STORAGE_KEY);e&&(this._watermarkService.updateWatermarkConfig(e),(r=this._context.mainComponent)==null||r.makeDirty())}_initWatermarkUpdate(){this.disposeWithMe(this._watermarkService.updateConfig$.subscribe(e=>{var r,t;if(!e){this._watermarkLayer.updateConfig(),(r=this._context.mainComponent)==null||r.makeDirty();return}e.type===o.IWatermarkTypeEnum.UserInfo?this._watermarkLayer.updateConfig(e,this._userManagerService.getCurrentUser()):this._watermarkLayer.updateConfig(e),(t=this._context.mainComponent)==null||t.makeDirty()}))}};S=U([l(1,n.Inject(exports.WatermarkService)),l(2,n.Inject(n.ILocalStorageService)),l(3,n.Inject(n.UserManagerService))],S);var O=Object.getOwnPropertyDescriptor,w=(a,e,r,t)=>{for(var i=t>1?void 0:t?O(e,r):e,s=a.length-1,c;s>=0;s--)(c=a[s])&&(i=c(i)||i);return i},m=(a,e)=>(r,t)=>e(r,t,a),g;exports.UniverWatermarkPlugin=(g=class extends n.Plugin{constructor(e=v,r,t,i,s){super(),this._config=e,this._injector=r,this._configService=t,this._renderManagerSrv=i,this._localStorageService=s;const{...c}=n.merge({},v,this._config);this._configService.setConfig(h,c),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){const e=this._configService.getConfig(h);if(!e)return;const{userWatermarkSettings:r,textWatermarkSettings:t,imageWatermarkSettings:i}=e;if(r)this._localStorageService.setItem(o.UNIVER_WATERMARK_STORAGE_KEY,{type:o.IWatermarkTypeEnum.UserInfo,config:{userInfo:n.merge({},E,r)}});else if(t)this._localStorageService.setItem(o.UNIVER_WATERMARK_STORAGE_KEY,{type:o.IWatermarkTypeEnum.Text,config:{text:n.merge({},u,t)}});else if(i)this._localStorageService.setItem(o.UNIVER_WATERMARK_STORAGE_KEY,{type:o.IWatermarkTypeEnum.Image,config:{image:n.merge({},R,i)}});else{const s=await this._localStorageService.getItem(o.UNIVER_WATERMARK_STORAGE_KEY);(s==null?void 0:s.type)===o.IWatermarkTypeEnum.UserInfo&&this._localStorageService.removeItem(o.UNIVER_WATERMARK_STORAGE_KEY)}}_initDependencies(){[[exports.WatermarkService]].forEach(e=>{this._injector.add(e)})}onRendered(){this._injector.get(exports.WatermarkService),this._initRenderDependencies()}_initRenderDependencies(){[[S]].forEach(e=>{this._renderManagerSrv.registerRenderModule(n.UniverInstanceType.UNIVER_SHEET,e),this._renderManagerSrv.registerRenderModule(n.UniverInstanceType.UNIVER_DOC,e)})}},_(g,"pluginName","UNIVER_WATERMARK_PLUGIN"),_(g,"packageName",f.name),_(g,"version",f.version),g);exports.UniverWatermarkPlugin=w([m(1,n.Inject(n.Injector)),m(2,n.IConfigService),m(3,o.IRenderManagerService),m(4,n.Inject(n.ILocalStorageService))],exports.UniverWatermarkPlugin);exports.WATERMARK_IMAGE_ALLOW_IMAGE_LIST=W;exports.WatermarkImageBaseConfig=R;exports.WatermarkTextBaseConfig=u;exports.WatermarkUserInfoBaseConfig=E;
|
package/lib/es/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Inject as g, ILocalStorageService as
|
|
5
|
-
import { UNIVER_WATERMARK_STORAGE_KEY as
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var W = (t, e, r) => e in t ? R(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var s = (t, e, r) => W(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { Inject as g, ILocalStorageService as d, Disposable as w, UserManagerService as E, RxDisposable as x, Injector as A, IConfigService as M, Plugin as $, merge as p, UniverInstanceType as S } from "@univerjs/core";
|
|
5
|
+
import { UNIVER_WATERMARK_STORAGE_KEY as o, WatermarkLayer as b, UNIVER_WATERMARK_LAYER_INDEX as D, IWatermarkTypeEnum as m, IRenderManagerService as U } from "@univerjs/engine-render";
|
|
6
6
|
import { Subject as u } from "rxjs";
|
|
7
|
-
const
|
|
7
|
+
const J = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], L = {
|
|
8
8
|
content: "",
|
|
9
9
|
fontSize: 16,
|
|
10
10
|
color: "rgb(0,0,0)",
|
|
@@ -18,7 +18,7 @@ const H = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], D = {
|
|
|
18
18
|
spacingY: 100,
|
|
19
19
|
rotate: 0,
|
|
20
20
|
opacity: 0.15
|
|
21
|
-
},
|
|
21
|
+
}, O = {
|
|
22
22
|
url: "",
|
|
23
23
|
width: 100,
|
|
24
24
|
height: 100,
|
|
@@ -31,7 +31,7 @@ const H = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], D = {
|
|
|
31
31
|
spacingY: 100,
|
|
32
32
|
rotate: 0,
|
|
33
33
|
opacity: 0.15
|
|
34
|
-
},
|
|
34
|
+
}, j = {
|
|
35
35
|
name: !0,
|
|
36
36
|
email: !1,
|
|
37
37
|
phone: !1,
|
|
@@ -48,29 +48,32 @@ const H = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], D = {
|
|
|
48
48
|
spacingY: 100,
|
|
49
49
|
rotate: -30,
|
|
50
50
|
opacity: 0.15
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
}, P = "@univerjs/watermark", T = "0.17.0", I = {
|
|
52
|
+
name: P,
|
|
53
|
+
version: T
|
|
54
|
+
}, k = "watermark.config", C = {};
|
|
55
|
+
var N = Object.getOwnPropertyDescriptor, K = (t, e, r, a) => {
|
|
56
|
+
for (var i = a > 1 ? void 0 : a ? N(e, r) : e, n = t.length - 1, c; n >= 0; n--)
|
|
57
|
+
(c = t[n]) && (i = c(i) || i);
|
|
55
58
|
return i;
|
|
56
|
-
},
|
|
57
|
-
let l = class extends
|
|
59
|
+
}, G = (t, e) => (r, a) => e(r, a, t);
|
|
60
|
+
let l = class extends w {
|
|
58
61
|
constructor(e) {
|
|
59
62
|
super();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
s(this, "_updateConfig$", new u());
|
|
64
|
+
s(this, "updateConfig$", this._updateConfig$.asObservable());
|
|
65
|
+
s(this, "_refresh$", new u());
|
|
66
|
+
s(this, "refresh$", this._refresh$.asObservable());
|
|
64
67
|
this._localStorageService = e;
|
|
65
68
|
}
|
|
66
69
|
async getWatermarkConfig() {
|
|
67
|
-
return await this._localStorageService.getItem(
|
|
70
|
+
return await this._localStorageService.getItem(o);
|
|
68
71
|
}
|
|
69
72
|
updateWatermarkConfig(e) {
|
|
70
|
-
this._localStorageService.setItem(
|
|
73
|
+
this._localStorageService.setItem(o, e), this._updateConfig$.next(e);
|
|
71
74
|
}
|
|
72
75
|
deleteWatermarkConfig() {
|
|
73
|
-
this._localStorageService.removeItem(
|
|
76
|
+
this._localStorageService.removeItem(o), this._updateConfig$.next(null);
|
|
74
77
|
}
|
|
75
78
|
refresh() {
|
|
76
79
|
this._refresh$.next(Math.random());
|
|
@@ -79,19 +82,19 @@ let l = class extends W {
|
|
|
79
82
|
this._refresh$.complete(), this._updateConfig$.complete();
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
|
-
l =
|
|
83
|
-
|
|
85
|
+
l = K([
|
|
86
|
+
G(0, g(d))
|
|
84
87
|
], l);
|
|
85
|
-
var
|
|
86
|
-
for (var i = a > 1 ? void 0 : a ?
|
|
87
|
-
(
|
|
88
|
+
var Y = Object.getOwnPropertyDescriptor, V = (t, e, r, a) => {
|
|
89
|
+
for (var i = a > 1 ? void 0 : a ? Y(e, r) : e, n = t.length - 1, c; n >= 0; n--)
|
|
90
|
+
(c = t[n]) && (i = c(i) || i);
|
|
88
91
|
return i;
|
|
89
92
|
}, h = (t, e) => (r, a) => e(r, a, t);
|
|
90
|
-
let
|
|
93
|
+
let v = class extends x {
|
|
91
94
|
constructor(e, r, a, i) {
|
|
92
95
|
super();
|
|
93
|
-
|
|
94
|
-
this._context = e, this._watermarkService = r, this._localStorageService = a, this._userManagerService = i, this._watermarkLayer = new
|
|
96
|
+
s(this, "_watermarkLayer");
|
|
97
|
+
this._context = e, this._watermarkService = r, this._localStorageService = a, this._userManagerService = i, this._watermarkLayer = new b(e.scene, [], D), this._initAddRender(), this._initWatermarkUpdate(), this._initWatermarkConfig();
|
|
95
98
|
}
|
|
96
99
|
_initAddRender() {
|
|
97
100
|
const { scene: e } = this._context;
|
|
@@ -99,7 +102,7 @@ let d = class extends E {
|
|
|
99
102
|
}
|
|
100
103
|
async _initWatermarkConfig() {
|
|
101
104
|
var r;
|
|
102
|
-
const e = await this._localStorageService.getItem(
|
|
105
|
+
const e = await this._localStorageService.getItem(o);
|
|
103
106
|
e && (this._watermarkService.updateWatermarkConfig(e), (r = this._context.mainComponent) == null || r.makeDirty());
|
|
104
107
|
}
|
|
105
108
|
_initWatermarkUpdate() {
|
|
@@ -110,62 +113,60 @@ let d = class extends E {
|
|
|
110
113
|
this._watermarkLayer.updateConfig(), (r = this._context.mainComponent) == null || r.makeDirty();
|
|
111
114
|
return;
|
|
112
115
|
}
|
|
113
|
-
e.type ===
|
|
116
|
+
e.type === m.UserInfo ? this._watermarkLayer.updateConfig(e, this._userManagerService.getCurrentUser()) : this._watermarkLayer.updateConfig(e), (a = this._context.mainComponent) == null || a.makeDirty();
|
|
114
117
|
})
|
|
115
118
|
);
|
|
116
119
|
}
|
|
117
120
|
};
|
|
118
|
-
|
|
121
|
+
v = V([
|
|
119
122
|
h(1, g(l)),
|
|
120
|
-
h(2, g(
|
|
121
|
-
h(3, g(
|
|
122
|
-
],
|
|
123
|
-
var
|
|
124
|
-
for (var i = a > 1 ? void 0 : a ?
|
|
125
|
-
(
|
|
123
|
+
h(2, g(d)),
|
|
124
|
+
h(3, g(E))
|
|
125
|
+
], v);
|
|
126
|
+
var X = Object.getOwnPropertyDescriptor, B = (t, e, r, a) => {
|
|
127
|
+
for (var i = a > 1 ? void 0 : a ? X(e, r) : e, n = t.length - 1, c; n >= 0; n--)
|
|
128
|
+
(c = t[n]) && (i = c(i) || i);
|
|
126
129
|
return i;
|
|
127
|
-
}, f = (t, e) => (r, a) => e(r, a, t);
|
|
128
|
-
|
|
129
|
-
var p;
|
|
130
|
-
let k = (p = class extends M {
|
|
130
|
+
}, f = (t, e) => (r, a) => e(r, a, t), _;
|
|
131
|
+
let y = (_ = class extends $ {
|
|
131
132
|
constructor(t = C, e, r, a, i) {
|
|
132
133
|
super(), this._config = t, this._injector = e, this._configService = r, this._renderManagerSrv = a, this._localStorageService = i;
|
|
133
|
-
const { ...n } =
|
|
134
|
+
const { ...n } = p(
|
|
134
135
|
{},
|
|
135
136
|
C,
|
|
136
137
|
this._config
|
|
137
138
|
);
|
|
138
|
-
this._configService.setConfig(
|
|
139
|
+
this._configService.setConfig(k, n), this._initWatermarkStorage(), this._initDependencies();
|
|
139
140
|
}
|
|
140
141
|
async _initWatermarkStorage() {
|
|
141
|
-
const t = this._configService.getConfig(
|
|
142
|
+
const t = this._configService.getConfig(k);
|
|
142
143
|
if (!t)
|
|
143
144
|
return;
|
|
144
145
|
const { userWatermarkSettings: e, textWatermarkSettings: r, imageWatermarkSettings: a } = t;
|
|
145
146
|
if (e)
|
|
146
|
-
this._localStorageService.setItem(
|
|
147
|
-
type:
|
|
147
|
+
this._localStorageService.setItem(o, {
|
|
148
|
+
type: m.UserInfo,
|
|
148
149
|
config: {
|
|
149
|
-
userInfo:
|
|
150
|
+
userInfo: p({}, j, e)
|
|
150
151
|
}
|
|
151
152
|
});
|
|
152
153
|
else if (r)
|
|
153
|
-
this._localStorageService.setItem(
|
|
154
|
-
type:
|
|
154
|
+
this._localStorageService.setItem(o, {
|
|
155
|
+
type: m.Text,
|
|
155
156
|
config: {
|
|
156
|
-
text:
|
|
157
|
+
text: p({}, L, r)
|
|
157
158
|
}
|
|
158
159
|
});
|
|
159
160
|
else if (a)
|
|
160
|
-
this._localStorageService.setItem(
|
|
161
|
-
type:
|
|
161
|
+
this._localStorageService.setItem(o, {
|
|
162
|
+
type: m.Image,
|
|
162
163
|
config: {
|
|
163
|
-
image:
|
|
164
|
+
image: p({}, O, a)
|
|
164
165
|
}
|
|
165
166
|
});
|
|
166
167
|
else {
|
|
167
|
-
const i = await this._localStorageService.getItem(
|
|
168
|
-
(i == null ? void 0 : i.type) ===
|
|
168
|
+
const i = await this._localStorageService.getItem(o);
|
|
169
|
+
(i == null ? void 0 : i.type) === m.UserInfo && this._localStorageService.removeItem(o);
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
_initDependencies() {
|
|
@@ -178,23 +179,23 @@ let k = (p = class extends M {
|
|
|
178
179
|
}
|
|
179
180
|
_initRenderDependencies() {
|
|
180
181
|
[
|
|
181
|
-
[
|
|
182
|
+
[v]
|
|
182
183
|
].forEach((t) => {
|
|
183
184
|
this._renderManagerSrv.registerRenderModule(S.UNIVER_SHEET, t), this._renderManagerSrv.registerRenderModule(S.UNIVER_DOC, t);
|
|
184
185
|
});
|
|
185
186
|
}
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
f(1, g(
|
|
189
|
-
f(2,
|
|
190
|
-
f(3,
|
|
191
|
-
f(4, g(
|
|
192
|
-
],
|
|
187
|
+
}, s(_, "pluginName", "UNIVER_WATERMARK_PLUGIN"), s(_, "packageName", I.name), s(_, "version", I.version), _);
|
|
188
|
+
y = B([
|
|
189
|
+
f(1, g(A)),
|
|
190
|
+
f(2, M),
|
|
191
|
+
f(3, U),
|
|
192
|
+
f(4, g(d))
|
|
193
|
+
], y);
|
|
193
194
|
export {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
y as UniverWatermarkPlugin,
|
|
196
|
+
J as WATERMARK_IMAGE_ALLOW_IMAGE_LIST,
|
|
197
|
+
O as WatermarkImageBaseConfig,
|
|
197
198
|
l as WatermarkService,
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
L as WatermarkTextBaseConfig,
|
|
200
|
+
j as WatermarkUserInfoBaseConfig
|
|
200
201
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Inject as g, ILocalStorageService as
|
|
5
|
-
import { UNIVER_WATERMARK_STORAGE_KEY as
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var W = (t, e, r) => e in t ? R(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var s = (t, e, r) => W(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { Inject as g, ILocalStorageService as d, Disposable as w, UserManagerService as E, RxDisposable as x, Injector as A, IConfigService as M, Plugin as $, merge as p, UniverInstanceType as S } from "@univerjs/core";
|
|
5
|
+
import { UNIVER_WATERMARK_STORAGE_KEY as o, WatermarkLayer as b, UNIVER_WATERMARK_LAYER_INDEX as D, IWatermarkTypeEnum as m, IRenderManagerService as U } from "@univerjs/engine-render";
|
|
6
6
|
import { Subject as u } from "rxjs";
|
|
7
|
-
const
|
|
7
|
+
const J = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], L = {
|
|
8
8
|
content: "",
|
|
9
9
|
fontSize: 16,
|
|
10
10
|
color: "rgb(0,0,0)",
|
|
@@ -18,7 +18,7 @@ const H = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], D = {
|
|
|
18
18
|
spacingY: 100,
|
|
19
19
|
rotate: 0,
|
|
20
20
|
opacity: 0.15
|
|
21
|
-
},
|
|
21
|
+
}, O = {
|
|
22
22
|
url: "",
|
|
23
23
|
width: 100,
|
|
24
24
|
height: 100,
|
|
@@ -31,7 +31,7 @@ const H = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], D = {
|
|
|
31
31
|
spacingY: 100,
|
|
32
32
|
rotate: 0,
|
|
33
33
|
opacity: 0.15
|
|
34
|
-
},
|
|
34
|
+
}, j = {
|
|
35
35
|
name: !0,
|
|
36
36
|
email: !1,
|
|
37
37
|
phone: !1,
|
|
@@ -48,29 +48,32 @@ const H = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], D = {
|
|
|
48
48
|
spacingY: 100,
|
|
49
49
|
rotate: -30,
|
|
50
50
|
opacity: 0.15
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
}, P = "@univerjs/watermark", T = "0.17.0", I = {
|
|
52
|
+
name: P,
|
|
53
|
+
version: T
|
|
54
|
+
}, k = "watermark.config", C = {};
|
|
55
|
+
var N = Object.getOwnPropertyDescriptor, K = (t, e, r, a) => {
|
|
56
|
+
for (var i = a > 1 ? void 0 : a ? N(e, r) : e, n = t.length - 1, c; n >= 0; n--)
|
|
57
|
+
(c = t[n]) && (i = c(i) || i);
|
|
55
58
|
return i;
|
|
56
|
-
},
|
|
57
|
-
let l = class extends
|
|
59
|
+
}, G = (t, e) => (r, a) => e(r, a, t);
|
|
60
|
+
let l = class extends w {
|
|
58
61
|
constructor(e) {
|
|
59
62
|
super();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
s(this, "_updateConfig$", new u());
|
|
64
|
+
s(this, "updateConfig$", this._updateConfig$.asObservable());
|
|
65
|
+
s(this, "_refresh$", new u());
|
|
66
|
+
s(this, "refresh$", this._refresh$.asObservable());
|
|
64
67
|
this._localStorageService = e;
|
|
65
68
|
}
|
|
66
69
|
async getWatermarkConfig() {
|
|
67
|
-
return await this._localStorageService.getItem(
|
|
70
|
+
return await this._localStorageService.getItem(o);
|
|
68
71
|
}
|
|
69
72
|
updateWatermarkConfig(e) {
|
|
70
|
-
this._localStorageService.setItem(
|
|
73
|
+
this._localStorageService.setItem(o, e), this._updateConfig$.next(e);
|
|
71
74
|
}
|
|
72
75
|
deleteWatermarkConfig() {
|
|
73
|
-
this._localStorageService.removeItem(
|
|
76
|
+
this._localStorageService.removeItem(o), this._updateConfig$.next(null);
|
|
74
77
|
}
|
|
75
78
|
refresh() {
|
|
76
79
|
this._refresh$.next(Math.random());
|
|
@@ -79,19 +82,19 @@ let l = class extends W {
|
|
|
79
82
|
this._refresh$.complete(), this._updateConfig$.complete();
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
|
-
l =
|
|
83
|
-
|
|
85
|
+
l = K([
|
|
86
|
+
G(0, g(d))
|
|
84
87
|
], l);
|
|
85
|
-
var
|
|
86
|
-
for (var i = a > 1 ? void 0 : a ?
|
|
87
|
-
(
|
|
88
|
+
var Y = Object.getOwnPropertyDescriptor, V = (t, e, r, a) => {
|
|
89
|
+
for (var i = a > 1 ? void 0 : a ? Y(e, r) : e, n = t.length - 1, c; n >= 0; n--)
|
|
90
|
+
(c = t[n]) && (i = c(i) || i);
|
|
88
91
|
return i;
|
|
89
92
|
}, h = (t, e) => (r, a) => e(r, a, t);
|
|
90
|
-
let
|
|
93
|
+
let v = class extends x {
|
|
91
94
|
constructor(e, r, a, i) {
|
|
92
95
|
super();
|
|
93
|
-
|
|
94
|
-
this._context = e, this._watermarkService = r, this._localStorageService = a, this._userManagerService = i, this._watermarkLayer = new
|
|
96
|
+
s(this, "_watermarkLayer");
|
|
97
|
+
this._context = e, this._watermarkService = r, this._localStorageService = a, this._userManagerService = i, this._watermarkLayer = new b(e.scene, [], D), this._initAddRender(), this._initWatermarkUpdate(), this._initWatermarkConfig();
|
|
95
98
|
}
|
|
96
99
|
_initAddRender() {
|
|
97
100
|
const { scene: e } = this._context;
|
|
@@ -99,7 +102,7 @@ let d = class extends E {
|
|
|
99
102
|
}
|
|
100
103
|
async _initWatermarkConfig() {
|
|
101
104
|
var r;
|
|
102
|
-
const e = await this._localStorageService.getItem(
|
|
105
|
+
const e = await this._localStorageService.getItem(o);
|
|
103
106
|
e && (this._watermarkService.updateWatermarkConfig(e), (r = this._context.mainComponent) == null || r.makeDirty());
|
|
104
107
|
}
|
|
105
108
|
_initWatermarkUpdate() {
|
|
@@ -110,62 +113,60 @@ let d = class extends E {
|
|
|
110
113
|
this._watermarkLayer.updateConfig(), (r = this._context.mainComponent) == null || r.makeDirty();
|
|
111
114
|
return;
|
|
112
115
|
}
|
|
113
|
-
e.type ===
|
|
116
|
+
e.type === m.UserInfo ? this._watermarkLayer.updateConfig(e, this._userManagerService.getCurrentUser()) : this._watermarkLayer.updateConfig(e), (a = this._context.mainComponent) == null || a.makeDirty();
|
|
114
117
|
})
|
|
115
118
|
);
|
|
116
119
|
}
|
|
117
120
|
};
|
|
118
|
-
|
|
121
|
+
v = V([
|
|
119
122
|
h(1, g(l)),
|
|
120
|
-
h(2, g(
|
|
121
|
-
h(3, g(
|
|
122
|
-
],
|
|
123
|
-
var
|
|
124
|
-
for (var i = a > 1 ? void 0 : a ?
|
|
125
|
-
(
|
|
123
|
+
h(2, g(d)),
|
|
124
|
+
h(3, g(E))
|
|
125
|
+
], v);
|
|
126
|
+
var X = Object.getOwnPropertyDescriptor, B = (t, e, r, a) => {
|
|
127
|
+
for (var i = a > 1 ? void 0 : a ? X(e, r) : e, n = t.length - 1, c; n >= 0; n--)
|
|
128
|
+
(c = t[n]) && (i = c(i) || i);
|
|
126
129
|
return i;
|
|
127
|
-
}, f = (t, e) => (r, a) => e(r, a, t);
|
|
128
|
-
|
|
129
|
-
var p;
|
|
130
|
-
let k = (p = class extends M {
|
|
130
|
+
}, f = (t, e) => (r, a) => e(r, a, t), _;
|
|
131
|
+
let y = (_ = class extends $ {
|
|
131
132
|
constructor(t = C, e, r, a, i) {
|
|
132
133
|
super(), this._config = t, this._injector = e, this._configService = r, this._renderManagerSrv = a, this._localStorageService = i;
|
|
133
|
-
const { ...n } =
|
|
134
|
+
const { ...n } = p(
|
|
134
135
|
{},
|
|
135
136
|
C,
|
|
136
137
|
this._config
|
|
137
138
|
);
|
|
138
|
-
this._configService.setConfig(
|
|
139
|
+
this._configService.setConfig(k, n), this._initWatermarkStorage(), this._initDependencies();
|
|
139
140
|
}
|
|
140
141
|
async _initWatermarkStorage() {
|
|
141
|
-
const t = this._configService.getConfig(
|
|
142
|
+
const t = this._configService.getConfig(k);
|
|
142
143
|
if (!t)
|
|
143
144
|
return;
|
|
144
145
|
const { userWatermarkSettings: e, textWatermarkSettings: r, imageWatermarkSettings: a } = t;
|
|
145
146
|
if (e)
|
|
146
|
-
this._localStorageService.setItem(
|
|
147
|
-
type:
|
|
147
|
+
this._localStorageService.setItem(o, {
|
|
148
|
+
type: m.UserInfo,
|
|
148
149
|
config: {
|
|
149
|
-
userInfo:
|
|
150
|
+
userInfo: p({}, j, e)
|
|
150
151
|
}
|
|
151
152
|
});
|
|
152
153
|
else if (r)
|
|
153
|
-
this._localStorageService.setItem(
|
|
154
|
-
type:
|
|
154
|
+
this._localStorageService.setItem(o, {
|
|
155
|
+
type: m.Text,
|
|
155
156
|
config: {
|
|
156
|
-
text:
|
|
157
|
+
text: p({}, L, r)
|
|
157
158
|
}
|
|
158
159
|
});
|
|
159
160
|
else if (a)
|
|
160
|
-
this._localStorageService.setItem(
|
|
161
|
-
type:
|
|
161
|
+
this._localStorageService.setItem(o, {
|
|
162
|
+
type: m.Image,
|
|
162
163
|
config: {
|
|
163
|
-
image:
|
|
164
|
+
image: p({}, O, a)
|
|
164
165
|
}
|
|
165
166
|
});
|
|
166
167
|
else {
|
|
167
|
-
const i = await this._localStorageService.getItem(
|
|
168
|
-
(i == null ? void 0 : i.type) ===
|
|
168
|
+
const i = await this._localStorageService.getItem(o);
|
|
169
|
+
(i == null ? void 0 : i.type) === m.UserInfo && this._localStorageService.removeItem(o);
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
_initDependencies() {
|
|
@@ -178,23 +179,23 @@ let k = (p = class extends M {
|
|
|
178
179
|
}
|
|
179
180
|
_initRenderDependencies() {
|
|
180
181
|
[
|
|
181
|
-
[
|
|
182
|
+
[v]
|
|
182
183
|
].forEach((t) => {
|
|
183
184
|
this._renderManagerSrv.registerRenderModule(S.UNIVER_SHEET, t), this._renderManagerSrv.registerRenderModule(S.UNIVER_DOC, t);
|
|
184
185
|
});
|
|
185
186
|
}
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
f(1, g(
|
|
189
|
-
f(2,
|
|
190
|
-
f(3,
|
|
191
|
-
f(4, g(
|
|
192
|
-
],
|
|
187
|
+
}, s(_, "pluginName", "UNIVER_WATERMARK_PLUGIN"), s(_, "packageName", I.name), s(_, "version", I.version), _);
|
|
188
|
+
y = B([
|
|
189
|
+
f(1, g(A)),
|
|
190
|
+
f(2, M),
|
|
191
|
+
f(3, U),
|
|
192
|
+
f(4, g(d))
|
|
193
|
+
], y);
|
|
193
194
|
export {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
y as UniverWatermarkPlugin,
|
|
196
|
+
J as WATERMARK_IMAGE_ALLOW_IMAGE_LIST,
|
|
197
|
+
O as WatermarkImageBaseConfig,
|
|
197
198
|
l as WatermarkService,
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
L as WatermarkTextBaseConfig,
|
|
200
|
+
j as WatermarkUserInfoBaseConfig
|
|
200
201
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export { WATERMARK_IMAGE_ALLOW_IMAGE_LIST, WatermarkImageBaseConfig, WatermarkTextBaseConfig, WatermarkUserInfoBaseConfig } from './common/const';
|
|
17
|
-
export type { IUniverWatermarkConfig } from './
|
|
17
|
+
export type { IUniverWatermarkConfig } from './config/config';
|
|
18
18
|
export { UniverWatermarkPlugin } from './plugin';
|
|
19
19
|
export { WatermarkService } from './services/watermark.service';
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IUniverWatermarkConfig } from './
|
|
1
|
+
import { IUniverWatermarkConfig } from './config/config';
|
|
2
2
|
import { IConfigService, ILocalStorageService, Injector, Plugin } from '@univerjs/core';
|
|
3
3
|
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
4
4
|
export declare class UniverWatermarkPlugin extends Plugin {
|
|
@@ -8,6 +8,8 @@ export declare class UniverWatermarkPlugin extends Plugin {
|
|
|
8
8
|
private readonly _renderManagerSrv;
|
|
9
9
|
private readonly _localStorageService;
|
|
10
10
|
static pluginName: string;
|
|
11
|
+
static packageName: string;
|
|
12
|
+
static version: string;
|
|
11
13
|
constructor(_config: Partial<IUniverWatermarkConfig> | undefined, _injector: Injector, _configService: IConfigService, _renderManagerSrv: IRenderManagerService, _localStorageService: ILocalStorageService);
|
|
12
14
|
private _initWatermarkStorage;
|
|
13
15
|
private _initDependencies;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","rxjs"],t):(a=typeof globalThis<"u"?globalThis:a||self,t(a.UniverWatermark={},a.UniverCore,a.UniverEngineRender,a.rxjs))})(this,(function(a,t,n,
|
|
1
|
+
(function(a,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","rxjs"],t):(a=typeof globalThis<"u"?globalThis:a||self,t(a.UniverWatermark={},a.UniverCore,a.UniverEngineRender,a.rxjs))})(this,(function(a,t,n,u){"use strict";var M=Object.defineProperty;var j=(a,t,n)=>t in a?M(a,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[t]=n;var m=(a,t,n)=>j(a,typeof t!="symbol"?t+"":t,n);var g;const d=["image/png","image/jpeg","image/jpg","image/bmp"],S={content:"",fontSize:16,color:"rgb(0,0,0)",bold:!1,italic:!1,direction:"ltr",x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},h={url:"",width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},p={name:!0,email:!1,phone:!1,uid:!1,fontSize:16,color:"rgb(0,0,0)",bold:!1,italic:!1,direction:"ltr",x:60,y:60,repeat:!0,spacingX:200,spacingY:100,rotate:-30,opacity:.15},E={name:"@univerjs/watermark",version:"0.17.0"},I="watermark.config",W={};var k=Object.getOwnPropertyDescriptor,R=(o,e,r,i)=>{for(var s=i>1?void 0:i?k(e,r):e,c=o.length-1,_;c>=0;c--)(_=o[c])&&(s=_(s)||s);return s},A=(o,e)=>(r,i)=>e(r,i,o);a.WatermarkService=class extends t.Disposable{constructor(r){super();m(this,"_updateConfig$",new u.Subject);m(this,"updateConfig$",this._updateConfig$.asObservable());m(this,"_refresh$",new u.Subject);m(this,"refresh$",this._refresh$.asObservable());this._localStorageService=r}async getWatermarkConfig(){return await this._localStorageService.getItem(n.UNIVER_WATERMARK_STORAGE_KEY)}updateWatermarkConfig(r){this._localStorageService.setItem(n.UNIVER_WATERMARK_STORAGE_KEY,r),this._updateConfig$.next(r)}deleteWatermarkConfig(){this._localStorageService.removeItem(n.UNIVER_WATERMARK_STORAGE_KEY),this._updateConfig$.next(null)}refresh(){this._refresh$.next(Math.random())}dispose(){this._refresh$.complete(),this._updateConfig$.complete()}},a.WatermarkService=R([A(0,t.Inject(t.ILocalStorageService))],a.WatermarkService);var y=Object.getOwnPropertyDescriptor,T=(o,e,r,i)=>{for(var s=i>1?void 0:i?y(e,r):e,c=o.length-1,_;c>=0;c--)(_=o[c])&&(s=_(s)||s);return s},l=(o,e)=>(r,i)=>e(r,i,o);let v=class extends t.RxDisposable{constructor(e,r,i,s){super();m(this,"_watermarkLayer");this._context=e,this._watermarkService=r,this._localStorageService=i,this._userManagerService=s,this._watermarkLayer=new n.WatermarkLayer(e.scene,[],n.UNIVER_WATERMARK_LAYER_INDEX),this._initAddRender(),this._initWatermarkUpdate(),this._initWatermarkConfig()}_initAddRender(){const{scene:e}=this._context;e.addLayer(this._watermarkLayer)}async _initWatermarkConfig(){var r;const e=await this._localStorageService.getItem(n.UNIVER_WATERMARK_STORAGE_KEY);e&&(this._watermarkService.updateWatermarkConfig(e),(r=this._context.mainComponent)==null||r.makeDirty())}_initWatermarkUpdate(){this.disposeWithMe(this._watermarkService.updateConfig$.subscribe(e=>{var r,i;if(!e){this._watermarkLayer.updateConfig(),(r=this._context.mainComponent)==null||r.makeDirty();return}e.type===n.IWatermarkTypeEnum.UserInfo?this._watermarkLayer.updateConfig(e,this._userManagerService.getCurrentUser()):this._watermarkLayer.updateConfig(e),(i=this._context.mainComponent)==null||i.makeDirty()}))}};v=T([l(1,t.Inject(a.WatermarkService)),l(2,t.Inject(t.ILocalStorageService)),l(3,t.Inject(t.UserManagerService))],v);var C=Object.getOwnPropertyDescriptor,U=(o,e,r,i)=>{for(var s=i>1?void 0:i?C(e,r):e,c=o.length-1,_;c>=0;c--)(_=o[c])&&(s=_(s)||s);return s},f=(o,e)=>(r,i)=>e(r,i,o);a.UniverWatermarkPlugin=(g=class extends t.Plugin{constructor(e=W,r,i,s,c){super(),this._config=e,this._injector=r,this._configService=i,this._renderManagerSrv=s,this._localStorageService=c;const{..._}=t.merge({},W,this._config);this._configService.setConfig(I,_),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){const e=this._configService.getConfig(I);if(!e)return;const{userWatermarkSettings:r,textWatermarkSettings:i,imageWatermarkSettings:s}=e;if(r)this._localStorageService.setItem(n.UNIVER_WATERMARK_STORAGE_KEY,{type:n.IWatermarkTypeEnum.UserInfo,config:{userInfo:t.merge({},p,r)}});else if(i)this._localStorageService.setItem(n.UNIVER_WATERMARK_STORAGE_KEY,{type:n.IWatermarkTypeEnum.Text,config:{text:t.merge({},S,i)}});else if(s)this._localStorageService.setItem(n.UNIVER_WATERMARK_STORAGE_KEY,{type:n.IWatermarkTypeEnum.Image,config:{image:t.merge({},h,s)}});else{const c=await this._localStorageService.getItem(n.UNIVER_WATERMARK_STORAGE_KEY);(c==null?void 0:c.type)===n.IWatermarkTypeEnum.UserInfo&&this._localStorageService.removeItem(n.UNIVER_WATERMARK_STORAGE_KEY)}}_initDependencies(){[[a.WatermarkService]].forEach(e=>{this._injector.add(e)})}onRendered(){this._injector.get(a.WatermarkService),this._initRenderDependencies()}_initRenderDependencies(){[[v]].forEach(e=>{this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,e),this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,e)})}},m(g,"pluginName","UNIVER_WATERMARK_PLUGIN"),m(g,"packageName",E.name),m(g,"version",E.version),g),a.UniverWatermarkPlugin=U([f(1,t.Inject(t.Injector)),f(2,t.IConfigService),f(3,n.IRenderManagerService),f(4,t.Inject(t.ILocalStorageService))],a.UniverWatermarkPlugin),a.WATERMARK_IMAGE_ALLOW_IMAGE_LIST=d,a.WatermarkImageBaseConfig=h,a.WatermarkTextBaseConfig=S,a.WatermarkUserInfoBaseConfig=p,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/watermark",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "univer watermark plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -58,15 +58,15 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/core": "0.
|
|
62
|
-
"@univerjs/engine-render": "0.
|
|
61
|
+
"@univerjs/core": "0.17.0",
|
|
62
|
+
"@univerjs/engine-render": "0.17.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"rxjs": "^7.8.2",
|
|
66
66
|
"typescript": "^5.9.3",
|
|
67
67
|
"vite": "^7.3.1",
|
|
68
68
|
"vitest": "^4.0.18",
|
|
69
|
-
"@univerjs-infra/shared": "0.
|
|
69
|
+
"@univerjs-infra/shared": "0.17.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"test": "vitest run",
|
|
File without changes
|