@univerjs/docs-drawing 0.20.0 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/drawing`);var n=class extends t.UnitDrawingService{};const r=(0,e.createIdentifier)(`univer.doc.plugin.doc-drawing.service`);function i(e,t){return function(n,r){t(n,r,e)}}function a(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}const o=`DOC_DRAWING_PLUGIN`;let s=class extends e.Disposable{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let t=t=>{let n=this._univerInstanceService.getUnit(t,e.UniverInstanceType.UNIVER_DOC);if(n){let e=n.getSnapshot().drawings,t=n.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:t==null?[]:t};return JSON.stringify(r)}return``},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:o,businesses:[e.UniverInstanceType.UNIVER_DOC],toJson:e=>t(e),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(t){let n=this._univerInstanceService.getUnit(t,e.UniverInstanceType.UNIVER_DOC);if(!n)return!1;let r=t,i=n.getDrawings(),a=n.getDrawingsOrder();if(!i||!a)return!1;Object.keys(i).forEach(e=>{i[e]={...i[e]}});let o={[r]:{unitId:t,subUnitId:r,data:i,order:a}};return this._docDrawingService.registerDrawingData(t,o),this._drawingManagerService.registerDrawingData(t,o),!0}};s=a([i(0,r),i(1,t.IDrawingManagerService),i(2,e.IResourceManagerService),i(3,e.IUniverInstanceService)],s);var c=`@univerjs/docs-drawing`,l=`0.20.0`;const u=`docs-drawing.config`;Symbol(u);const 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}let g=class extends e.Plugin{constructor(t=d,n,r){super(),this._config=t,this._injector=n,this._configService=r;let{...i}=(0,e.merge)({},d,this._config);this._configService.setConfig(u,i)}onStarting(){[[s],[n],[r,{useClass:n}]].forEach(e=>this._injector.add(e)),(0,e.touchDependencies)(this._injector,[[s]])}};h(g,`pluginName`,o),h(g,`packageName`,c),h(g,`version`,l),h(g,`type`,e.UniverInstanceType.UNIVER_DOC),g=a([i(1,(0,e.Inject)(e.Injector)),i(2,e.IConfigService)],g),exports.DOCS_DRAWING_PLUGIN=o,Object.defineProperty(exports,`DocDrawingController`,{enumerable:!0,get:function(){return s}}),exports.DocDrawingService=n,exports.IDocDrawingService=r,Object.defineProperty(exports,`UniverDocsDrawingPlugin`,{enumerable:!0,get:function(){return g}});
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/drawing`);var n=class extends t.UnitDrawingService{};const r=(0,e.createIdentifier)(`univer.doc.plugin.doc-drawing.service`);function i(e,t){return function(n,r){t(n,r,e)}}function a(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}const o=`DOC_DRAWING_PLUGIN`;let s=class extends e.Disposable{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let t=t=>{let n=this._univerInstanceService.getUnit(t,e.UniverInstanceType.UNIVER_DOC);if(n){let e=n.getSnapshot().drawings,t=n.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:t==null?[]:t};return JSON.stringify(r)}return``},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:o,businesses:[e.UniverInstanceType.UNIVER_DOC],toJson:e=>t(e),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(t){let n=this._univerInstanceService.getUnit(t,e.UniverInstanceType.UNIVER_DOC);if(!n)return!1;let r=t,i=n.getDrawings(),a=n.getDrawingsOrder();if(!i||!a)return!1;Object.keys(i).forEach(e=>{i[e]={...i[e]}});let o={[r]:{unitId:t,subUnitId:r,data:i,order:a}};return this._docDrawingService.registerDrawingData(t,o),this._drawingManagerService.registerDrawingData(t,o),!0}};s=a([i(0,r),i(1,t.IDrawingManagerService),i(2,e.IResourceManagerService),i(3,e.IUniverInstanceService)],s);var c=`@univerjs/docs-drawing`,l=`0.20.1`;const u=`docs-drawing.config`;Symbol(u);const 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}let g=class extends e.Plugin{constructor(t=d,n,r){super(),this._config=t,this._injector=n,this._configService=r;let{...i}=(0,e.merge)({},d,this._config);this._configService.setConfig(u,i)}onStarting(){[[s],[n],[r,{useClass:n}]].forEach(e=>this._injector.add(e)),(0,e.touchDependencies)(this._injector,[[s]])}};h(g,`pluginName`,o),h(g,`packageName`,c),h(g,`version`,l),h(g,`type`,e.UniverInstanceType.UNIVER_DOC),g=a([i(1,(0,e.Inject)(e.Injector)),i(2,e.IConfigService)],g),exports.DOCS_DRAWING_PLUGIN=o,Object.defineProperty(exports,`DocDrawingController`,{enumerable:!0,get:function(){return s}}),exports.DocDrawingService=n,exports.IDocDrawingService=r,Object.defineProperty(exports,`UniverDocsDrawingPlugin`,{enumerable:!0,get:function(){return g}});
package/lib/es/index.js CHANGED
@@ -1 +1 @@
1
- import{Disposable as e,IConfigService as t,IResourceManagerService as n,IUniverInstanceService as r,Inject as i,Injector as a,Plugin as o,UniverInstanceType as s,createIdentifier as c,merge as l,touchDependencies as u}from"@univerjs/core";import{IDrawingManagerService as d,UnitDrawingService as f}from"@univerjs/drawing";var p=class extends f{};const m=c(`univer.doc.plugin.doc-drawing.service`);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}const _=`DOC_DRAWING_PLUGIN`;let v=class extends e{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(t){let e=t.getSnapshot().drawings,n=t.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:n==null?[]:n};return JSON.stringify(r)}return``},t=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:_,businesses:[s.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>t(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(!t)return!1;let n=e,r=t.getDrawings(),i=t.getDrawingsOrder();if(!r||!i)return!1;Object.keys(r).forEach(e=>{r[e]={...r[e]}});let a={[n]:{unitId:e,subUnitId:n,data:r,order:i}};return this._docDrawingService.registerDrawingData(e,a),this._drawingManagerService.registerDrawingData(e,a),!0}};v=g([h(0,m),h(1,d),h(2,n),h(3,r)],v);var y=`@univerjs/docs-drawing`,b=`0.20.0`;const x=`docs-drawing.config`;Symbol(x);const S={};function C(e){"@babel/helpers - typeof";return C=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},C(e)}function w(e,t){if(C(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(C(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function T(e){var t=w(e,`string`);return C(t)==`symbol`?t:t+``}function E(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=class extends o{constructor(e=S,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=l({},S,this._config);this._configService.setConfig(x,r)}onStarting(){[[v],[p],[m,{useClass:p}]].forEach(e=>this._injector.add(e)),u(this._injector,[[v]])}};E(D,`pluginName`,_),E(D,`packageName`,y),E(D,`version`,b),E(D,`type`,s.UNIVER_DOC),D=g([h(1,i(a)),h(2,t)],D);export{_ as DOCS_DRAWING_PLUGIN,v as DocDrawingController,p as DocDrawingService,m as IDocDrawingService,D as UniverDocsDrawingPlugin};
1
+ import{Disposable as e,IConfigService as t,IResourceManagerService as n,IUniverInstanceService as r,Inject as i,Injector as a,Plugin as o,UniverInstanceType as s,createIdentifier as c,merge as l,touchDependencies as u}from"@univerjs/core";import{IDrawingManagerService as d,UnitDrawingService as f}from"@univerjs/drawing";var p=class extends f{};const m=c(`univer.doc.plugin.doc-drawing.service`);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}const _=`DOC_DRAWING_PLUGIN`;let v=class extends e{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(t){let e=t.getSnapshot().drawings,n=t.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:n==null?[]:n};return JSON.stringify(r)}return``},t=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:_,businesses:[s.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>t(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(!t)return!1;let n=e,r=t.getDrawings(),i=t.getDrawingsOrder();if(!r||!i)return!1;Object.keys(r).forEach(e=>{r[e]={...r[e]}});let a={[n]:{unitId:e,subUnitId:n,data:r,order:i}};return this._docDrawingService.registerDrawingData(e,a),this._drawingManagerService.registerDrawingData(e,a),!0}};v=g([h(0,m),h(1,d),h(2,n),h(3,r)],v);var y=`@univerjs/docs-drawing`,b=`0.20.1`;const x=`docs-drawing.config`;Symbol(x);const S={};function C(e){"@babel/helpers - typeof";return C=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},C(e)}function w(e,t){if(C(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(C(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function T(e){var t=w(e,`string`);return C(t)==`symbol`?t:t+``}function E(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=class extends o{constructor(e=S,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=l({},S,this._config);this._configService.setConfig(x,r)}onStarting(){[[v],[p],[m,{useClass:p}]].forEach(e=>this._injector.add(e)),u(this._injector,[[v]])}};E(D,`pluginName`,_),E(D,`packageName`,y),E(D,`version`,b),E(D,`type`,s.UNIVER_DOC),D=g([h(1,i(a)),h(2,t)],D);export{_ as DOCS_DRAWING_PLUGIN,v as DocDrawingController,p as DocDrawingService,m as IDocDrawingService,D as UniverDocsDrawingPlugin};
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- import{Disposable as e,IConfigService as t,IResourceManagerService as n,IUniverInstanceService as r,Inject as i,Injector as a,Plugin as o,UniverInstanceType as s,createIdentifier as c,merge as l,touchDependencies as u}from"@univerjs/core";import{IDrawingManagerService as d,UnitDrawingService as f}from"@univerjs/drawing";var p=class extends f{};const m=c(`univer.doc.plugin.doc-drawing.service`);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}const _=`DOC_DRAWING_PLUGIN`;let v=class extends e{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(t){let e=t.getSnapshot().drawings,n=t.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:n==null?[]:n};return JSON.stringify(r)}return``},t=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:_,businesses:[s.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>t(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(!t)return!1;let n=e,r=t.getDrawings(),i=t.getDrawingsOrder();if(!r||!i)return!1;Object.keys(r).forEach(e=>{r[e]={...r[e]}});let a={[n]:{unitId:e,subUnitId:n,data:r,order:i}};return this._docDrawingService.registerDrawingData(e,a),this._drawingManagerService.registerDrawingData(e,a),!0}};v=g([h(0,m),h(1,d),h(2,n),h(3,r)],v);var y=`@univerjs/docs-drawing`,b=`0.20.0`;const x=`docs-drawing.config`;Symbol(x);const S={};function C(e){"@babel/helpers - typeof";return C=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},C(e)}function w(e,t){if(C(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(C(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function T(e){var t=w(e,`string`);return C(t)==`symbol`?t:t+``}function E(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=class extends o{constructor(e=S,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=l({},S,this._config);this._configService.setConfig(x,r)}onStarting(){[[v],[p],[m,{useClass:p}]].forEach(e=>this._injector.add(e)),u(this._injector,[[v]])}};E(D,`pluginName`,_),E(D,`packageName`,y),E(D,`version`,b),E(D,`type`,s.UNIVER_DOC),D=g([h(1,i(a)),h(2,t)],D);export{_ as DOCS_DRAWING_PLUGIN,v as DocDrawingController,p as DocDrawingService,m as IDocDrawingService,D as UniverDocsDrawingPlugin};
1
+ import{Disposable as e,IConfigService as t,IResourceManagerService as n,IUniverInstanceService as r,Inject as i,Injector as a,Plugin as o,UniverInstanceType as s,createIdentifier as c,merge as l,touchDependencies as u}from"@univerjs/core";import{IDrawingManagerService as d,UnitDrawingService as f}from"@univerjs/drawing";var p=class extends f{};const m=c(`univer.doc.plugin.doc-drawing.service`);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}const _=`DOC_DRAWING_PLUGIN`;let v=class extends e{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(t){let e=t.getSnapshot().drawings,n=t.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:n==null?[]:n};return JSON.stringify(r)}return``},t=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:_,businesses:[s.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>t(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let t=this._univerInstanceService.getUnit(e,s.UNIVER_DOC);if(!t)return!1;let n=e,r=t.getDrawings(),i=t.getDrawingsOrder();if(!r||!i)return!1;Object.keys(r).forEach(e=>{r[e]={...r[e]}});let a={[n]:{unitId:e,subUnitId:n,data:r,order:i}};return this._docDrawingService.registerDrawingData(e,a),this._drawingManagerService.registerDrawingData(e,a),!0}};v=g([h(0,m),h(1,d),h(2,n),h(3,r)],v);var y=`@univerjs/docs-drawing`,b=`0.20.1`;const x=`docs-drawing.config`;Symbol(x);const S={};function C(e){"@babel/helpers - typeof";return C=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},C(e)}function w(e,t){if(C(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(C(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function T(e){var t=w(e,`string`);return C(t)==`symbol`?t:t+``}function E(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=class extends o{constructor(e=S,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=l({},S,this._config);this._configService.setConfig(x,r)}onStarting(){[[v],[p],[m,{useClass:p}]].forEach(e=>this._injector.add(e)),u(this._injector,[[v]])}};E(D,`pluginName`,_),E(D,`packageName`,y),E(D,`version`,b),E(D,`type`,s.UNIVER_DOC),D=g([h(1,i(a)),h(2,t)],D);export{_ as DOCS_DRAWING_PLUGIN,v as DocDrawingController,p as DocDrawingService,m as IDocDrawingService,D as UniverDocsDrawingPlugin};
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/drawing`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsDrawing={},e.UniverCore,e.UniverDrawing))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends n.UnitDrawingService{};let i=(0,t.createIdentifier)(`univer.doc.plugin.doc-drawing.service`);function a(e,t){return function(n,r){t(n,r,e)}}function o(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 s=`DOC_DRAWING_PLUGIN`,c=class extends t.Disposable{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(n){let e=n.getSnapshot().drawings,t=n.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:t==null?[]:t};return JSON.stringify(r)}return``},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:s,businesses:[t.UniverInstanceType.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(!n)return!1;let r=e,i=n.getDrawings(),a=n.getDrawingsOrder();if(!i||!a)return!1;Object.keys(i).forEach(e=>{i[e]={...i[e]}});let o={[r]:{unitId:e,subUnitId:r,data:i,order:a}};return this._docDrawingService.registerDrawingData(e,o),this._drawingManagerService.registerDrawingData(e,o),!0}};c=o([a(0,i),a(1,n.IDrawingManagerService),a(2,t.IResourceManagerService),a(3,t.IUniverInstanceService)],c);var l=`@univerjs/docs-drawing`,u=`0.20.0`;let d=`docs-drawing.config`;Symbol(d);let f={};function p(e){"@babel/helpers - typeof";return p=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},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let _=class extends t.Plugin{constructor(e=f,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},f,this._config);this._configService.setConfig(d,i)}onStarting(){[[c],[r],[i,{useClass:r}]].forEach(e=>this._injector.add(e)),(0,t.touchDependencies)(this._injector,[[c]])}};g(_,`pluginName`,s),g(_,`packageName`,l),g(_,`version`,u),g(_,`type`,t.UniverInstanceType.UNIVER_DOC),_=o([a(1,(0,t.Inject)(t.Injector)),a(2,t.IConfigService)],_),e.DOCS_DRAWING_PLUGIN=s,Object.defineProperty(e,`DocDrawingController`,{enumerable:!0,get:function(){return c}}),e.DocDrawingService=r,e.IDocDrawingService=i,Object.defineProperty(e,`UniverDocsDrawingPlugin`,{enumerable:!0,get:function(){return _}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/drawing`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsDrawing={},e.UniverCore,e.UniverDrawing))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends n.UnitDrawingService{};let i=(0,t.createIdentifier)(`univer.doc.plugin.doc-drawing.service`);function a(e,t){return function(n,r){t(n,r,e)}}function o(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 s=`DOC_DRAWING_PLUGIN`,c=class extends t.Disposable{constructor(e,t,n,r){super(),this._docDrawingService=e,this._drawingManagerService=t,this._resourceManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){let e=e=>{let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(n){let e=n.getSnapshot().drawings,t=n.getSnapshot().drawingsOrder,r={data:e==null?{}:e,order:t==null?[]:t};return JSON.stringify(r)}return``},n=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:s,businesses:[t.UniverInstanceType.UNIVER_DOC],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,t)=>{var n,r;this._setDrawingDataForUnit(e,{data:(n=t.data)==null?{}:n,order:(r=t.order)==null?[]:r})}}))}_setDrawingDataForUnit(e,t){let n=this._univerInstanceService.getUnit(e);n!=null&&(n.resetDrawing(t.data,t.order),this.loadDrawingDataForUnit(e))}loadDrawingDataForUnit(e){let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(!n)return!1;let r=e,i=n.getDrawings(),a=n.getDrawingsOrder();if(!i||!a)return!1;Object.keys(i).forEach(e=>{i[e]={...i[e]}});let o={[r]:{unitId:e,subUnitId:r,data:i,order:a}};return this._docDrawingService.registerDrawingData(e,o),this._drawingManagerService.registerDrawingData(e,o),!0}};c=o([a(0,i),a(1,n.IDrawingManagerService),a(2,t.IResourceManagerService),a(3,t.IUniverInstanceService)],c);var l=`@univerjs/docs-drawing`,u=`0.20.1`;let d=`docs-drawing.config`;Symbol(d);let f={};function p(e){"@babel/helpers - typeof";return p=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},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let _=class extends t.Plugin{constructor(e=f,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},f,this._config);this._configService.setConfig(d,i)}onStarting(){[[c],[r],[i,{useClass:r}]].forEach(e=>this._injector.add(e)),(0,t.touchDependencies)(this._injector,[[c]])}};g(_,`pluginName`,s),g(_,`packageName`,l),g(_,`version`,u),g(_,`type`,t.UniverInstanceType.UNIVER_DOC),_=o([a(1,(0,t.Inject)(t.Injector)),a(2,t.IConfigService)],_),e.DOCS_DRAWING_PLUGIN=s,Object.defineProperty(e,`DocDrawingController`,{enumerable:!0,get:function(){return c}}),e.DocDrawingService=r,e.IDocDrawingService=i,Object.defineProperty(e,`UniverDocsDrawingPlugin`,{enumerable:!0,get:function(){return _}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-drawing",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -43,13 +43,13 @@
43
43
  "lib"
44
44
  ],
45
45
  "dependencies": {
46
- "@univerjs/core": "0.20.0",
47
- "@univerjs/drawing": "0.20.0"
46
+ "@univerjs/core": "0.20.1",
47
+ "@univerjs/drawing": "0.20.1"
48
48
  },
49
49
  "devDependencies": {
50
50
  "typescript": "^6.0.2",
51
51
  "vitest": "^4.1.1",
52
- "@univerjs-infra/shared": "0.20.0"
52
+ "@univerjs-infra/shared": "0.20.1"
53
53
  },
54
54
  "scripts": {
55
55
  "test": "vitest run",