@univerjs/sheets-drawing 1.0.0-alpha.5 → 1.0.0-alpha.6
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 +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
package/lib/cjs/index.js
CHANGED
|
@@ -653,7 +653,7 @@ SheetsDrawingLoadController = __decorate([
|
|
|
653
653
|
//#endregion
|
|
654
654
|
//#region package.json
|
|
655
655
|
var name = "@univerjs/sheets-drawing";
|
|
656
|
-
var version = "1.0.0-alpha.
|
|
656
|
+
var version = "1.0.0-alpha.6";
|
|
657
657
|
|
|
658
658
|
//#endregion
|
|
659
659
|
//#region src/config/config.ts
|
package/lib/es/index.js
CHANGED
|
@@ -652,7 +652,7 @@ SheetsDrawingLoadController = __decorate([
|
|
|
652
652
|
//#endregion
|
|
653
653
|
//#region package.json
|
|
654
654
|
var name = "@univerjs/sheets-drawing";
|
|
655
|
-
var version = "1.0.0-alpha.
|
|
655
|
+
var version = "1.0.0-alpha.6";
|
|
656
656
|
|
|
657
657
|
//#endregion
|
|
658
658
|
//#region src/config/config.ts
|
package/lib/index.js
CHANGED
|
@@ -652,7 +652,7 @@ SheetsDrawingLoadController = __decorate([
|
|
|
652
652
|
//#endregion
|
|
653
653
|
//#region package.json
|
|
654
654
|
var name = "@univerjs/sheets-drawing";
|
|
655
|
-
var version = "1.0.0-alpha.
|
|
655
|
+
var version = "1.0.0-alpha.6";
|
|
656
656
|
|
|
657
657
|
//#endregion
|
|
658
658
|
//#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);if(Array.isArray(y)&&y.length===0)return!1;let 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}};function _(e){return e===n.DrawingTypeEnum.DRAWING_CHART}function v(e,t,n){return(0,r.resolveDrawingRotateEnabled)(e,{getChildren:e=>{var r;return(r=n==null?void 0:n(e))==null?t.getDrawingsByGroup(e):r},isKnownNonRotatableType:_})}function y(e){var t,n,r;return((t=e.transform)==null?void 0:t.angle)!==void 0||((n=e.sheetTransform)==null?void 0:n.angle)!==void 0||((r=e.axisAlignSheetTransform)==null?void 0:r.angle)!==void 0}function b(e,t){let n=t==null?void 0:t.angle,r={...t==null?{}:t,...e};return n===void 0?delete r.angle:r.angle=n,r}function x(e,t){var n,r,i,a;if(!e.drawingId||!e.unitId||!e.subUnitId||!y(e))return e;let o=t.getDrawingByParam({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId});if(!o||v({...o,...e,drawingType:(n=e.drawingType)==null?o.drawingType:n,transform:{...o.transform,...e.transform}},t))return e;let s={...e};return((r=e.transform)==null?void 0:r.angle)!==void 0&&(s.transform=b(e.transform,o.transform)),((i=e.sheetTransform)==null?void 0:i.angle)!==void 0&&(s.sheetTransform=b(e.sheetTransform,o.sheetTransform)),((a=e.axisAlignSheetTransform)==null?void 0:a.angle)!==void 0&&(s.axisAlignSheetTransform=b(e.axisAlignSheetTransform,o.axisAlignSheetTransform)),s}let S={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,m=d.map(e=>x(e,c)),h={...r,drawings:m},{unitId:g,subUnitId:_,undo:v,redo:y,objects:b}=c.getBatchUpdateOp(m),C=l.onCommandExecute({id:S.id,params:h}),w=[...(i=C.preRedos)==null?[]:i,{id:f.id,params:{unitId:g,subUnitId:_,op:y,objects:b,type:2}},{id:p.id,params:[g]},...C.redos],T=[...(a=C.preUndos)==null?[]:a,{id:f.id,params:{unitId:g,subUnitId:_,op:v,objects:b,type:2}},{id:p.id,params:[g]},...C.undos];return(0,n.sequenceExecute)(w,o).result?(s.pushUndoRedo({unitID:g,undoMutations:T,redoMutations:w}),!0):!1}};function C(e,t){return function(n,r){t(n,r,e)}}function w(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 T=`SHEET_DRAWING_PLUGIN`;function E(e,t){let n=new Set,r=[];return t.forEach(t=>{let i=e[t];i&&(n.add(t),r.push(i))}),Object.values(e).forEach(e=>{n.has(e.drawingId)||r.push(e)}),r}let D=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(){[S,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:T,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 i;let t=e.params,r=t.unitId||this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=t.subUnitId||((i=this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:i.getSheetId());if(!r||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(r,a),s=Object.values(o);if(s.length===0)return{redos:[],undos:[]};let{unitId:c,subUnitId:l,undo:u,redo:d,objects:p}=this._sheetDrawingService.getBatchRemoveOp(s);return Array.isArray(p)&&p.length===0?{redos:[],undos:[]}:{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:n,targetSubUnitId:i,copyContext:a}=e.params;if(!t||!n||!i)return{redos:[],undos:[]};let o=(0,r.getOrCreateDrawingCopyPlan)(a,E(this._sheetDrawingService.getDrawingData(t,n),this._sheetDrawingService.getDrawingOrder(t,n)),{unitId:t,sourceSubUnitId:n,targetSubUnitId:i}).drawings;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:[]}}}))}};D=w([C(0,(0,n.Inject)(t.SheetInterceptorService)),C(1,(0,n.Inject)(n.IUniverInstanceService)),C(2,n.ICommandService),C(3,u),C(4,r.IDrawingManagerService),C(5,n.IResourceManagerService)],D);var O=`@univerjs/sheets-drawing`,k=`1.0.0-alpha.5`;let A={};function j(e){"@babel/helpers - typeof";return j=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},j(e)}function M(e,t){if(j(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(j(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function N(e){var t=M(e,`string`);return j(t)==`symbol`?t:t+``}function P(e,t,n){return(t=N(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let F=class extends n.Plugin{constructor(e=A,t,r){super(),this._config=e,this._injector=t,this._configService=r;let{...i}=(0,n.merge)({},A,this._config);this._configService.setConfig(`sheets-drawing.config`,i)}onStarting(){[[D],[u,{useClass:l}]].forEach(e=>this._injector.add(e)),this._injector.get(D)}};P(F,`pluginName`,T),P(F,`packageName`,O),P(F,`version`,k),P(F,`type`,n.UniverInstanceType.UNIVER_SHEET),F=w([(0,n.DependentOn)(r.UniverDrawingPlugin),C(1,(0,n.Inject)(n.Injector)),C(2,n.IConfigService)],F),e.ClearSheetDrawingTransformerOperation=p,e.DrawingApplyType=d,e.ISheetDrawingService=u,e.InsertSheetDrawingCommand=m,e.RemoveSheetDrawingCommand=h,e.SHEET_DRAWING_PLUGIN=T,e.SetDrawingApplyMutation=f,e.SetDrawingArrangeCommand=g,e.SetSheetDrawingCommand=S,e.SheetDrawingAnchorType=c,e.SheetDrawingService=l,Object.defineProperty(e,"UniverSheetsDrawingPlugin",{enumerable:!0,get:function(){return F}}),e.drawingPositionToTransform=a,e.isKnownSheetNonRotatableDrawingType=_,e.resolveSheetDrawingRotateEnabled=v,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);if(Array.isArray(y)&&y.length===0)return!1;let 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}};function _(e){return e===n.DrawingTypeEnum.DRAWING_CHART}function v(e,t,n){return(0,r.resolveDrawingRotateEnabled)(e,{getChildren:e=>{var r;return(r=n==null?void 0:n(e))==null?t.getDrawingsByGroup(e):r},isKnownNonRotatableType:_})}function y(e){var t,n,r;return((t=e.transform)==null?void 0:t.angle)!==void 0||((n=e.sheetTransform)==null?void 0:n.angle)!==void 0||((r=e.axisAlignSheetTransform)==null?void 0:r.angle)!==void 0}function b(e,t){let n=t==null?void 0:t.angle,r={...t==null?{}:t,...e};return n===void 0?delete r.angle:r.angle=n,r}function x(e,t){var n,r,i,a;if(!e.drawingId||!e.unitId||!e.subUnitId||!y(e))return e;let o=t.getDrawingByParam({unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId});if(!o||v({...o,...e,drawingType:(n=e.drawingType)==null?o.drawingType:n,transform:{...o.transform,...e.transform}},t))return e;let s={...e};return((r=e.transform)==null?void 0:r.angle)!==void 0&&(s.transform=b(e.transform,o.transform)),((i=e.sheetTransform)==null?void 0:i.angle)!==void 0&&(s.sheetTransform=b(e.sheetTransform,o.sheetTransform)),((a=e.axisAlignSheetTransform)==null?void 0:a.angle)!==void 0&&(s.axisAlignSheetTransform=b(e.axisAlignSheetTransform,o.axisAlignSheetTransform)),s}let S={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,m=d.map(e=>x(e,c)),h={...r,drawings:m},{unitId:g,subUnitId:_,undo:v,redo:y,objects:b}=c.getBatchUpdateOp(m),C=l.onCommandExecute({id:S.id,params:h}),w=[...(i=C.preRedos)==null?[]:i,{id:f.id,params:{unitId:g,subUnitId:_,op:y,objects:b,type:2}},{id:p.id,params:[g]},...C.redos],T=[...(a=C.preUndos)==null?[]:a,{id:f.id,params:{unitId:g,subUnitId:_,op:v,objects:b,type:2}},{id:p.id,params:[g]},...C.undos];return(0,n.sequenceExecute)(w,o).result?(s.pushUndoRedo({unitID:g,undoMutations:T,redoMutations:w}),!0):!1}};function C(e,t){return function(n,r){t(n,r,e)}}function w(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 T=`SHEET_DRAWING_PLUGIN`;function E(e,t){let n=new Set,r=[];return t.forEach(t=>{let i=e[t];i&&(n.add(t),r.push(i))}),Object.values(e).forEach(e=>{n.has(e.drawingId)||r.push(e)}),r}let D=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(){[S,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:T,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 i;let t=e.params,r=t.unitId||this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=t.subUnitId||((i=this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:i.getSheetId());if(!r||!a)return{redos:[],undos:[]};let o=this._sheetDrawingService.getDrawingData(r,a),s=Object.values(o);if(s.length===0)return{redos:[],undos:[]};let{unitId:c,subUnitId:l,undo:u,redo:d,objects:p}=this._sheetDrawingService.getBatchRemoveOp(s);return Array.isArray(p)&&p.length===0?{redos:[],undos:[]}:{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:n,targetSubUnitId:i,copyContext:a}=e.params;if(!t||!n||!i)return{redos:[],undos:[]};let o=(0,r.getOrCreateDrawingCopyPlan)(a,E(this._sheetDrawingService.getDrawingData(t,n),this._sheetDrawingService.getDrawingOrder(t,n)),{unitId:t,sourceSubUnitId:n,targetSubUnitId:i}).drawings;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:[]}}}))}};D=w([C(0,(0,n.Inject)(t.SheetInterceptorService)),C(1,(0,n.Inject)(n.IUniverInstanceService)),C(2,n.ICommandService),C(3,u),C(4,r.IDrawingManagerService),C(5,n.IResourceManagerService)],D);var O=`@univerjs/sheets-drawing`,k=`1.0.0-alpha.6`;let A={};function j(e){"@babel/helpers - typeof";return j=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},j(e)}function M(e,t){if(j(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(j(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function N(e){var t=M(e,`string`);return j(t)==`symbol`?t:t+``}function P(e,t,n){return(t=N(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let F=class extends n.Plugin{constructor(e=A,t,r){super(),this._config=e,this._injector=t,this._configService=r;let{...i}=(0,n.merge)({},A,this._config);this._configService.setConfig(`sheets-drawing.config`,i)}onStarting(){[[D],[u,{useClass:l}]].forEach(e=>this._injector.add(e)),this._injector.get(D)}};P(F,`pluginName`,T),P(F,`packageName`,O),P(F,`version`,k),P(F,`type`,n.UniverInstanceType.UNIVER_SHEET),F=w([(0,n.DependentOn)(r.UniverDrawingPlugin),C(1,(0,n.Inject)(n.Injector)),C(2,n.IConfigService)],F),e.ClearSheetDrawingTransformerOperation=p,e.DrawingApplyType=d,e.ISheetDrawingService=u,e.InsertSheetDrawingCommand=m,e.RemoveSheetDrawingCommand=h,e.SHEET_DRAWING_PLUGIN=T,e.SetDrawingApplyMutation=f,e.SetDrawingArrangeCommand=g,e.SetSheetDrawingCommand=S,e.SheetDrawingAnchorType=c,e.SheetDrawingService=l,Object.defineProperty(e,"UniverSheetsDrawingPlugin",{enumerable:!0,get:function(){return F}}),e.drawingPositionToTransform=a,e.isKnownSheetNonRotatableDrawingType=_,e.resolveSheetDrawingRotateEnabled=v,e.transformToAxisAlignPosition=s,e.transformToDrawingPosition=o});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-drawing",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
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/core": "1.0.0-alpha.
|
|
63
|
-
"@univerjs/drawing": "1.0.0-alpha.
|
|
64
|
-
"@univerjs/engine-render": "1.0.0-alpha.
|
|
65
|
-
"@univerjs/sheets": "1.0.0-alpha.
|
|
62
|
+
"@univerjs/core": "1.0.0-alpha.6",
|
|
63
|
+
"@univerjs/drawing": "1.0.0-alpha.6",
|
|
64
|
+
"@univerjs/engine-render": "1.0.0-alpha.6",
|
|
65
|
+
"@univerjs/sheets": "1.0.0-alpha.6"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"typescript": "^6.0.3",
|
|
69
69
|
"vitest": "^4.1.10",
|
|
70
|
-
"@univerjs-infra/shared": "1.0.0-alpha.
|
|
70
|
+
"@univerjs-infra/shared": "1.0.0-alpha.6"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"test": "vitest run",
|