@univerjs/watermark 0.5.4 → 0.5.5-experimental.20250123-34738ff
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/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 +22 -18
- package/lib/es/index.js +170 -163
- 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/types/facade/f-univer.d.ts +0 -1
- 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 +5 -5
- package/LICENSE +0 -176
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});const core=require("@univerjs/core"),watermark=require("@univerjs/watermark"),_FUniverWatermarkMixin=class _FUniverWatermarkMixin extends core.FUniver{addWatermark(type,config){const watermarkService=this._injector.get(watermark.WatermarkService);if(type===watermark.IWatermarkTypeEnum.Text)watermarkService.updateWatermarkConfig({type:watermark.IWatermarkTypeEnum.Text,config:{text:{...watermark.WatermarkTextBaseConfig,...config}}});else if(type===watermark.IWatermarkTypeEnum.Image)watermarkService.updateWatermarkConfig({type:watermark.IWatermarkTypeEnum.Image,config:{image:{...watermark.WatermarkImageBaseConfig,...config}}});else throw new Error("Unknown watermark type");return this}deleteWatermark(){return this._injector.get(watermark.WatermarkService).deleteWatermarkConfig(),this}};__name(_FUniverWatermarkMixin,"FUniverWatermarkMixin");let FUniverWatermarkMixin=_FUniverWatermarkMixin;core.FUniver.extend(FUniverWatermarkMixin);
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;
|
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={"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=locale;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={"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=locale;
|
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={"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=locale;
|
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={"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=locale;
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={"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=locale;
|
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={"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=locale;
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={"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=locale;
|
package/lib/es/facade.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
3
|
+
import { FUniver } from "@univerjs/core";
|
|
4
|
+
import { WatermarkService, IWatermarkTypeEnum, WatermarkTextBaseConfig, WatermarkImageBaseConfig } from "@univerjs/watermark";
|
|
5
|
+
const _FUniverWatermarkMixin = class _FUniverWatermarkMixin extends FUniver {
|
|
6
|
+
addWatermark(type, config) {
|
|
7
|
+
const watermarkService = this._injector.get(WatermarkService);
|
|
8
|
+
if (type === IWatermarkTypeEnum.Text)
|
|
9
|
+
watermarkService.updateWatermarkConfig({
|
|
10
|
+
type: IWatermarkTypeEnum.Text,
|
|
9
11
|
config: {
|
|
10
12
|
text: {
|
|
11
|
-
...
|
|
12
|
-
...
|
|
13
|
+
...WatermarkTextBaseConfig,
|
|
14
|
+
...config
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
});
|
|
16
|
-
else if (
|
|
17
|
-
|
|
18
|
-
type:
|
|
18
|
+
else if (type === IWatermarkTypeEnum.Image)
|
|
19
|
+
watermarkService.updateWatermarkConfig({
|
|
20
|
+
type: IWatermarkTypeEnum.Image,
|
|
19
21
|
config: {
|
|
20
22
|
image: {
|
|
21
|
-
...
|
|
22
|
-
...
|
|
23
|
+
...WatermarkImageBaseConfig,
|
|
24
|
+
...config
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
});
|
|
@@ -28,7 +30,9 @@ class k extends m {
|
|
|
28
30
|
return this;
|
|
29
31
|
}
|
|
30
32
|
deleteWatermark() {
|
|
31
|
-
return this._injector.get(
|
|
33
|
+
return this._injector.get(WatermarkService).deleteWatermarkConfig(), this;
|
|
32
34
|
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
+
};
|
|
36
|
+
__name(_FUniverWatermarkMixin, "FUniverWatermarkMixin");
|
|
37
|
+
let FUniverWatermarkMixin = _FUniverWatermarkMixin;
|
|
38
|
+
FUniver.extend(FUniverWatermarkMixin);
|
package/lib/es/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { Inject, ILocalStorageService, Disposable, UserManagerService, RxDisposable, Injector, Plugin, merge, UniverInstanceType, IConfigService } from "@univerjs/core";
|
|
6
|
+
import { Layer, IRenderManagerService } from "@univerjs/engine-render";
|
|
7
|
+
import { Subject } from "rxjs";
|
|
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 = {
|
|
8
9
|
content: "",
|
|
9
10
|
fontSize: 16,
|
|
10
11
|
color: "rgb(0,0,0)",
|
|
@@ -18,7 +19,7 @@ const h = "UNIVER_WATERMARK_STORAGE_KEY", F = 10, ue = ["image/png", "image/jpeg
|
|
|
18
19
|
spacingY: 100,
|
|
19
20
|
rotate: 0,
|
|
20
21
|
opacity: 0.15
|
|
21
|
-
},
|
|
22
|
+
}, WatermarkImageBaseConfig = {
|
|
22
23
|
url: "",
|
|
23
24
|
width: 100,
|
|
24
25
|
height: 100,
|
|
@@ -31,7 +32,7 @@ const h = "UNIVER_WATERMARK_STORAGE_KEY", F = 10, ue = ["image/png", "image/jpeg
|
|
|
31
32
|
spacingY: 100,
|
|
32
33
|
rotate: 0,
|
|
33
34
|
opacity: 0.15
|
|
34
|
-
},
|
|
35
|
+
}, WatermarkUserInfoBaseConfig = {
|
|
35
36
|
name: !0,
|
|
36
37
|
email: !1,
|
|
37
38
|
phone: !1,
|
|
@@ -49,30 +50,30 @@ const h = "UNIVER_WATERMARK_STORAGE_KEY", F = 10, ue = ["image/png", "image/jpeg
|
|
|
49
50
|
rotate: -30,
|
|
50
51
|
opacity: 0.15
|
|
51
52
|
};
|
|
52
|
-
var
|
|
53
|
-
const
|
|
54
|
-
var
|
|
55
|
-
for (var
|
|
56
|
-
(
|
|
57
|
-
return
|
|
58
|
-
},
|
|
59
|
-
let
|
|
60
|
-
constructor(
|
|
53
|
+
var IWatermarkTypeEnum = /* @__PURE__ */ ((IWatermarkTypeEnum2) => (IWatermarkTypeEnum2.UserInfo = "userInfo", IWatermarkTypeEnum2.Text = "text", IWatermarkTypeEnum2.Image = "image", IWatermarkTypeEnum2))(IWatermarkTypeEnum || {});
|
|
54
|
+
const WATERMARK_PLUGIN_CONFIG_KEY = "watermark.config", defaultPluginConfig = {};
|
|
55
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
56
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
57
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
58
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
59
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a;
|
|
60
|
+
let WatermarkService = (_a = class extends Disposable {
|
|
61
|
+
constructor(_localStorageService) {
|
|
61
62
|
super();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this._localStorageService =
|
|
63
|
+
__publicField(this, "_updateConfig$", new Subject());
|
|
64
|
+
__publicField(this, "updateConfig$", this._updateConfig$.asObservable());
|
|
65
|
+
__publicField(this, "_refresh$", new Subject());
|
|
66
|
+
__publicField(this, "refresh$", this._refresh$.asObservable());
|
|
67
|
+
this._localStorageService = _localStorageService;
|
|
67
68
|
}
|
|
68
69
|
async getWatermarkConfig() {
|
|
69
|
-
return await this._localStorageService.getItem(
|
|
70
|
+
return await this._localStorageService.getItem(UNIVER_WATERMARK_STORAGE_KEY);
|
|
70
71
|
}
|
|
71
|
-
updateWatermarkConfig(
|
|
72
|
-
this._localStorageService.setItem(
|
|
72
|
+
updateWatermarkConfig(config) {
|
|
73
|
+
this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, config), this._updateConfig$.next(config);
|
|
73
74
|
}
|
|
74
75
|
deleteWatermarkConfig() {
|
|
75
|
-
this._localStorageService.removeItem(
|
|
76
|
+
this._localStorageService.removeItem(UNIVER_WATERMARK_STORAGE_KEY), this._updateConfig$.next(null);
|
|
76
77
|
}
|
|
77
78
|
refresh() {
|
|
78
79
|
this._refresh$.next(Math.random());
|
|
@@ -80,197 +81,203 @@ let R = class extends Y {
|
|
|
80
81
|
dispose() {
|
|
81
82
|
this._refresh$.complete(), this._updateConfig$.complete();
|
|
82
83
|
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
],
|
|
87
|
-
function
|
|
88
|
-
const
|
|
89
|
-
|
|
84
|
+
}, __name(_a, "WatermarkService"), _a);
|
|
85
|
+
WatermarkService = __decorateClass$2([
|
|
86
|
+
__decorateParam$2(0, Inject(ILocalStorageService))
|
|
87
|
+
], WatermarkService);
|
|
88
|
+
function renderWatermark(ctx, config, image, userInfo) {
|
|
89
|
+
const type = config.type, watermarkConfig = config.config;
|
|
90
|
+
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);
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
__name(renderWatermark, "renderWatermark");
|
|
93
|
+
function renderUserInfoWatermark(ctx, config, userInfo) {
|
|
94
|
+
const { x, y, repeat, spacingX, spacingY, rotate, opacity, name, fontSize, color, bold, italic, direction } = config;
|
|
95
|
+
if (!userInfo)
|
|
94
96
|
return;
|
|
95
|
-
let
|
|
96
|
-
if (
|
|
97
|
+
let watermarkContent = "";
|
|
98
|
+
if (name && (watermarkContent += `${userInfo.name} `), !watermarkContent)
|
|
97
99
|
return;
|
|
98
|
-
|
|
99
|
-
let
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
102
|
-
for (let
|
|
103
|
-
for (let
|
|
104
|
-
|
|
100
|
+
ctx.save(), ctx.globalAlpha = opacity, ctx.direction = direction;
|
|
101
|
+
let fontStyle = "";
|
|
102
|
+
if (italic && (fontStyle += "italic "), bold && (fontStyle += "bold "), fontStyle += `${fontSize}px Arial`, ctx.font = fontStyle, ctx.fillStyle = color, repeat) {
|
|
103
|
+
const canvasWidth = ctx.canvas.width, canvasHeight = ctx.canvas.height;
|
|
104
|
+
for (let posY = y; posY < canvasHeight; posY += fontSize + spacingY)
|
|
105
|
+
for (let posX = x; posX < canvasWidth; posX += ctx.measureText(watermarkContent).width + spacingX)
|
|
106
|
+
ctx.save(), ctx.translate(posX, posY), ctx.rotate(Math.PI / 180 * rotate), ctx.fillText(watermarkContent, 0, 0), ctx.restore();
|
|
105
107
|
} else
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
ctx.save(), ctx.translate(x, y), ctx.rotate(Math.PI / 180 * rotate), ctx.fillText(watermarkContent, 0, 0), ctx.restore();
|
|
109
|
+
ctx.restore();
|
|
108
110
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
__name(renderUserInfoWatermark, "renderUserInfoWatermark");
|
|
112
|
+
function renderTextWatermark(ctx, config) {
|
|
113
|
+
const { x, y, repeat, spacingX, spacingY, rotate, opacity, content, fontSize, color, bold, italic, direction } = config;
|
|
114
|
+
ctx.save(), ctx.globalAlpha = opacity, ctx.direction = direction;
|
|
115
|
+
let fontStyle = "";
|
|
116
|
+
if (italic && (fontStyle += "italic "), bold && (fontStyle += "bold "), fontStyle += `${fontSize}px Arial`, ctx.font = fontStyle, ctx.fillStyle = color, content)
|
|
117
|
+
if (repeat) {
|
|
118
|
+
const canvasWidth = ctx.canvas.width, canvasHeight = ctx.canvas.height;
|
|
119
|
+
for (let posY = y; posY < canvasHeight; posY += fontSize + spacingY)
|
|
120
|
+
for (let posX = x; posX < canvasWidth; posX += ctx.measureText(content).width + spacingX)
|
|
121
|
+
ctx.save(), ctx.translate(posX, posY), ctx.rotate(Math.PI / 180 * rotate), ctx.fillText(content, 0, 0), ctx.restore();
|
|
119
122
|
} else
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
ctx.save(), ctx.translate(x, y), ctx.rotate(Math.PI / 180 * rotate), ctx.fillText(content, 0, 0), ctx.restore();
|
|
124
|
+
ctx.restore();
|
|
122
125
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
__name(renderTextWatermark, "renderTextWatermark");
|
|
127
|
+
function renderImageWatermark(ctx, config, image) {
|
|
128
|
+
const { x, y, repeat, spacingX, spacingY, rotate, opacity, width, height, maintainAspectRatio, originRatio } = config;
|
|
129
|
+
if (!(image != null && image.complete))
|
|
126
130
|
return;
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
const
|
|
131
|
-
for (let
|
|
132
|
-
for (let
|
|
133
|
-
|
|
131
|
+
ctx.save(), ctx.globalAlpha = opacity;
|
|
132
|
+
const actualWidth = width, actualHeight = maintainAspectRatio ? width / originRatio : height;
|
|
133
|
+
if (repeat) {
|
|
134
|
+
const canvasWidth = ctx.canvas.width, canvasHeight = ctx.canvas.height;
|
|
135
|
+
for (let posY = y; posY < canvasHeight; posY += actualHeight + spacingY)
|
|
136
|
+
for (let posX = x; posX < canvasWidth; posX += actualWidth + spacingX)
|
|
137
|
+
ctx.save(), ctx.translate(posX, posY), ctx.rotate(Math.PI / 180 * rotate), ctx.drawImage(image, 0, 0, actualWidth, actualHeight), ctx.restore();
|
|
134
138
|
} else
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
ctx.save(), ctx.translate(x, y), ctx.rotate(Math.PI / 180 * rotate), ctx.drawImage(image, 0, 0, actualWidth, actualHeight), ctx.restore();
|
|
140
|
+
ctx.restore();
|
|
137
141
|
}
|
|
138
|
-
|
|
142
|
+
__name(renderImageWatermark, "renderImageWatermark");
|
|
143
|
+
const _WatermarkLayer = class _WatermarkLayer extends Layer {
|
|
139
144
|
constructor() {
|
|
140
145
|
super(...arguments);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
__publicField(this, "_config");
|
|
147
|
+
__publicField(this, "_image");
|
|
148
|
+
__publicField(this, "_user");
|
|
144
149
|
}
|
|
145
|
-
render(
|
|
146
|
-
var
|
|
147
|
-
super.render(
|
|
148
|
-
const
|
|
149
|
-
return
|
|
150
|
+
render(ctx, isMaxLayer = !1) {
|
|
151
|
+
var _a4;
|
|
152
|
+
super.render(ctx, isMaxLayer);
|
|
153
|
+
const mainCtx = ctx || ((_a4 = this.scene.getEngine()) == null ? void 0 : _a4.getCanvas().getContext());
|
|
154
|
+
return mainCtx && mainCtx.getId() && this._renderWatermark(mainCtx), this;
|
|
150
155
|
}
|
|
151
|
-
updateConfig(
|
|
152
|
-
var
|
|
153
|
-
this._config =
|
|
156
|
+
updateConfig(config, user) {
|
|
157
|
+
var _a4;
|
|
158
|
+
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);
|
|
154
159
|
}
|
|
155
|
-
_renderWatermark(
|
|
156
|
-
this._config &&
|
|
160
|
+
_renderWatermark(ctx) {
|
|
161
|
+
this._config && renderWatermark(ctx, this._config, this._image, this._user);
|
|
157
162
|
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
};
|
|
164
|
+
__name(_WatermarkLayer, "WatermarkLayer");
|
|
165
|
+
let WatermarkLayer = _WatermarkLayer;
|
|
166
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
167
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
168
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
169
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
170
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a2;
|
|
171
|
+
let WatermarkRenderController = (_a2 = class extends RxDisposable {
|
|
172
|
+
constructor(_context, _watermarkService, _localStorageService, _userManagerService) {
|
|
166
173
|
super();
|
|
167
|
-
|
|
168
|
-
this._context =
|
|
174
|
+
__publicField(this, "_watermarkLayer");
|
|
175
|
+
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();
|
|
169
176
|
}
|
|
170
177
|
_initAddRender() {
|
|
171
|
-
const { scene
|
|
172
|
-
|
|
178
|
+
const { scene } = this._context;
|
|
179
|
+
scene.addLayer(this._watermarkLayer);
|
|
173
180
|
}
|
|
174
181
|
async _initWatermarkConfig() {
|
|
175
|
-
var
|
|
176
|
-
const
|
|
177
|
-
|
|
182
|
+
var _a4;
|
|
183
|
+
const config = await this._localStorageService.getItem(UNIVER_WATERMARK_STORAGE_KEY);
|
|
184
|
+
config && (this._watermarkService.updateWatermarkConfig(config), (_a4 = this._context.mainComponent) == null || _a4.makeDirty());
|
|
178
185
|
}
|
|
179
186
|
_initWatermarkUpdate() {
|
|
180
187
|
this.disposeWithMe(
|
|
181
|
-
this._watermarkService.updateConfig$.subscribe((
|
|
182
|
-
var
|
|
183
|
-
if (!
|
|
184
|
-
this._watermarkLayer.updateConfig(), (
|
|
188
|
+
this._watermarkService.updateConfig$.subscribe((_config) => {
|
|
189
|
+
var _a4, _b;
|
|
190
|
+
if (!_config) {
|
|
191
|
+
this._watermarkLayer.updateConfig(), (_a4 = this._context.mainComponent) == null || _a4.makeDirty();
|
|
185
192
|
return;
|
|
186
193
|
}
|
|
187
|
-
|
|
194
|
+
_config.type === IWatermarkTypeEnum.UserInfo ? this._watermarkLayer.updateConfig(_config, this._userManagerService.getCurrentUser()) : this._watermarkLayer.updateConfig(_config), (_b = this._context.mainComponent) == null || _b.makeDirty();
|
|
188
195
|
})
|
|
189
196
|
);
|
|
190
197
|
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
],
|
|
197
|
-
var
|
|
198
|
-
for (var
|
|
199
|
-
(
|
|
200
|
-
return
|
|
201
|
-
},
|
|
202
|
-
const
|
|
203
|
-
var
|
|
204
|
-
let
|
|
205
|
-
constructor(
|
|
206
|
-
super(), this._config =
|
|
207
|
-
const { ...
|
|
198
|
+
}, __name(_a2, "WatermarkRenderController"), _a2);
|
|
199
|
+
WatermarkRenderController = __decorateClass$1([
|
|
200
|
+
__decorateParam$1(1, Inject(WatermarkService)),
|
|
201
|
+
__decorateParam$1(2, Inject(ILocalStorageService)),
|
|
202
|
+
__decorateParam$1(3, Inject(UserManagerService))
|
|
203
|
+
], WatermarkRenderController);
|
|
204
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
205
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
206
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
207
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
208
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
|
|
209
|
+
const PLUGIN_NAME = "UNIVER_WATERMARK_PLUGIN";
|
|
210
|
+
var _a3;
|
|
211
|
+
let UniverWatermarkPlugin = (_a3 = class extends Plugin {
|
|
212
|
+
constructor(_config = defaultPluginConfig, _injector, _configService, _renderManagerSrv, _localStorageService) {
|
|
213
|
+
super(), this._config = _config, this._injector = _injector, this._configService = _configService, this._renderManagerSrv = _renderManagerSrv, this._localStorageService = _localStorageService;
|
|
214
|
+
const { ...rest } = merge(
|
|
208
215
|
{},
|
|
209
|
-
|
|
216
|
+
defaultPluginConfig,
|
|
210
217
|
this._config
|
|
211
218
|
);
|
|
212
|
-
this._configService.setConfig(
|
|
219
|
+
this._configService.setConfig(WATERMARK_PLUGIN_CONFIG_KEY, rest), this._initWatermarkStorage(), this._initDependencies();
|
|
213
220
|
}
|
|
214
221
|
async _initWatermarkStorage() {
|
|
215
|
-
const
|
|
216
|
-
if (!
|
|
222
|
+
const config = this._configService.getConfig(WATERMARK_PLUGIN_CONFIG_KEY);
|
|
223
|
+
if (!config)
|
|
217
224
|
return;
|
|
218
|
-
const { userWatermarkSettings
|
|
219
|
-
if (
|
|
220
|
-
this._localStorageService.setItem(
|
|
221
|
-
type:
|
|
225
|
+
const { userWatermarkSettings, textWatermarkSettings, imageWatermarkSettings } = config;
|
|
226
|
+
if (userWatermarkSettings)
|
|
227
|
+
this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, {
|
|
228
|
+
type: IWatermarkTypeEnum.UserInfo,
|
|
222
229
|
config: {
|
|
223
|
-
userInfo:
|
|
230
|
+
userInfo: merge({}, WatermarkUserInfoBaseConfig, userWatermarkSettings)
|
|
224
231
|
}
|
|
225
232
|
});
|
|
226
|
-
else if (
|
|
227
|
-
this._localStorageService.setItem(
|
|
228
|
-
type:
|
|
233
|
+
else if (textWatermarkSettings)
|
|
234
|
+
this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, {
|
|
235
|
+
type: IWatermarkTypeEnum.Text,
|
|
229
236
|
config: {
|
|
230
|
-
text:
|
|
237
|
+
text: merge({}, WatermarkTextBaseConfig, textWatermarkSettings)
|
|
231
238
|
}
|
|
232
239
|
});
|
|
233
|
-
else if (
|
|
234
|
-
this._localStorageService.setItem(
|
|
235
|
-
type:
|
|
240
|
+
else if (imageWatermarkSettings)
|
|
241
|
+
this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, {
|
|
242
|
+
type: IWatermarkTypeEnum.Image,
|
|
236
243
|
config: {
|
|
237
|
-
image:
|
|
244
|
+
image: merge({}, WatermarkImageBaseConfig, imageWatermarkSettings)
|
|
238
245
|
}
|
|
239
246
|
});
|
|
240
247
|
else {
|
|
241
|
-
const
|
|
242
|
-
(
|
|
248
|
+
const config2 = await this._localStorageService.getItem(UNIVER_WATERMARK_STORAGE_KEY);
|
|
249
|
+
(config2 == null ? void 0 : config2.type) === IWatermarkTypeEnum.UserInfo && this._localStorageService.removeItem(UNIVER_WATERMARK_STORAGE_KEY);
|
|
243
250
|
}
|
|
244
251
|
}
|
|
245
252
|
_initDependencies() {
|
|
246
|
-
[[
|
|
247
|
-
this._injector.add(
|
|
253
|
+
[[WatermarkService]].forEach((d) => {
|
|
254
|
+
this._injector.add(d);
|
|
248
255
|
});
|
|
249
256
|
}
|
|
250
257
|
onRendered() {
|
|
251
|
-
this._injector.get(
|
|
258
|
+
this._injector.get(WatermarkService), this._initRenderDependencies();
|
|
252
259
|
}
|
|
253
260
|
_initRenderDependencies() {
|
|
254
261
|
[
|
|
255
|
-
[
|
|
256
|
-
].forEach((
|
|
257
|
-
this._renderManagerSrv.registerRenderModule(
|
|
262
|
+
[WatermarkRenderController]
|
|
263
|
+
].forEach((d) => {
|
|
264
|
+
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_SHEET, d), this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, d);
|
|
258
265
|
});
|
|
259
266
|
}
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
],
|
|
267
|
+
}, __name(_a3, "UniverWatermarkPlugin"), __publicField(_a3, "pluginName", PLUGIN_NAME), _a3);
|
|
268
|
+
UniverWatermarkPlugin = __decorateClass([
|
|
269
|
+
__decorateParam(1, Inject(Injector)),
|
|
270
|
+
__decorateParam(2, IConfigService),
|
|
271
|
+
__decorateParam(3, IRenderManagerService),
|
|
272
|
+
__decorateParam(4, Inject(ILocalStorageService))
|
|
273
|
+
], UniverWatermarkPlugin);
|
|
267
274
|
export {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
275
|
+
IWatermarkTypeEnum,
|
|
276
|
+
UNIVER_WATERMARK_STORAGE_KEY,
|
|
277
|
+
UniverWatermarkPlugin,
|
|
278
|
+
WATERMARK_IMAGE_ALLOW_IMAGE_LIST,
|
|
279
|
+
WatermarkImageBaseConfig,
|
|
280
|
+
WatermarkService,
|
|
281
|
+
WatermarkTextBaseConfig,
|
|
282
|
+
WatermarkUserInfoBaseConfig
|
|
276
283
|
};
|
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
|
@@ -3,7 +3,6 @@ import { FUniver } from '@univerjs/core';
|
|
|
3
3
|
export interface IFUniverWatermarkMixin {
|
|
4
4
|
/**
|
|
5
5
|
* Adds a watermark to the unit. Supports both text and image watermarks based on the specified type.
|
|
6
|
-
*
|
|
7
6
|
* @param {IWatermarkTypeEnum.Text | IWatermarkTypeEnum.Image} type - The type of watermark to add. Can be either 'Text' or 'Image'.
|
|
8
7
|
* @param {ITextWatermarkConfig | IImageWatermarkConfig} config - The configuration object for the watermark.
|
|
9
8
|
* - If the type is 'Text', the config should follow the ITextWatermarkConfig interface.
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(require("@univerjs/core"),require("@univerjs/watermark")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/watermark"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverCore,global.UniverWatermark))})(this,function(core,watermark){"use strict";var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});const _FUniverWatermarkMixin=class _FUniverWatermarkMixin extends core.FUniver{addWatermark(type,config){const watermarkService=this._injector.get(watermark.WatermarkService);if(type===watermark.IWatermarkTypeEnum.Text)watermarkService.updateWatermarkConfig({type:watermark.IWatermarkTypeEnum.Text,config:{text:{...watermark.WatermarkTextBaseConfig,...config}}});else if(type===watermark.IWatermarkTypeEnum.Image)watermarkService.updateWatermarkConfig({type:watermark.IWatermarkTypeEnum.Image,config:{image:{...watermark.WatermarkImageBaseConfig,...config}}});else throw new Error("Unknown watermark type");return this}deleteWatermark(){return this._injector.get(watermark.WatermarkService).deleteWatermarkConfig(),this}};__name(_FUniverWatermarkMixin,"FUniverWatermarkMixin");let FUniverWatermarkMixin=_FUniverWatermarkMixin;core.FUniver.extend(FUniverWatermarkMixin)});
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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"})});
|
|
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"})});
|
package/lib/umd/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverWatermarkEnUS=factory())})(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(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverWatermarkFaIR=factory())})(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(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverWatermarkFrFR=factory())})(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(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverWatermarkRuRU=factory())})(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(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverWatermarkViVN=factory())})(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(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverWatermarkZhCN=factory())})(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(global,factory){typeof exports=="object"&&typeof module<"u"?module.exports=factory():typeof define=="function"&&define.amd?define(factory):(global=typeof globalThis<"u"?globalThis:global||self,global.UniverWatermarkZhTW=factory())})(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.
|
|
3
|
+
"version": "0.5.5-experimental.20250123-34738ff",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "univer watermark plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -59,15 +59,15 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"clsx": "^2.1.1",
|
|
62
|
-
"@univerjs/core": "0.5.
|
|
63
|
-
"@univerjs/engine-render": "0.5.
|
|
62
|
+
"@univerjs/core": "0.5.5-experimental.20250123-34738ff",
|
|
63
|
+
"@univerjs/engine-render": "0.5.5-experimental.20250123-34738ff"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"rxjs": "^7.8.1",
|
|
67
|
-
"typescript": "^5.7.
|
|
67
|
+
"typescript": "^5.7.3",
|
|
68
68
|
"vite": "^6.0.7",
|
|
69
69
|
"vitest": "^2.1.8",
|
|
70
|
-
"@univerjs-infra/shared": "0.5.
|
|
70
|
+
"@univerjs-infra/shared": "0.5.5"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"test": "vitest run",
|
package/LICENSE
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
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
|