@univerjs/watermark 0.5.5-nightly.202501220324 → 0.5.5
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/LICENSE +176 -0
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +18 -22
- package/lib/es/index.js +163 -170
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const i=require("@univerjs/core"),e=require("@univerjs/watermark");class n extends i.FUniver{addWatermark(r,t){const a=this._injector.get(e.WatermarkService);if(r===e.IWatermarkTypeEnum.Text)a.updateWatermarkConfig({type:e.IWatermarkTypeEnum.Text,config:{text:{...e.WatermarkTextBaseConfig,...t}}});else if(r===e.IWatermarkTypeEnum.Image)a.updateWatermarkConfig({type:e.IWatermarkTypeEnum.Image,config:{image:{...e.WatermarkImageBaseConfig,...t}}});else throw new Error("Unknown watermark type");return this}deleteWatermark(){return this._injector.get(e.WatermarkService).deleteWatermarkConfig(),this}}i.FUniver.extend(n);
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),engineRender=require("@univerjs/engine-render"),rxjs=require("rxjs"),UNIVER_WATERMARK_STORAGE_KEY="UNIVER_WATERMARK_STORAGE_KEY",UNIVER_WATERMARK_LAYER_INDEX=10,WATERMARK_IMAGE_ALLOW_IMAGE_LIST=["image/png","image/jpeg","image/jpg","image/bmp"],WatermarkTextBaseConfig={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},WatermarkImageBaseConfig={url:"",width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},WatermarkUserInfoBaseConfig={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};var IWatermarkTypeEnum=(IWatermarkTypeEnum2=>(IWatermarkTypeEnum2.UserInfo="userInfo",IWatermarkTypeEnum2.Text="text",IWatermarkTypeEnum2.Image="image",IWatermarkTypeEnum2))(IWatermarkTypeEnum||{});const WATERMARK_PLUGIN_CONFIG_KEY="watermark.config",defaultPluginConfig={};var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a;exports.WatermarkService=(_a=class extends core.Disposable{constructor(_localStorageService){super();__publicField(this,"_updateConfig$",new rxjs.Subject);__publicField(this,"updateConfig$",this._updateConfig$.asObservable());__publicField(this,"_refresh$",new rxjs.Subject);__publicField(this,"refresh$",this._refresh$.asObservable());this._localStorageService=_localStorageService}async getWatermarkConfig(){return await this._localStorageService.getItem(UNIVER_WATERMARK_STORAGE_KEY)}updateWatermarkConfig(config){this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY,config),this._updateConfig$.next(config)}deleteWatermarkConfig(){this._localStorageService.removeItem(UNIVER_WATERMARK_STORAGE_KEY),this._updateConfig$.next(null)}refresh(){this._refresh$.next(Math.random())}dispose(){this._refresh$.complete(),this._updateConfig$.complete()}},__name(_a,"WatermarkService"),_a);exports.WatermarkService=__decorateClass$2([__decorateParam$2(0,core.Inject(core.ILocalStorageService))],exports.WatermarkService);function renderWatermark(ctx,config,image,userInfo){const type=config.type,watermarkConfig=config.config;type===IWatermarkTypeEnum.UserInfo&&watermarkConfig.userInfo?renderUserInfoWatermark(ctx,watermarkConfig.userInfo,userInfo):type===IWatermarkTypeEnum.Image&&watermarkConfig.image?renderImageWatermark(ctx,watermarkConfig.image,image):type===IWatermarkTypeEnum.Text&&watermarkConfig.text&&renderTextWatermark(ctx,watermarkConfig.text)}__name(renderWatermark,"renderWatermark");function renderUserInfoWatermark(ctx,config,userInfo){const{x,y,repeat,spacingX,spacingY,rotate,opacity,name,fontSize,color,bold,italic,direction}=config;if(!userInfo)return;let watermarkContent="";if(name&&(watermarkContent+=`${userInfo.name} `),!watermarkContent)return;ctx.save(),ctx.globalAlpha=opacity,ctx.direction=direction;let fontStyle="";if(italic&&(fontStyle+="italic "),bold&&(fontStyle+="bold "),fontStyle+=`${fontSize}px Arial`,ctx.font=fontStyle,ctx.fillStyle=color,repeat){const canvasWidth=ctx.canvas.width,canvasHeight=ctx.canvas.height;for(let posY=y;posY<canvasHeight;posY+=fontSize+spacingY)for(let posX=x;posX<canvasWidth;posX+=ctx.measureText(watermarkContent).width+spacingX)ctx.save(),ctx.translate(posX,posY),ctx.rotate(Math.PI/180*rotate),ctx.fillText(watermarkContent,0,0),ctx.restore()}else ctx.save(),ctx.translate(x,y),ctx.rotate(Math.PI/180*rotate),ctx.fillText(watermarkContent,0,0),ctx.restore();ctx.restore()}__name(renderUserInfoWatermark,"renderUserInfoWatermark");function renderTextWatermark(ctx,config){const{x,y,repeat,spacingX,spacingY,rotate,opacity,content,fontSize,color,bold,italic,direction}=config;ctx.save(),ctx.globalAlpha=opacity,ctx.direction=direction;let fontStyle="";if(italic&&(fontStyle+="italic "),bold&&(fontStyle+="bold "),fontStyle+=`${fontSize}px Arial`,ctx.font=fontStyle,ctx.fillStyle=color,content)if(repeat){const canvasWidth=ctx.canvas.width,canvasHeight=ctx.canvas.height;for(let posY=y;posY<canvasHeight;posY+=fontSize+spacingY)for(let posX=x;posX<canvasWidth;posX+=ctx.measureText(content).width+spacingX)ctx.save(),ctx.translate(posX,posY),ctx.rotate(Math.PI/180*rotate),ctx.fillText(content,0,0),ctx.restore()}else ctx.save(),ctx.translate(x,y),ctx.rotate(Math.PI/180*rotate),ctx.fillText(content,0,0),ctx.restore();ctx.restore()}__name(renderTextWatermark,"renderTextWatermark");function renderImageWatermark(ctx,config,image){const{x,y,repeat,spacingX,spacingY,rotate,opacity,width,height,maintainAspectRatio,originRatio}=config;if(!(image!=null&&image.complete))return;ctx.save(),ctx.globalAlpha=opacity;const actualWidth=width,actualHeight=maintainAspectRatio?width/originRatio:height;if(repeat){const canvasWidth=ctx.canvas.width,canvasHeight=ctx.canvas.height;for(let posY=y;posY<canvasHeight;posY+=actualHeight+spacingY)for(let posX=x;posX<canvasWidth;posX+=actualWidth+spacingX)ctx.save(),ctx.translate(posX,posY),ctx.rotate(Math.PI/180*rotate),ctx.drawImage(image,0,0,actualWidth,actualHeight),ctx.restore()}else ctx.save(),ctx.translate(x,y),ctx.rotate(Math.PI/180*rotate),ctx.drawImage(image,0,0,actualWidth,actualHeight),ctx.restore();ctx.restore()}__name(renderImageWatermark,"renderImageWatermark");const _WatermarkLayer=class _WatermarkLayer extends engineRender.Layer{constructor(){super(...arguments);__publicField(this,"_config");__publicField(this,"_image");__publicField(this,"_user")}render(ctx,isMaxLayer=!1){var _a4;super.render(ctx,isMaxLayer);const mainCtx=ctx||((_a4=this.scene.getEngine())==null?void 0:_a4.getCanvas().getContext());return mainCtx&&mainCtx.getId()&&this._renderWatermark(mainCtx),this}updateConfig(config,user){var _a4;this._config=config,((_a4=this._config)==null?void 0:_a4.type)===IWatermarkTypeEnum.Image&&this._config.config.image&&(this._image=new Image,this._image.src=this._config.config.image.url),user&&(this._user=user)}_renderWatermark(ctx){this._config&&renderWatermark(ctx,this._config,this._image,this._user)}};__name(_WatermarkLayer,"WatermarkLayer");let WatermarkLayer=_WatermarkLayer;var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1"),_a2;let WatermarkRenderController=(_a2=class extends core.RxDisposable{constructor(_context,_watermarkService,_localStorageService,_userManagerService){super();__publicField(this,"_watermarkLayer");this._context=_context,this._watermarkService=_watermarkService,this._localStorageService=_localStorageService,this._userManagerService=_userManagerService,this._watermarkLayer=new WatermarkLayer(_context.scene,[],UNIVER_WATERMARK_LAYER_INDEX),this._initAddRender(),this._initWatermarkUpdate(),this._initWatermarkConfig()}_initAddRender(){const{scene}=this._context;scene.addLayer(this._watermarkLayer)}async _initWatermarkConfig(){var _a4;const config=await this._localStorageService.getItem(UNIVER_WATERMARK_STORAGE_KEY);config&&(this._watermarkService.updateWatermarkConfig(config),(_a4=this._context.mainComponent)==null||_a4.makeDirty())}_initWatermarkUpdate(){this.disposeWithMe(this._watermarkService.updateConfig$.subscribe(_config=>{var _a4,_b;if(!_config){this._watermarkLayer.updateConfig(),(_a4=this._context.mainComponent)==null||_a4.makeDirty();return}_config.type===IWatermarkTypeEnum.UserInfo?this._watermarkLayer.updateConfig(_config,this._userManagerService.getCurrentUser()):this._watermarkLayer.updateConfig(_config),(_b=this._context.mainComponent)==null||_b.makeDirty()}))}},__name(_a2,"WatermarkRenderController"),_a2);WatermarkRenderController=__decorateClass$1([__decorateParam$1(1,core.Inject(exports.WatermarkService)),__decorateParam$1(2,core.Inject(core.ILocalStorageService)),__decorateParam$1(3,core.Inject(core.UserManagerService))],WatermarkRenderController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");const PLUGIN_NAME="UNIVER_WATERMARK_PLUGIN";var _a3;exports.UniverWatermarkPlugin=(_a3=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService,_renderManagerSrv,_localStorageService){super(),this._config=_config,this._injector=_injector,this._configService=_configService,this._renderManagerSrv=_renderManagerSrv,this._localStorageService=_localStorageService;const{...rest}=core.merge({},defaultPluginConfig,this._config);this._configService.setConfig(WATERMARK_PLUGIN_CONFIG_KEY,rest),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){const config=this._configService.getConfig(WATERMARK_PLUGIN_CONFIG_KEY);if(!config)return;const{userWatermarkSettings,textWatermarkSettings,imageWatermarkSettings}=config;if(userWatermarkSettings)this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY,{type:IWatermarkTypeEnum.UserInfo,config:{userInfo:core.merge({},WatermarkUserInfoBaseConfig,userWatermarkSettings)}});else if(textWatermarkSettings)this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY,{type:IWatermarkTypeEnum.Text,config:{text:core.merge({},WatermarkTextBaseConfig,textWatermarkSettings)}});else if(imageWatermarkSettings)this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY,{type:IWatermarkTypeEnum.Image,config:{image:core.merge({},WatermarkImageBaseConfig,imageWatermarkSettings)}});else{const config2=await this._localStorageService.getItem(UNIVER_WATERMARK_STORAGE_KEY);(config2==null?void 0:config2.type)===IWatermarkTypeEnum.UserInfo&&this._localStorageService.removeItem(UNIVER_WATERMARK_STORAGE_KEY)}}_initDependencies(){[[exports.WatermarkService]].forEach(d=>{this._injector.add(d)})}onRendered(){this._injector.get(exports.WatermarkService),this._initRenderDependencies()}_initRenderDependencies(){[[WatermarkRenderController]].forEach(d=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_SHEET,d),this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,d)})}},__name(_a3,"UniverWatermarkPlugin"),__publicField(_a3,"pluginName",PLUGIN_NAME),_a3);exports.UniverWatermarkPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService),__decorateParam(3,engineRender.IRenderManagerService),__decorateParam(4,core.Inject(core.ILocalStorageService))],exports.UniverWatermarkPlugin);exports.IWatermarkTypeEnum=IWatermarkTypeEnum;exports.UNIVER_WATERMARK_STORAGE_KEY=UNIVER_WATERMARK_STORAGE_KEY;exports.WATERMARK_IMAGE_ALLOW_IMAGE_LIST=WATERMARK_IMAGE_ALLOW_IMAGE_LIST;exports.WatermarkImageBaseConfig=WatermarkImageBaseConfig;exports.WatermarkTextBaseConfig=WatermarkTextBaseConfig;exports.WatermarkUserInfoBaseConfig=WatermarkUserInfoBaseConfig;
|
|
1
|
+
"use strict";var O=Object.defineProperty;var D=(e,t,r)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var l=(e,t,r)=>D(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),U=require("@univerjs/engine-render"),P=require("rxjs"),f="UNIVER_WATERMARK_STORAGE_KEY",N=10,Y=["image/png","image/jpeg","image/jpg","image/bmp"],j={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},$={url:"",width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},L={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};var c=(e=>(e.UserInfo="userInfo",e.Text="text",e.Image="image",e))(c||{});const b="watermark.config",T={};var K=Object.defineProperty,G=Object.getOwnPropertyDescriptor,X=(e,t,r,i)=>{for(var a=i>1?void 0:i?G(t,r):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(a=(i?o(t,r,a):o(a))||a);return i&&a&&K(t,r,a),a},V=(e,t)=>(r,i)=>t(r,i,e);exports.WatermarkService=class extends s.Disposable{constructor(r){super();l(this,"_updateConfig$",new P.Subject);l(this,"updateConfig$",this._updateConfig$.asObservable());l(this,"_refresh$",new P.Subject);l(this,"refresh$",this._refresh$.asObservable());this._localStorageService=r}async getWatermarkConfig(){return await this._localStorageService.getItem(f)}updateWatermarkConfig(r){this._localStorageService.setItem(f,r),this._updateConfig$.next(r)}deleteWatermarkConfig(){this._localStorageService.removeItem(f),this._updateConfig$.next(null)}refresh(){this._refresh$.next(Math.random())}dispose(){this._refresh$.complete(),this._updateConfig$.complete()}};exports.WatermarkService=X([V(0,s.Inject(s.ILocalStorageService))],exports.WatermarkService);function B(e,t,r,i){const a=t.type,n=t.config;a===c.UserInfo&&n.userInfo?H(e,n.userInfo,i):a===c.Image&&n.image?q(e,n.image,r):a===c.Text&&n.text&&z(e,n.text)}function H(e,t,r){const{x:i,y:a,repeat:n,spacingX:o,spacingY:I,rotate:u,opacity:p,name:d,fontSize:W,color:y,bold:C,italic:S,direction:g}=t;if(!r)return;let _="";if(d&&(_+=`${r.name} `),!_)return;e.save(),e.globalAlpha=p,e.direction=g;let v="";if(S&&(v+="italic "),C&&(v+="bold "),v+=`${W}px Arial`,e.font=v,e.fillStyle=y,n){const h=e.canvas.width,m=e.canvas.height;for(let k=a;k<m;k+=W+I)for(let A=i;A<h;A+=e.measureText(_).width+o)e.save(),e.translate(A,k),e.rotate(Math.PI/180*u),e.fillText(_,0,0),e.restore()}else e.save(),e.translate(i,a),e.rotate(Math.PI/180*u),e.fillText(_,0,0),e.restore();e.restore()}function z(e,t){const{x:r,y:i,repeat:a,spacingX:n,spacingY:o,rotate:I,opacity:u,content:p,fontSize:d,color:W,bold:y,italic:C,direction:S}=t;e.save(),e.globalAlpha=u,e.direction=S;let g="";if(C&&(g+="italic "),y&&(g+="bold "),g+=`${d}px Arial`,e.font=g,e.fillStyle=W,p)if(a){const _=e.canvas.width,v=e.canvas.height;for(let h=i;h<v;h+=d+o)for(let m=r;m<_;m+=e.measureText(p).width+n)e.save(),e.translate(m,h),e.rotate(Math.PI/180*I),e.fillText(p,0,0),e.restore()}else e.save(),e.translate(r,i),e.rotate(Math.PI/180*I),e.fillText(p,0,0),e.restore();e.restore()}function q(e,t,r){const{x:i,y:a,repeat:n,spacingX:o,spacingY:I,rotate:u,opacity:p,width:d,height:W,maintainAspectRatio:y,originRatio:C}=t;if(!(r!=null&&r.complete))return;e.save(),e.globalAlpha=p;const S=d,g=y?d/C:W;if(n){const _=e.canvas.width,v=e.canvas.height;for(let h=a;h<v;h+=g+I)for(let m=i;m<_;m+=S+o)e.save(),e.translate(m,h),e.rotate(Math.PI/180*u),e.drawImage(r,0,0,S,g),e.restore()}else e.save(),e.translate(i,a),e.rotate(Math.PI/180*u),e.drawImage(r,0,0,S,g),e.restore();e.restore()}class F extends U.Layer{constructor(){super(...arguments);l(this,"_config");l(this,"_image");l(this,"_user")}render(r,i=!1){var n;super.render(r,i);const a=r||((n=this.scene.getEngine())==null?void 0:n.getCanvas().getContext());return a&&a.getId()&&this._renderWatermark(a),this}updateConfig(r,i){var a;this._config=r,((a=this._config)==null?void 0:a.type)===c.Image&&this._config.config.image&&(this._image=new Image,this._image.src=this._config.config.image.url),i&&(this._user=i)}_renderWatermark(r){this._config&&B(r,this._config,this._image,this._user)}}var J=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,Z=(e,t,r,i)=>{for(var a=i>1?void 0:i?Q(t,r):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(a=(i?o(t,r,a):o(a))||a);return i&&a&&J(t,r,a),a},w=(e,t)=>(r,i)=>t(r,i,e);let M=class extends s.RxDisposable{constructor(t,r,i,a){super();l(this,"_watermarkLayer");this._context=t,this._watermarkService=r,this._localStorageService=i,this._userManagerService=a,this._watermarkLayer=new F(t.scene,[],N),this._initAddRender(),this._initWatermarkUpdate(),this._initWatermarkConfig()}_initAddRender(){const{scene:t}=this._context;t.addLayer(this._watermarkLayer)}async _initWatermarkConfig(){var r;const t=await this._localStorageService.getItem(f);t&&(this._watermarkService.updateWatermarkConfig(t),(r=this._context.mainComponent)==null||r.makeDirty())}_initWatermarkUpdate(){this.disposeWithMe(this._watermarkService.updateConfig$.subscribe(t=>{var r,i;if(!t){this._watermarkLayer.updateConfig(),(r=this._context.mainComponent)==null||r.makeDirty();return}t.type===c.UserInfo?this._watermarkLayer.updateConfig(t,this._userManagerService.getCurrentUser()):this._watermarkLayer.updateConfig(t),(i=this._context.mainComponent)==null||i.makeDirty()}))}};M=Z([w(1,s.Inject(exports.WatermarkService)),w(2,s.Inject(s.ILocalStorageService)),w(3,s.Inject(s.UserManagerService))],M);var x=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(e,t,r,i)=>{for(var a=i>1?void 0:i?ee(t,r):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(a=(i?o(t,r,a):o(a))||a);return i&&a&&x(t,r,a),a},R=(e,t)=>(r,i)=>t(r,i,e);const re="UNIVER_WATERMARK_PLUGIN";var E;exports.UniverWatermarkPlugin=(E=class extends s.Plugin{constructor(t=T,r,i,a,n){super(),this._config=t,this._injector=r,this._configService=i,this._renderManagerSrv=a,this._localStorageService=n;const{...o}=s.merge({},T,this._config);this._configService.setConfig(b,o),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){const t=this._configService.getConfig(b);if(!t)return;const{userWatermarkSettings:r,textWatermarkSettings:i,imageWatermarkSettings:a}=t;if(r)this._localStorageService.setItem(f,{type:c.UserInfo,config:{userInfo:s.merge({},L,r)}});else if(i)this._localStorageService.setItem(f,{type:c.Text,config:{text:s.merge({},j,i)}});else if(a)this._localStorageService.setItem(f,{type:c.Image,config:{image:s.merge({},$,a)}});else{const n=await this._localStorageService.getItem(f);(n==null?void 0:n.type)===c.UserInfo&&this._localStorageService.removeItem(f)}}_initDependencies(){[[exports.WatermarkService]].forEach(t=>{this._injector.add(t)})}onRendered(){this._injector.get(exports.WatermarkService),this._initRenderDependencies()}_initRenderDependencies(){[[M]].forEach(t=>{this._renderManagerSrv.registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,t),this._renderManagerSrv.registerRenderModule(s.UniverInstanceType.UNIVER_DOC,t)})}},l(E,"pluginName",re),E);exports.UniverWatermarkPlugin=te([R(1,s.Inject(s.Injector)),R(2,s.IConfigService),R(3,U.IRenderManagerService),R(4,s.Inject(s.ILocalStorageService))],exports.UniverWatermarkPlugin);exports.IWatermarkTypeEnum=c;exports.UNIVER_WATERMARK_STORAGE_KEY=f;exports.WATERMARK_IMAGE_ALLOW_IMAGE_LIST=Y;exports.WatermarkImageBaseConfig=$;exports.WatermarkTextBaseConfig=j;exports.WatermarkUserInfoBaseConfig=L;
|
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const t={"univer-watermark":{title:"Watermark",type:"Type",text:"Text",image:"Image",uploadImage:"Upload Image",replaceImage:"Replace Image",keepRatio:"Keep Ratio",width:"Width",height:"Height",style:"Style Settings",content:"Content",textPlaceholder:"Enter text",fontSize:"Font Size",direction:"Direction",ltr:"Left to Right",rtl:"Right to Left",inherits:"Inherit",opacity:"Opacity",layout:"Layout Settings",rotate:"Rotate",repeat:"Repeat",spacingX:"Horizontal Spacing",spacingY:"Vertical Spacing",startX:"Horizontal Start Position",startY:"Vertical Start Position",cancel:"Cancel Watermark",close:"Close Panel",copy:"Copy Config"}};module.exports=t;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const t={"univer-watermark":{title:"علامت آب",type:"نوع",text:"متن",image:"تصویر",uploadImage:"آپلود تصویر",replaceImage:"جایگزینی تصویر",keepRatio:"حفظ نسبت",width:"عرض",height:"ارتفاع",style:"تنظیمات سبک",content:"محتوا",textPlaceholder:"متن را وارد کنید",fontSize:"اندازه فونت",direction:"جهت",ltr:"چپ به راست",rtl:"راست به چپ",inherits:"ارث بردن",opacity:"شفافیت",layout:"تنظیمات چیدمان",rotate:"چرخاندن",repeat:"تکرار",spacingX:"فاصله افقی",spacingY:"فاصله عمودی",startX:"موقعیت شروع افقی",startY:"موقعیت شروع عمودی",cancel:"لغو علامت آب",close:"بستن پنل",copy:"کپی تنظیمات"}};module.exports=t;
|
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const e={"univer-watermark":{title:"Filigrane",type:"Type",text:"Texte",image:"Image",uploadImage:"Télécharger une image",replaceImage:"Remplacer l'image",keepRatio:"Conserver les proportions",width:"Largeur",height:"Hauteur",style:"Paramètres de style",content:"Contenu",textPlaceholder:"Saisir du texte",fontSize:"Taille de police",direction:"Direction",ltr:"De gauche à droite",rtl:"De droite à gauche",inherits:"Hériter",opacity:"Opacité",layout:"Paramètres de mise en page",rotate:"Rotation",repeat:"Répéter",spacingX:"Espacement horizontal",spacingY:"Espacement vertical",startX:"Position horizontale de départ",startY:"Position verticale de départ",cancel:"Annuler le filigrane",close:"Fermer le panneau",copy:"Copier la configuration"}};module.exports=e;
|
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const t={"univer-watermark":{title:"Водяной знак",type:"Тип",text:"Текст",image:"Изображение",uploadImage:"Загрузить изображение",replaceImage:"Заменить изображение",keepRatio:"Сохранить пропорции",width:"Ширина",height:"Высота",style:"Настройки стиля",content:"Содержание",textPlaceholder:"Введите текст",fontSize:"Размер шрифта",direction:"Направление",ltr:"Слева направо",rtl:"Справа налево",inherits:"Наследовать",opacity:"Прозрачность",layout:"Настройки макета",rotate:"Поворот",repeat:"Повтор",spacingX:"Горизонтальный интервал",spacingY:"Вертикальный интервал",startX:"Горизонтальная начальная позиция",startY:"Вертикальная начальная позиция",cancel:"Отменить водяной знак",close:"Закрыть панель",copy:"Копировать конфигурацию"}};module.exports=t;
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const t={"univer-watermark":{title:"Hình mờ",type:"Loại",text:"Văn bản",image:"Hình ảnh",uploadImage:"Tải lên hình ảnh",replaceImage:"Thay thế hình ảnh",keepRatio:"Giữ tỷ lệ",width:"Chiều rộng",height:"Chiều cao",style:"Cài đặt kiểu",content:"Nội dung",textPlaceholder:"Nhập văn bản",fontSize:"Kích thước phông chữ",direction:"Hướng",ltr:"Trái sang phải",rtl:"Phải sang trái",inherits:"Thừa kế",opacity:"Độ mờ",layout:"Cài đặt bố cục",rotate:"Xoay",repeat:"Lặp lại",spacingX:"Khoảng cách ngang",spacingY:"Khoảng cách dọc",startX:"Vị trí bắt đầu ngang",startY:"Vị trí bắt đầu dọc",cancel:"Hủy hình mờ",close:"Đóng bảng điều khiển",copy:"Sao chép cấu hình"}};module.exports=t;
|
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const t={"univer-watermark":{title:"水印",type:"类型",text:"文本",image:"图片",uploadImage:"上传图片",replaceImage:"替换图片",keepRatio:"保持比例",width:"长度",height:"高度",style:"样式设置",content:"内容",textPlaceholder:"请输入文本",fontSize:"字体大小",direction:"方向",ltr:"从左到右",rtl:"从右到左",inherits:"继承",opacity:"透明度",layout:"布局设置",rotate:"旋转",repeat:"重复",spacingX:"水平间距",spacingY:"垂直间距",startX:"水平起始位置",startY:"垂直起始位置",cancel:"取消水印",close:"关闭面板",copy:"复制配置"}};module.exports=t;
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const t={"univer-watermark":{title:"浮水印",type:"類型",text:"文字",image:"圖片",uploadImage:"上傳圖片",replaceImage:"替換圖片",keepRatio:"保持比例",width:"長度",height:"高度",style:"樣式設置",content:"內容",textPlaceholder:"請輸入文字",fontSize:"字體大小",direction:"方向",ltr:"從左到右",rtl:"從右到左",inherits:"繼承",opacity:"透明度",layout:"佈局設置",rotate:"旋轉",repeat:"重複",spacingX:"水平間距",spacingY:"垂直間距",startX:"水平起始位置",startY:"垂直起始位置",cancel:"取消浮水印",close:"關閉面板",copy:"複製配置"}};module.exports=t;
|
package/lib/es/facade.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
watermarkService.updateWatermarkConfig({
|
|
10
|
-
type: IWatermarkTypeEnum.Text,
|
|
1
|
+
import { FUniver as m } from "@univerjs/core";
|
|
2
|
+
import { WatermarkService as i, IWatermarkTypeEnum as e, WatermarkTextBaseConfig as n, WatermarkImageBaseConfig as o } from "@univerjs/watermark";
|
|
3
|
+
class k extends m {
|
|
4
|
+
addWatermark(r, t) {
|
|
5
|
+
const a = this._injector.get(i);
|
|
6
|
+
if (r === e.Text)
|
|
7
|
+
a.updateWatermarkConfig({
|
|
8
|
+
type: e.Text,
|
|
11
9
|
config: {
|
|
12
10
|
text: {
|
|
13
|
-
...
|
|
14
|
-
...
|
|
11
|
+
...n,
|
|
12
|
+
...t
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
|
-
else if (
|
|
19
|
-
|
|
20
|
-
type:
|
|
16
|
+
else if (r === e.Image)
|
|
17
|
+
a.updateWatermarkConfig({
|
|
18
|
+
type: e.Image,
|
|
21
19
|
config: {
|
|
22
20
|
image: {
|
|
23
|
-
...
|
|
24
|
-
...
|
|
21
|
+
...o,
|
|
22
|
+
...t
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
});
|
|
@@ -30,9 +28,7 @@ const _FUniverWatermarkMixin = class _FUniverWatermarkMixin extends FUniver {
|
|
|
30
28
|
return this;
|
|
31
29
|
}
|
|
32
30
|
deleteWatermark() {
|
|
33
|
-
return this._injector.get(
|
|
31
|
+
return this._injector.get(i).deleteWatermarkConfig(), this;
|
|
34
32
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let FUniverWatermarkMixin = _FUniverWatermarkMixin;
|
|
38
|
-
FUniver.extend(FUniverWatermarkMixin);
|
|
33
|
+
}
|
|
34
|
+
m.extend(k);
|
package/lib/es/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const UNIVER_WATERMARK_STORAGE_KEY = "UNIVER_WATERMARK_STORAGE_KEY", UNIVER_WATERMARK_LAYER_INDEX = 10, WATERMARK_IMAGE_ALLOW_IMAGE_LIST = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], WatermarkTextBaseConfig = {
|
|
1
|
+
var j = Object.defineProperty;
|
|
2
|
+
var N = (e, t, r) => t in e ? j(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var l = (e, t, r) => N(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { Inject as y, ILocalStorageService as $, Disposable as Y, UserManagerService as X, RxDisposable as K, Injector as G, Plugin as V, merge as w, UniverInstanceType as U, IConfigService as H } from "@univerjs/core";
|
|
5
|
+
import { Layer as z, IRenderManagerService as B } from "@univerjs/engine-render";
|
|
6
|
+
import { Subject as T } from "rxjs";
|
|
7
|
+
const h = "UNIVER_WATERMARK_STORAGE_KEY", F = 10, ue = ["image/png", "image/jpeg", "image/jpg", "image/bmp"], q = {
|
|
9
8
|
content: "",
|
|
10
9
|
fontSize: 16,
|
|
11
10
|
color: "rgb(0,0,0)",
|
|
@@ -19,7 +18,7 @@ const UNIVER_WATERMARK_STORAGE_KEY = "UNIVER_WATERMARK_STORAGE_KEY", UNIVER_WATE
|
|
|
19
18
|
spacingY: 100,
|
|
20
19
|
rotate: 0,
|
|
21
20
|
opacity: 0.15
|
|
22
|
-
},
|
|
21
|
+
}, J = {
|
|
23
22
|
url: "",
|
|
24
23
|
width: 100,
|
|
25
24
|
height: 100,
|
|
@@ -32,7 +31,7 @@ const UNIVER_WATERMARK_STORAGE_KEY = "UNIVER_WATERMARK_STORAGE_KEY", UNIVER_WATE
|
|
|
32
31
|
spacingY: 100,
|
|
33
32
|
rotate: 0,
|
|
34
33
|
opacity: 0.15
|
|
35
|
-
},
|
|
34
|
+
}, Q = {
|
|
36
35
|
name: !0,
|
|
37
36
|
email: !1,
|
|
38
37
|
phone: !1,
|
|
@@ -50,30 +49,30 @@ const UNIVER_WATERMARK_STORAGE_KEY = "UNIVER_WATERMARK_STORAGE_KEY", UNIVER_WATE
|
|
|
50
49
|
rotate: -30,
|
|
51
50
|
opacity: 0.15
|
|
52
51
|
};
|
|
53
|
-
var
|
|
54
|
-
const
|
|
55
|
-
var
|
|
56
|
-
for (var
|
|
57
|
-
(
|
|
58
|
-
return
|
|
59
|
-
},
|
|
60
|
-
let
|
|
61
|
-
constructor(
|
|
52
|
+
var f = /* @__PURE__ */ ((e) => (e.UserInfo = "userInfo", e.Text = "text", e.Image = "image", e))(f || {});
|
|
53
|
+
const O = "watermark.config", D = {};
|
|
54
|
+
var Z = Object.defineProperty, x = Object.getOwnPropertyDescriptor, ee = (e, t, r, i) => {
|
|
55
|
+
for (var a = i > 1 ? void 0 : i ? x(t, r) : t, n = e.length - 1, s; n >= 0; n--)
|
|
56
|
+
(s = e[n]) && (a = (i ? s(t, r, a) : s(a)) || a);
|
|
57
|
+
return i && a && Z(t, r, a), a;
|
|
58
|
+
}, te = (e, t) => (r, i) => t(r, i, e);
|
|
59
|
+
let R = class extends Y {
|
|
60
|
+
constructor(t) {
|
|
62
61
|
super();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this._localStorageService =
|
|
62
|
+
l(this, "_updateConfig$", new T());
|
|
63
|
+
l(this, "updateConfig$", this._updateConfig$.asObservable());
|
|
64
|
+
l(this, "_refresh$", new T());
|
|
65
|
+
l(this, "refresh$", this._refresh$.asObservable());
|
|
66
|
+
this._localStorageService = t;
|
|
68
67
|
}
|
|
69
68
|
async getWatermarkConfig() {
|
|
70
|
-
return await this._localStorageService.getItem(
|
|
69
|
+
return await this._localStorageService.getItem(h);
|
|
71
70
|
}
|
|
72
|
-
updateWatermarkConfig(
|
|
73
|
-
this._localStorageService.setItem(
|
|
71
|
+
updateWatermarkConfig(t) {
|
|
72
|
+
this._localStorageService.setItem(h, t), this._updateConfig$.next(t);
|
|
74
73
|
}
|
|
75
74
|
deleteWatermarkConfig() {
|
|
76
|
-
this._localStorageService.removeItem(
|
|
75
|
+
this._localStorageService.removeItem(h), this._updateConfig$.next(null);
|
|
77
76
|
}
|
|
78
77
|
refresh() {
|
|
79
78
|
this._refresh$.next(Math.random());
|
|
@@ -81,203 +80,197 @@ let WatermarkService = (_a = class extends Disposable {
|
|
|
81
80
|
dispose() {
|
|
82
81
|
this._refresh$.complete(), this._updateConfig$.complete();
|
|
83
82
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
],
|
|
88
|
-
function
|
|
89
|
-
const
|
|
90
|
-
|
|
83
|
+
};
|
|
84
|
+
R = ee([
|
|
85
|
+
te(0, y($))
|
|
86
|
+
], R);
|
|
87
|
+
function re(e, t, r, i) {
|
|
88
|
+
const a = t.type, n = t.config;
|
|
89
|
+
a === f.UserInfo && n.userInfo ? ae(e, n.userInfo, i) : a === f.Image && n.image ? ne(e, n.image, r) : a === f.Text && n.text && ie(e, n.text);
|
|
91
90
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!userInfo)
|
|
91
|
+
function ae(e, t, r) {
|
|
92
|
+
const { x: i, y: a, repeat: n, spacingX: s, spacingY: S, rotate: v, opacity: p, name: m, fontSize: I, color: C, bold: W, italic: u, direction: o } = t;
|
|
93
|
+
if (!r)
|
|
96
94
|
return;
|
|
97
|
-
let
|
|
98
|
-
if (
|
|
95
|
+
let c = "";
|
|
96
|
+
if (m && (c += `${r.name} `), !c)
|
|
99
97
|
return;
|
|
100
|
-
|
|
101
|
-
let
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
for (let
|
|
105
|
-
for (let
|
|
106
|
-
|
|
98
|
+
e.save(), e.globalAlpha = p, e.direction = o;
|
|
99
|
+
let d = "";
|
|
100
|
+
if (u && (d += "italic "), W && (d += "bold "), d += `${I}px Arial`, e.font = d, e.fillStyle = C, n) {
|
|
101
|
+
const g = e.canvas.width, _ = e.canvas.height;
|
|
102
|
+
for (let b = a; b < _; b += I + S)
|
|
103
|
+
for (let P = i; P < g; P += e.measureText(c).width + s)
|
|
104
|
+
e.save(), e.translate(P, b), e.rotate(Math.PI / 180 * v), e.fillText(c, 0, 0), e.restore();
|
|
107
105
|
} else
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
e.save(), e.translate(i, a), e.rotate(Math.PI / 180 * v), e.fillText(c, 0, 0), e.restore();
|
|
107
|
+
e.restore();
|
|
110
108
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
ctx.save(), ctx.translate(posX, posY), ctx.rotate(Math.PI / 180 * rotate), ctx.fillText(content, 0, 0), ctx.restore();
|
|
109
|
+
function ie(e, t) {
|
|
110
|
+
const { x: r, y: i, repeat: a, spacingX: n, spacingY: s, rotate: S, opacity: v, content: p, fontSize: m, color: I, bold: C, italic: W, direction: u } = t;
|
|
111
|
+
e.save(), e.globalAlpha = v, e.direction = u;
|
|
112
|
+
let o = "";
|
|
113
|
+
if (W && (o += "italic "), C && (o += "bold "), o += `${m}px Arial`, e.font = o, e.fillStyle = I, p)
|
|
114
|
+
if (a) {
|
|
115
|
+
const c = e.canvas.width, d = e.canvas.height;
|
|
116
|
+
for (let g = i; g < d; g += m + s)
|
|
117
|
+
for (let _ = r; _ < c; _ += e.measureText(p).width + n)
|
|
118
|
+
e.save(), e.translate(_, g), e.rotate(Math.PI / 180 * S), e.fillText(p, 0, 0), e.restore();
|
|
122
119
|
} else
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
e.save(), e.translate(r, i), e.rotate(Math.PI / 180 * S), e.fillText(p, 0, 0), e.restore();
|
|
121
|
+
e.restore();
|
|
125
122
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (!(image != null && image.complete))
|
|
123
|
+
function ne(e, t, r) {
|
|
124
|
+
const { x: i, y: a, repeat: n, spacingX: s, spacingY: S, rotate: v, opacity: p, width: m, height: I, maintainAspectRatio: C, originRatio: W } = t;
|
|
125
|
+
if (!(r != null && r.complete))
|
|
130
126
|
return;
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
const
|
|
135
|
-
for (let
|
|
136
|
-
for (let
|
|
137
|
-
|
|
127
|
+
e.save(), e.globalAlpha = p;
|
|
128
|
+
const u = m, o = C ? m / W : I;
|
|
129
|
+
if (n) {
|
|
130
|
+
const c = e.canvas.width, d = e.canvas.height;
|
|
131
|
+
for (let g = a; g < d; g += o + S)
|
|
132
|
+
for (let _ = i; _ < c; _ += u + s)
|
|
133
|
+
e.save(), e.translate(_, g), e.rotate(Math.PI / 180 * v), e.drawImage(r, 0, 0, u, o), e.restore();
|
|
138
134
|
} else
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
e.save(), e.translate(i, a), e.rotate(Math.PI / 180 * v), e.drawImage(r, 0, 0, u, o), e.restore();
|
|
136
|
+
e.restore();
|
|
141
137
|
}
|
|
142
|
-
|
|
143
|
-
const _WatermarkLayer = class _WatermarkLayer extends Layer {
|
|
138
|
+
class se extends z {
|
|
144
139
|
constructor() {
|
|
145
140
|
super(...arguments);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
l(this, "_config");
|
|
142
|
+
l(this, "_image");
|
|
143
|
+
l(this, "_user");
|
|
149
144
|
}
|
|
150
|
-
render(
|
|
151
|
-
var
|
|
152
|
-
super.render(
|
|
153
|
-
const
|
|
154
|
-
return
|
|
145
|
+
render(r, i = !1) {
|
|
146
|
+
var n;
|
|
147
|
+
super.render(r, i);
|
|
148
|
+
const a = r || ((n = this.scene.getEngine()) == null ? void 0 : n.getCanvas().getContext());
|
|
149
|
+
return a && a.getId() && this._renderWatermark(a), this;
|
|
155
150
|
}
|
|
156
|
-
updateConfig(
|
|
157
|
-
var
|
|
158
|
-
this._config =
|
|
151
|
+
updateConfig(r, i) {
|
|
152
|
+
var a;
|
|
153
|
+
this._config = r, ((a = this._config) == null ? void 0 : a.type) === f.Image && this._config.config.image && (this._image = new Image(), this._image.src = this._config.config.image.url), i && (this._user = i);
|
|
159
154
|
}
|
|
160
|
-
_renderWatermark(
|
|
161
|
-
this._config &&
|
|
155
|
+
_renderWatermark(r) {
|
|
156
|
+
this._config && re(r, this._config, this._image, this._user);
|
|
162
157
|
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
let WatermarkRenderController = (_a2 = class extends RxDisposable {
|
|
172
|
-
constructor(_context, _watermarkService, _localStorageService, _userManagerService) {
|
|
158
|
+
}
|
|
159
|
+
var oe = Object.defineProperty, le = Object.getOwnPropertyDescriptor, fe = (e, t, r, i) => {
|
|
160
|
+
for (var a = i > 1 ? void 0 : i ? le(t, r) : t, n = e.length - 1, s; n >= 0; n--)
|
|
161
|
+
(s = e[n]) && (a = (i ? s(t, r, a) : s(a)) || a);
|
|
162
|
+
return i && a && oe(t, r, a), a;
|
|
163
|
+
}, M = (e, t) => (r, i) => t(r, i, e);
|
|
164
|
+
let k = class extends K {
|
|
165
|
+
constructor(t, r, i, a) {
|
|
173
166
|
super();
|
|
174
|
-
|
|
175
|
-
this._context =
|
|
167
|
+
l(this, "_watermarkLayer");
|
|
168
|
+
this._context = t, this._watermarkService = r, this._localStorageService = i, this._userManagerService = a, this._watermarkLayer = new se(t.scene, [], F), this._initAddRender(), this._initWatermarkUpdate(), this._initWatermarkConfig();
|
|
176
169
|
}
|
|
177
170
|
_initAddRender() {
|
|
178
|
-
const { scene } = this._context;
|
|
179
|
-
|
|
171
|
+
const { scene: t } = this._context;
|
|
172
|
+
t.addLayer(this._watermarkLayer);
|
|
180
173
|
}
|
|
181
174
|
async _initWatermarkConfig() {
|
|
182
|
-
var
|
|
183
|
-
const
|
|
184
|
-
|
|
175
|
+
var r;
|
|
176
|
+
const t = await this._localStorageService.getItem(h);
|
|
177
|
+
t && (this._watermarkService.updateWatermarkConfig(t), (r = this._context.mainComponent) == null || r.makeDirty());
|
|
185
178
|
}
|
|
186
179
|
_initWatermarkUpdate() {
|
|
187
180
|
this.disposeWithMe(
|
|
188
|
-
this._watermarkService.updateConfig$.subscribe((
|
|
189
|
-
var
|
|
190
|
-
if (!
|
|
191
|
-
this._watermarkLayer.updateConfig(), (
|
|
181
|
+
this._watermarkService.updateConfig$.subscribe((t) => {
|
|
182
|
+
var r, i;
|
|
183
|
+
if (!t) {
|
|
184
|
+
this._watermarkLayer.updateConfig(), (r = this._context.mainComponent) == null || r.makeDirty();
|
|
192
185
|
return;
|
|
193
186
|
}
|
|
194
|
-
|
|
187
|
+
t.type === f.UserInfo ? this._watermarkLayer.updateConfig(t, this._userManagerService.getCurrentUser()) : this._watermarkLayer.updateConfig(t), (i = this._context.mainComponent) == null || i.makeDirty();
|
|
195
188
|
})
|
|
196
189
|
);
|
|
197
190
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
],
|
|
204
|
-
var
|
|
205
|
-
for (var
|
|
206
|
-
(
|
|
207
|
-
return
|
|
208
|
-
},
|
|
209
|
-
const
|
|
210
|
-
var
|
|
211
|
-
let
|
|
212
|
-
constructor(
|
|
213
|
-
super(), this._config =
|
|
214
|
-
const { ...
|
|
191
|
+
};
|
|
192
|
+
k = fe([
|
|
193
|
+
M(1, y(R)),
|
|
194
|
+
M(2, y($)),
|
|
195
|
+
M(3, y(X))
|
|
196
|
+
], k);
|
|
197
|
+
var ce = Object.defineProperty, ge = Object.getOwnPropertyDescriptor, _e = (e, t, r, i) => {
|
|
198
|
+
for (var a = i > 1 ? void 0 : i ? ge(t, r) : t, n = e.length - 1, s; n >= 0; n--)
|
|
199
|
+
(s = e[n]) && (a = (i ? s(t, r, a) : s(a)) || a);
|
|
200
|
+
return i && a && ce(t, r, a), a;
|
|
201
|
+
}, A = (e, t) => (r, i) => t(r, i, e);
|
|
202
|
+
const he = "UNIVER_WATERMARK_PLUGIN";
|
|
203
|
+
var E;
|
|
204
|
+
let L = (E = class extends V {
|
|
205
|
+
constructor(e = D, t, r, i, a) {
|
|
206
|
+
super(), this._config = e, this._injector = t, this._configService = r, this._renderManagerSrv = i, this._localStorageService = a;
|
|
207
|
+
const { ...n } = w(
|
|
215
208
|
{},
|
|
216
|
-
|
|
209
|
+
D,
|
|
217
210
|
this._config
|
|
218
211
|
);
|
|
219
|
-
this._configService.setConfig(
|
|
212
|
+
this._configService.setConfig(O, n), this._initWatermarkStorage(), this._initDependencies();
|
|
220
213
|
}
|
|
221
214
|
async _initWatermarkStorage() {
|
|
222
|
-
const
|
|
223
|
-
if (!
|
|
215
|
+
const e = this._configService.getConfig(O);
|
|
216
|
+
if (!e)
|
|
224
217
|
return;
|
|
225
|
-
const { userWatermarkSettings, textWatermarkSettings, imageWatermarkSettings } =
|
|
226
|
-
if (
|
|
227
|
-
this._localStorageService.setItem(
|
|
228
|
-
type:
|
|
218
|
+
const { userWatermarkSettings: t, textWatermarkSettings: r, imageWatermarkSettings: i } = e;
|
|
219
|
+
if (t)
|
|
220
|
+
this._localStorageService.setItem(h, {
|
|
221
|
+
type: f.UserInfo,
|
|
229
222
|
config: {
|
|
230
|
-
userInfo:
|
|
223
|
+
userInfo: w({}, Q, t)
|
|
231
224
|
}
|
|
232
225
|
});
|
|
233
|
-
else if (
|
|
234
|
-
this._localStorageService.setItem(
|
|
235
|
-
type:
|
|
226
|
+
else if (r)
|
|
227
|
+
this._localStorageService.setItem(h, {
|
|
228
|
+
type: f.Text,
|
|
236
229
|
config: {
|
|
237
|
-
text:
|
|
230
|
+
text: w({}, q, r)
|
|
238
231
|
}
|
|
239
232
|
});
|
|
240
|
-
else if (
|
|
241
|
-
this._localStorageService.setItem(
|
|
242
|
-
type:
|
|
233
|
+
else if (i)
|
|
234
|
+
this._localStorageService.setItem(h, {
|
|
235
|
+
type: f.Image,
|
|
243
236
|
config: {
|
|
244
|
-
image:
|
|
237
|
+
image: w({}, J, i)
|
|
245
238
|
}
|
|
246
239
|
});
|
|
247
240
|
else {
|
|
248
|
-
const
|
|
249
|
-
(
|
|
241
|
+
const a = await this._localStorageService.getItem(h);
|
|
242
|
+
(a == null ? void 0 : a.type) === f.UserInfo && this._localStorageService.removeItem(h);
|
|
250
243
|
}
|
|
251
244
|
}
|
|
252
245
|
_initDependencies() {
|
|
253
|
-
[[
|
|
254
|
-
this._injector.add(
|
|
246
|
+
[[R]].forEach((e) => {
|
|
247
|
+
this._injector.add(e);
|
|
255
248
|
});
|
|
256
249
|
}
|
|
257
250
|
onRendered() {
|
|
258
|
-
this._injector.get(
|
|
251
|
+
this._injector.get(R), this._initRenderDependencies();
|
|
259
252
|
}
|
|
260
253
|
_initRenderDependencies() {
|
|
261
254
|
[
|
|
262
|
-
[
|
|
263
|
-
].forEach((
|
|
264
|
-
this._renderManagerSrv.registerRenderModule(
|
|
255
|
+
[k]
|
|
256
|
+
].forEach((e) => {
|
|
257
|
+
this._renderManagerSrv.registerRenderModule(U.UNIVER_SHEET, e), this._renderManagerSrv.registerRenderModule(U.UNIVER_DOC, e);
|
|
265
258
|
});
|
|
266
259
|
}
|
|
267
|
-
},
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
],
|
|
260
|
+
}, l(E, "pluginName", he), E);
|
|
261
|
+
L = _e([
|
|
262
|
+
A(1, y(G)),
|
|
263
|
+
A(2, H),
|
|
264
|
+
A(3, B),
|
|
265
|
+
A(4, y($))
|
|
266
|
+
], L);
|
|
274
267
|
export {
|
|
275
|
-
IWatermarkTypeEnum,
|
|
276
|
-
UNIVER_WATERMARK_STORAGE_KEY,
|
|
277
|
-
UniverWatermarkPlugin,
|
|
278
|
-
WATERMARK_IMAGE_ALLOW_IMAGE_LIST,
|
|
279
|
-
WatermarkImageBaseConfig,
|
|
280
|
-
WatermarkService,
|
|
281
|
-
WatermarkTextBaseConfig,
|
|
282
|
-
WatermarkUserInfoBaseConfig
|
|
268
|
+
f as IWatermarkTypeEnum,
|
|
269
|
+
h as UNIVER_WATERMARK_STORAGE_KEY,
|
|
270
|
+
L as UniverWatermarkPlugin,
|
|
271
|
+
ue as WATERMARK_IMAGE_ALLOW_IMAGE_LIST,
|
|
272
|
+
J as WatermarkImageBaseConfig,
|
|
273
|
+
R as WatermarkService,
|
|
274
|
+
q as WatermarkTextBaseConfig,
|
|
275
|
+
Q as WatermarkUserInfoBaseConfig
|
|
283
276
|
};
|
package/lib/es/locale/en-US.js
CHANGED
package/lib/es/locale/fa-IR.js
CHANGED
package/lib/es/locale/fr-FR.js
CHANGED
package/lib/es/locale/ru-RU.js
CHANGED
package/lib/es/locale/vi-VN.js
CHANGED
package/lib/es/locale/zh-CN.js
CHANGED
package/lib/es/locale/zh-TW.js
CHANGED
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(r,e){typeof exports=="object"&&typeof module<"u"?e(require("@univerjs/core"),require("@univerjs/watermark")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/watermark"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.UniverCore,r.UniverWatermark))})(this,function(r,e){"use strict";class a extends r.FUniver{addWatermark(t,i){const n=this._injector.get(e.WatermarkService);if(t===e.IWatermarkTypeEnum.Text)n.updateWatermarkConfig({type:e.IWatermarkTypeEnum.Text,config:{text:{...e.WatermarkTextBaseConfig,...i}}});else if(t===e.IWatermarkTypeEnum.Image)n.updateWatermarkConfig({type:e.IWatermarkTypeEnum.Image,config:{image:{...e.WatermarkImageBaseConfig,...i}}});else throw new Error("Unknown watermark type");return this}deleteWatermark(){return this._injector.get(e.WatermarkService).deleteWatermarkConfig(),this}}r.FUniver.extend(a)});
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","rxjs"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverWatermark={},global.UniverCore,global.UniverEngineRender,global.rxjs))})(this,function(exports2,core,engineRender,rxjs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c;const UNIVER_WATERMARK_STORAGE_KEY="UNIVER_WATERMARK_STORAGE_KEY",WATERMARK_IMAGE_ALLOW_IMAGE_LIST=["image/png","image/jpeg","image/jpg","image/bmp"],WatermarkTextBaseConfig={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},WatermarkImageBaseConfig={url:"",width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},WatermarkUserInfoBaseConfig={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};var IWatermarkTypeEnum=(IWatermarkTypeEnum2=>(IWatermarkTypeEnum2.UserInfo="userInfo",IWatermarkTypeEnum2.Text="text",IWatermarkTypeEnum2.Image="image",IWatermarkTypeEnum2))(IWatermarkTypeEnum||{});const WATERMARK_PLUGIN_CONFIG_KEY="watermark.config",defaultPluginConfig={};var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");exports2.WatermarkService=(_a=class extends core.Disposable{constructor(_localStorageService){super();__publicField(this,"_updateConfig$",new rxjs.Subject);__publicField(this,"updateConfig$",this._updateConfig$.asObservable());__publicField(this,"_refresh$",new rxjs.Subject);__publicField(this,"refresh$",this._refresh$.asObservable());this._localStorageService=_localStorageService}async getWatermarkConfig(){return await this._localStorageService.getItem(UNIVER_WATERMARK_STORAGE_KEY)}updateWatermarkConfig(config){this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY,config),this._updateConfig$.next(config)}deleteWatermarkConfig(){this._localStorageService.removeItem(UNIVER_WATERMARK_STORAGE_KEY),this._updateConfig$.next(null)}refresh(){this._refresh$.next(Math.random())}dispose(){this._refresh$.complete(),this._updateConfig$.complete()}},__name(_a,"WatermarkService"),_a),exports2.WatermarkService=__decorateClass$2([__decorateParam$2(0,core.Inject(core.ILocalStorageService))],exports2.WatermarkService);function renderWatermark(ctx,config,image,userInfo){const type=config.type,watermarkConfig=config.config;type===IWatermarkTypeEnum.UserInfo&&watermarkConfig.userInfo?renderUserInfoWatermark(ctx,watermarkConfig.userInfo,userInfo):type===IWatermarkTypeEnum.Image&&watermarkConfig.image?renderImageWatermark(ctx,watermarkConfig.image,image):type===IWatermarkTypeEnum.Text&&watermarkConfig.text&&renderTextWatermark(ctx,watermarkConfig.text)}__name(renderWatermark,"renderWatermark");function renderUserInfoWatermark(ctx,config,userInfo){const{x,y,repeat,spacingX,spacingY,rotate,opacity,name,fontSize,color,bold,italic,direction}=config;if(!userInfo)return;let watermarkContent="";if(name&&(watermarkContent+=`${userInfo.name} `),!watermarkContent)return;ctx.save(),ctx.globalAlpha=opacity,ctx.direction=direction;let fontStyle="";if(italic&&(fontStyle+="italic "),bold&&(fontStyle+="bold "),fontStyle+=`${fontSize}px Arial`,ctx.font=fontStyle,ctx.fillStyle=color,repeat){const canvasWidth=ctx.canvas.width,canvasHeight=ctx.canvas.height;for(let posY=y;posY<canvasHeight;posY+=fontSize+spacingY)for(let posX=x;posX<canvasWidth;posX+=ctx.measureText(watermarkContent).width+spacingX)ctx.save(),ctx.translate(posX,posY),ctx.rotate(Math.PI/180*rotate),ctx.fillText(watermarkContent,0,0),ctx.restore()}else ctx.save(),ctx.translate(x,y),ctx.rotate(Math.PI/180*rotate),ctx.fillText(watermarkContent,0,0),ctx.restore();ctx.restore()}__name(renderUserInfoWatermark,"renderUserInfoWatermark");function renderTextWatermark(ctx,config){const{x,y,repeat,spacingX,spacingY,rotate,opacity,content,fontSize,color,bold,italic,direction}=config;ctx.save(),ctx.globalAlpha=opacity,ctx.direction=direction;let fontStyle="";if(italic&&(fontStyle+="italic "),bold&&(fontStyle+="bold "),fontStyle+=`${fontSize}px Arial`,ctx.font=fontStyle,ctx.fillStyle=color,content)if(repeat){const canvasWidth=ctx.canvas.width,canvasHeight=ctx.canvas.height;for(let posY=y;posY<canvasHeight;posY+=fontSize+spacingY)for(let posX=x;posX<canvasWidth;posX+=ctx.measureText(content).width+spacingX)ctx.save(),ctx.translate(posX,posY),ctx.rotate(Math.PI/180*rotate),ctx.fillText(content,0,0),ctx.restore()}else ctx.save(),ctx.translate(x,y),ctx.rotate(Math.PI/180*rotate),ctx.fillText(content,0,0),ctx.restore();ctx.restore()}__name(renderTextWatermark,"renderTextWatermark");function renderImageWatermark(ctx,config,image){const{x,y,repeat,spacingX,spacingY,rotate,opacity,width,height,maintainAspectRatio,originRatio}=config;if(!(image!=null&&image.complete))return;ctx.save(),ctx.globalAlpha=opacity;const actualWidth=width,actualHeight=maintainAspectRatio?width/originRatio:height;if(repeat){const canvasWidth=ctx.canvas.width,canvasHeight=ctx.canvas.height;for(let posY=y;posY<canvasHeight;posY+=actualHeight+spacingY)for(let posX=x;posX<canvasWidth;posX+=actualWidth+spacingX)ctx.save(),ctx.translate(posX,posY),ctx.rotate(Math.PI/180*rotate),ctx.drawImage(image,0,0,actualWidth,actualHeight),ctx.restore()}else ctx.save(),ctx.translate(x,y),ctx.rotate(Math.PI/180*rotate),ctx.drawImage(image,0,0,actualWidth,actualHeight),ctx.restore();ctx.restore()}__name(renderImageWatermark,"renderImageWatermark");const _WatermarkLayer=class _WatermarkLayer extends engineRender.Layer{constructor(){super(...arguments);__publicField(this,"_config");__publicField(this,"_image");__publicField(this,"_user")}render(ctx,isMaxLayer=!1){var _a2;super.render(ctx,isMaxLayer);const mainCtx=ctx||((_a2=this.scene.getEngine())==null?void 0:_a2.getCanvas().getContext());return mainCtx&&mainCtx.getId()&&this._renderWatermark(mainCtx),this}updateConfig(config,user){var _a2;this._config=config,((_a2=this._config)==null?void 0:_a2.type)===IWatermarkTypeEnum.Image&&this._config.config.image&&(this._image=new Image,this._image.src=this._config.config.image.url),user&&(this._user=user)}_renderWatermark(ctx){this._config&&renderWatermark(ctx,this._config,this._image,this._user)}};__name(_WatermarkLayer,"WatermarkLayer");let WatermarkLayer=_WatermarkLayer;var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let WatermarkRenderController=(_b=class extends core.RxDisposable{constructor(_context,_watermarkService,_localStorageService,_userManagerService){super();__publicField(this,"_watermarkLayer");this._context=_context,this._watermarkService=_watermarkService,this._localStorageService=_localStorageService,this._userManagerService=_userManagerService,this._watermarkLayer=new WatermarkLayer(_context.scene,[],10),this._initAddRender(),this._initWatermarkUpdate(),this._initWatermarkConfig()}_initAddRender(){const{scene}=this._context;scene.addLayer(this._watermarkLayer)}async _initWatermarkConfig(){var _a2;const config=await this._localStorageService.getItem(UNIVER_WATERMARK_STORAGE_KEY);config&&(this._watermarkService.updateWatermarkConfig(config),(_a2=this._context.mainComponent)==null||_a2.makeDirty())}_initWatermarkUpdate(){this.disposeWithMe(this._watermarkService.updateConfig$.subscribe(_config=>{var _a2,_b2;if(!_config){this._watermarkLayer.updateConfig(),(_a2=this._context.mainComponent)==null||_a2.makeDirty();return}_config.type===IWatermarkTypeEnum.UserInfo?this._watermarkLayer.updateConfig(_config,this._userManagerService.getCurrentUser()):this._watermarkLayer.updateConfig(_config),(_b2=this._context.mainComponent)==null||_b2.makeDirty()}))}},__name(_b,"WatermarkRenderController"),_b);WatermarkRenderController=__decorateClass$1([__decorateParam$1(1,core.Inject(exports2.WatermarkService)),__decorateParam$1(2,core.Inject(core.ILocalStorageService)),__decorateParam$1(3,core.Inject(core.UserManagerService))],WatermarkRenderController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");const PLUGIN_NAME="UNIVER_WATERMARK_PLUGIN";exports2.UniverWatermarkPlugin=(_c=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService,_renderManagerSrv,_localStorageService){super(),this._config=_config,this._injector=_injector,this._configService=_configService,this._renderManagerSrv=_renderManagerSrv,this._localStorageService=_localStorageService;const{...rest}=core.merge({},defaultPluginConfig,this._config);this._configService.setConfig(WATERMARK_PLUGIN_CONFIG_KEY,rest),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){const config=this._configService.getConfig(WATERMARK_PLUGIN_CONFIG_KEY);if(!config)return;const{userWatermarkSettings,textWatermarkSettings,imageWatermarkSettings}=config;if(userWatermarkSettings)this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY,{type:IWatermarkTypeEnum.UserInfo,config:{userInfo:core.merge({},WatermarkUserInfoBaseConfig,userWatermarkSettings)}});else if(textWatermarkSettings)this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY,{type:IWatermarkTypeEnum.Text,config:{text:core.merge({},WatermarkTextBaseConfig,textWatermarkSettings)}});else if(imageWatermarkSettings)this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY,{type:IWatermarkTypeEnum.Image,config:{image:core.merge({},WatermarkImageBaseConfig,imageWatermarkSettings)}});else{const config2=await this._localStorageService.getItem(UNIVER_WATERMARK_STORAGE_KEY);(config2==null?void 0:config2.type)===IWatermarkTypeEnum.UserInfo&&this._localStorageService.removeItem(UNIVER_WATERMARK_STORAGE_KEY)}}_initDependencies(){[[exports2.WatermarkService]].forEach(d=>{this._injector.add(d)})}onRendered(){this._injector.get(exports2.WatermarkService),this._initRenderDependencies()}_initRenderDependencies(){[[WatermarkRenderController]].forEach(d=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_SHEET,d),this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,d)})}},__name(_c,"UniverWatermarkPlugin"),__publicField(_c,"pluginName",PLUGIN_NAME),_c),exports2.UniverWatermarkPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService),__decorateParam(3,engineRender.IRenderManagerService),__decorateParam(4,core.Inject(core.ILocalStorageService))],exports2.UniverWatermarkPlugin),exports2.IWatermarkTypeEnum=IWatermarkTypeEnum,exports2.UNIVER_WATERMARK_STORAGE_KEY=UNIVER_WATERMARK_STORAGE_KEY,exports2.WATERMARK_IMAGE_ALLOW_IMAGE_LIST=WATERMARK_IMAGE_ALLOW_IMAGE_LIST,exports2.WatermarkImageBaseConfig=WatermarkImageBaseConfig,exports2.WatermarkTextBaseConfig=WatermarkTextBaseConfig,exports2.WatermarkUserInfoBaseConfig=WatermarkUserInfoBaseConfig,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(o,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","rxjs"],n):(o=typeof globalThis<"u"?globalThis:o||self,n(o.UniverWatermark={},o.UniverCore,o.UniverEngineRender,o.rxjs))})(this,function(o,n,S,T){"use strict";var te=Object.defineProperty;var re=(o,n,S)=>n in o?te(o,n,{enumerable:!0,configurable:!0,writable:!0,value:S}):o[n]=S;var _=(o,n,S)=>re(o,typeof n!="symbol"?n+"":n,S);var M;const l="UNIVER_WATERMARK_STORAGE_KEY",D=["image/png","image/jpeg","image/jpg","image/bmp"],j={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},b={url:"",width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},L={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};var g=(e=>(e.UserInfo="userInfo",e.Text="text",e.Image="image",e))(g||{});const $="watermark.config",O={};var N=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,K=(e,r,t,i)=>{for(var a=i>1?void 0:i?Y(r,t):r,s=e.length-1,f;s>=0;s--)(f=e[s])&&(a=(i?f(r,t,a):f(a))||a);return i&&a&&N(r,t,a),a},G=(e,r)=>(t,i)=>r(t,i,e);o.WatermarkService=class extends n.Disposable{constructor(t){super();_(this,"_updateConfig$",new T.Subject);_(this,"updateConfig$",this._updateConfig$.asObservable());_(this,"_refresh$",new T.Subject);_(this,"refresh$",this._refresh$.asObservable());this._localStorageService=t}async getWatermarkConfig(){return await this._localStorageService.getItem(l)}updateWatermarkConfig(t){this._localStorageService.setItem(l,t),this._updateConfig$.next(t)}deleteWatermarkConfig(){this._localStorageService.removeItem(l),this._updateConfig$.next(null)}refresh(){this._refresh$.next(Math.random())}dispose(){this._refresh$.complete(),this._updateConfig$.complete()}},o.WatermarkService=K([G(0,n.Inject(n.ILocalStorageService))],o.WatermarkService);function X(e,r,t,i){const a=r.type,s=r.config;a===g.UserInfo&&s.userInfo?V(e,s.userInfo,i):a===g.Image&&s.image?H(e,s.image,t):a===g.Text&&s.text&&B(e,s.text)}function V(e,r,t){const{x:i,y:a,repeat:s,spacingX:f,spacingY:R,rotate:I,opacity:v,name:p,fontSize:y,color:C,bold:A,italic:W,direction:c}=r;if(!t)return;let h="";if(p&&(h+=`${t.name} `),!h)return;e.save(),e.globalAlpha=v,e.direction=c;let u="";if(W&&(u+="italic "),A&&(u+="bold "),u+=`${y}px Arial`,e.font=u,e.fillStyle=C,s){const m=e.canvas.width,d=e.canvas.height;for(let U=a;U<d;U+=y+R)for(let P=i;P<m;P+=e.measureText(h).width+f)e.save(),e.translate(P,U),e.rotate(Math.PI/180*I),e.fillText(h,0,0),e.restore()}else e.save(),e.translate(i,a),e.rotate(Math.PI/180*I),e.fillText(h,0,0),e.restore();e.restore()}function B(e,r){const{x:t,y:i,repeat:a,spacingX:s,spacingY:f,rotate:R,opacity:I,content:v,fontSize:p,color:y,bold:C,italic:A,direction:W}=r;e.save(),e.globalAlpha=I,e.direction=W;let c="";if(A&&(c+="italic "),C&&(c+="bold "),c+=`${p}px Arial`,e.font=c,e.fillStyle=y,v)if(a){const h=e.canvas.width,u=e.canvas.height;for(let m=i;m<u;m+=p+f)for(let d=t;d<h;d+=e.measureText(v).width+s)e.save(),e.translate(d,m),e.rotate(Math.PI/180*R),e.fillText(v,0,0),e.restore()}else e.save(),e.translate(t,i),e.rotate(Math.PI/180*R),e.fillText(v,0,0),e.restore();e.restore()}function H(e,r,t){const{x:i,y:a,repeat:s,spacingX:f,spacingY:R,rotate:I,opacity:v,width:p,height:y,maintainAspectRatio:C,originRatio:A}=r;if(!(t!=null&&t.complete))return;e.save(),e.globalAlpha=v;const W=p,c=C?p/A:y;if(s){const h=e.canvas.width,u=e.canvas.height;for(let m=a;m<u;m+=c+R)for(let d=i;d<h;d+=W+f)e.save(),e.translate(d,m),e.rotate(Math.PI/180*I),e.drawImage(t,0,0,W,c),e.restore()}else e.save(),e.translate(i,a),e.rotate(Math.PI/180*I),e.drawImage(t,0,0,W,c),e.restore();e.restore()}class z extends S.Layer{constructor(){super(...arguments);_(this,"_config");_(this,"_image");_(this,"_user")}render(t,i=!1){var s;super.render(t,i);const a=t||((s=this.scene.getEngine())==null?void 0:s.getCanvas().getContext());return a&&a.getId()&&this._renderWatermark(a),this}updateConfig(t,i){var a;this._config=t,((a=this._config)==null?void 0:a.type)===g.Image&&this._config.config.image&&(this._image=new Image,this._image.src=this._config.config.image.url),i&&(this._user=i)}_renderWatermark(t){this._config&&X(t,this._config,this._image,this._user)}}var q=Object.defineProperty,F=Object.getOwnPropertyDescriptor,J=(e,r,t,i)=>{for(var a=i>1?void 0:i?F(r,t):r,s=e.length-1,f;s>=0;s--)(f=e[s])&&(a=(i?f(r,t,a):f(a))||a);return i&&a&&q(r,t,a),a},E=(e,r)=>(t,i)=>r(t,i,e);let w=class extends n.RxDisposable{constructor(r,t,i,a){super();_(this,"_watermarkLayer");this._context=r,this._watermarkService=t,this._localStorageService=i,this._userManagerService=a,this._watermarkLayer=new z(r.scene,[],10),this._initAddRender(),this._initWatermarkUpdate(),this._initWatermarkConfig()}_initAddRender(){const{scene:r}=this._context;r.addLayer(this._watermarkLayer)}async _initWatermarkConfig(){var t;const r=await this._localStorageService.getItem(l);r&&(this._watermarkService.updateWatermarkConfig(r),(t=this._context.mainComponent)==null||t.makeDirty())}_initWatermarkUpdate(){this.disposeWithMe(this._watermarkService.updateConfig$.subscribe(r=>{var t,i;if(!r){this._watermarkLayer.updateConfig(),(t=this._context.mainComponent)==null||t.makeDirty();return}r.type===g.UserInfo?this._watermarkLayer.updateConfig(r,this._userManagerService.getCurrentUser()):this._watermarkLayer.updateConfig(r),(i=this._context.mainComponent)==null||i.makeDirty()}))}};w=J([E(1,n.Inject(o.WatermarkService)),E(2,n.Inject(n.ILocalStorageService)),E(3,n.Inject(n.UserManagerService))],w);var Q=Object.defineProperty,Z=Object.getOwnPropertyDescriptor,x=(e,r,t,i)=>{for(var a=i>1?void 0:i?Z(r,t):r,s=e.length-1,f;s>=0;s--)(f=e[s])&&(a=(i?f(r,t,a):f(a))||a);return i&&a&&Q(r,t,a),a},k=(e,r)=>(t,i)=>r(t,i,e);const ee="UNIVER_WATERMARK_PLUGIN";o.UniverWatermarkPlugin=(M=class extends n.Plugin{constructor(r=O,t,i,a,s){super(),this._config=r,this._injector=t,this._configService=i,this._renderManagerSrv=a,this._localStorageService=s;const{...f}=n.merge({},O,this._config);this._configService.setConfig($,f),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){const r=this._configService.getConfig($);if(!r)return;const{userWatermarkSettings:t,textWatermarkSettings:i,imageWatermarkSettings:a}=r;if(t)this._localStorageService.setItem(l,{type:g.UserInfo,config:{userInfo:n.merge({},L,t)}});else if(i)this._localStorageService.setItem(l,{type:g.Text,config:{text:n.merge({},j,i)}});else if(a)this._localStorageService.setItem(l,{type:g.Image,config:{image:n.merge({},b,a)}});else{const s=await this._localStorageService.getItem(l);(s==null?void 0:s.type)===g.UserInfo&&this._localStorageService.removeItem(l)}}_initDependencies(){[[o.WatermarkService]].forEach(r=>{this._injector.add(r)})}onRendered(){this._injector.get(o.WatermarkService),this._initRenderDependencies()}_initRenderDependencies(){[[w]].forEach(r=>{this._renderManagerSrv.registerRenderModule(n.UniverInstanceType.UNIVER_SHEET,r),this._renderManagerSrv.registerRenderModule(n.UniverInstanceType.UNIVER_DOC,r)})}},_(M,"pluginName",ee),M),o.UniverWatermarkPlugin=x([k(1,n.Inject(n.Injector)),k(2,n.IConfigService),k(3,S.IRenderManagerService),k(4,n.Inject(n.ILocalStorageService))],o.UniverWatermarkPlugin),o.IWatermarkTypeEnum=g,o.UNIVER_WATERMARK_STORAGE_KEY=l,o.WATERMARK_IMAGE_ALLOW_IMAGE_LIST=D,o.WatermarkImageBaseConfig=b,o.WatermarkTextBaseConfig=j,o.WatermarkUserInfoBaseConfig=L,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/lib/umd/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverWatermarkEnUS=t())})(this,function(){"use strict";return{"univer-watermark":{title:"Watermark",type:"Type",text:"Text",image:"Image",uploadImage:"Upload Image",replaceImage:"Replace Image",keepRatio:"Keep Ratio",width:"Width",height:"Height",style:"Style Settings",content:"Content",textPlaceholder:"Enter text",fontSize:"Font Size",direction:"Direction",ltr:"Left to Right",rtl:"Right to Left",inherits:"Inherit",opacity:"Opacity",layout:"Layout Settings",rotate:"Rotate",repeat:"Repeat",spacingX:"Horizontal Spacing",spacingY:"Vertical Spacing",startX:"Horizontal Start Position",startY:"Vertical Start Position",cancel:"Cancel Watermark",close:"Close Panel",copy:"Copy Config"}}});
|
package/lib/umd/locale/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverWatermarkFaIR=t())})(this,function(){"use strict";return{"univer-watermark":{title:"علامت آب",type:"نوع",text:"متن",image:"تصویر",uploadImage:"آپلود تصویر",replaceImage:"جایگزینی تصویر",keepRatio:"حفظ نسبت",width:"عرض",height:"ارتفاع",style:"تنظیمات سبک",content:"محتوا",textPlaceholder:"متن را وارد کنید",fontSize:"اندازه فونت",direction:"جهت",ltr:"چپ به راست",rtl:"راست به چپ",inherits:"ارث بردن",opacity:"شفافیت",layout:"تنظیمات چیدمان",rotate:"چرخاندن",repeat:"تکرار",spacingX:"فاصله افقی",spacingY:"فاصله عمودی",startX:"موقعیت شروع افقی",startY:"موقعیت شروع عمودی",cancel:"لغو علامت آب",close:"بستن پنل",copy:"کپی تنظیمات"}}});
|
package/lib/umd/locale/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverWatermarkFrFR=t())})(this,function(){"use strict";return{"univer-watermark":{title:"Filigrane",type:"Type",text:"Texte",image:"Image",uploadImage:"Télécharger une image",replaceImage:"Remplacer l'image",keepRatio:"Conserver les proportions",width:"Largeur",height:"Hauteur",style:"Paramètres de style",content:"Contenu",textPlaceholder:"Saisir du texte",fontSize:"Taille de police",direction:"Direction",ltr:"De gauche à droite",rtl:"De droite à gauche",inherits:"Hériter",opacity:"Opacité",layout:"Paramètres de mise en page",rotate:"Rotation",repeat:"Répéter",spacingX:"Espacement horizontal",spacingY:"Espacement vertical",startX:"Position horizontale de départ",startY:"Position verticale de départ",cancel:"Annuler le filigrane",close:"Fermer le panneau",copy:"Copier la configuration"}}});
|
package/lib/umd/locale/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverWatermarkRuRU=t())})(this,function(){"use strict";return{"univer-watermark":{title:"Водяной знак",type:"Тип",text:"Текст",image:"Изображение",uploadImage:"Загрузить изображение",replaceImage:"Заменить изображение",keepRatio:"Сохранить пропорции",width:"Ширина",height:"Высота",style:"Настройки стиля",content:"Содержание",textPlaceholder:"Введите текст",fontSize:"Размер шрифта",direction:"Направление",ltr:"Слева направо",rtl:"Справа налево",inherits:"Наследовать",opacity:"Прозрачность",layout:"Настройки макета",rotate:"Поворот",repeat:"Повтор",spacingX:"Горизонтальный интервал",spacingY:"Вертикальный интервал",startX:"Горизонтальная начальная позиция",startY:"Вертикальная начальная позиция",cancel:"Отменить водяной знак",close:"Закрыть панель",copy:"Копировать конфигурацию"}}});
|
package/lib/umd/locale/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(n,e){typeof exports=="object"&&typeof module<"u"?module.exports=e():typeof define=="function"&&define.amd?define(e):(n=typeof globalThis<"u"?globalThis:n||self,n.UniverWatermarkViVN=e())})(this,function(){"use strict";return{"univer-watermark":{title:"Hình mờ",type:"Loại",text:"Văn bản",image:"Hình ảnh",uploadImage:"Tải lên hình ảnh",replaceImage:"Thay thế hình ảnh",keepRatio:"Giữ tỷ lệ",width:"Chiều rộng",height:"Chiều cao",style:"Cài đặt kiểu",content:"Nội dung",textPlaceholder:"Nhập văn bản",fontSize:"Kích thước phông chữ",direction:"Hướng",ltr:"Trái sang phải",rtl:"Phải sang trái",inherits:"Thừa kế",opacity:"Độ mờ",layout:"Cài đặt bố cục",rotate:"Xoay",repeat:"Lặp lại",spacingX:"Khoảng cách ngang",spacingY:"Khoảng cách dọc",startX:"Vị trí bắt đầu ngang",startY:"Vị trí bắt đầu dọc",cancel:"Hủy hình mờ",close:"Đóng bảng điều khiển",copy:"Sao chép cấu hình"}}});
|
package/lib/umd/locale/zh-CN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverWatermarkZhCN=t())})(this,function(){"use strict";return{"univer-watermark":{title:"水印",type:"类型",text:"文本",image:"图片",uploadImage:"上传图片",replaceImage:"替换图片",keepRatio:"保持比例",width:"长度",height:"高度",style:"样式设置",content:"内容",textPlaceholder:"请输入文本",fontSize:"字体大小",direction:"方向",ltr:"从左到右",rtl:"从右到左",inherits:"继承",opacity:"透明度",layout:"布局设置",rotate:"旋转",repeat:"重复",spacingX:"水平间距",spacingY:"垂直间距",startX:"水平起始位置",startY:"垂直起始位置",cancel:"取消水印",close:"关闭面板",copy:"复制配置"}}});
|
package/lib/umd/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverWatermarkZhTW=t())})(this,function(){"use strict";return{"univer-watermark":{title:"浮水印",type:"類型",text:"文字",image:"圖片",uploadImage:"上傳圖片",replaceImage:"替換圖片",keepRatio:"保持比例",width:"長度",height:"高度",style:"樣式設置",content:"內容",textPlaceholder:"請輸入文字",fontSize:"字體大小",direction:"方向",ltr:"從左到右",rtl:"從右到左",inherits:"繼承",opacity:"透明度",layout:"佈局設置",rotate:"旋轉",repeat:"重複",spacingX:"水平間距",spacingY:"垂直間距",startX:"水平起始位置",startY:"垂直起始位置",cancel:"取消浮水印",close:"關閉面板",copy:"複製配置"}}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/watermark",
|
|
3
|
-
"version": "0.5.5
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "univer watermark plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"clsx": "^2.1.1",
|
|
62
|
-
"@univerjs/core": "0.5.5
|
|
63
|
-
"@univerjs/engine-render": "0.5.5
|
|
62
|
+
"@univerjs/core": "0.5.5",
|
|
63
|
+
"@univerjs/engine-render": "0.5.5"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"rxjs": "^7.8.1",
|