@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 CHANGED
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var I=(a,e,r)=>e in a?E(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r;var _=(a,e,r)=>I(a,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@univerjs/core"),o=require("@univerjs/engine-render"),f=require("rxjs"),d=["image/png","image/jpeg","image/jpg","image/bmp"],v={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},u={url:"",width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},R={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},p="watermark.config",h={};var W=Object.getOwnPropertyDescriptor,A=(a,e,r,t)=>{for(var i=t>1?void 0:t?W(e,r):e,s=a.length-1,c;s>=0;s--)(c=a[s])&&(i=c(i)||i);return i},k=(a,e)=>(r,t)=>e(r,t,a);exports.WatermarkService=class extends n.Disposable{constructor(r){super();_(this,"_updateConfig$",new f.Subject);_(this,"updateConfig$",this._updateConfig$.asObservable());_(this,"_refresh$",new f.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=A([k(0,n.Inject(n.ILocalStorageService))],exports.WatermarkService);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},m=(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=T([m(1,n.Inject(exports.WatermarkService)),m(2,n.Inject(n.ILocalStorageService)),m(3,n.Inject(n.UserManagerService))],S);var C=Object.getOwnPropertyDescriptor,M=(a,e,r,t)=>{for(var i=t>1?void 0:t?C(e,r):e,s=a.length-1,c;s>=0;s--)(c=a[s])&&(i=c(i)||i);return i},g=(a,e)=>(r,t)=>e(r,t,a);const U="UNIVER_WATERMARK_PLUGIN";var l;exports.UniverWatermarkPlugin=(l=class extends n.Plugin{constructor(e=h,r,t,i,s){super(),this._config=e,this._injector=r,this._configService=t,this._renderManagerSrv=i,this._localStorageService=s;const{...c}=n.merge({},h,this._config);this._configService.setConfig(p,c),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){const e=this._configService.getConfig(p);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({},R,r)}});else if(t)this._localStorageService.setItem(o.UNIVER_WATERMARK_STORAGE_KEY,{type:o.IWatermarkTypeEnum.Text,config:{text:n.merge({},v,t)}});else if(i)this._localStorageService.setItem(o.UNIVER_WATERMARK_STORAGE_KEY,{type:o.IWatermarkTypeEnum.Image,config:{image:n.merge({},u,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)})}},_(l,"pluginName",U),l);exports.UniverWatermarkPlugin=M([g(1,n.Inject(n.Injector)),g(2,n.IConfigService),g(3,o.IRenderManagerService),g(4,n.Inject(n.ILocalStorageService))],exports.UniverWatermarkPlugin);exports.WATERMARK_IMAGE_ALLOW_IMAGE_LIST=d;exports.WatermarkImageBaseConfig=u;exports.WatermarkTextBaseConfig=v;exports.WatermarkUserInfoBaseConfig=R;
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 y = Object.defineProperty;
2
- var R = (t, e, r) => e in t ? y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var c = (t, e, r) => R(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { Inject as g, ILocalStorageService as v, Disposable as W, UserManagerService as w, RxDisposable as E, Injector as x, IConfigService as A, Plugin as M, merge as m, UniverInstanceType as S } from "@univerjs/core";
5
- import { UNIVER_WATERMARK_STORAGE_KEY as s, WatermarkLayer as U, UNIVER_WATERMARK_LAYER_INDEX as $, IWatermarkTypeEnum as _, IRenderManagerService as b } from "@univerjs/engine-render";
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 H = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], D = {
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
- }, L = {
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
- }, O = {
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
- }, I = "watermark.config", C = {};
52
- var P = Object.getOwnPropertyDescriptor, j = (t, e, r, a) => {
53
- for (var i = a > 1 ? void 0 : a ? P(e, r) : e, n = t.length - 1, o; n >= 0; n--)
54
- (o = t[n]) && (i = o(i) || i);
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
- }, N = (t, e) => (r, a) => e(r, a, t);
57
- let l = class extends W {
59
+ }, G = (t, e) => (r, a) => e(r, a, t);
60
+ let l = class extends w {
58
61
  constructor(e) {
59
62
  super();
60
- c(this, "_updateConfig$", new u());
61
- c(this, "updateConfig$", this._updateConfig$.asObservable());
62
- c(this, "_refresh$", new u());
63
- c(this, "refresh$", this._refresh$.asObservable());
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(s);
70
+ return await this._localStorageService.getItem(o);
68
71
  }
69
72
  updateWatermarkConfig(e) {
70
- this._localStorageService.setItem(s, e), this._updateConfig$.next(e);
73
+ this._localStorageService.setItem(o, e), this._updateConfig$.next(e);
71
74
  }
72
75
  deleteWatermarkConfig() {
73
- this._localStorageService.removeItem(s), this._updateConfig$.next(null);
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 = j([
83
- N(0, g(v))
85
+ l = K([
86
+ G(0, g(d))
84
87
  ], l);
85
- var T = Object.getOwnPropertyDescriptor, G = (t, e, r, a) => {
86
- for (var i = a > 1 ? void 0 : a ? T(e, r) : e, n = t.length - 1, o; n >= 0; n--)
87
- (o = t[n]) && (i = o(i) || i);
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 d = class extends E {
93
+ let v = class extends x {
91
94
  constructor(e, r, a, i) {
92
95
  super();
93
- c(this, "_watermarkLayer");
94
- this._context = e, this._watermarkService = r, this._localStorageService = a, this._userManagerService = i, this._watermarkLayer = new U(e.scene, [], $), this._initAddRender(), this._initWatermarkUpdate(), this._initWatermarkConfig();
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(s);
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 === _.UserInfo ? this._watermarkLayer.updateConfig(e, this._userManagerService.getCurrentUser()) : this._watermarkLayer.updateConfig(e), (a = this._context.mainComponent) == null || a.makeDirty();
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
- d = G([
121
+ v = V([
119
122
  h(1, g(l)),
120
- h(2, g(v)),
121
- h(3, g(w))
122
- ], d);
123
- var K = Object.getOwnPropertyDescriptor, Y = (t, e, r, a) => {
124
- for (var i = a > 1 ? void 0 : a ? K(e, r) : e, n = t.length - 1, o; n >= 0; n--)
125
- (o = t[n]) && (i = o(i) || i);
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
- const V = "UNIVER_WATERMARK_PLUGIN";
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 } = m(
134
+ const { ...n } = p(
134
135
  {},
135
136
  C,
136
137
  this._config
137
138
  );
138
- this._configService.setConfig(I, n), this._initWatermarkStorage(), this._initDependencies();
139
+ this._configService.setConfig(k, n), this._initWatermarkStorage(), this._initDependencies();
139
140
  }
140
141
  async _initWatermarkStorage() {
141
- const t = this._configService.getConfig(I);
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(s, {
147
- type: _.UserInfo,
147
+ this._localStorageService.setItem(o, {
148
+ type: m.UserInfo,
148
149
  config: {
149
- userInfo: m({}, O, e)
150
+ userInfo: p({}, j, e)
150
151
  }
151
152
  });
152
153
  else if (r)
153
- this._localStorageService.setItem(s, {
154
- type: _.Text,
154
+ this._localStorageService.setItem(o, {
155
+ type: m.Text,
155
156
  config: {
156
- text: m({}, D, r)
157
+ text: p({}, L, r)
157
158
  }
158
159
  });
159
160
  else if (a)
160
- this._localStorageService.setItem(s, {
161
- type: _.Image,
161
+ this._localStorageService.setItem(o, {
162
+ type: m.Image,
162
163
  config: {
163
- image: m({}, L, a)
164
+ image: p({}, O, a)
164
165
  }
165
166
  });
166
167
  else {
167
- const i = await this._localStorageService.getItem(s);
168
- (i == null ? void 0 : i.type) === _.UserInfo && this._localStorageService.removeItem(s);
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
- [d]
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
- }, c(p, "pluginName", V), p);
187
- k = Y([
188
- f(1, g(x)),
189
- f(2, A),
190
- f(3, b),
191
- f(4, g(v))
192
- ], k);
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
- k as UniverWatermarkPlugin,
195
- H as WATERMARK_IMAGE_ALLOW_IMAGE_LIST,
196
- L as WatermarkImageBaseConfig,
195
+ y as UniverWatermarkPlugin,
196
+ J as WATERMARK_IMAGE_ALLOW_IMAGE_LIST,
197
+ O as WatermarkImageBaseConfig,
197
198
  l as WatermarkService,
198
- D as WatermarkTextBaseConfig,
199
- O as WatermarkUserInfoBaseConfig
199
+ L as WatermarkTextBaseConfig,
200
+ j as WatermarkUserInfoBaseConfig
200
201
  };
package/lib/index.js CHANGED
@@ -1,10 +1,10 @@
1
- var y = Object.defineProperty;
2
- var R = (t, e, r) => e in t ? y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var c = (t, e, r) => R(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { Inject as g, ILocalStorageService as v, Disposable as W, UserManagerService as w, RxDisposable as E, Injector as x, IConfigService as A, Plugin as M, merge as m, UniverInstanceType as S } from "@univerjs/core";
5
- import { UNIVER_WATERMARK_STORAGE_KEY as s, WatermarkLayer as U, UNIVER_WATERMARK_LAYER_INDEX as $, IWatermarkTypeEnum as _, IRenderManagerService as b } from "@univerjs/engine-render";
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 H = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], D = {
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
- }, L = {
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
- }, O = {
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
- }, I = "watermark.config", C = {};
52
- var P = Object.getOwnPropertyDescriptor, j = (t, e, r, a) => {
53
- for (var i = a > 1 ? void 0 : a ? P(e, r) : e, n = t.length - 1, o; n >= 0; n--)
54
- (o = t[n]) && (i = o(i) || i);
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
- }, N = (t, e) => (r, a) => e(r, a, t);
57
- let l = class extends W {
59
+ }, G = (t, e) => (r, a) => e(r, a, t);
60
+ let l = class extends w {
58
61
  constructor(e) {
59
62
  super();
60
- c(this, "_updateConfig$", new u());
61
- c(this, "updateConfig$", this._updateConfig$.asObservable());
62
- c(this, "_refresh$", new u());
63
- c(this, "refresh$", this._refresh$.asObservable());
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(s);
70
+ return await this._localStorageService.getItem(o);
68
71
  }
69
72
  updateWatermarkConfig(e) {
70
- this._localStorageService.setItem(s, e), this._updateConfig$.next(e);
73
+ this._localStorageService.setItem(o, e), this._updateConfig$.next(e);
71
74
  }
72
75
  deleteWatermarkConfig() {
73
- this._localStorageService.removeItem(s), this._updateConfig$.next(null);
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 = j([
83
- N(0, g(v))
85
+ l = K([
86
+ G(0, g(d))
84
87
  ], l);
85
- var T = Object.getOwnPropertyDescriptor, G = (t, e, r, a) => {
86
- for (var i = a > 1 ? void 0 : a ? T(e, r) : e, n = t.length - 1, o; n >= 0; n--)
87
- (o = t[n]) && (i = o(i) || i);
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 d = class extends E {
93
+ let v = class extends x {
91
94
  constructor(e, r, a, i) {
92
95
  super();
93
- c(this, "_watermarkLayer");
94
- this._context = e, this._watermarkService = r, this._localStorageService = a, this._userManagerService = i, this._watermarkLayer = new U(e.scene, [], $), this._initAddRender(), this._initWatermarkUpdate(), this._initWatermarkConfig();
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(s);
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 === _.UserInfo ? this._watermarkLayer.updateConfig(e, this._userManagerService.getCurrentUser()) : this._watermarkLayer.updateConfig(e), (a = this._context.mainComponent) == null || a.makeDirty();
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
- d = G([
121
+ v = V([
119
122
  h(1, g(l)),
120
- h(2, g(v)),
121
- h(3, g(w))
122
- ], d);
123
- var K = Object.getOwnPropertyDescriptor, Y = (t, e, r, a) => {
124
- for (var i = a > 1 ? void 0 : a ? K(e, r) : e, n = t.length - 1, o; n >= 0; n--)
125
- (o = t[n]) && (i = o(i) || i);
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
- const V = "UNIVER_WATERMARK_PLUGIN";
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 } = m(
134
+ const { ...n } = p(
134
135
  {},
135
136
  C,
136
137
  this._config
137
138
  );
138
- this._configService.setConfig(I, n), this._initWatermarkStorage(), this._initDependencies();
139
+ this._configService.setConfig(k, n), this._initWatermarkStorage(), this._initDependencies();
139
140
  }
140
141
  async _initWatermarkStorage() {
141
- const t = this._configService.getConfig(I);
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(s, {
147
- type: _.UserInfo,
147
+ this._localStorageService.setItem(o, {
148
+ type: m.UserInfo,
148
149
  config: {
149
- userInfo: m({}, O, e)
150
+ userInfo: p({}, j, e)
150
151
  }
151
152
  });
152
153
  else if (r)
153
- this._localStorageService.setItem(s, {
154
- type: _.Text,
154
+ this._localStorageService.setItem(o, {
155
+ type: m.Text,
155
156
  config: {
156
- text: m({}, D, r)
157
+ text: p({}, L, r)
157
158
  }
158
159
  });
159
160
  else if (a)
160
- this._localStorageService.setItem(s, {
161
- type: _.Image,
161
+ this._localStorageService.setItem(o, {
162
+ type: m.Image,
162
163
  config: {
163
- image: m({}, L, a)
164
+ image: p({}, O, a)
164
165
  }
165
166
  });
166
167
  else {
167
- const i = await this._localStorageService.getItem(s);
168
- (i == null ? void 0 : i.type) === _.UserInfo && this._localStorageService.removeItem(s);
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
- [d]
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
- }, c(p, "pluginName", V), p);
187
- k = Y([
188
- f(1, g(x)),
189
- f(2, A),
190
- f(3, b),
191
- f(4, g(v))
192
- ], k);
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
- k as UniverWatermarkPlugin,
195
- H as WATERMARK_IMAGE_ALLOW_IMAGE_LIST,
196
- L as WatermarkImageBaseConfig,
195
+ y as UniverWatermarkPlugin,
196
+ J as WATERMARK_IMAGE_ALLOW_IMAGE_LIST,
197
+ O as WatermarkImageBaseConfig,
197
198
  l as WatermarkService,
198
- D as WatermarkTextBaseConfig,
199
- O as WatermarkUserInfoBaseConfig
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 {};
@@ -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 './controllers/config.schema';
17
+ export type { IUniverWatermarkConfig } from './config/config';
18
18
  export { UniverWatermarkPlugin } from './plugin';
19
19
  export { WatermarkService } from './services/watermark.service';
@@ -1,4 +1,4 @@
1
- import { IUniverWatermarkConfig } from './controllers/config.schema';
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,S){"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 u;const W=["image/png","image/jpeg","image/jpg","image/bmp"],h={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},v={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="watermark.config",I={};var d=Object.getOwnPropertyDescriptor,k=(o,e,r,i)=>{for(var s=i>1?void 0:i?d(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 S.Subject);m(this,"updateConfig$",this._updateConfig$.asObservable());m(this,"_refresh$",new S.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=k([A(0,t.Inject(t.ILocalStorageService))],a.WatermarkService);var R=Object.getOwnPropertyDescriptor,y=(o,e,r,i)=>{for(var s=i>1?void 0:i?R(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);let l=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()}))}};l=y([f(1,t.Inject(a.WatermarkService)),f(2,t.Inject(t.ILocalStorageService)),f(3,t.Inject(t.UserManagerService))],l);var T=Object.getOwnPropertyDescriptor,C=(o,e,r,i)=>{for(var s=i>1?void 0:i?T(e,r):e,c=o.length-1,_;c>=0;c--)(_=o[c])&&(s=_(s)||s);return s},g=(o,e)=>(r,i)=>e(r,i,o);const U="UNIVER_WATERMARK_PLUGIN";a.UniverWatermarkPlugin=(u=class extends t.Plugin{constructor(e=I,r,i,s,c){super(),this._config=e,this._injector=r,this._configService=i,this._renderManagerSrv=s,this._localStorageService=c;const{..._}=t.merge({},I,this._config);this._configService.setConfig(E,_),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){const e=this._configService.getConfig(E);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({},h,i)}});else if(s)this._localStorageService.setItem(n.UNIVER_WATERMARK_STORAGE_KEY,{type:n.IWatermarkTypeEnum.Image,config:{image:t.merge({},v,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(){[[l]].forEach(e=>{this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,e),this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,e)})}},m(u,"pluginName",U),u),a.UniverWatermarkPlugin=C([g(1,t.Inject(t.Injector)),g(2,t.IConfigService),g(3,n.IRenderManagerService),g(4,t.Inject(t.ILocalStorageService))],a.UniverWatermarkPlugin),a.WATERMARK_IMAGE_ALLOW_IMAGE_LIST=W,a.WatermarkImageBaseConfig=v,a.WatermarkTextBaseConfig=h,a.WatermarkUserInfoBaseConfig=p,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
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.16.1",
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.16.1",
62
- "@univerjs/engine-render": "0.16.1"
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.16.1"
69
+ "@univerjs-infra/shared": "0.17.0"
70
70
  },
71
71
  "scripts": {
72
72
  "test": "vitest run",