@univerjs/sheets-drawing 0.22.0 → 0.22.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
@@ -584,7 +584,7 @@ SheetsDrawingLoadController = __decorate([
584
584
  //#endregion
585
585
  //#region package.json
586
586
  var name = "@univerjs/sheets-drawing";
587
- var version = "0.22.0";
587
+ var version = "0.22.1";
588
588
 
589
589
  //#endregion
590
590
  //#region src/config/config.ts
package/lib/es/index.js CHANGED
@@ -583,7 +583,7 @@ SheetsDrawingLoadController = __decorate([
583
583
  //#endregion
584
584
  //#region package.json
585
585
  var name = "@univerjs/sheets-drawing";
586
- var version = "0.22.0";
586
+ var version = "0.22.1";
587
587
 
588
588
  //#endregion
589
589
  //#region src/config/config.ts
package/lib/index.js CHANGED
@@ -583,7 +583,7 @@ SheetsDrawingLoadController = __decorate([
583
583
  //#endregion
584
584
  //#region package.json
585
585
  var name = "@univerjs/sheets-drawing";
586
- var version = "0.22.0";
586
+ var version = "0.22.1";
587
587
 
588
588
  //#endregion
589
589
  //#region src/config/config.ts
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/sheets`),require(`@univerjs/core`),require(`@univerjs/drawing`),require(`@univerjs/engine-render`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/sheets`,`@univerjs/core`,`@univerjs/drawing`,`@univerjs/engine-render`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDrawing={},e.UniverSheets,e.UniverCore,e.UniverDrawing,e.UniverEngineRender))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e,n){if(!n)return;let{unitId:r,sheetId:i,skeleton:a}=n,{from:o,to:s,flipY:c=!1,flipX:l=!1,angle:u=0,skewX:d=0,skewY:f=0}=e,{left:p,top:m,width:h,height:g}=(0,t.convertPositionSheetOverGridToAbsolute)(r,i,{from:o,to:s},a),_=a.rowHeaderWidth+a.columnTotalWidth,v=a.columnHeaderHeight+a.rowTotalHeight;return p+h>_&&(p=_-h),m+g>v&&(m=v-g),{flipY:c,flipX:l,angle:u,skewX:d,skewY:f,left:p,top:m,width:h,height:g}}function o(e,t){let{left:n=0,top:r=0,width:i=0,height:a=0,flipY:o=!1,flipX:s=!1,angle:c=0,skewX:l=0,skewY:u=0}=e;return{flipY:o,flipX:s,angle:c,skewX:l,skewY:u,from:t.getCellIndexAndOffsetByPosition(n,r),to:t.getCellIndexAndOffsetByPosition(n+i,r+a)}}function s(e,t){let{left:n=0,top:r=0,width:i=0,height:a=0,angle:s=0}=e,c=(s%360+360)%360;return o(c>=45&&c<135||c>=225&&c<315?{...e,left:n+i/2-a/2,top:r+a/2-i/2,width:a,height:i}:e,t)}let c=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var l=class extends r.UnitDrawingService{};let u=(0,n.createIdentifier)(`sheets-drawing.sheet-drawing.service`),d=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}({}),f={id:`sheet.mutation.set-drawing-apply`,type:n.CommandType.MUTATION,handler:(e,t)=>{let n=e.get(r.IDrawingManagerService),i=e.get(u),{op:a,unitId:o,subUnitId:s,type:c,objects:l}=t;switch(n.applyJson1(o,s,a),i.applyJson1(o,s,a),c){case 0:n.addNotification(l),i.addNotification(l);break;case 1:n.removeNotification(l),i.removeNotification(l);break;case 2:n.updateNotification(l),i.updateNotification(l);break;case 3:n.orderNotification(l),i.orderNotification(l);break;case 4:n.groupUpdateNotification(l),i.groupUpdateNotification(l);break;case 5:n.ungroupUpdateNotification(l),i.ungroupUpdateNotification(l);break}return!0}},p={id:`sheet.operation.clear-drawing-transformer`,type:n.CommandType.MUTATION,handler:(e,t)=>{let n=e.get(i.IRenderManagerService);return t.forEach(e=>{var t;(t=n.getRenderById(e))==null||(t=t.scene.getTransformer())==null||t.debounceRefreshControls()}),!0}},m={id:`sheet.command.insert-sheet-image`,type:n.CommandType.COMMAND,handler:(e,r)=>{var i,a;if(!r)return!1;let o=e.get(n.ICommandService),s=e.get(n.IUndoRedoService),c=e.get(u),l=e.get(t.SheetInterceptorService),d=r.drawings,{unitId:h,subUnitId:g,undo:_,redo:v,objects:y}=c.getBatchAddOp(d),b=l.onCommandExecute({id:m.id,params:r}),x=[...(i=b.preRedos)==null?[]:i,{id:f.id,params:{unitId:h,subUnitId:g,op:v,objects:y,type:0}},{id:p.id,params:[h]},...b.redos],S=[...(a=b.preUndos)==null?[]:a,{id:f.id,params:{unitId:h,subUnitId:g,op:_,objects:y,type:1}},{id:p.id,params:[h]},...b.undos];return(0,n.sequenceExecute)(x,o).result?(s.pushUndoRedo({unitID:h,undoMutations:S,redoMutations:x}),!0):!1}},h={id:`sheet.command.remove-sheet-image`,type:n.CommandType.COMMAND,handler:(e,r)=>{var i,a;if(!r)return!1;let o=e.get(n.ICommandService),s=e.get(n.IUndoRedoService),c=e.get(t.SheetInterceptorService),l=e.get(u),{drawings:d}=r,{unitId:m,subUnitId:g,undo:_,redo:v,objects:y}=l.getBatchRemoveOp(d),b=c.onCommandExecute({id:h.id,params:r}),x=[...(i=b.preRedos)==null?[]:i,{id:f.id,params:{unitId:m,subUnitId:g,op:v,objects:y,type:1}},{id:p.id,params:[m]},...b.redos],S=[...(a=b.preUndos)==null?[]:a,{id:f.id,params:{unitId:m,subUnitId:g,op:_,objects:y,type:0}},{id:p.id,params:[m]},...b.undos];return(0,n.sequenceExecute)(x,o).result?(s.pushUndoRedo({unitID:m,undoMutations:S,redoMutations:x}),!0):!1}},g={id:`sheet.command.set-drawing-arrange`,type:n.CommandType.COMMAND,handler:(e,t)=>{let r=e.get(n.ICommandService),i=e.get(n.IUndoRedoService);if(!t)return!1;let a=e.get(u),{unitId:o,subUnitId:s,drawingIds:c,arrangeType:l}=t,d={unitId:o,subUnitId:s,drawingIds:c},p;if(l===n.ArrangeTypeEnum.forward?p=a.getForwardDrawingsOp(d):l===n.ArrangeTypeEnum.backward?p=a.getBackwardDrawingOp(d):l===n.ArrangeTypeEnum.front?p=a.getFrontDrawingsOp(d):l===n.ArrangeTypeEnum.back&&(p=a.getBackDrawingsOp(d)),p==null)return!1;let{objects:m,redo:h,undo:g}=p;return r.syncExecuteCommand(f.id,{op:h,unitId:o,subUnitId:s,objects:m,type:3})?(i.pushUndoRedo({unitID:o,undoMutations:[{id:f.id,params:{op:g,unitId:o,subUnitId:s,objects:m,type:3}}],redoMutations:[{id:f.id,params:{op:h,unitId:o,subUnitId:s,objects:m,type:3}}]}),!0):!1}},_={id:`sheet.command.set-sheet-image`,type:n.CommandType.COMMAND,handler:(e,r)=>{var i,a;if(!r)return!1;let o=e.get(n.ICommandService),s=e.get(n.IUndoRedoService),c=e.get(u),l=e.get(t.SheetInterceptorService),{drawings:d}=r,{unitId:m,subUnitId:h,undo:g,redo:v,objects:y}=c.getBatchUpdateOp(d),b=l.onCommandExecute({id:_.id,params:r}),x=[...(i=b.preRedos)==null?[]:i,{id:f.id,params:{unitId:m,subUnitId:h,op:v,objects:y,type:2}},{id:p.id,params:[m]},...b.redos],S=[...(a=b.preUndos)==null?[]:a,{id:f.id,params:{unitId:m,subUnitId:h,op:g,objects:y,type:2}},{id:p.id,params:[m]},...b.undos];return(0,n.sequenceExecute)(x,o).result?(s.pushUndoRedo({unitID:m,undoMutations:S,redoMutations:x}),!0):!1}};function v(e,t){return function(n,r){t(n,r,e)}}function y(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 b=`SHEET_DRAWING_PLUGIN`,x=class extends n.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._initCommands(),this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(f))}_initCommands(){[_,m,h,g,p].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_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:b,businesses:[n.UniverInstanceType.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===t.RemoveSheetCommand.id){var r;let t=e.params,i=t.unitId||this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=t.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),s=Object.values(o).filter(e=>e.drawingType!==n.DrawingTypeEnum.DRAWING_CHART);if(s.length===0)return{redos:[],undos:[]};let{unitId:c,subUnitId:l,undo:u,redo:d,objects:p}=this._sheetDrawingService.getBatchRemoveOp(s);return{redos:[{id:f.id,params:{op:d,unitId:c,subUnitId:l,objects:p,type:1}}],undos:[{id:f.id,params:{op:u,unitId:c,subUnitId:l,objects:p,type:0}}]}}else if(e.id===t.CopySheetCommand.id){let{unitId:t,subUnitId:r,targetSubUnitId:i}=e.params;if(!t||!r||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(t,r),o=Object.values(a).filter(e=>e.drawingType!==n.DrawingTypeEnum.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:(0,n.generateRandomId)(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:f.id,params:{op:u,unitId:s,subUnitId:c,objects:d,type:0}}],undos:[{id:f.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:1}}]}}return{redos:[],undos:[]}}}))}};x=y([v(0,(0,n.Inject)(t.SheetInterceptorService)),v(1,(0,n.Inject)(n.IUniverInstanceService)),v(2,n.ICommandService),v(3,u),v(4,r.IDrawingManagerService),v(5,n.IResourceManagerService)],x);var S=`@univerjs/sheets-drawing`,C=`0.22.0`;let w=`sheets-drawing.config`;Symbol(w);let T={};function E(e){"@babel/helpers - typeof";return E=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(e)}function D(e,t){if(E(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(E(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function O(e){var t=D(e,`string`);return E(t)==`symbol`?t:t+``}function k(e,t,n){return(t=O(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let A=class extends n.Plugin{constructor(e=T,t,r){super(),this._config=e,this._injector=t,this._configService=r;let{...i}=(0,n.merge)({},T,this._config);this._configService.setConfig(w,i)}onStarting(){[[x],[u,{useClass:l}]].forEach(e=>this._injector.add(e)),this._injector.get(x)}};k(A,`pluginName`,b),k(A,`packageName`,S),k(A,`version`,C),k(A,`type`,n.UniverInstanceType.UNIVER_SHEET),A=y([(0,n.DependentOn)(r.UniverDrawingPlugin),v(1,(0,n.Inject)(n.Injector)),v(2,n.IConfigService)],A),e.ClearSheetDrawingTransformerOperation=p,e.DrawingApplyType=d,e.ISheetDrawingService=u,e.InsertSheetDrawingCommand=m,e.RemoveSheetDrawingCommand=h,e.SHEET_DRAWING_PLUGIN=b,e.SetDrawingApplyMutation=f,e.SetDrawingArrangeCommand=g,e.SetSheetDrawingCommand=_,e.SheetDrawingAnchorType=c,Object.defineProperty(e,`UniverSheetsDrawingPlugin`,{enumerable:!0,get:function(){return A}}),e.drawingPositionToTransform=a,e.transformToAxisAlignPosition=s,e.transformToDrawingPosition=o});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/sheets`),require(`@univerjs/core`),require(`@univerjs/drawing`),require(`@univerjs/engine-render`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/sheets`,`@univerjs/core`,`@univerjs/drawing`,`@univerjs/engine-render`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDrawing={},e.UniverSheets,e.UniverCore,e.UniverDrawing,e.UniverEngineRender))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e,n){if(!n)return;let{unitId:r,sheetId:i,skeleton:a}=n,{from:o,to:s,flipY:c=!1,flipX:l=!1,angle:u=0,skewX:d=0,skewY:f=0}=e,{left:p,top:m,width:h,height:g}=(0,t.convertPositionSheetOverGridToAbsolute)(r,i,{from:o,to:s},a),_=a.rowHeaderWidth+a.columnTotalWidth,v=a.columnHeaderHeight+a.rowTotalHeight;return p+h>_&&(p=_-h),m+g>v&&(m=v-g),{flipY:c,flipX:l,angle:u,skewX:d,skewY:f,left:p,top:m,width:h,height:g}}function o(e,t){let{left:n=0,top:r=0,width:i=0,height:a=0,flipY:o=!1,flipX:s=!1,angle:c=0,skewX:l=0,skewY:u=0}=e;return{flipY:o,flipX:s,angle:c,skewX:l,skewY:u,from:t.getCellIndexAndOffsetByPosition(n,r),to:t.getCellIndexAndOffsetByPosition(n+i,r+a)}}function s(e,t){let{left:n=0,top:r=0,width:i=0,height:a=0,angle:s=0}=e,c=(s%360+360)%360;return o(c>=45&&c<135||c>=225&&c<315?{...e,left:n+i/2-a/2,top:r+a/2-i/2,width:a,height:i}:e,t)}let c=function(e){return e.Position=`0`,e.Both=`1`,e.None=`2`,e}({});var l=class extends r.UnitDrawingService{};let u=(0,n.createIdentifier)(`sheets-drawing.sheet-drawing.service`),d=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}({}),f={id:`sheet.mutation.set-drawing-apply`,type:n.CommandType.MUTATION,handler:(e,t)=>{let n=e.get(r.IDrawingManagerService),i=e.get(u),{op:a,unitId:o,subUnitId:s,type:c,objects:l}=t;switch(n.applyJson1(o,s,a),i.applyJson1(o,s,a),c){case 0:n.addNotification(l),i.addNotification(l);break;case 1:n.removeNotification(l),i.removeNotification(l);break;case 2:n.updateNotification(l),i.updateNotification(l);break;case 3:n.orderNotification(l),i.orderNotification(l);break;case 4:n.groupUpdateNotification(l),i.groupUpdateNotification(l);break;case 5:n.ungroupUpdateNotification(l),i.ungroupUpdateNotification(l);break}return!0}},p={id:`sheet.operation.clear-drawing-transformer`,type:n.CommandType.MUTATION,handler:(e,t)=>{let n=e.get(i.IRenderManagerService);return t.forEach(e=>{var t;(t=n.getRenderById(e))==null||(t=t.scene.getTransformer())==null||t.debounceRefreshControls()}),!0}},m={id:`sheet.command.insert-sheet-image`,type:n.CommandType.COMMAND,handler:(e,r)=>{var i,a;if(!r)return!1;let o=e.get(n.ICommandService),s=e.get(n.IUndoRedoService),c=e.get(u),l=e.get(t.SheetInterceptorService),d=r.drawings,{unitId:h,subUnitId:g,undo:_,redo:v,objects:y}=c.getBatchAddOp(d),b=l.onCommandExecute({id:m.id,params:r}),x=[...(i=b.preRedos)==null?[]:i,{id:f.id,params:{unitId:h,subUnitId:g,op:v,objects:y,type:0}},{id:p.id,params:[h]},...b.redos],S=[...(a=b.preUndos)==null?[]:a,{id:f.id,params:{unitId:h,subUnitId:g,op:_,objects:y,type:1}},{id:p.id,params:[h]},...b.undos];return(0,n.sequenceExecute)(x,o).result?(s.pushUndoRedo({unitID:h,undoMutations:S,redoMutations:x}),!0):!1}},h={id:`sheet.command.remove-sheet-image`,type:n.CommandType.COMMAND,handler:(e,r)=>{var i,a;if(!r)return!1;let o=e.get(n.ICommandService),s=e.get(n.IUndoRedoService),c=e.get(t.SheetInterceptorService),l=e.get(u),{drawings:d}=r,{unitId:m,subUnitId:g,undo:_,redo:v,objects:y}=l.getBatchRemoveOp(d),b=c.onCommandExecute({id:h.id,params:r}),x=[...(i=b.preRedos)==null?[]:i,{id:f.id,params:{unitId:m,subUnitId:g,op:v,objects:y,type:1}},{id:p.id,params:[m]},...b.redos],S=[...(a=b.preUndos)==null?[]:a,{id:f.id,params:{unitId:m,subUnitId:g,op:_,objects:y,type:0}},{id:p.id,params:[m]},...b.undos];return(0,n.sequenceExecute)(x,o).result?(s.pushUndoRedo({unitID:m,undoMutations:S,redoMutations:x}),!0):!1}},g={id:`sheet.command.set-drawing-arrange`,type:n.CommandType.COMMAND,handler:(e,t)=>{let r=e.get(n.ICommandService),i=e.get(n.IUndoRedoService);if(!t)return!1;let a=e.get(u),{unitId:o,subUnitId:s,drawingIds:c,arrangeType:l}=t,d={unitId:o,subUnitId:s,drawingIds:c},p;if(l===n.ArrangeTypeEnum.forward?p=a.getForwardDrawingsOp(d):l===n.ArrangeTypeEnum.backward?p=a.getBackwardDrawingOp(d):l===n.ArrangeTypeEnum.front?p=a.getFrontDrawingsOp(d):l===n.ArrangeTypeEnum.back&&(p=a.getBackDrawingsOp(d)),p==null)return!1;let{objects:m,redo:h,undo:g}=p;return r.syncExecuteCommand(f.id,{op:h,unitId:o,subUnitId:s,objects:m,type:3})?(i.pushUndoRedo({unitID:o,undoMutations:[{id:f.id,params:{op:g,unitId:o,subUnitId:s,objects:m,type:3}}],redoMutations:[{id:f.id,params:{op:h,unitId:o,subUnitId:s,objects:m,type:3}}]}),!0):!1}},_={id:`sheet.command.set-sheet-image`,type:n.CommandType.COMMAND,handler:(e,r)=>{var i,a;if(!r)return!1;let o=e.get(n.ICommandService),s=e.get(n.IUndoRedoService),c=e.get(u),l=e.get(t.SheetInterceptorService),{drawings:d}=r,{unitId:m,subUnitId:h,undo:g,redo:v,objects:y}=c.getBatchUpdateOp(d),b=l.onCommandExecute({id:_.id,params:r}),x=[...(i=b.preRedos)==null?[]:i,{id:f.id,params:{unitId:m,subUnitId:h,op:v,objects:y,type:2}},{id:p.id,params:[m]},...b.redos],S=[...(a=b.preUndos)==null?[]:a,{id:f.id,params:{unitId:m,subUnitId:h,op:g,objects:y,type:2}},{id:p.id,params:[m]},...b.undos];return(0,n.sequenceExecute)(x,o).result?(s.pushUndoRedo({unitID:m,undoMutations:S,redoMutations:x}),!0):!1}};function v(e,t){return function(n,r){t(n,r,e)}}function y(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 b=`SHEET_DRAWING_PLUGIN`,x=class extends n.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._initCommands(),this._initSnapshot(),this._initSheetChange(),this.disposeWithMe(this._commandService.registerCommand(f))}_initCommands(){[_,m,h,g,p].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_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:b,businesses:[n.UniverInstanceType.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===t.RemoveSheetCommand.id){var r;let t=e.params,i=t.unitId||this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=t.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(i,a),s=Object.values(o).filter(e=>e.drawingType!==n.DrawingTypeEnum.DRAWING_CHART);if(s.length===0)return{redos:[],undos:[]};let{unitId:c,subUnitId:l,undo:u,redo:d,objects:p}=this._sheetDrawingService.getBatchRemoveOp(s);return{redos:[{id:f.id,params:{op:d,unitId:c,subUnitId:l,objects:p,type:1}}],undos:[{id:f.id,params:{op:u,unitId:c,subUnitId:l,objects:p,type:0}}]}}else if(e.id===t.CopySheetCommand.id){let{unitId:t,subUnitId:r,targetSubUnitId:i}=e.params;if(!t||!r||!i)return{redos:[],undos:[]};let a=this._sheetDrawingService.getDrawingData(t,r),o=Object.values(a).filter(e=>e.drawingType!==n.DrawingTypeEnum.DRAWING_CHART).map(e=>({...e,subUnitId:i,drawingId:(0,n.generateRandomId)(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:f.id,params:{op:u,unitId:s,subUnitId:c,objects:d,type:0}}],undos:[{id:f.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:1}}]}}return{redos:[],undos:[]}}}))}};x=y([v(0,(0,n.Inject)(t.SheetInterceptorService)),v(1,(0,n.Inject)(n.IUniverInstanceService)),v(2,n.ICommandService),v(3,u),v(4,r.IDrawingManagerService),v(5,n.IResourceManagerService)],x);var S=`@univerjs/sheets-drawing`,C=`0.22.1`;let w=`sheets-drawing.config`;Symbol(w);let T={};function E(e){"@babel/helpers - typeof";return E=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(e)}function D(e,t){if(E(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(E(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function O(e){var t=D(e,`string`);return E(t)==`symbol`?t:t+``}function k(e,t,n){return(t=O(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let A=class extends n.Plugin{constructor(e=T,t,r){super(),this._config=e,this._injector=t,this._configService=r;let{...i}=(0,n.merge)({},T,this._config);this._configService.setConfig(w,i)}onStarting(){[[x],[u,{useClass:l}]].forEach(e=>this._injector.add(e)),this._injector.get(x)}};k(A,`pluginName`,b),k(A,`packageName`,S),k(A,`version`,C),k(A,`type`,n.UniverInstanceType.UNIVER_SHEET),A=y([(0,n.DependentOn)(r.UniverDrawingPlugin),v(1,(0,n.Inject)(n.Injector)),v(2,n.IConfigService)],A),e.ClearSheetDrawingTransformerOperation=p,e.DrawingApplyType=d,e.ISheetDrawingService=u,e.InsertSheetDrawingCommand=m,e.RemoveSheetDrawingCommand=h,e.SHEET_DRAWING_PLUGIN=b,e.SetDrawingApplyMutation=f,e.SetDrawingArrangeCommand=g,e.SetSheetDrawingCommand=_,e.SheetDrawingAnchorType=c,Object.defineProperty(e,`UniverSheetsDrawingPlugin`,{enumerable:!0,get:function(){return A}}),e.drawingPositionToTransform=a,e.transformToAxisAlignPosition=s,e.transformToDrawingPosition=o});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-drawing",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "private": false,
5
5
  "description": "Drawing model integration for Univer Sheets.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -59,15 +59,15 @@
59
59
  "lib"
60
60
  ],
61
61
  "dependencies": {
62
- "@univerjs/drawing": "0.22.0",
63
- "@univerjs/engine-render": "0.22.0",
64
- "@univerjs/core": "0.22.0",
65
- "@univerjs/sheets": "0.22.0"
62
+ "@univerjs/core": "0.22.1",
63
+ "@univerjs/engine-render": "0.22.1",
64
+ "@univerjs/drawing": "0.22.1",
65
+ "@univerjs/sheets": "0.22.1"
66
66
  },
67
67
  "devDependencies": {
68
68
  "typescript": "^6.0.3",
69
69
  "vitest": "^4.1.5",
70
- "@univerjs-infra/shared": "0.22.0"
70
+ "@univerjs-infra/shared": "0.22.1"
71
71
  },
72
72
  "scripts": {
73
73
  "test": "vitest run",