@univerjs/watermark 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/facade.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/facade/f-univer.d.ts +9 -5
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=require(`@univerjs/core/facade`),t=require(`@univerjs/engine-render`),n=require(`@univerjs/watermark`);var r=class extends e.FUniver{addWatermark(e,r){let i=this._injector.get(n.WatermarkService);if(e===t.IWatermarkTypeEnum.Text)i.updateWatermarkConfig({type:t.IWatermarkTypeEnum.Text,config:{text:{...n.WatermarkTextBaseConfig,...r}}});else if(e===t.IWatermarkTypeEnum.Image)i.updateWatermarkConfig({type:t.IWatermarkTypeEnum.Image,config:{image:{...n.WatermarkImageBaseConfig,...r}}});else throw Error(`Unknown watermark type`);return this}deleteWatermark(){return this._injector.get(n.WatermarkService).deleteWatermarkConfig(),this}}
|
|
1
|
+
let e=require(`@univerjs/core/facade`),t=require(`@univerjs/engine-render`),n=require(`@univerjs/watermark`);var r=class extends e.FEnum{get IWatermarkTypeEnum(){return t.IWatermarkTypeEnum}},i=class extends e.FUniver{addWatermark(e,r){let i=this._injector.get(n.WatermarkService);if(e===t.IWatermarkTypeEnum.Text)i.updateWatermarkConfig({type:t.IWatermarkTypeEnum.Text,config:{text:{...n.WatermarkTextBaseConfig,...r}}});else if(e===t.IWatermarkTypeEnum.Image)i.updateWatermarkConfig({type:t.IWatermarkTypeEnum.Image,config:{image:{...n.WatermarkImageBaseConfig,...r}}});else throw Error(`Unknown watermark type`);return this}deleteWatermark(){return this._injector.get(n.WatermarkService).deleteWatermarkConfig(),this}};e.FUniver.extend(i),e.FEnum.extend(r);
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/engine-render`),n=require(`rxjs`);const r=[`image/png`,`image/jpeg`,`image/jpg`,`image/bmp`],i={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},a={url:``,width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},o={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 s=`@univerjs/watermark`,c=`0.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/engine-render`),n=require(`rxjs`);const r=[`image/png`,`image/jpeg`,`image/jpg`,`image/bmp`],i={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},a={url:``,width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},o={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 s=`@univerjs/watermark`,c=`0.20.0`;const l=`watermark.config`;Symbol(l);const u={};function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){return function(n,r){t(n,r,e)}}function g(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let _=class extends e.Disposable{constructor(e){super(),this._localStorageService=e,m(this,`_updateConfig$`,new n.Subject),m(this,`updateConfig$`,this._updateConfig$.asObservable()),m(this,`_refresh$`,new n.Subject),m(this,`refresh$`,this._refresh$.asObservable())}async getWatermarkConfig(){return await this._localStorageService.getItem(t.UNIVER_WATERMARK_STORAGE_KEY)}updateWatermarkConfig(e){this._localStorageService.setItem(t.UNIVER_WATERMARK_STORAGE_KEY,e),this._updateConfig$.next(e)}deleteWatermarkConfig(){this._localStorageService.removeItem(t.UNIVER_WATERMARK_STORAGE_KEY),this._updateConfig$.next(null)}refresh(){this._refresh$.next(Math.random())}dispose(){this._refresh$.complete(),this._updateConfig$.complete()}};_=g([h(0,(0,e.Inject)(e.ILocalStorageService))],_);let v=class extends e.RxDisposable{constructor(e,n,r,i){super(),this._context=e,this._watermarkService=n,this._localStorageService=r,this._userManagerService=i,m(this,`_watermarkLayer`,void 0),this._watermarkLayer=new t.WatermarkLayer(e.scene,[],t.UNIVER_WATERMARK_LAYER_INDEX),this._initAddRender(),this._initWatermarkUpdate(),this._initWatermarkConfig()}_initAddRender(){let{scene:e}=this._context;e.addLayer(this._watermarkLayer)}async _initWatermarkConfig(){let e=await this._localStorageService.getItem(t.UNIVER_WATERMARK_STORAGE_KEY);if(e){var n;this._watermarkService.updateWatermarkConfig(e),(n=this._context.mainComponent)==null||n.makeDirty()}}_initWatermarkUpdate(){this.disposeWithMe(this._watermarkService.updateConfig$.subscribe(e=>{var n;if(!e){var r;this._watermarkLayer.updateConfig(),(r=this._context.mainComponent)==null||r.makeDirty();return}e.type===t.IWatermarkTypeEnum.UserInfo?this._watermarkLayer.updateConfig(e,this._userManagerService.getCurrentUser()):this._watermarkLayer.updateConfig(e),(n=this._context.mainComponent)==null||n.makeDirty()}))}};v=g([h(1,(0,e.Inject)(_)),h(2,(0,e.Inject)(e.ILocalStorageService)),h(3,(0,e.Inject)(e.UserManagerService))],v);let y=class extends e.Plugin{constructor(t=u,n,r,i,a){super(),this._config=t,this._injector=n,this._configService=r,this._renderManagerSrv=i,this._localStorageService=a;let{...o}=(0,e.merge)({},u,this._config);this._configService.setConfig(l,o),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){let n=this._configService.getConfig(l);if(!n)return;let{userWatermarkSettings:r,textWatermarkSettings:s,imageWatermarkSettings:c}=n;if(r)this._localStorageService.setItem(t.UNIVER_WATERMARK_STORAGE_KEY,{type:t.IWatermarkTypeEnum.UserInfo,config:{userInfo:(0,e.merge)({},o,r)}});else if(s)this._localStorageService.setItem(t.UNIVER_WATERMARK_STORAGE_KEY,{type:t.IWatermarkTypeEnum.Text,config:{text:(0,e.merge)({},i,s)}});else if(c)this._localStorageService.setItem(t.UNIVER_WATERMARK_STORAGE_KEY,{type:t.IWatermarkTypeEnum.Image,config:{image:(0,e.merge)({},a,c)}});else{let e=await this._localStorageService.getItem(t.UNIVER_WATERMARK_STORAGE_KEY);(e==null?void 0:e.type)===t.IWatermarkTypeEnum.UserInfo&&this._localStorageService.removeItem(t.UNIVER_WATERMARK_STORAGE_KEY)}}_initDependencies(){[[_]].forEach(e=>{this._injector.add(e)})}onRendered(){this._injector.get(_),this._initRenderDependencies()}_initRenderDependencies(){[[v]].forEach(t=>{this._renderManagerSrv.registerRenderModule(e.UniverInstanceType.UNIVER_SHEET,t),this._renderManagerSrv.registerRenderModule(e.UniverInstanceType.UNIVER_DOC,t)})}};m(y,`pluginName`,`UNIVER_WATERMARK_PLUGIN`),m(y,`packageName`,s),m(y,`version`,c),y=g([h(1,(0,e.Inject)(e.Injector)),h(2,e.IConfigService),h(3,t.IRenderManagerService),h(4,(0,e.Inject)(e.ILocalStorageService))],y),Object.defineProperty(exports,`UniverWatermarkPlugin`,{enumerable:!0,get:function(){return y}}),exports.WATERMARK_IMAGE_ALLOW_IMAGE_LIST=r,exports.WatermarkImageBaseConfig=a,Object.defineProperty(exports,`WatermarkService`,{enumerable:!0,get:function(){return _}}),exports.WatermarkTextBaseConfig=i,exports.WatermarkUserInfoBaseConfig=o;
|
package/lib/es/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FEnum as e,FUniver as t}from"@univerjs/core/facade";import{IWatermarkTypeEnum as n}from"@univerjs/engine-render";import{WatermarkImageBaseConfig as r,WatermarkService as i,WatermarkTextBaseConfig as a}from"@univerjs/watermark";var o=class extends t{addWatermark(e,t){let o=this._injector.get(i);if(e===n.Text)o.updateWatermarkConfig({type:n.Text,config:{text:{...a,...t}}});else if(e===n.Image)o.updateWatermarkConfig({type:n.Image,config:{image:{...r,...t}}});else throw Error(`Unknown watermark type`);return this}deleteWatermark(){return this._injector.get(i).deleteWatermarkConfig(),this}}
|
|
1
|
+
import{FEnum as e,FUniver as t}from"@univerjs/core/facade";import{IWatermarkTypeEnum as n}from"@univerjs/engine-render";import{WatermarkImageBaseConfig as r,WatermarkService as i,WatermarkTextBaseConfig as a}from"@univerjs/watermark";var o=class extends e{get IWatermarkTypeEnum(){return n}},s=class extends t{addWatermark(e,t){let o=this._injector.get(i);if(e===n.Text)o.updateWatermarkConfig({type:n.Text,config:{text:{...a,...t}}});else if(e===n.Image)o.updateWatermarkConfig({type:n.Image,config:{image:{...r,...t}}});else throw Error(`Unknown watermark type`);return this}deleteWatermark(){return this._injector.get(i).deleteWatermarkConfig(),this}};t.extend(s),e.extend(o);export{};
|
package/lib/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Disposable as e,IConfigService as t,ILocalStorageService as n,Inject as r,Injector as i,Plugin as a,RxDisposable as o,UniverInstanceType as s,UserManagerService as c,merge as l}from"@univerjs/core";import{IRenderManagerService as u,IWatermarkTypeEnum as d,UNIVER_WATERMARK_LAYER_INDEX as f,UNIVER_WATERMARK_STORAGE_KEY as p,WatermarkLayer as m}from"@univerjs/engine-render";import{Subject as h}from"rxjs";const g=[`image/png`,`image/jpeg`,`image/jpg`,`image/bmp`],_={content:``,fontSize:16,color:`rgb(0,0,0)`,bold:!1,italic:!1,direction:`ltr`,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},v={url:``,width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},y={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 b=`@univerjs/watermark`,x=`0.
|
|
1
|
+
import{Disposable as e,IConfigService as t,ILocalStorageService as n,Inject as r,Injector as i,Plugin as a,RxDisposable as o,UniverInstanceType as s,UserManagerService as c,merge as l}from"@univerjs/core";import{IRenderManagerService as u,IWatermarkTypeEnum as d,UNIVER_WATERMARK_LAYER_INDEX as f,UNIVER_WATERMARK_STORAGE_KEY as p,WatermarkLayer as m}from"@univerjs/engine-render";import{Subject as h}from"rxjs";const g=[`image/png`,`image/jpeg`,`image/jpg`,`image/bmp`],_={content:``,fontSize:16,color:`rgb(0,0,0)`,bold:!1,italic:!1,direction:`ltr`,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},v={url:``,width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},y={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 b=`@univerjs/watermark`,x=`0.20.0`;const S=`watermark.config`;Symbol(S);const C={};function w(e){"@babel/helpers - typeof";return w=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},w(e)}function T(e,t){if(w(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(w(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function E(e){var t=T(e,`string`);return w(t)==`symbol`?t:t+``}function D(e,t,n){return(t=E(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e,t){return function(n,r){t(n,r,e)}}function k(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let A=class extends e{constructor(e){super(),this._localStorageService=e,D(this,`_updateConfig$`,new h),D(this,`updateConfig$`,this._updateConfig$.asObservable()),D(this,`_refresh$`,new h),D(this,`refresh$`,this._refresh$.asObservable())}async getWatermarkConfig(){return await this._localStorageService.getItem(p)}updateWatermarkConfig(e){this._localStorageService.setItem(p,e),this._updateConfig$.next(e)}deleteWatermarkConfig(){this._localStorageService.removeItem(p),this._updateConfig$.next(null)}refresh(){this._refresh$.next(Math.random())}dispose(){this._refresh$.complete(),this._updateConfig$.complete()}};A=k([O(0,r(n))],A);let j=class extends o{constructor(e,t,n,r){super(),this._context=e,this._watermarkService=t,this._localStorageService=n,this._userManagerService=r,D(this,`_watermarkLayer`,void 0),this._watermarkLayer=new m(e.scene,[],f),this._initAddRender(),this._initWatermarkUpdate(),this._initWatermarkConfig()}_initAddRender(){let{scene:e}=this._context;e.addLayer(this._watermarkLayer)}async _initWatermarkConfig(){let e=await this._localStorageService.getItem(p);if(e){var t;this._watermarkService.updateWatermarkConfig(e),(t=this._context.mainComponent)==null||t.makeDirty()}}_initWatermarkUpdate(){this.disposeWithMe(this._watermarkService.updateConfig$.subscribe(e=>{var t;if(!e){var n;this._watermarkLayer.updateConfig(),(n=this._context.mainComponent)==null||n.makeDirty();return}e.type===d.UserInfo?this._watermarkLayer.updateConfig(e,this._userManagerService.getCurrentUser()):this._watermarkLayer.updateConfig(e),(t=this._context.mainComponent)==null||t.makeDirty()}))}};j=k([O(1,r(A)),O(2,r(n)),O(3,r(c))],j);let M=class extends a{constructor(e=C,t,n,r,i){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerSrv=r,this._localStorageService=i;let{...a}=l({},C,this._config);this._configService.setConfig(S,a),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){let e=this._configService.getConfig(S);if(!e)return;let{userWatermarkSettings:t,textWatermarkSettings:n,imageWatermarkSettings:r}=e;if(t)this._localStorageService.setItem(p,{type:d.UserInfo,config:{userInfo:l({},y,t)}});else if(n)this._localStorageService.setItem(p,{type:d.Text,config:{text:l({},_,n)}});else if(r)this._localStorageService.setItem(p,{type:d.Image,config:{image:l({},v,r)}});else{let e=await this._localStorageService.getItem(p);(e==null?void 0:e.type)===d.UserInfo&&this._localStorageService.removeItem(p)}}_initDependencies(){[[A]].forEach(e=>{this._injector.add(e)})}onRendered(){this._injector.get(A),this._initRenderDependencies()}_initRenderDependencies(){[[j]].forEach(e=>{this._renderManagerSrv.registerRenderModule(s.UNIVER_SHEET,e),this._renderManagerSrv.registerRenderModule(s.UNIVER_DOC,e)})}};D(M,`pluginName`,`UNIVER_WATERMARK_PLUGIN`),D(M,`packageName`,b),D(M,`version`,x),M=k([O(1,r(i)),O(2,t),O(3,u),O(4,r(n))],M);export{M as UniverWatermarkPlugin,g as WATERMARK_IMAGE_ALLOW_IMAGE_LIST,v as WatermarkImageBaseConfig,A as WatermarkService,_ as WatermarkTextBaseConfig,y as WatermarkUserInfoBaseConfig};
|
package/lib/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FEnum as e,FUniver as t}from"@univerjs/core/facade";import{IWatermarkTypeEnum as n}from"@univerjs/engine-render";import{WatermarkImageBaseConfig as r,WatermarkService as i,WatermarkTextBaseConfig as a}from"@univerjs/watermark";var o=class extends t{addWatermark(e,t){let o=this._injector.get(i);if(e===n.Text)o.updateWatermarkConfig({type:n.Text,config:{text:{...a,...t}}});else if(e===n.Image)o.updateWatermarkConfig({type:n.Image,config:{image:{...r,...t}}});else throw Error(`Unknown watermark type`);return this}deleteWatermark(){return this._injector.get(i).deleteWatermarkConfig(),this}}
|
|
1
|
+
import{FEnum as e,FUniver as t}from"@univerjs/core/facade";import{IWatermarkTypeEnum as n}from"@univerjs/engine-render";import{WatermarkImageBaseConfig as r,WatermarkService as i,WatermarkTextBaseConfig as a}from"@univerjs/watermark";var o=class extends e{get IWatermarkTypeEnum(){return n}},s=class extends t{addWatermark(e,t){let o=this._injector.get(i);if(e===n.Text)o.updateWatermarkConfig({type:n.Text,config:{text:{...a,...t}}});else if(e===n.Image)o.updateWatermarkConfig({type:n.Image,config:{image:{...r,...t}}});else throw Error(`Unknown watermark type`);return this}deleteWatermark(){return this._injector.get(i).deleteWatermarkConfig(),this}};t.extend(s),e.extend(o);export{};
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Disposable as e,IConfigService as t,ILocalStorageService as n,Inject as r,Injector as i,Plugin as a,RxDisposable as o,UniverInstanceType as s,UserManagerService as c,merge as l}from"@univerjs/core";import{IRenderManagerService as u,IWatermarkTypeEnum as d,UNIVER_WATERMARK_LAYER_INDEX as f,UNIVER_WATERMARK_STORAGE_KEY as p,WatermarkLayer as m}from"@univerjs/engine-render";import{Subject as h}from"rxjs";const g=[`image/png`,`image/jpeg`,`image/jpg`,`image/bmp`],_={content:``,fontSize:16,color:`rgb(0,0,0)`,bold:!1,italic:!1,direction:`ltr`,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},v={url:``,width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},y={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 b=`@univerjs/watermark`,x=`0.
|
|
1
|
+
import{Disposable as e,IConfigService as t,ILocalStorageService as n,Inject as r,Injector as i,Plugin as a,RxDisposable as o,UniverInstanceType as s,UserManagerService as c,merge as l}from"@univerjs/core";import{IRenderManagerService as u,IWatermarkTypeEnum as d,UNIVER_WATERMARK_LAYER_INDEX as f,UNIVER_WATERMARK_STORAGE_KEY as p,WatermarkLayer as m}from"@univerjs/engine-render";import{Subject as h}from"rxjs";const g=[`image/png`,`image/jpeg`,`image/jpg`,`image/bmp`],_={content:``,fontSize:16,color:`rgb(0,0,0)`,bold:!1,italic:!1,direction:`ltr`,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},v={url:``,width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},y={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 b=`@univerjs/watermark`,x=`0.20.0`;const S=`watermark.config`;Symbol(S);const C={};function w(e){"@babel/helpers - typeof";return w=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},w(e)}function T(e,t){if(w(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(w(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function E(e){var t=T(e,`string`);return w(t)==`symbol`?t:t+``}function D(e,t,n){return(t=E(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e,t){return function(n,r){t(n,r,e)}}function k(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let A=class extends e{constructor(e){super(),this._localStorageService=e,D(this,`_updateConfig$`,new h),D(this,`updateConfig$`,this._updateConfig$.asObservable()),D(this,`_refresh$`,new h),D(this,`refresh$`,this._refresh$.asObservable())}async getWatermarkConfig(){return await this._localStorageService.getItem(p)}updateWatermarkConfig(e){this._localStorageService.setItem(p,e),this._updateConfig$.next(e)}deleteWatermarkConfig(){this._localStorageService.removeItem(p),this._updateConfig$.next(null)}refresh(){this._refresh$.next(Math.random())}dispose(){this._refresh$.complete(),this._updateConfig$.complete()}};A=k([O(0,r(n))],A);let j=class extends o{constructor(e,t,n,r){super(),this._context=e,this._watermarkService=t,this._localStorageService=n,this._userManagerService=r,D(this,`_watermarkLayer`,void 0),this._watermarkLayer=new m(e.scene,[],f),this._initAddRender(),this._initWatermarkUpdate(),this._initWatermarkConfig()}_initAddRender(){let{scene:e}=this._context;e.addLayer(this._watermarkLayer)}async _initWatermarkConfig(){let e=await this._localStorageService.getItem(p);if(e){var t;this._watermarkService.updateWatermarkConfig(e),(t=this._context.mainComponent)==null||t.makeDirty()}}_initWatermarkUpdate(){this.disposeWithMe(this._watermarkService.updateConfig$.subscribe(e=>{var t;if(!e){var n;this._watermarkLayer.updateConfig(),(n=this._context.mainComponent)==null||n.makeDirty();return}e.type===d.UserInfo?this._watermarkLayer.updateConfig(e,this._userManagerService.getCurrentUser()):this._watermarkLayer.updateConfig(e),(t=this._context.mainComponent)==null||t.makeDirty()}))}};j=k([O(1,r(A)),O(2,r(n)),O(3,r(c))],j);let M=class extends a{constructor(e=C,t,n,r,i){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerSrv=r,this._localStorageService=i;let{...a}=l({},C,this._config);this._configService.setConfig(S,a),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){let e=this._configService.getConfig(S);if(!e)return;let{userWatermarkSettings:t,textWatermarkSettings:n,imageWatermarkSettings:r}=e;if(t)this._localStorageService.setItem(p,{type:d.UserInfo,config:{userInfo:l({},y,t)}});else if(n)this._localStorageService.setItem(p,{type:d.Text,config:{text:l({},_,n)}});else if(r)this._localStorageService.setItem(p,{type:d.Image,config:{image:l({},v,r)}});else{let e=await this._localStorageService.getItem(p);(e==null?void 0:e.type)===d.UserInfo&&this._localStorageService.removeItem(p)}}_initDependencies(){[[A]].forEach(e=>{this._injector.add(e)})}onRendered(){this._injector.get(A),this._initRenderDependencies()}_initRenderDependencies(){[[j]].forEach(e=>{this._renderManagerSrv.registerRenderModule(s.UNIVER_SHEET,e),this._renderManagerSrv.registerRenderModule(s.UNIVER_DOC,e)})}};D(M,`pluginName`,`UNIVER_WATERMARK_PLUGIN`),D(M,`packageName`,b),D(M,`version`,x),M=k([O(1,r(i)),O(2,t),O(3,u),O(4,r(n))],M);export{M as UniverWatermarkPlugin,g as WATERMARK_IMAGE_ALLOW_IMAGE_LIST,v as WatermarkImageBaseConfig,A as WatermarkService,_ as WatermarkTextBaseConfig,y as WatermarkUserInfoBaseConfig};
|
|
@@ -14,8 +14,14 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IImageWatermarkConfig, ITextWatermarkConfig } from '@univerjs/engine-render';
|
|
17
|
-
import { FUniver } from '@univerjs/core/facade';
|
|
17
|
+
import { FEnum, FUniver } from '@univerjs/core/facade';
|
|
18
18
|
import { IWatermarkTypeEnum } from '@univerjs/engine-render';
|
|
19
|
+
interface IFWatermarkEnumMixin {
|
|
20
|
+
IWatermarkTypeEnum: typeof IWatermarkTypeEnum;
|
|
21
|
+
}
|
|
22
|
+
export declare class FWatermarkEnumMixin extends FEnum implements IFWatermarkEnumMixin {
|
|
23
|
+
get IWatermarkTypeEnum(): typeof IWatermarkTypeEnum;
|
|
24
|
+
}
|
|
19
25
|
/**
|
|
20
26
|
* @ignore
|
|
21
27
|
*/
|
|
@@ -69,12 +75,10 @@ export declare class FUniverWatermarkMixin extends FUniver {
|
|
|
69
75
|
addWatermark(type: IWatermarkTypeEnum.Image, config: IImageWatermarkConfig): FUniver;
|
|
70
76
|
deleteWatermark(): FUniver;
|
|
71
77
|
}
|
|
72
|
-
export declare class FWatermarkEnum {
|
|
73
|
-
get IWatermarkTypeEnum(): typeof IWatermarkTypeEnum;
|
|
74
|
-
}
|
|
75
78
|
declare module '@univerjs/core/facade' {
|
|
76
79
|
interface FUniver extends IFUniverWatermarkMixin {
|
|
77
80
|
}
|
|
78
|
-
interface FEnum extends
|
|
81
|
+
interface FEnum extends IFWatermarkEnumMixin {
|
|
79
82
|
}
|
|
80
83
|
}
|
|
84
|
+
export {};
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(require(`@univerjs/core/facade`),require(`@univerjs/engine-render`),require(`@univerjs/watermark`)):typeof define==`function`&&define.amd?define([`@univerjs/core/facade`,`@univerjs/engine-render`,`@univerjs/watermark`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade,e.UniverEngineRender,e.UniverWatermark))})(this,function(e,t,n){var r=class extends e.FUniver{addWatermark(e,r){let i=this._injector.get(n.WatermarkService);if(e===t.IWatermarkTypeEnum.Text)i.updateWatermarkConfig({type:t.IWatermarkTypeEnum.Text,config:{text:{...n.WatermarkTextBaseConfig,...r}}});else if(e===t.IWatermarkTypeEnum.Image)i.updateWatermarkConfig({type:t.IWatermarkTypeEnum.Image,config:{image:{...n.WatermarkImageBaseConfig,...r}}});else throw Error(`Unknown watermark type`);return this}deleteWatermark(){return this._injector.get(n.WatermarkService).deleteWatermarkConfig(),this}}
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(require(`@univerjs/core/facade`),require(`@univerjs/engine-render`),require(`@univerjs/watermark`)):typeof define==`function`&&define.amd?define([`@univerjs/core/facade`,`@univerjs/engine-render`,`@univerjs/watermark`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade,e.UniverEngineRender,e.UniverWatermark))})(this,function(e,t,n){var r=class extends e.FEnum{get IWatermarkTypeEnum(){return t.IWatermarkTypeEnum}},i=class extends e.FUniver{addWatermark(e,r){let i=this._injector.get(n.WatermarkService);if(e===t.IWatermarkTypeEnum.Text)i.updateWatermarkConfig({type:t.IWatermarkTypeEnum.Text,config:{text:{...n.WatermarkTextBaseConfig,...r}}});else if(e===t.IWatermarkTypeEnum.Image)i.updateWatermarkConfig({type:t.IWatermarkTypeEnum.Image,config:{image:{...n.WatermarkImageBaseConfig,...r}}});else throw Error(`Unknown watermark type`);return this}deleteWatermark(){return this._injector.get(n.WatermarkService).deleteWatermarkConfig(),this}};e.FUniver.extend(i),e.FEnum.extend(r)});
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/engine-render`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/engine-render`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverWatermark={},e.UniverCore,e.UniverEngineRender,e.rxjs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let i=[`image/png`,`image/jpeg`,`image/jpg`,`image/bmp`],a={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},o={url:``,width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},s={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=`@univerjs/watermark`,l=`0.
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/engine-render`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/engine-render`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverWatermark={},e.UniverCore,e.UniverEngineRender,e.rxjs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let i=[`image/png`,`image/jpeg`,`image/jpg`,`image/bmp`],a={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},o={url:``,width:100,height:100,maintainAspectRatio:!0,originRatio:1,x:60,y:36,repeat:!0,spacingX:200,spacingY:100,rotate:0,opacity:.15},s={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=`@univerjs/watermark`,l=`0.20.0`;let u=`watermark.config`;Symbol(u);let d={};function f(e){"@babel/helpers - typeof";return f=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},f(e)}function p(e,t){if(f(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(f(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function m(e){var t=p(e,`string`);return f(t)==`symbol`?t:t+``}function h(e,t,n){return(t=m(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e,t){return function(n,r){t(n,r,e)}}function _(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let v=class extends t.Disposable{constructor(e){super(),this._localStorageService=e,h(this,`_updateConfig$`,new r.Subject),h(this,`updateConfig$`,this._updateConfig$.asObservable()),h(this,`_refresh$`,new r.Subject),h(this,`refresh$`,this._refresh$.asObservable())}async getWatermarkConfig(){return await this._localStorageService.getItem(n.UNIVER_WATERMARK_STORAGE_KEY)}updateWatermarkConfig(e){this._localStorageService.setItem(n.UNIVER_WATERMARK_STORAGE_KEY,e),this._updateConfig$.next(e)}deleteWatermarkConfig(){this._localStorageService.removeItem(n.UNIVER_WATERMARK_STORAGE_KEY),this._updateConfig$.next(null)}refresh(){this._refresh$.next(Math.random())}dispose(){this._refresh$.complete(),this._updateConfig$.complete()}};v=_([g(0,(0,t.Inject)(t.ILocalStorageService))],v);let y=class extends t.RxDisposable{constructor(e,t,r,i){super(),this._context=e,this._watermarkService=t,this._localStorageService=r,this._userManagerService=i,h(this,`_watermarkLayer`,void 0),this._watermarkLayer=new n.WatermarkLayer(e.scene,[],n.UNIVER_WATERMARK_LAYER_INDEX),this._initAddRender(),this._initWatermarkUpdate(),this._initWatermarkConfig()}_initAddRender(){let{scene:e}=this._context;e.addLayer(this._watermarkLayer)}async _initWatermarkConfig(){let e=await this._localStorageService.getItem(n.UNIVER_WATERMARK_STORAGE_KEY);if(e){var t;this._watermarkService.updateWatermarkConfig(e),(t=this._context.mainComponent)==null||t.makeDirty()}}_initWatermarkUpdate(){this.disposeWithMe(this._watermarkService.updateConfig$.subscribe(e=>{var t;if(!e){var r;this._watermarkLayer.updateConfig(),(r=this._context.mainComponent)==null||r.makeDirty();return}e.type===n.IWatermarkTypeEnum.UserInfo?this._watermarkLayer.updateConfig(e,this._userManagerService.getCurrentUser()):this._watermarkLayer.updateConfig(e),(t=this._context.mainComponent)==null||t.makeDirty()}))}};y=_([g(1,(0,t.Inject)(v)),g(2,(0,t.Inject)(t.ILocalStorageService)),g(3,(0,t.Inject)(t.UserManagerService))],y);let b=class extends t.Plugin{constructor(e=d,n,r,i,a){super(),this._config=e,this._injector=n,this._configService=r,this._renderManagerSrv=i,this._localStorageService=a;let{...o}=(0,t.merge)({},d,this._config);this._configService.setConfig(u,o),this._initWatermarkStorage(),this._initDependencies()}async _initWatermarkStorage(){let e=this._configService.getConfig(u);if(!e)return;let{userWatermarkSettings:r,textWatermarkSettings:i,imageWatermarkSettings:c}=e;if(r)this._localStorageService.setItem(n.UNIVER_WATERMARK_STORAGE_KEY,{type:n.IWatermarkTypeEnum.UserInfo,config:{userInfo:(0,t.merge)({},s,r)}});else if(i)this._localStorageService.setItem(n.UNIVER_WATERMARK_STORAGE_KEY,{type:n.IWatermarkTypeEnum.Text,config:{text:(0,t.merge)({},a,i)}});else if(c)this._localStorageService.setItem(n.UNIVER_WATERMARK_STORAGE_KEY,{type:n.IWatermarkTypeEnum.Image,config:{image:(0,t.merge)({},o,c)}});else{let e=await this._localStorageService.getItem(n.UNIVER_WATERMARK_STORAGE_KEY);(e==null?void 0:e.type)===n.IWatermarkTypeEnum.UserInfo&&this._localStorageService.removeItem(n.UNIVER_WATERMARK_STORAGE_KEY)}}_initDependencies(){[[v]].forEach(e=>{this._injector.add(e)})}onRendered(){this._injector.get(v),this._initRenderDependencies()}_initRenderDependencies(){[[y]].forEach(e=>{this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,e),this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,e)})}};h(b,`pluginName`,`UNIVER_WATERMARK_PLUGIN`),h(b,`packageName`,c),h(b,`version`,l),b=_([g(1,(0,t.Inject)(t.Injector)),g(2,t.IConfigService),g(3,n.IRenderManagerService),g(4,(0,t.Inject)(t.ILocalStorageService))],b),Object.defineProperty(e,`UniverWatermarkPlugin`,{enumerable:!0,get:function(){return b}}),e.WATERMARK_IMAGE_ALLOW_IMAGE_LIST=i,e.WatermarkImageBaseConfig=o,Object.defineProperty(e,`WatermarkService`,{enumerable:!0,get:function(){return v}}),e.WatermarkTextBaseConfig=a,e.WatermarkUserInfoBaseConfig=s});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/watermark",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "univer watermark plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/core": "0.
|
|
62
|
-
"@univerjs/engine-render": "0.
|
|
61
|
+
"@univerjs/core": "0.20.0",
|
|
62
|
+
"@univerjs/engine-render": "0.20.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"rxjs": "^7.8.2",
|
|
66
66
|
"typescript": "^6.0.2",
|
|
67
67
|
"vitest": "^4.1.1",
|
|
68
|
-
"@univerjs-infra/shared": "0.
|
|
68
|
+
"@univerjs-infra/shared": "0.20.0"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"test": "vitest run",
|