@univerjs/sheets-drawing 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/drawing`),n=require(`@univerjs/sheets`),r=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var i=class extends t.UnitDrawingService{};const a=(0,e.createIdentifier)(`sheets-drawing.sheet-drawing.service`);let o=function(e){return e[e.INSERT=0]=`INSERT`,e[e.REMOVE=1]=`REMOVE`,e[e.UPDATE=2]=`UPDATE`,e[e.ARRANGE=3]=`ARRANGE`,e[e.GROUP=4]=`GROUP`,e[e.UNGROUP=5]=`UNGROUP`,e}({});const s={id:`sheet.mutation.set-drawing-apply`,type:e.CommandType.MUTATION,handler:(e,n)=>{let r=e.get(t.IDrawingManagerService),i=e.get(a),{op:s,unitId:c,subUnitId:l,type:u,objects:d}=n;switch(r.applyJson1(c,l,s),i.applyJson1(c,l,s),u){case o.INSERT:r.addNotification(d),i.addNotification(d);break;case o.REMOVE:r.removeNotification(d),i.removeNotification(d);break;case o.UPDATE:r.updateNotification(d),i.updateNotification(d);break;case o.ARRANGE:r.orderNotification(d),i.orderNotification(d);break;case o.GROUP:r.groupUpdateNotification(d);break;case o.UNGROUP:r.ungroupUpdateNotification(d);break}return!0}};function c(e,t){return function(n,r){t(n,r,e)}}function l(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 u=`SHEET_DRAWING_PLUGIN`;let d=class extends e.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(s))}_initSnapshot(){let t=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:u,businesses:[e.UniverInstanceType.UNIVER_SHEET],toJson:(e,n)=>t(e,n),parseJson:e=>n(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{if(t.id===n.RemoveSheetCommand.id){var r;let n=t.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!i||!a)return{redos:[],undos:[]};let c=this._sheetDrawingService.getDrawingData(i,a),l=Object.values(c).filter(t=>t.drawingType!==e.DrawingTypeEnum.DRAWING_CHART);if(l.length===0)return{redos:[],undos:[]};let{unitId:u,subUnitId:d,undo:f,redo:p,objects:m}=this._sheetDrawingService.getBatchRemoveOp(l);return{redos:[{id:s.id,params:{op:p,unitId:u,subUnitId:d,objects:m,type:o.REMOVE}}],undos:[{id:s.id,params:{op:f,unitId:u,subUnitId:d,objects:m,type:o.INSERT}}]}}else if(t.id===n.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:i}=t.params;if(!n||!r||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(n,r),c=Object.values(a).filter(t=>t.drawingType!==e.DrawingTypeEnum.DRAWING_CHART).map(t=>({...t,subUnitId:i,drawingId:(0,e.generateRandomId)(6)}));if(c.length===0)return{redos:[],undos:[]};let{unitId:l,subUnitId:u,undo:d,redo:f,objects:p}=this._sheetDrawingService.getBatchAddOp(c);return{redos:[{id:s.id,params:{op:f,unitId:l,subUnitId:u,objects:p,type:o.INSERT}}],undos:[{id:s.id,params:{op:d,unitId:l,subUnitId:u,objects:p,type:o.REMOVE}}]}}return{redos:[],undos:[]}}}))}};d=l([c(0,(0,e.Inject)(n.SheetInterceptorService)),c(1,(0,e.Inject)(e.IUniverInstanceService)),c(2,e.ICommandService),c(3,a),c(4,t.IDrawingManagerService),c(5,e.IResourceManagerService)],d);var f=`@univerjs/sheets-drawing`,p=`0.18.0`;const m=`sheets-drawing.config`;Symbol(m);const h={};function g(e){"@babel/helpers - typeof";return g=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},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let b=class extends e.Plugin{constructor(t=h,n,r){super(),this._config=t,this._injector=n,this._configService=r;let{...i}=(0,e.merge)({},h,this._config);this._configService.setConfig(m,i)}onStarting(){[[d],[a,{useClass:i}]].forEach(e=>this._injector.add(e)),this._injector.get(d)}};y(b,`pluginName`,u),y(b,`packageName`,f),y(b,`version`,p),y(b,`type`,e.UniverInstanceType.UNIVER_SHEET),b=l([(0,e.DependentOn)(t.UniverDrawingPlugin),c(1,(0,e.Inject)(e.Injector)),c(2,e.IConfigService)],b),exports.DrawingApplyType=o,exports.ISheetDrawingService=a,exports.SHEET_DRAWING_PLUGIN=u,exports.SetDrawingApplyMutation=s,exports.SheetDrawingAnchorType=r,Object.defineProperty(exports,`UniverSheetsDrawingPlugin`,{enumerable:!0,get:function(){return b}});
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/drawing`),n=require(`@univerjs/sheets`),r=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var i=class extends t.UnitDrawingService{};const a=(0,e.createIdentifier)(`sheets-drawing.sheet-drawing.service`);let o=function(e){return e[e.INSERT=0]=`INSERT`,e[e.REMOVE=1]=`REMOVE`,e[e.UPDATE=2]=`UPDATE`,e[e.ARRANGE=3]=`ARRANGE`,e[e.GROUP=4]=`GROUP`,e[e.UNGROUP=5]=`UNGROUP`,e}({});const s={id:`sheet.mutation.set-drawing-apply`,type:e.CommandType.MUTATION,handler:(e,n)=>{let r=e.get(t.IDrawingManagerService),i=e.get(a),{op:s,unitId:c,subUnitId:l,type:u,objects:d}=n;switch(r.applyJson1(c,l,s),i.applyJson1(c,l,s),u){case o.INSERT:r.addNotification(d),i.addNotification(d);break;case o.REMOVE:r.removeNotification(d),i.removeNotification(d);break;case o.UPDATE:r.updateNotification(d),i.updateNotification(d);break;case o.ARRANGE:r.orderNotification(d),i.orderNotification(d);break;case o.GROUP:r.groupUpdateNotification(d);break;case o.UNGROUP:r.ungroupUpdateNotification(d);break}return!0}};function c(e,t){return function(n,r){t(n,r,e)}}function l(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 u=`SHEET_DRAWING_PLUGIN`;let d=class extends e.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(s))}_initSnapshot(){let t=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:u,businesses:[e.UniverInstanceType.UNIVER_SHEET],toJson:(e,n)=>t(e,n),parseJson:e=>n(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{if(t.id===n.RemoveSheetCommand.id){var r;let n=t.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!i||!a)return{redos:[],undos:[]};let c=this._sheetDrawingService.getDrawingData(i,a),l=Object.values(c).filter(t=>t.drawingType!==e.DrawingTypeEnum.DRAWING_CHART);if(l.length===0)return{redos:[],undos:[]};let{unitId:u,subUnitId:d,undo:f,redo:p,objects:m}=this._sheetDrawingService.getBatchRemoveOp(l);return{redos:[{id:s.id,params:{op:p,unitId:u,subUnitId:d,objects:m,type:o.REMOVE}}],undos:[{id:s.id,params:{op:f,unitId:u,subUnitId:d,objects:m,type:o.INSERT}}]}}else if(t.id===n.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:i}=t.params;if(!n||!r||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(n,r),c=Object.values(a).filter(t=>t.drawingType!==e.DrawingTypeEnum.DRAWING_CHART).map(t=>({...t,subUnitId:i,drawingId:(0,e.generateRandomId)(6)}));if(c.length===0)return{redos:[],undos:[]};let{unitId:l,subUnitId:u,undo:d,redo:f,objects:p}=this._sheetDrawingService.getBatchAddOp(c);return{redos:[{id:s.id,params:{op:f,unitId:l,subUnitId:u,objects:p,type:o.INSERT}}],undos:[{id:s.id,params:{op:d,unitId:l,subUnitId:u,objects:p,type:o.REMOVE}}]}}return{redos:[],undos:[]}}}))}};d=l([c(0,(0,e.Inject)(n.SheetInterceptorService)),c(1,(0,e.Inject)(e.IUniverInstanceService)),c(2,e.ICommandService),c(3,a),c(4,t.IDrawingManagerService),c(5,e.IResourceManagerService)],d);var f=`@univerjs/sheets-drawing`,p=`0.19.0`;const m=`sheets-drawing.config`;Symbol(m);const h={};function g(e){"@babel/helpers - typeof";return g=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},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let b=class extends e.Plugin{constructor(t=h,n,r){super(),this._config=t,this._injector=n,this._configService=r;let{...i}=(0,e.merge)({},h,this._config);this._configService.setConfig(m,i)}onStarting(){[[d],[a,{useClass:i}]].forEach(e=>this._injector.add(e)),this._injector.get(d)}};y(b,`pluginName`,u),y(b,`packageName`,f),y(b,`version`,p),y(b,`type`,e.UniverInstanceType.UNIVER_SHEET),b=l([(0,e.DependentOn)(t.UniverDrawingPlugin),c(1,(0,e.Inject)(e.Injector)),c(2,e.IConfigService)],b),exports.DrawingApplyType=o,exports.ISheetDrawingService=a,exports.SHEET_DRAWING_PLUGIN=u,exports.SetDrawingApplyMutation=s,exports.SheetDrawingAnchorType=r,Object.defineProperty(exports,`UniverSheetsDrawingPlugin`,{enumerable:!0,get:function(){return b}});
package/lib/es/index.js CHANGED
@@ -1 +1 @@
1
- import{CommandType as e,DependentOn as t,Disposable as n,DrawingTypeEnum as r,ICommandService as i,IConfigService as a,IResourceManagerService as o,IUniverInstanceService as s,Inject as c,Injector as l,Plugin as u,UniverInstanceType as d,createIdentifier as f,generateRandomId as p,merge as m}from"@univerjs/core";import{IDrawingManagerService as h,UnitDrawingService as g,UniverDrawingPlugin as _}from"@univerjs/drawing";import{CopySheetCommand as v,RemoveSheetCommand as y,SheetInterceptorService as b}from"@univerjs/sheets";let x=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var S=class extends g{};const C=f(`sheets-drawing.sheet-drawing.service`);let w=function(e){return e[e.INSERT=0]=`INSERT`,e[e.REMOVE=1]=`REMOVE`,e[e.UPDATE=2]=`UPDATE`,e[e.ARRANGE=3]=`ARRANGE`,e[e.GROUP=4]=`GROUP`,e[e.UNGROUP=5]=`UNGROUP`,e}({});const T={id:`sheet.mutation.set-drawing-apply`,type:e.MUTATION,handler:(e,t)=>{let n=e.get(h),r=e.get(C),{op:i,unitId:a,subUnitId:o,type:s,objects:c}=t;switch(n.applyJson1(a,o,i),r.applyJson1(a,o,i),s){case w.INSERT:n.addNotification(c),r.addNotification(c);break;case w.REMOVE:n.removeNotification(c),r.removeNotification(c);break;case w.UPDATE:n.updateNotification(c),r.updateNotification(c);break;case w.ARRANGE:n.orderNotification(c),r.orderNotification(c);break;case w.GROUP:n.groupUpdateNotification(c);break;case w.UNGROUP:n.ungroupUpdateNotification(c);break}return!0}};function E(e,t){return function(n,r){t(n,r,e)}}function D(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=`SHEET_DRAWING_PLUGIN`;let k=class extends n{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(T))}_initSnapshot(){let e=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:O,businesses:[d.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:e=>t(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===y.id){var t;let n=e.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),s=Object.values(o).filter(e=>e.drawingType!==r.DRAWING_CHART);if(s.length===0)return{redos:[],undos:[]};let{unitId:c,subUnitId:l,undo:u,redo:f,objects:p}=this._sheetDrawingService.getBatchRemoveOp(s);return{redos:[{id:T.id,params:{op:f,unitId:c,subUnitId:l,objects:p,type:w.REMOVE}}],undos:[{id:T.id,params:{op:u,unitId:c,subUnitId:l,objects:p,type:w.INSERT}}]}}else if(e.id===v.id){let{unitId:t,subUnitId:n,targetSubUnitId:i}=e.params;if(!t||!n||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(t,n),o=Object.values(a).filter(e=>e.drawingType!==r.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:p(6)}));if(o.length===0)return{redos:[],undos:[]};let{unitId:s,subUnitId:c,undo:l,redo:u,objects:d}=this._sheetDrawingService.getBatchAddOp(o);return{redos:[{id:T.id,params:{op:u,unitId:s,subUnitId:c,objects:d,type:w.INSERT}}],undos:[{id:T.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:w.REMOVE}}]}}return{redos:[],undos:[]}}}))}};k=D([E(0,c(b)),E(1,c(s)),E(2,i),E(3,C),E(4,h),E(5,o)],k);var A=`@univerjs/sheets-drawing`,j=`0.18.0`;const M=`sheets-drawing.config`;Symbol(M);const N={};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 F(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 I(e){var t=F(e,`string`);return P(t)==`symbol`?t:t+``}function L(e,t,n){return(t=I(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let R=class extends u{constructor(e=N,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=m({},N,this._config);this._configService.setConfig(M,r)}onStarting(){[[k],[C,{useClass:S}]].forEach(e=>this._injector.add(e)),this._injector.get(k)}};L(R,`pluginName`,O),L(R,`packageName`,A),L(R,`version`,j),L(R,`type`,d.UNIVER_SHEET),R=D([t(_),E(1,c(l)),E(2,a)],R);export{w as DrawingApplyType,C as ISheetDrawingService,O as SHEET_DRAWING_PLUGIN,T as SetDrawingApplyMutation,x as SheetDrawingAnchorType,R as UniverSheetsDrawingPlugin};
1
+ import{CommandType as e,DependentOn as t,Disposable as n,DrawingTypeEnum as r,ICommandService as i,IConfigService as a,IResourceManagerService as o,IUniverInstanceService as s,Inject as c,Injector as l,Plugin as u,UniverInstanceType as d,createIdentifier as f,generateRandomId as p,merge as m}from"@univerjs/core";import{IDrawingManagerService as h,UnitDrawingService as g,UniverDrawingPlugin as _}from"@univerjs/drawing";import{CopySheetCommand as v,RemoveSheetCommand as y,SheetInterceptorService as b}from"@univerjs/sheets";let x=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var S=class extends g{};const C=f(`sheets-drawing.sheet-drawing.service`);let w=function(e){return e[e.INSERT=0]=`INSERT`,e[e.REMOVE=1]=`REMOVE`,e[e.UPDATE=2]=`UPDATE`,e[e.ARRANGE=3]=`ARRANGE`,e[e.GROUP=4]=`GROUP`,e[e.UNGROUP=5]=`UNGROUP`,e}({});const T={id:`sheet.mutation.set-drawing-apply`,type:e.MUTATION,handler:(e,t)=>{let n=e.get(h),r=e.get(C),{op:i,unitId:a,subUnitId:o,type:s,objects:c}=t;switch(n.applyJson1(a,o,i),r.applyJson1(a,o,i),s){case w.INSERT:n.addNotification(c),r.addNotification(c);break;case w.REMOVE:n.removeNotification(c),r.removeNotification(c);break;case w.UPDATE:n.updateNotification(c),r.updateNotification(c);break;case w.ARRANGE:n.orderNotification(c),r.orderNotification(c);break;case w.GROUP:n.groupUpdateNotification(c);break;case w.UNGROUP:n.ungroupUpdateNotification(c);break}return!0}};function E(e,t){return function(n,r){t(n,r,e)}}function D(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=`SHEET_DRAWING_PLUGIN`;let k=class extends n{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(T))}_initSnapshot(){let e=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:O,businesses:[d.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:e=>t(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===y.id){var t;let n=e.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),s=Object.values(o).filter(e=>e.drawingType!==r.DRAWING_CHART);if(s.length===0)return{redos:[],undos:[]};let{unitId:c,subUnitId:l,undo:u,redo:f,objects:p}=this._sheetDrawingService.getBatchRemoveOp(s);return{redos:[{id:T.id,params:{op:f,unitId:c,subUnitId:l,objects:p,type:w.REMOVE}}],undos:[{id:T.id,params:{op:u,unitId:c,subUnitId:l,objects:p,type:w.INSERT}}]}}else if(e.id===v.id){let{unitId:t,subUnitId:n,targetSubUnitId:i}=e.params;if(!t||!n||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(t,n),o=Object.values(a).filter(e=>e.drawingType!==r.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:p(6)}));if(o.length===0)return{redos:[],undos:[]};let{unitId:s,subUnitId:c,undo:l,redo:u,objects:d}=this._sheetDrawingService.getBatchAddOp(o);return{redos:[{id:T.id,params:{op:u,unitId:s,subUnitId:c,objects:d,type:w.INSERT}}],undos:[{id:T.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:w.REMOVE}}]}}return{redos:[],undos:[]}}}))}};k=D([E(0,c(b)),E(1,c(s)),E(2,i),E(3,C),E(4,h),E(5,o)],k);var A=`@univerjs/sheets-drawing`,j=`0.19.0`;const M=`sheets-drawing.config`;Symbol(M);const N={};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 F(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 I(e){var t=F(e,`string`);return P(t)==`symbol`?t:t+``}function L(e,t,n){return(t=I(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let R=class extends u{constructor(e=N,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=m({},N,this._config);this._configService.setConfig(M,r)}onStarting(){[[k],[C,{useClass:S}]].forEach(e=>this._injector.add(e)),this._injector.get(k)}};L(R,`pluginName`,O),L(R,`packageName`,A),L(R,`version`,j),L(R,`type`,d.UNIVER_SHEET),R=D([t(_),E(1,c(l)),E(2,a)],R);export{w as DrawingApplyType,C as ISheetDrawingService,O as SHEET_DRAWING_PLUGIN,T as SetDrawingApplyMutation,x as SheetDrawingAnchorType,R as UniverSheetsDrawingPlugin};
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- import{CommandType as e,DependentOn as t,Disposable as n,DrawingTypeEnum as r,ICommandService as i,IConfigService as a,IResourceManagerService as o,IUniverInstanceService as s,Inject as c,Injector as l,Plugin as u,UniverInstanceType as d,createIdentifier as f,generateRandomId as p,merge as m}from"@univerjs/core";import{IDrawingManagerService as h,UnitDrawingService as g,UniverDrawingPlugin as _}from"@univerjs/drawing";import{CopySheetCommand as v,RemoveSheetCommand as y,SheetInterceptorService as b}from"@univerjs/sheets";let x=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var S=class extends g{};const C=f(`sheets-drawing.sheet-drawing.service`);let w=function(e){return e[e.INSERT=0]=`INSERT`,e[e.REMOVE=1]=`REMOVE`,e[e.UPDATE=2]=`UPDATE`,e[e.ARRANGE=3]=`ARRANGE`,e[e.GROUP=4]=`GROUP`,e[e.UNGROUP=5]=`UNGROUP`,e}({});const T={id:`sheet.mutation.set-drawing-apply`,type:e.MUTATION,handler:(e,t)=>{let n=e.get(h),r=e.get(C),{op:i,unitId:a,subUnitId:o,type:s,objects:c}=t;switch(n.applyJson1(a,o,i),r.applyJson1(a,o,i),s){case w.INSERT:n.addNotification(c),r.addNotification(c);break;case w.REMOVE:n.removeNotification(c),r.removeNotification(c);break;case w.UPDATE:n.updateNotification(c),r.updateNotification(c);break;case w.ARRANGE:n.orderNotification(c),r.orderNotification(c);break;case w.GROUP:n.groupUpdateNotification(c);break;case w.UNGROUP:n.ungroupUpdateNotification(c);break}return!0}};function E(e,t){return function(n,r){t(n,r,e)}}function D(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=`SHEET_DRAWING_PLUGIN`;let k=class extends n{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(T))}_initSnapshot(){let e=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:O,businesses:[d.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:e=>t(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===y.id){var t;let n=e.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),s=Object.values(o).filter(e=>e.drawingType!==r.DRAWING_CHART);if(s.length===0)return{redos:[],undos:[]};let{unitId:c,subUnitId:l,undo:u,redo:f,objects:p}=this._sheetDrawingService.getBatchRemoveOp(s);return{redos:[{id:T.id,params:{op:f,unitId:c,subUnitId:l,objects:p,type:w.REMOVE}}],undos:[{id:T.id,params:{op:u,unitId:c,subUnitId:l,objects:p,type:w.INSERT}}]}}else if(e.id===v.id){let{unitId:t,subUnitId:n,targetSubUnitId:i}=e.params;if(!t||!n||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(t,n),o=Object.values(a).filter(e=>e.drawingType!==r.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:p(6)}));if(o.length===0)return{redos:[],undos:[]};let{unitId:s,subUnitId:c,undo:l,redo:u,objects:d}=this._sheetDrawingService.getBatchAddOp(o);return{redos:[{id:T.id,params:{op:u,unitId:s,subUnitId:c,objects:d,type:w.INSERT}}],undos:[{id:T.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:w.REMOVE}}]}}return{redos:[],undos:[]}}}))}};k=D([E(0,c(b)),E(1,c(s)),E(2,i),E(3,C),E(4,h),E(5,o)],k);var A=`@univerjs/sheets-drawing`,j=`0.18.0`;const M=`sheets-drawing.config`;Symbol(M);const N={};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 F(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 I(e){var t=F(e,`string`);return P(t)==`symbol`?t:t+``}function L(e,t,n){return(t=I(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let R=class extends u{constructor(e=N,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=m({},N,this._config);this._configService.setConfig(M,r)}onStarting(){[[k],[C,{useClass:S}]].forEach(e=>this._injector.add(e)),this._injector.get(k)}};L(R,`pluginName`,O),L(R,`packageName`,A),L(R,`version`,j),L(R,`type`,d.UNIVER_SHEET),R=D([t(_),E(1,c(l)),E(2,a)],R);export{w as DrawingApplyType,C as ISheetDrawingService,O as SHEET_DRAWING_PLUGIN,T as SetDrawingApplyMutation,x as SheetDrawingAnchorType,R as UniverSheetsDrawingPlugin};
1
+ import{CommandType as e,DependentOn as t,Disposable as n,DrawingTypeEnum as r,ICommandService as i,IConfigService as a,IResourceManagerService as o,IUniverInstanceService as s,Inject as c,Injector as l,Plugin as u,UniverInstanceType as d,createIdentifier as f,generateRandomId as p,merge as m}from"@univerjs/core";import{IDrawingManagerService as h,UnitDrawingService as g,UniverDrawingPlugin as _}from"@univerjs/drawing";import{CopySheetCommand as v,RemoveSheetCommand as y,SheetInterceptorService as b}from"@univerjs/sheets";let x=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var S=class extends g{};const C=f(`sheets-drawing.sheet-drawing.service`);let w=function(e){return e[e.INSERT=0]=`INSERT`,e[e.REMOVE=1]=`REMOVE`,e[e.UPDATE=2]=`UPDATE`,e[e.ARRANGE=3]=`ARRANGE`,e[e.GROUP=4]=`GROUP`,e[e.UNGROUP=5]=`UNGROUP`,e}({});const T={id:`sheet.mutation.set-drawing-apply`,type:e.MUTATION,handler:(e,t)=>{let n=e.get(h),r=e.get(C),{op:i,unitId:a,subUnitId:o,type:s,objects:c}=t;switch(n.applyJson1(a,o,i),r.applyJson1(a,o,i),s){case w.INSERT:n.addNotification(c),r.addNotification(c);break;case w.REMOVE:n.removeNotification(c),r.removeNotification(c);break;case w.UPDATE:n.updateNotification(c),r.updateNotification(c);break;case w.ARRANGE:n.orderNotification(c),r.orderNotification(c);break;case w.GROUP:n.groupUpdateNotification(c);break;case w.UNGROUP:n.ungroupUpdateNotification(c);break}return!0}};function E(e,t){return function(n,r){t(n,r,e)}}function D(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=`SHEET_DRAWING_PLUGIN`;let k=class extends n{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(T))}_initSnapshot(){let e=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:O,businesses:[d.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:e=>t(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===y.id){var t;let n=e.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(d.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),s=Object.values(o).filter(e=>e.drawingType!==r.DRAWING_CHART);if(s.length===0)return{redos:[],undos:[]};let{unitId:c,subUnitId:l,undo:u,redo:f,objects:p}=this._sheetDrawingService.getBatchRemoveOp(s);return{redos:[{id:T.id,params:{op:f,unitId:c,subUnitId:l,objects:p,type:w.REMOVE}}],undos:[{id:T.id,params:{op:u,unitId:c,subUnitId:l,objects:p,type:w.INSERT}}]}}else if(e.id===v.id){let{unitId:t,subUnitId:n,targetSubUnitId:i}=e.params;if(!t||!n||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(t,n),o=Object.values(a).filter(e=>e.drawingType!==r.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:p(6)}));if(o.length===0)return{redos:[],undos:[]};let{unitId:s,subUnitId:c,undo:l,redo:u,objects:d}=this._sheetDrawingService.getBatchAddOp(o);return{redos:[{id:T.id,params:{op:u,unitId:s,subUnitId:c,objects:d,type:w.INSERT}}],undos:[{id:T.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:w.REMOVE}}]}}return{redos:[],undos:[]}}}))}};k=D([E(0,c(b)),E(1,c(s)),E(2,i),E(3,C),E(4,h),E(5,o)],k);var A=`@univerjs/sheets-drawing`,j=`0.19.0`;const M=`sheets-drawing.config`;Symbol(M);const N={};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 F(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 I(e){var t=F(e,`string`);return P(t)==`symbol`?t:t+``}function L(e,t,n){return(t=I(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let R=class extends u{constructor(e=N,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{...r}=m({},N,this._config);this._configService.setConfig(M,r)}onStarting(){[[k],[C,{useClass:S}]].forEach(e=>this._injector.add(e)),this._injector.get(k)}};L(R,`pluginName`,O),L(R,`packageName`,A),L(R,`version`,j),L(R,`type`,d.UNIVER_SHEET),R=D([t(_),E(1,c(l)),E(2,a)],R);export{w as DrawingApplyType,C as ISheetDrawingService,O as SHEET_DRAWING_PLUGIN,T as SetDrawingApplyMutation,x as SheetDrawingAnchorType,R as UniverSheetsDrawingPlugin};
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`),require(`@univerjs/sheets`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`,`@univerjs/sheets`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDrawing={},e.UniverCore,e.UniverDrawing,e.UniverSheets))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let i=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var a=class extends n.UnitDrawingService{};let o=(0,t.createIdentifier)(`sheets-drawing.sheet-drawing.service`),s=function(e){return e[e.INSERT=0]=`INSERT`,e[e.REMOVE=1]=`REMOVE`,e[e.UPDATE=2]=`UPDATE`,e[e.ARRANGE=3]=`ARRANGE`,e[e.GROUP=4]=`GROUP`,e[e.UNGROUP=5]=`UNGROUP`,e}({}),c={id:`sheet.mutation.set-drawing-apply`,type:t.CommandType.MUTATION,handler:(e,t)=>{let r=e.get(n.IDrawingManagerService),i=e.get(o),{op:a,unitId:c,subUnitId:l,type:u,objects:d}=t;switch(r.applyJson1(c,l,a),i.applyJson1(c,l,a),u){case s.INSERT:r.addNotification(d),i.addNotification(d);break;case s.REMOVE:r.removeNotification(d),i.removeNotification(d);break;case s.UPDATE:r.updateNotification(d),i.updateNotification(d);break;case s.ARRANGE:r.orderNotification(d),i.orderNotification(d);break;case s.GROUP:r.groupUpdateNotification(d);break;case s.UNGROUP:r.ungroupUpdateNotification(d);break}return!0}};function l(e,t){return function(n,r){t(n,r,e)}}function u(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 d=`SHEET_DRAWING_PLUGIN`,f=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(c))}_initSnapshot(){let e=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:d,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:e=>n(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,i=r.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=r.subUnitId||((n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),l=Object.values(o).filter(e=>e.drawingType!==t.DrawingTypeEnum.DRAWING_CHART);if(l.length===0)return{redos:[],undos:[]};let{unitId:u,subUnitId:d,undo:f,redo:p,objects:m}=this._sheetDrawingService.getBatchRemoveOp(l);return{redos:[{id:c.id,params:{op:p,unitId:u,subUnitId:d,objects:m,type:s.REMOVE}}],undos:[{id:c.id,params:{op:f,unitId:u,subUnitId:d,objects:m,type:s.INSERT}}]}}else if(e.id===r.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:i}=e.params;if(!n||!r||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(n,r),o=Object.values(a).filter(e=>e.drawingType!==t.DrawingTypeEnum.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:(0,t.generateRandomId)(6)}));if(o.length===0)return{redos:[],undos:[]};let{unitId:l,subUnitId:u,undo:d,redo:f,objects:p}=this._sheetDrawingService.getBatchAddOp(o);return{redos:[{id:c.id,params:{op:f,unitId:l,subUnitId:u,objects:p,type:s.INSERT}}],undos:[{id:c.id,params:{op:d,unitId:l,subUnitId:u,objects:p,type:s.REMOVE}}]}}return{redos:[],undos:[]}}}))}};f=u([l(0,(0,t.Inject)(r.SheetInterceptorService)),l(1,(0,t.Inject)(t.IUniverInstanceService)),l(2,t.ICommandService),l(3,o),l(4,n.IDrawingManagerService),l(5,t.IResourceManagerService)],f);var p=`@univerjs/sheets-drawing`,m=`0.18.0`;let h=`sheets-drawing.config`;Symbol(h);let g={};function _(e){"@babel/helpers - typeof";return _=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},_(e)}function v(e,t){if(_(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(_(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function y(e){var t=v(e,`string`);return _(t)==`symbol`?t:t+``}function b(e,t,n){return(t=y(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let x=class extends t.Plugin{constructor(e=g,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},g,this._config);this._configService.setConfig(h,i)}onStarting(){[[f],[o,{useClass:a}]].forEach(e=>this._injector.add(e)),this._injector.get(f)}};b(x,`pluginName`,d),b(x,`packageName`,p),b(x,`version`,m),b(x,`type`,t.UniverInstanceType.UNIVER_SHEET),x=u([(0,t.DependentOn)(n.UniverDrawingPlugin),l(1,(0,t.Inject)(t.Injector)),l(2,t.IConfigService)],x),e.DrawingApplyType=s,e.ISheetDrawingService=o,e.SHEET_DRAWING_PLUGIN=d,e.SetDrawingApplyMutation=c,e.SheetDrawingAnchorType=i,Object.defineProperty(e,`UniverSheetsDrawingPlugin`,{enumerable:!0,get:function(){return x}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/drawing`),require(`@univerjs/sheets`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`,`@univerjs/sheets`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDrawing={},e.UniverCore,e.UniverDrawing,e.UniverSheets))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let i=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var a=class extends n.UnitDrawingService{};let o=(0,t.createIdentifier)(`sheets-drawing.sheet-drawing.service`),s=function(e){return e[e.INSERT=0]=`INSERT`,e[e.REMOVE=1]=`REMOVE`,e[e.UPDATE=2]=`UPDATE`,e[e.ARRANGE=3]=`ARRANGE`,e[e.GROUP=4]=`GROUP`,e[e.UNGROUP=5]=`UNGROUP`,e}({}),c={id:`sheet.mutation.set-drawing-apply`,type:t.CommandType.MUTATION,handler:(e,t)=>{let r=e.get(n.IDrawingManagerService),i=e.get(o),{op:a,unitId:c,subUnitId:l,type:u,objects:d}=t;switch(r.applyJson1(c,l,a),i.applyJson1(c,l,a),u){case s.INSERT:r.addNotification(d),i.addNotification(d);break;case s.REMOVE:r.removeNotification(d),i.removeNotification(d);break;case s.UPDATE:r.updateNotification(d),i.updateNotification(d);break;case s.ARRANGE:r.orderNotification(d),i.orderNotification(d);break;case s.GROUP:r.groupUpdateNotification(d);break;case s.UNGROUP:r.ungroupUpdateNotification(d);break}return!0}};function l(e,t){return function(n,r){t(n,r,e)}}function u(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 d=`SHEET_DRAWING_PLUGIN`,f=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._commandService=n,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=a,this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(c))}_initSnapshot(){let e=(e,t)=>{let n=t||this._sheetDrawingService.getDrawingDataForUnit(e);return n?JSON.stringify(n):``},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:d,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:(t,n)=>e(t,n),parseJson:e=>n(e),onUnLoad:e=>{this._sheetDrawingService.removeDrawingDataForUnit(e),this._drawingManagerService.removeDrawingDataForUnit(e)},onLoad:(e,t)=>{this._sheetDrawingService.registerDrawingData(e,t),this._drawingManagerService.registerDrawingData(e,t)}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,i=r.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=r.subUnitId||((n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),l=Object.values(o).filter(e=>e.drawingType!==t.DrawingTypeEnum.DRAWING_CHART);if(l.length===0)return{redos:[],undos:[]};let{unitId:u,subUnitId:d,undo:f,redo:p,objects:m}=this._sheetDrawingService.getBatchRemoveOp(l);return{redos:[{id:c.id,params:{op:p,unitId:u,subUnitId:d,objects:m,type:s.REMOVE}}],undos:[{id:c.id,params:{op:f,unitId:u,subUnitId:d,objects:m,type:s.INSERT}}]}}else if(e.id===r.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:i}=e.params;if(!n||!r||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(n,r),o=Object.values(a).filter(e=>e.drawingType!==t.DrawingTypeEnum.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:(0,t.generateRandomId)(6)}));if(o.length===0)return{redos:[],undos:[]};let{unitId:l,subUnitId:u,undo:d,redo:f,objects:p}=this._sheetDrawingService.getBatchAddOp(o);return{redos:[{id:c.id,params:{op:f,unitId:l,subUnitId:u,objects:p,type:s.INSERT}}],undos:[{id:c.id,params:{op:d,unitId:l,subUnitId:u,objects:p,type:s.REMOVE}}]}}return{redos:[],undos:[]}}}))}};f=u([l(0,(0,t.Inject)(r.SheetInterceptorService)),l(1,(0,t.Inject)(t.IUniverInstanceService)),l(2,t.ICommandService),l(3,o),l(4,n.IDrawingManagerService),l(5,t.IResourceManagerService)],f);var p=`@univerjs/sheets-drawing`,m=`0.19.0`;let h=`sheets-drawing.config`;Symbol(h);let g={};function _(e){"@babel/helpers - typeof";return _=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},_(e)}function v(e,t){if(_(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(_(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function y(e){var t=v(e,`string`);return _(t)==`symbol`?t:t+``}function b(e,t,n){return(t=y(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let x=class extends t.Plugin{constructor(e=g,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},g,this._config);this._configService.setConfig(h,i)}onStarting(){[[f],[o,{useClass:a}]].forEach(e=>this._injector.add(e)),this._injector.get(f)}};b(x,`pluginName`,d),b(x,`packageName`,p),b(x,`version`,m),b(x,`type`,t.UniverInstanceType.UNIVER_SHEET),x=u([(0,t.DependentOn)(n.UniverDrawingPlugin),l(1,(0,t.Inject)(t.Injector)),l(2,t.IConfigService)],x),e.DrawingApplyType=s,e.ISheetDrawingService=o,e.SHEET_DRAWING_PLUGIN=d,e.SetDrawingApplyMutation=c,e.SheetDrawingAnchorType=i,Object.defineProperty(e,`UniverSheetsDrawingPlugin`,{enumerable:!0,get:function(){return x}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-drawing",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -43,14 +43,14 @@
43
43
  "lib"
44
44
  ],
45
45
  "dependencies": {
46
- "@univerjs/core": "0.18.0",
47
- "@univerjs/sheets": "0.18.0",
48
- "@univerjs/drawing": "0.18.0"
46
+ "@univerjs/core": "0.19.0",
47
+ "@univerjs/drawing": "0.19.0",
48
+ "@univerjs/sheets": "0.19.0"
49
49
  },
50
50
  "devDependencies": {
51
- "typescript": "^5.9.3",
52
- "vitest": "^4.1.0",
53
- "@univerjs-infra/shared": "0.18.0"
51
+ "typescript": "^6.0.2",
52
+ "vitest": "^4.1.1",
53
+ "@univerjs-infra/shared": "0.19.0"
54
54
  },
55
55
  "scripts": {
56
56
  "test": "vitest run",