@univerjs/sheets-drawing-ui 0.1.13

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.
Files changed (43) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +16 -0
  3. package/lib/cjs/index.js +1 -0
  4. package/lib/es/index.js +2054 -0
  5. package/lib/index.css +1 -0
  6. package/lib/locale/en-US.json +31 -0
  7. package/lib/locale/ru-RU.json +31 -0
  8. package/lib/locale/zh-CN.json +31 -0
  9. package/lib/types/basics/transform-position.d.ts +6 -0
  10. package/lib/types/commands/commands/delete-drawings.command.d.ts +3 -0
  11. package/lib/types/commands/commands/group-sheet-drawing.command.d.ts +6 -0
  12. package/lib/types/commands/commands/insert-sheet-drawing.command.d.ts +6 -0
  13. package/lib/types/commands/commands/interfaces.d.ts +21 -0
  14. package/lib/types/commands/commands/move-drawings.command.d.ts +6 -0
  15. package/lib/types/commands/commands/remove-sheet-drawing.command.d.ts +6 -0
  16. package/lib/types/commands/commands/set-drawing-arrange.command.d.ts +10 -0
  17. package/lib/types/commands/commands/set-sheet-drawing.command.d.ts +6 -0
  18. package/lib/types/commands/commands/ungroup-sheet-drawing.command.d.ts +6 -0
  19. package/lib/types/commands/commands/utils.d.ts +4 -0
  20. package/lib/types/commands/operations/clear-drawing-transformer.operation.d.ts +3 -0
  21. package/lib/types/commands/operations/edit-sheet-drawing.operation.d.ts +4 -0
  22. package/lib/types/commands/operations/insert-image.operation.d.ts +7 -0
  23. package/lib/types/commands/operations/open-drawing-panel.operation.d.ts +6 -0
  24. package/lib/types/controllers/drawing-popup-menu.controller.d.ts +24 -0
  25. package/lib/types/controllers/sheet-drawing-transform-affected.controller.d.ts +34 -0
  26. package/lib/types/controllers/sheet-drawing-update.controller.d.ts +35 -0
  27. package/lib/types/controllers/sheet-drawing.controller.d.ts +23 -0
  28. package/lib/types/controllers/shortcuts/drawing.shortcut.d.ts +10 -0
  29. package/lib/types/index.d.ts +17 -0
  30. package/lib/types/locale/en-US.d.ts +4 -0
  31. package/lib/types/locale/ru-RU.d.ts +4 -0
  32. package/lib/types/locale/zh-CN.d.ts +47 -0
  33. package/lib/types/plugin.d.ts +14 -0
  34. package/lib/types/services/canvas-float-dom-manager.service.d.ts +60 -0
  35. package/lib/types/views/menu/image.menu.d.ts +7 -0
  36. package/lib/types/views/sheet-image-panel/SheetDrawingAnchor.d.ts +7 -0
  37. package/lib/types/views/sheet-image-panel/SheetDrawingPanel.d.ts +3 -0
  38. package/lib/types/views/sheet-image-panel/component-name.d.ts +16 -0
  39. package/lib/types/views/upload-component/UploadFile.d.ts +9 -0
  40. package/lib/types/views/upload-component/component-name.d.ts +20 -0
  41. package/lib/types/views/upload-loading/UploadLoading.d.ts +3 -0
  42. package/lib/umd/index.js +1 -0
  43. package/package.json +99 -0
@@ -0,0 +1 @@
1
+ (function(A,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/engine-render"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/drawing"),require("@univerjs/ui"),require("@wendellhu/redi/react-bindings"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets"),require("react"),require("@univerjs/design"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/engine-render","@univerjs/drawing-ui","@univerjs/sheets-ui","rxjs","@univerjs/drawing","@univerjs/ui","@wendellhu/redi/react-bindings","@univerjs/sheets-drawing","@univerjs/sheets","react","@univerjs/design","clsx"],h):(A=typeof globalThis<"u"?globalThis:A||self,h(A.UniverSheetsDrawingUi={},A.UniverCore,A["@wendellhu/redi"],A.UniverEngineRender,A.UniverDrawingUi,A.UniverSheetsUi,A.rxjs,A.UniverDrawing,A.UniverUi,A["@wendellhu/redi/react-bindings"],A.UniverSheetsDrawing,A.UniverSheets,A.React,A.UniverDesign,A.clsx))})(this,function(A,h,j,x,ne,k,te,P,B,z,m,C,b,q,se){"use strict";var Mn=Object.defineProperty;var Tn=(A,h,j)=>h in A?Mn(A,h,{enumerable:!0,configurable:!0,writable:!0,value:j}):A[h]=j;var X=(A,h,j)=>(Tn(A,typeof h!="symbol"?h+"":h,j),j);var fe;const L={id:"sheet.operation.clear-drawing-transformer",type:h.CommandType.MUTATION,handler:(r,o)=>{const n=r.get(x.IRenderManagerService);return o.forEach(e=>{var t,i;(i=(t=n.getRenderById(e))==null?void 0:t.scene.getTransformer())==null||i.debounceRefreshControls()}),!0}},Se={id:"sheet.command.remove-sheet-image",type:h.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(h.ICommandService),e=r.get(h.IUndoRedoService),t=r.get(m.ISheetDrawingService);if(!o)return!1;const{drawings:i}=o,a=[];i.forEach(S=>{const{unitId:f}=S;a.push(f)});const s=t.getBatchRemoveOp(i),{unitId:c,subUnitId:u,undo:l,redo:d,objects:g}=s;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:c,subUnitId:u,op:d,objects:g,type:m.DrawingApplyType.REMOVE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:u,op:l,objects:g,type:m.DrawingApplyType.INSERT}},{id:L.id,params:a}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:u,op:d,objects:g,type:m.DrawingApplyType.REMOVE}},{id:L.id,params:a}]}),!0):!1}},_e="COMPONENT_SHEET_DRAWING_PANEL",Ce={id:"sidebar.operation.sheet-image",type:h.CommandType.COMMAND,handler:async(r,o)=>{const n=r.get(B.ISidebarService),e=r.get(h.LocaleService),t=r.get(h.IUniverInstanceService),i=r.get(P.IDrawingManagerService);if(!C.getSheetCommandTarget(t))return!1;switch(o.value){case"open":n.open({header:{title:e.t("sheetImage.panel.title")},children:{label:_e},onClose:()=>{i.focusDrawing(null)},width:360});break;case"close":default:n.close();break}return!0}},Ie={id:"sheet.operation.edit-sheet-image",type:h.CommandType.OPERATION,handler:(r,o)=>{const n=r.get(P.IDrawingManagerService),e=r.get(h.ICommandService);return o==null?!1:(n.focusDrawing([o]),e.executeCommand(Ce.id,{value:"open"}),!0)}},ce={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},Le=()=>{const r=z.useDependency(P.IImageIoService),o=z.useDependency(h.LocaleService),[n,e]=b.useState(0);return b.useEffect(()=>{const t=r.change$.subscribe(i=>{e(i)});return()=>{t.unsubscribe()}},[r]),b.createElement("div",{style:{display:n>0?"block":"none"},className:ce.uploadLoading},b.createElement("div",{className:ce.uploadLoadingBody},b.createElement("div",{className:ce.uploadLoadingBodyAnimation}),b.createElement("div",{className:ce.uploadLoadingBodyText},`${o.t("uploadLoading.loading")}: ${n}`)))};var We=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Be=(r,o,n,e)=>{for(var t=e>1?void 0:e?Ge(o,n):o,i=r.length-1,a;i>=0;i--)(a=r[i])&&(t=(e?a(o,n,t):a(t))||t);return e&&t&&We(o,n,t),t},Q=(r,o)=>(n,e)=>o(n,e,r);let le=class extends h.RxDisposable{constructor(o,n,e,t,i,a,s){super();X(this,"_initImagePopupMenu",new Set);this._injector=o,this._drawingManagerService=n,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=i,this._contextService=a,this._uiPartsService=s,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET).pipe(te.takeUntil(this.dispose$)).subscribe(o=>this._create(o)),this._univerInstanceService.getTypeOfUnitDisposed$(h.UniverInstanceType.UNIVER_SHEET).pipe(te.takeUntil(this.dispose$)).subscribe(o=>this._dispose(o)),this._univerInstanceService.getAllUnitsForType(h.UniverInstanceType.UNIVER_SHEET).forEach(o=>this._create(o)),this._uiPartsService.registerComponent(B.BuiltInUIPart.CONTENT,()=>z.connectInjector(Le,this._injector))}_dispose(o){const n=o.getUnitId();this._renderManagerService.removeRender(n)}_create(o){if(!o)return;const n=o.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(o){const n=o.getAllObjects();for(const e of n)if(e instanceof ne.ImageCropperObject)return!0;return!1}_popupMenuListener(o){var i;const n=(i=this._renderManagerService.getRenderById(o))==null?void 0:i.scene;if(!n)return;const e=n.getTransformerByCreate();if(!e)return;const t=[];this.disposeWithMe(h.toDisposable(e.onCreateControlObservable.add(()=>{if(this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=e.getSelectedObjectMap();if(a.size>1){t.forEach(p=>p.dispose());return}const s=a.values().next().value;if(!s)return;const c=s.oKey,u=this._drawingManagerService.getDrawingOKey(c);if(!u)return;const{unitId:l,subUnitId:d,drawingId:g}=u;t.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s,{componentKey:ne.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(l,d,g)}}))),this._drawingManagerService.focusDrawing([{unitId:l,subUnitId:d,drawingId:g}])}))),this.disposeWithMe(h.toDisposable(e.onClearControlObservable.add(()=>{t.forEach(a=>a.dispose()),this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)}))),this.disposeWithMe(h.toDisposable(e.onChangingObservable.add(()=>{t.forEach(a=>a.dispose())})))}_getImageMenuItems(o,n,e){return[{label:"image-popup.edit",index:0,commandId:Ie.id,commandParams:{unitId:o,subUnitId:n,drawingId:e},disable:!1},{label:"image-popup.delete",index:1,commandId:Se.id,commandParams:{unitId:o,drawings:[{unitId:o,subUnitId:n,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:ne.OpenImageCropOperation.id,commandParams:{unitId:o,subUnitId:n,drawingId:e},disable:!1},{label:"image-popup.reset",index:3,commandId:ne.ImageResetSizeOperation.id,commandParams:[{unitId:o,subUnitId:n,drawingId:e}],disable:!1}]}};le=Be([h.OnLifecycle(h.LifecycleStages.Steady,le),Q(0,j.Inject(j.Injector)),Q(1,P.IDrawingManagerService),Q(2,j.Inject(k.SheetCanvasPopManagerService)),Q(3,x.IRenderManagerService),Q(4,h.IUniverInstanceService),Q(5,h.IContextService),Q(6,j.Inject(B.IUIPartsService))],le);const de={id:"sheet.operation.insert-float-image",type:h.CommandType.OPERATION,handler:(r,o)=>!0},ue={id:"sheet.operation.insert-cell-image",type:h.CommandType.OPERATION,handler:(r,o)=>!0},ve={id:"sheet.command.insert-sheet-image",type:h.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(h.ICommandService),e=r.get(h.IUndoRedoService),t=r.get(m.ISheetDrawingService);if(!o)return!1;const i=o.drawings,a=i.map(S=>S.unitId),s=t.getBatchAddOp(i),{unitId:c,subUnitId:u,undo:l,redo:d,objects:g}=s;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:d,unitId:c,subUnitId:u,objects:g,type:m.DrawingApplyType.INSERT})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:u,objects:g,type:m.DrawingApplyType.REMOVE}},{id:L.id,params:a}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:d,unitId:c,subUnitId:u,objects:g,type:m.DrawingApplyType.INSERT}},{id:L.id,params:a}]}),!0):!1}},me={id:"sheet.command.set-sheet-image",type:h.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(h.ICommandService),e=r.get(h.IUndoRedoService),t=r.get(m.ISheetDrawingService);if(!o)return!1;const{drawings:i}=o,a=t.getBatchUpdateOp(i),{unitId:s,subUnitId:c,undo:u,redo:l,objects:d}=a;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:s,subUnitId:c,op:l,objects:d,type:m.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:c,op:u,objects:d,type:m.DrawingApplyType.UPDATE}},{id:L.id,params:[s]}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:c,op:l,objects:d,type:m.DrawingApplyType.UPDATE}},{id:L.id,params:[s]}]}),!0):!1}},ye={id:"sheet.command.set-drawing-arrange",type:h.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(h.ICommandService),e=r.get(h.IUndoRedoService);if(!o)return!1;const t=r.get(m.ISheetDrawingService),{unitId:i,subUnitId:a,drawingIds:s,arrangeType:c}=o,u={unitId:i,subUnitId:a,drawingIds:s};let l;if(c===P.ArrangeTypeEnum.forward?l=t.getForwardDrawingsOp(u):c===P.ArrangeTypeEnum.backward?l=t.getBackwardDrawingOp(u):c===P.ArrangeTypeEnum.front?l=t.getFrontDrawingsOp(u):c===P.ArrangeTypeEnum.back&&(l=t.getBackDrawingsOp(u)),l==null)return!1;const{objects:d,redo:g,undo:p}=l;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:g,unitId:i,subUnitId:a,objects:d,type:m.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:i,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:p,unitId:i,subUnitId:a,objects:d,type:m.DrawingApplyType.ARRANGE}}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:g,unitId:i,subUnitId:a,objects:d,type:m.DrawingApplyType.ARRANGE}}]}),!0):!1}};function Fe(r){const o=[];return r.forEach(n=>{const{parent:e,children:t}=n,{unitId:i,subUnitId:a,drawingId:s}=e,c=x.getGroupState(0,0,t.map(d=>d.transform||{})),u=t.map(d=>{const g=d.transform||{left:0,top:0},{unitId:p,subUnitId:S,drawingId:f}=d;return{unitId:p,subUnitId:S,drawingId:f,transform:{...g,left:g.left-c.left,top:g.top-c.top},groupId:s}}),l={unitId:i,subUnitId:a,drawingId:s,drawingType:P.DrawingTypeEnum.DRAWING_GROUP,transform:c};o.push({parent:l,children:u})}),o}function xe(r){const o=[];return r.forEach(n=>{const{parent:e,children:t}=n,{unitId:i,subUnitId:a,drawingId:s,transform:c={width:0,height:0}}=e;if(c==null)return;const u=t.map(d=>{const{transform:g}=d,{unitId:p,subUnitId:S,drawingId:f}=d,_=x.transformObjectOutOfGroup(g||{},c,c.width||0,c.height||0);return{unitId:p,subUnitId:S,drawingId:f,transform:_,groupId:void 0}}),l={unitId:i,subUnitId:a,drawingId:s,drawingType:P.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};o.push({parent:l,children:u})}),o}const Me={id:"sheet.command.group-sheet-image",type:h.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(h.ICommandService),e=r.get(h.IUndoRedoService),t=r.get(m.ISheetDrawingService);if(!o)return!1;const i=[];o.forEach(({parent:p,children:S})=>{i.push(p.unitId),S.forEach(f=>{i.push(f.unitId)})});const a=t.getGroupDrawingOp(o),{unitId:s,subUnitId:c,undo:u,redo:l,objects:d}=a;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:l,unitId:s,subUnitId:c,objects:d,type:m.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:c,objects:xe(d),type:m.DrawingApplyType.UNGROUP}},{id:L.id,params:i}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:m.DrawingApplyType.GROUP}},{id:L.id,params:i}]}),!0):!1}},Te={id:"sheet.command.ungroup-sheet-image",type:h.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(h.ICommandService),e=r.get(h.IUndoRedoService),t=r.get(m.ISheetDrawingService);if(!o)return!1;const i=[];o.forEach(({parent:p,children:S})=>{i.push(p.unitId),S.forEach(f=>{i.push(f.unitId)})});const a=t.getUngroupDrawingOp(o),{unitId:s,subUnitId:c,undo:u,redo:l,objects:d}=a;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:l,unitId:s,subUnitId:c,objects:d,type:m.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:c,objects:Fe(d),type:m.DrawingApplyType.GROUP}},{id:L.id,params:i}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:m.DrawingApplyType.UNGROUP}},{id:L.id,params:i}]}),!0):!1}};function V(r,o){const{from:n,to:e}=r,{column:t,columnOffset:i,row:a,rowOffset:s}=n,{column:c,columnOffset:u,row:l,rowOffset:d}=e,g=o.attachRangeWithCoord({startColumn:t,endColumn:t,startRow:a,endRow:a});if(g==null)return;const p=o.attachRangeWithCoord({startColumn:c,endColumn:c,startRow:l,endRow:l});if(p==null)return;const{startX:S,startY:f}=g,{startX:_,startY:R}=p,y=x.precisionTo(S+i,1),I=x.precisionTo(f+s,1);let T=x.precisionTo(_+u-y,1),w=x.precisionTo(R+d-I,1);return g.startX===p.endX&&(T=0),g.startY===p.endY&&(w=0),{left:y,top:I,width:T,height:w}}function W(r,o){const{left:n=0,top:e=0,width:t=0,height:i=0}=r,a=o.getSelectionCellByPosition(n,e);if(a==null)return;const s={column:a.actualColumn,columnOffset:x.precisionTo(n-a.startX,1),row:a.actualRow,rowOffset:x.precisionTo(e-a.startY,1)},c=o.getSelectionCellByPosition(n+t,e+i);if(c==null)return;const u={column:c.actualColumn,columnOffset:x.precisionTo(n+t-c.startX,1),row:c.actualRow,rowOffset:x.precisionTo(e+i-c.startY,1)};return{from:s,to:u}}var Ve=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,He=(r,o,n,e)=>{for(var t=e>1?void 0:e?$e(o,n):o,i=r.length-1,a;i>=0;i--)(a=r[i])&&(t=(e?a(o,n,t):a(t))||t);return e&&t&&Ve(o,n,t),t},Y=(r,o)=>(n,e)=>o(n,e,r);let pe=class extends h.Disposable{constructor(r,o,n,e,t,i,a,s,c,u,l){super(),this._commandService=r,this._univerInstanceService=o,this._selectionManagerService=n,this._selectionRenderService=e,this._imageIoService=t,this._sheetDrawingService=i,this._drawingManagerService=a,this._contextService=s,this._messageService=c,this._localeService=u,this._renderManagerService=l,this._init()}_init(){this._initCommandListeners(),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async r=>{if(r.id===ue.id||r.id===de.id){const o=r.params;if(o.files==null)return;const n=o.files.length;if(n>P.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(P.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(n),r.id===ue.id?o.files.forEach(async e=>{await this._insertCellImage(e)}):o.files.forEach(async e=>{await this._insertFloatImage(e)})}}))}async _insertCellImage(r){}async _insertFloatImage(r){let o;try{o=await this._imageIoService.saveImage(r)}catch(y){const I=y.message;I===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):I===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(o==null)return;const n=this._getUnitInfo();if(n==null)return;const{unitId:e,subUnitId:t}=n,{imageId:i,imageSourceType:a,source:s,base64Cache:c}=o,{width:u,height:l,image:d}=await P.getImageSize(c||""),g=this._renderManagerService.getRenderById(e);if(g==null)return;const{width:p,height:S}=g.scene;this._imageIoService.addImageSourceCache(s,a,d);let f=1;if(u>P.DRAWING_IMAGE_WIDTH_LIMIT||l>P.DRAWING_IMAGE_HEIGHT_LIMIT){const y=P.DRAWING_IMAGE_WIDTH_LIMIT/u,I=P.DRAWING_IMAGE_HEIGHT_LIMIT/l;f=Math.max(y,I)}const _=this._getImagePosition(u*f,l*f,p,S);if(_==null)return;const R={unitId:e,subUnitId:t,drawingId:i,drawingType:P.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a,source:s,transform:V(_,this._selectionRenderService),sheetTransform:_};this._commandService.executeCommand(ve.id,{unitId:e,drawings:[R]})}_getUnitInfo(){const r=this._univerInstanceService.getCurrentUnitForType(h.UniverInstanceType.UNIVER_SHEET);if(r==null)return;const o=r.getActiveSheet();if(o==null)return;const n=r.getUnitId(),e=o.getSheetId();return{unitId:n,subUnitId:e}}_getImagePosition(r,o,n,e){const t=this._selectionManagerService.getSelections();let i={startRow:0,endRow:0,startColumn:0,endColumn:0};t&&t.length>0&&(i=t[t.length-1].range);const a=this._selectionRenderService.attachRangeWithCoord(i);if(a==null)return;let{startColumn:s,startRow:c,startX:u,startY:l}=a,d=!1;if(u+r>n&&(u=n-r,u<0&&(u=0,r=n),d=!0),l+o>e&&(l=e-o,l<0&&(l=0,o=e),d=!0),d){const f=this._selectionRenderService.getSelectionCellByPosition(u,l);if(f==null)return;u=f.startX,l=f.startY,s=f.actualColumn,c=f.actualRow}const g={column:s,columnOffset:0,row:c,rowOffset:0},p=this._selectionRenderService.getSelectionCellByPosition(u+r,l+o);if(p==null)return;const S={column:p.actualColumn,columnOffset:u+r-p.startX,row:p.actualRow,rowOffset:l+o-p.startY};return{from:g,to:S}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(r=>{const{unitId:o,subUnitId:n,drawingIds:e,arrangeType:t}=r;this._commandService.executeCommand(ye.id,{unitId:o,subUnitId:n,drawingIds:e,arrangeType:t})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(r=>{const o=[];r.length!==0&&(r.forEach(n=>{const{unitId:e,subUnitId:t,drawingId:i,drawingType:a,transform:s}=n;if(s==null)return;const c=this._sheetDrawingService.getDrawingByParam({unitId:e,subUnitId:t,drawingId:i});if(c==null)return;const u=W({...c.transform,...s},this._selectionRenderService);if(u==null)return;const l={...n,transform:{...c.transform,...s,...V(u,this._selectionRenderService)},sheetTransform:{...u}};o.push(l)}),o.length>0&&this._commandService.executeCommand(me.id,{unitId:r[0].unitId,drawings:o}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Me.id,r);const{unitId:o,subUnitId:n,drawingId:e}=r[0].parent;this._drawingManagerService.focusDrawing([{unitId:o,subUnitId:n,drawingId:e}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Te.id,r)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(r=>{r==null||r.length===0?(this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(r))}))}};pe=He([h.OnLifecycle(h.LifecycleStages.Rendered,pe),Y(0,h.ICommandService),Y(1,h.IUniverInstanceService),Y(2,j.Inject(C.SelectionManagerService)),Y(3,k.ISelectionRenderService),Y(4,P.IImageIoService),Y(5,m.ISheetDrawingService),Y(6,P.IDrawingManagerService),Y(7,h.IContextService),Y(8,B.IMessageService),Y(9,j.Inject(h.LocaleService)),Y(10,x.IRenderManagerService)],pe);var H=function(){return H=Object.assign||function(r){for(var o,n=1,e=arguments.length;n<e;n++){o=arguments[n];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(r[t]=o[t])}return r},H.apply(this,arguments)},Ye=function(r,o){var n={};for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&o.indexOf(e)<0&&(n[e]=r[e]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(r);t<e.length;t++)o.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(r,e[t])&&(n[e[t]]=r[e[t]]);return n},Re=b.forwardRef(function(r,o){var n=r.icon,e=r.id,t=r.className,i=r.extend,a=Ye(r,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),c=b.useRef("_".concat(ze()));return De(n,"".concat(e),{defIds:n.defIds,idSuffix:c.current},H({ref:o,className:s},a),i)});function De(r,o,n,e,t){return b.createElement(r.tag,H(H({key:o},Xe(r,n,t)),e),(ke(r,n).children||[]).map(function(i,a){return De(i,"".concat(o,"-").concat(r.tag,"-").concat(a),n,void 0,t)}))}function Xe(r,o,n){var e=H({},r.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=o.defIds;return!t||t.length===0||(r.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+o.idSuffix),Object.entries(e).forEach(function(i){var a=i[0],s=i[1];typeof s=="string"&&(e[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(o.idSuffix,")")))})),e}function ke(r,o){var n,e=o.defIds;return!e||e.length===0?r:r.tag==="defs"&&(!((n=r.children)===null||n===void 0)&&n.length)?H(H({},r),{children:r.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?H(H({},t),{attrs:H(H({},t.attrs),{id:t.attrs.id+o.idSuffix})}):t})}):r}function ze(){return Math.random().toString(36).substring(2,8)}Re.displayName="UniverIcon";var Ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z"}}]},Oe=b.forwardRef(function(r,o){return b.createElement(Re,Object.assign({},r,{id:"add-image-single",ref:o,icon:Ke}))});Oe.displayName="AddImageSingle";const Ae={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},be="COMPONENT_UPLOAD_FILE_MENU";var ge=(r=>(r[r.cellImage=0]="cellImage",r[r.floatImage=1]="floatImage",r))(ge||{});const qe=r=>{const{type:o}=r,n=z.useDependency(h.ICommandService),e=b.useRef(null),t=()=>{var s;(s=e.current)==null||s.click()},i=P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(s=>`.${s.replace("image/","")}`).join(","),a=s=>{const c=s.target.files;if(c==null)return;const u=Array.from(c);o===ge.floatImage?n.executeCommand(de.id,{files:u}):o===ge.cellImage&&n.executeCommand(ue.id,{files:u}),e.current&&(e.current.value="")};return b.createElement("div",{onClick:t,className:Ae.uploadFileMenu},b.createElement("input",{type:"file",className:Ae.uploadFileMenuInput,ref:e,onChange:a,accept:i,multiple:!0}))},Ee="addition-and-subtraction-single",Pe="sheet.menu.image";function Je(r){return{id:Pe,type:B.MenuItemType.SUBITEMS,positions:[B.MenuPosition.TOOLBAR_START],group:B.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:Ee,tooltip:"sheetImage.title",hidden$:B.getMenuHiddenObservable(r,h.UniverInstanceType.UNIVER_SHEET)}}function Ze(r){return{id:de.id,title:"sheetImage.upload.float",type:B.MenuItemType.SELECTOR,label:{name:be,props:{type:ge.floatImage}},positions:[Pe],hidden$:B.getMenuHiddenObservable(r,h.UniverInstanceType.UNIVER_SHEET)}}const J={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"},Qe=r=>{var I;const o=z.useDependency(h.ICommandService),n=z.useDependency(h.LocaleService),e=z.useDependency(P.IDrawingManagerService),t=z.useDependency(x.IRenderManagerService),{drawings:i}=r,a=i[0];if(a==null)return;const{unitId:s}=a,c=t.getRenderById(s),u=c==null?void 0:c.scene;if(u==null)return;const l=u.getTransformerByCreate(),[d,g]=b.useState(!0),p=(I=a.anchorType)!=null?I:m.SheetDrawingAnchorType.Position,[S,f]=b.useState(p);function _(T,w){const O=[];return T.forEach(v=>{const{oKey:N}=v,D=w.getDrawingOKey(N);if(D==null)return O.push(null),!0;const{unitId:F,subUnitId:U,drawingId:E,drawingType:M,anchorType:G,sheetTransform:K}=D;O.push({unitId:F,subUnitId:U,drawingId:E,anchorType:G,sheetTransform:K,drawingType:M})}),O}b.useEffect(()=>{const T=l.onClearControlObservable.add(O=>{O===!0&&g(!1)}),w=l.onChangeStartObservable.add(O=>{var D;const{objects:v}=O,N=_(v,e);if(N.length===0)g(!1);else if(N.length>=1){g(!0);const F=((D=N[0])==null?void 0:D.anchorType)||m.SheetDrawingAnchorType.Position;f(F)}});return()=>{w==null||w.dispose(),T==null||T.dispose()}},[]);function R(T){f(T);const w=e.getFocusDrawings();if(w.length===0)return;const O=w.map(v=>({unitId:v.unitId,subUnitId:v.subUnitId,drawingId:v.drawingId,anchorType:T}));o.executeCommand(me.id,{unitId:w[0].unitId,drawings:O})}const y=T=>T?"block":"none";return b.createElement("div",{className:se(J.imageCommonPanelGrid,J.imageCommonPanelBorder),style:{display:y(d)}},b.createElement("div",{className:J.imageCommonPanelRow},b.createElement("div",{className:se(J.imageCommonPanelColumn,J.imageCommonPanelTitle)},b.createElement("div",null,n.t("drawing-anchor.title")))),b.createElement("div",{className:se(J.imageCommonPanelRow)},b.createElement("div",{className:se(J.imageCommonPanelColumn)},b.createElement(q.RadioGroup,{value:S,onChange:R,direction:"vertical"},b.createElement(q.Radio,{value:m.SheetDrawingAnchorType.Both},n.t("drawing-anchor.both")),b.createElement(q.Radio,{value:m.SheetDrawingAnchorType.Position},n.t("drawing-anchor.position")),b.createElement(q.Radio,{value:m.SheetDrawingAnchorType.None},n.t("drawing-anchor.none"))))))},en=()=>{const r=z.useDependency(P.IDrawingManagerService),o=r.getFocusDrawings();if(o==null||o.length===0)return;const[n,e]=b.useState(o);return b.useEffect(()=>{const t=r.focus$.subscribe(i=>{e(i)});return()=>{t.unsubscribe()}},[]),b.createElement("div",{className:J.imageCommonPanel},b.createElement(ne.DrawingCommonPanel,{drawings:n}),b.createElement(Qe,{drawings:n}))},oe={id:"sheet.command.move-drawing",type:h.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(h.ICommandService),e=r.get(m.ISheetDrawingService),t=r.get(k.ISelectionRenderService),{direction:i}=o,a=e.getFocusDrawings();if(a.length===0)return!1;const s=a[0].unitId,c=a.map(l=>{const{transform:d}=l;if(d==null)return null;const g={...d},{left:p=0,top:S=0}=d;return i===h.Direction.UP?g.top=S-1:i===h.Direction.DOWN?g.top=S+1:i===h.Direction.LEFT?g.left=p-1:i===h.Direction.RIGHT&&(g.left=p+1),{...l,transform:g,sheetTransform:W(g,t)}}).filter(l=>l!=null);return n.syncExecuteCommand(me.id,{unitId:s,drawings:c})?(n.syncExecuteCommand(L.id,[s]),!0):!1}},Ue={id:"sheet.command.delete-drawing",type:h.CommandType.COMMAND,handler:r=>{const o=r.get(h.ICommandService),e=r.get(m.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,i=e.map(a=>{const{unitId:s,subUnitId:c,drawingId:u,drawingType:l}=a;return{unitId:s,subUnitId:c,drawingId:u,drawingType:l}});return o.executeCommand(Se.id,{unitId:t,drawings:i})}};function re(r){return!r.getContextValue(h.FOCUSING_FORMULA_EDITOR)&&!r.getContextValue(h.EDITOR_ACTIVATED)&&r.getContextValue(h.FOCUSING_COMMON_DRAWINGS)}const nn={id:oe.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:B.KeyCode.ARROW_DOWN,priority:100,preconditions:re,staticParameters:{direction:h.Direction.DOWN}},tn={id:oe.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:B.KeyCode.ARROW_UP,priority:100,preconditions:re,staticParameters:{direction:h.Direction.UP}},on={id:oe.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:B.KeyCode.ARROW_LEFT,priority:100,preconditions:re,staticParameters:{direction:h.Direction.LEFT}},rn={id:oe.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:B.KeyCode.ARROW_RIGHT,priority:100,preconditions:re,staticParameters:{direction:h.Direction.RIGHT}},an={id:Ue.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:re,binding:B.KeyCode.DELETE,mac:B.KeyCode.BACKSPACE};var sn=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,ln=(r,o,n,e)=>{for(var t=e>1?void 0:e?cn(o,n):o,i=r.length-1,a;i>=0;i--)(a=r[i])&&(t=(e?a(o,n,t):a(t))||t);return e&&t&&sn(o,n,t),t},ie=(r,o)=>(n,e)=>o(n,e,r);const dn={};let ae=class extends h.Disposable{constructor(r,o,n,e,t,i){super(),this._config=r,this._injector=o,this._componentManager=n,this._menuService=e,this._commandService=t,this._shortcutService=i,this._init()}_initCustomComponents(){const r=this._componentManager;this.disposeWithMe(r.register(Ee,Oe)),this.disposeWithMe(r.register(be,qe)),this.disposeWithMe(r.register(_e,en))}_initMenus(){const{menu:r={}}=this._config;[Je,Ze].forEach(o=>{this._menuService.addMenuItem(o(this._injector),r)})}_initCommands(){[de,ue,ve,Se,me,Ce,L,Ie,Me,Te,oe,Ue,ye].forEach(r=>this.disposeWithMe(this._commandService.registerCommand(r)))}_initShortcuts(){[nn,tn,on,rn,an].forEach(r=>{this.disposeWithMe(this._shortcutService.registerShortcut(r))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};ae=ln([h.OnLifecycle(h.LifecycleStages.Rendered,ae),ie(1,j.Inject(j.Injector)),ie(2,j.Inject(B.ComponentManager)),ie(3,B.IMenuService),ie(4,h.ICommandService),ie(5,B.IShortcutService)],ae);var un=Object.defineProperty,mn=Object.getOwnPropertyDescriptor,pn=(r,o,n,e)=>{for(var t=e>1?void 0:e?mn(o,n):o,i=r.length-1,a;i>=0;i--)(a=r[i])&&(t=(e?a(o,n,t):a(t))||t);return e&&t&&un(o,n,t),t},ee=(r,o)=>(n,e)=>o(n,e,r);const gn=[C.InsertRowCommand.id,C.InsertColCommand.id,C.RemoveRowCommand.id,C.RemoveColCommand.id,C.DeleteRangeMoveLeftCommand.id,C.DeleteRangeMoveUpCommand.id,C.InsertRangeMoveDownCommand.id,C.InsertRangeMoveRightCommand.id,C.DeltaRowHeightCommand.id,C.SetRowHeightCommand.id,C.DeltaColumnWidthCommand.id,C.SetColWidthCommand.id,C.SetRowHiddenCommand.id,C.SetSpecificRowsVisibleCommand.id,C.SetSpecificColsVisibleCommand.id,C.SetColHiddenCommand.id],hn=[C.SetRowVisibleMutation.id,C.SetRowHiddenMutation.id,C.SetColVisibleMutation.id,C.SetColHiddenMutation.id,C.SetWorksheetRowHeightMutation.id,C.SetWorksheetColWidthMutation.id];let he=class extends h.Disposable{constructor(r,o,n,e,t,i){super(),this._commandService=r,this._sheetInterceptorService=o,this._sheetDrawingService=n,this._drawingManagerService=e,this._selectionRenderService=t,this._univerInstanceService=i,this._init()}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(!gn.includes(r.id))return{redos:[],undos:[]};if(r.params==null)return{redos:[],undos:[]};const o=r.id;if(o===C.InsertRowCommand.id)return this._moveRowInterceptor(r.params,"insert");if(o===C.InsertColCommand.id)return this._moveColInterceptor(r.params,"insert");if(o===C.RemoveRowCommand.id)return this._moveRowInterceptor(r.params,"remove");if(o===C.RemoveColCommand.id)return this._moveColInterceptor(r.params,"remove");if(o===C.DeleteRangeMoveLeftCommand.id){const{range:n}=r.params;return this._getRangeMoveUndo(n,0)}else if(o===C.DeleteRangeMoveUpCommand.id){const{range:n}=r.params;return this._getRangeMoveUndo(n,1)}else if(o===C.InsertRangeMoveDownCommand.id){const{range:n}=r.params;return this._getRangeMoveUndo(n,2)}else if(o===C.InsertRangeMoveRightCommand.id){const{range:n}=r.params;return this._getRangeMoveUndo(n,3)}else if(o===C.SetRowHiddenCommand.id||o===C.SetSpecificRowsVisibleCommand.id){const n=r.params,{unitId:e,subUnitId:t,ranges:i}=n;return this._getDrawingUndoForRowVisible(e,t,i)}else if(o===C.SetSpecificColsVisibleCommand.id||o===C.SetColHiddenCommand.id){const n=r.params,{unitId:e,subUnitId:t,ranges:i}=n;return this._getDrawingUndoForColVisible(e,t,i)}else if(o===C.DeltaRowHeightCommand.id||o===C.SetRowHeightCommand.id||o===C.DeltaColumnWidthCommand.id||o===C.SetColWidthCommand.id){const n=r.params,{unitId:e,subUnitId:t,ranges:i}=n,a=o===C.DeltaRowHeightCommand.id||o===C.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,i,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(r,o){const n=C.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const e=n.unitId,t=n.subUnitId,i=[],a=[],s=this._sheetDrawingService.getDrawingData(e,t),c=[],u=[];if(Object.keys(s).forEach(l=>{const d=s[l],{updateDrawings:g,deleteDrawings:p}=this._getUpdateOrDeleteDrawings(r,o,d);c.push(...g),u.push(...p)}),c.length===0&&u.length===0)return{redos:[],undos:[]};if(c.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(c),{undo:d,redo:g,objects:p}=l;i.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:g,objects:p,type:m.DrawingApplyType.UPDATE}}),a.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:d,objects:p,type:m.DrawingApplyType.UPDATE}})}if(u.length>0){const l=this._sheetDrawingService.getBatchRemoveOp(u),d=l.undo,g=l.redo,p=l.objects;i.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:g,objects:p,type:m.DrawingApplyType.REMOVE}}),a.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:d,objects:p,type:m.DrawingApplyType.INSERT}})}return i.push({id:L.id,params:[e]}),a.push({id:L.id,params:[e]}),{redos:i,undos:a}}_getUpdateOrDeleteDrawings(r,o,n){const e=[],t=[],{sheetTransform:i,anchorType:a=m.SheetDrawingAnchorType.Position,transform:s,unitId:c,subUnitId:u,drawingId:l}=n,{from:d,to:g}=i,{row:p,column:S}=d,{row:f,column:_}=g;if(i==null||s==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:R,endRow:y,startColumn:I,endColumn:T}=r;let w=null,O=null;if(o===0&&p>=R&&f<=y)if(S>=I&&_<=T)t.push({unitId:c,subUnitId:u,drawingId:l});else{const v=this._shrinkCol(i,s,I,T,a);w=v==null?void 0:v.newSheetTransform,O=v==null?void 0:v.newTransform}else if(o===1&&S>=I&&_<=T)if(p>=R&&f<=y)t.push({unitId:c,subUnitId:u,drawingId:l});else{const v=this._shrinkRow(i,s,R,y,a);w=v==null?void 0:v.newSheetTransform,O=v==null?void 0:v.newTransform}else if(o===2){const v=this._expandRow(i,s,R,y,a);w=v==null?void 0:v.newSheetTransform,O=v==null?void 0:v.newTransform}else if(o===3){const v=this._expandCol(i,s,I,T,a);w=v==null?void 0:v.newSheetTransform,O=v==null?void 0:v.newTransform}if(w!=null&&O!=null){const v=V(w,this._selectionRenderService);e.push({...n,sheetTransform:w,transform:v})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(r,o,n){const e=W({...r},this._selectionRenderService);e!=null&&o.push({...n,sheetTransform:e})}_getDrawingUndoForColVisible(r,o,n){const e=this._drawingManagerService.getDrawingData(r,o),t=[],i=[];if(Object.keys(e).forEach(l=>{const d=e[l],{sheetTransform:g,transform:p,anchorType:S=m.SheetDrawingAnchorType.Position}=d;if(S===m.SheetDrawingAnchorType.None)this._remainDrawingSize(p,t,d);else{const{from:f,to:_}=g,{row:R,column:y}=f,{row:I,column:T}=_;for(let w=0;w<n.length;w++){const O=n[w],{startRow:v,endRow:N,startColumn:D,endColumn:F}=O;if(T<D)continue;if(S===m.SheetDrawingAnchorType.Position){let M=null,G=null;if(y>=D&&y<=F){const K=this._selectionRenderService.attachRangeWithCoord({startColumn:y,endColumn:F,startRow:f.row,endRow:_.row});if(K==null)return;G={...p,left:K.startX}}if(G!=null&&(M=W(G,this._selectionRenderService),M!=null&&G!=null)){t.push({...d,sheetTransform:M,transform:G});break}this._remainDrawingSize(p,t,d);continue}if(y>=D&&T<=F)continue;let U=null,E=null;if(y>=D&&y<=F){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:y,endColumn:F,startRow:f.row,endRow:_.row});if(M==null)return;E={...p,left:(M==null?void 0:M.startX)||0,width:((p==null?void 0:p.width)||0)-M.endX+M.startX}}else if(T>=D&&T<=F){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:D,endColumn:T,startRow:f.row,endRow:_.row});if(M==null)return;E={...p,left:M.startX-((p==null?void 0:p.width)||0)}}else{const M=this._selectionRenderService.attachRangeWithCoord({startColumn:D,endColumn:F,startRow:f.row,endRow:_.row});if(M==null)return;if(E={...p,width:((p==null?void 0:p.width)||0)-M.endX+M.startX},U=W(E,this._selectionRenderService),U!=null&&E!=null){i.push({...d,sheetTransform:U,transform:E});break}}if(E!=null&&(U=W(E,this._selectionRenderService)),E!=null&&U!=null){t.push({...d,sheetTransform:U,transform:E});break}else this._remainDrawingSize(p,t,d)}}}),t.length===0&&i.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(r,o,t),c=[],u=[];if(i.length>0){const{redos:l,undos:d}=this._createUndoAndRedoMutation(r,o,i);c.push(...l),u.push(...d)}return{redos:a,undos:s,preRedos:c,preUndos:u}}_createUndoAndRedoMutation(r,o,n){const e=this._sheetDrawingService.getBatchUpdateOp(n),{undo:t,redo:i,objects:a}=e,s=[{id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:o,op:i,objects:a,type:m.DrawingApplyType.UPDATE}},{id:L.id,params:[r]}],c=[{id:m.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:o,op:t,objects:a,type:m.DrawingApplyType.UPDATE}},{id:L.id,params:[r]}];return{redos:s,undos:c}}_getDrawingUndoForRowVisible(r,o,n){const e=this._drawingManagerService.getDrawingData(r,o),t=[],i=[];if(Object.keys(e).forEach(l=>{const d=e[l],{sheetTransform:g,transform:p,anchorType:S=m.SheetDrawingAnchorType.Position}=d;if(S===m.SheetDrawingAnchorType.None)this._remainDrawingSize(p,t,d);else{const{from:f,to:_}=g,{row:R,column:y}=f,{row:I,column:T}=_;for(let w=0;w<n.length;w++){const O=n[w],{startRow:v,endRow:N,startColumn:D,endColumn:F}=O;if(I<v)continue;if(S===m.SheetDrawingAnchorType.Position){let M=null,G=null;if(R>=v&&R<=N){const K=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:R,endRow:N});if(K==null)return;G={...p,top:K.startY}}if(G!=null&&(M=W(G,this._selectionRenderService),M!=null&&G!=null)){t.push({...d,sheetTransform:M,transform:G});break}this._remainDrawingSize(p,t,d);continue}if(R>=v&&I<=N)continue;let U=null,E=null;if(R>=v&&R<=N){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:R,endRow:N});if(M==null)return;E={...p,top:(M==null?void 0:M.startY)||0,height:((p==null?void 0:p.height)||0)-M.endY+M.startY}}else if(I>=v&&I<=N){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:v,endRow:I});if(M==null)return;E={...p,top:M.startY-((p==null?void 0:p.height)||0)}}else{const M=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:v,endRow:N});if(M==null)return;if(E={...p,height:((p==null?void 0:p.height)||0)-M.endY+M.startY},U=W(E,this._selectionRenderService),U!=null&&E!=null){i.push({...d,sheetTransform:U,transform:E});break}}if(E!=null&&(U=W(E,this._selectionRenderService)),E!=null&&U!=null){t.push({...d,sheetTransform:U,transform:E});break}else this._remainDrawingSize(p,t,d)}}}),t.length===0&&i.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(r,o,t),c=[],u=[];if(i.length>0){const{redos:l,undos:d}=this._createUndoAndRedoMutation(r,o,i);c.push(...l),u.push(...d)}return{redos:a,undos:s,preRedos:c,preUndos:u}}_getDrawingUndoForRowAndColSize(r,o,n,e){const t=this._drawingManagerService.getDrawingData(r,o),i=[];return Object.keys(t).forEach(a=>{const s=t[a],{sheetTransform:c,transform:u,anchorType:l=m.SheetDrawingAnchorType.Position}=s;if(l===m.SheetDrawingAnchorType.None)this._remainDrawingSize(u,i,s);else{const{from:d,to:g}=c,{row:p,column:S}=d,{row:f,column:_}=g;for(let R=0;R<n.length;R++){const y=n[R],{startRow:I,endRow:T,startColumn:w,endColumn:O}=y;if(f<I||_<w)continue;if(l===m.SheetDrawingAnchorType.Position&&(p<=I&&f>=T||S<=w&&_>=O)){this._remainDrawingSize(u,i,s);continue}const v=V({...c},this._selectionRenderService);if(v!=null){i.push({...s,transform:v});break}}}}),i.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(r,o,i)}_getUnitIdAndSubUnitId(r,o){let n,e;if(o==="insert")n=r.unitId,e=r.subUnitId;else{const t=C.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;n=t.unitId,e=t.subUnitId}return{unitId:n,subUnitId:e}}_moveRowInterceptor(r,o){const n=this._getUnitIdAndSubUnitId(r,o);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:i}=r,a=i.startRow,s=i.endRow,c=[],u=[],l=this._sheetDrawingService.getDrawingData(e,t),d=[],g=[];if(Object.keys(l).forEach(p=>{const S=l[p],{sheetTransform:f,transform:_,anchorType:R=m.SheetDrawingAnchorType.Position}=S;if(f==null||_==null)return;let y,I;if(o==="insert"){const w=this._expandRow(f,_,a,s,R);y=w==null?void 0:w.newSheetTransform,I=w==null?void 0:w.newTransform}else{const{from:w,to:O}=f,{row:v}=w,{row:N}=O;if(v>=a&&N<=s)g.push({unitId:e,subUnitId:t,drawingId:p});else{const D=this._shrinkRow(f,_,a,s,R);y=D==null?void 0:D.newSheetTransform,I=D==null?void 0:D.newTransform}}if(!y||!I)return;const T={unitId:e,subUnitId:t,drawingId:p,transform:I,sheetTransform:y};d.push(T)}),d.length===0&&g.length===0)return{redos:[],undos:[]};if(d.length>0){const p=this._sheetDrawingService.getBatchUpdateOp(d),{undo:S,redo:f,objects:_}=p;c.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:_,type:m.DrawingApplyType.UPDATE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:_,type:m.DrawingApplyType.UPDATE}})}if(g.length>0){const p=this._sheetDrawingService.getBatchRemoveOp(g),S=p.undo,f=p.redo,_=p.objects;c.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:_,type:m.DrawingApplyType.REMOVE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:_,type:m.DrawingApplyType.INSERT}})}return c.push({id:L.id,params:[e]}),u.push({id:L.id,params:[e]}),{redos:c,undos:u}}_moveColInterceptor(r,o){const n=this._getUnitIdAndSubUnitId(r,o);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:i}=r,a=i.startColumn,s=i.endColumn,c=[],u=[],l=this._sheetDrawingService.getDrawingData(e,t),d=[],g=[];if(Object.keys(l).forEach(p=>{const S=l[p],{sheetTransform:f,transform:_,anchorType:R=m.SheetDrawingAnchorType.Position}=S;if(f==null||_==null)return;let y,I;if(o==="insert"){const w=this._expandCol(f,_,a,s,R);y=w==null?void 0:w.newSheetTransform,I=w==null?void 0:w.newTransform}else{const{from:w,to:O}=f,{column:v}=w,{column:N}=O;if(v>=a&&N<=s)g.push({unitId:e,subUnitId:t,drawingId:p});else{const D=this._shrinkCol(f,_,a,s,R);y=D==null?void 0:D.newSheetTransform,I=D==null?void 0:D.newTransform}}if(!y||!I)return;const T={unitId:e,subUnitId:t,drawingId:p,transform:I,sheetTransform:y};d.push(T)}),d.length===0&&g.length===0)return{redos:[],undos:[]};if(d.length>0){const p=this._sheetDrawingService.getBatchUpdateOp(d),{undo:S,redo:f,objects:_}=p;c.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:_,type:m.DrawingApplyType.UPDATE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:_,type:m.DrawingApplyType.UPDATE}})}if(g.length>0){const p=this._sheetDrawingService.getBatchRemoveOp(g),S=p.undo,f=p.redo,_=p.objects;c.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:_,type:m.DrawingApplyType.REMOVE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:_,type:m.DrawingApplyType.INSERT}})}return c.push({id:L.id,params:[e]}),u.push({id:L.id,params:[e]}),{redos:c,undos:u}}_expandCol(r,o,n,e,t=m.SheetDrawingAnchorType.Position){const i=e-n+1,{from:a,to:s}=r,{column:c}=a,{column:u}=s;if(t===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...o},this._selectionRenderService),newTransform:o};let l=null,d=null;if(c>=n){const g=this._selectionRenderService.attachRangeWithCoord({startColumn:n,endColumn:e,startRow:a.row,endRow:s.row});if(g==null)return;d={...o,left:(o.left||0)+g.endX-g.startX},l=W(d,this._selectionRenderService)}else if(u>=e)if(t===m.SheetDrawingAnchorType.Both)l={from:{...a},to:{...s,column:u+i}},d=V(l,this._selectionRenderService);else return{newSheetTransform:W({...o},this._selectionRenderService),newTransform:o};return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_shrinkCol(r,o,n,e,t=m.SheetDrawingAnchorType.Position){const i=e-n+1,{from:a,to:s}=r,{column:c}=a,{column:u}=s;if(t===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...o},this._selectionRenderService),newTransform:o};let l=null,d=null;if(c>e)l={from:{...a,column:c-i},to:{...s,column:u-i}},d=V(l,this._selectionRenderService);else{if(c>=n&&u<=e)return null;if(c<n&&u>e)if(t===m.SheetDrawingAnchorType.Both)l={from:{...a},to:{...s,column:u-i}},d=V(l,this._selectionRenderService);else return{newSheetTransform:W({...o},this._selectionRenderService),newTransform:o};else if(c>=n&&c<=e){if(c===n)d={...o,left:(o.left||0)-r.from.columnOffset};else{const g=this._selectionRenderService.attachRangeWithCoord({startColumn:n,endColumn:c-1,startRow:a.row,endRow:s.row});if(g==null)return;d={...o,left:(o.left||0)-g.endX+g.startX-r.from.columnOffset}}l=W(d,this._selectionRenderService)}else if(u>=n&&u<=e&&t===m.SheetDrawingAnchorType.Both){const g=this._selectionRenderService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:a.row,endRow:s.row});if(g==null)return;l={from:{...a},to:{...s,column:n-1,columnOffset:g.endX-g.startX}},d=V(l,this._selectionRenderService)}}return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_expandRow(r,o,n,e,t=m.SheetDrawingAnchorType.Position){const i=e-n+1,{from:a,to:s}=r,{row:c}=a,{row:u}=s;if(t===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...o},this._selectionRenderService),newTransform:o};let l=null,d=null;if(c>=n){const g=this._selectionRenderService.attachRangeWithCoord({startRow:n,endRow:e,startColumn:a.column,endColumn:s.column});if(g==null)return;d={...o,top:(o.top||0)+g.endY-g.startY},l=W(d,this._selectionRenderService)}else if(u>=e)if(t===m.SheetDrawingAnchorType.Both)l={from:{...a},to:{...s,row:u+i}},d=V(l,this._selectionRenderService);else return{newSheetTransform:W({...o},this._selectionRenderService),newTransform:o};return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_shrinkRow(r,o,n,e,t=m.SheetDrawingAnchorType.Position){const i=e-n+1,{from:a,to:s}=r,{row:c}=a,{row:u}=s;if(t===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...o},this._selectionRenderService),newTransform:o};let l=null,d=null;if(c>e)l={from:{...a,row:c-i},to:{...s,row:u-i}},d=V(l,this._selectionRenderService);else{if(c>=n&&u<=e)return null;if(c<n&&u>e)if(t===m.SheetDrawingAnchorType.Both)l={from:{...a},to:{...s,row:u-i}},d=V(l,this._selectionRenderService);else return{newSheetTransform:W({...o},this._selectionRenderService),newTransform:o};else if(c>=n&&c<=e){if(c===n)d={...o,top:(o.top||0)-r.from.rowOffset};else{const g=this._selectionRenderService.attachRangeWithCoord({startRow:n,endRow:c-1,startColumn:a.column,endColumn:s.column});if(g==null)return;d={...o,top:(o.top||0)-g.endY+g.startY-r.from.rowOffset}}l=W(d,this._selectionRenderService)}else if(u>=n&&u<=e&&t===m.SheetDrawingAnchorType.Both){const g=this._selectionRenderService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:n-1,endRow:n-1});if(g==null)return;l={from:{...a},to:{...s,row:n-1,rowOffset:g.endY-g.startY}},d=V(l,this._selectionRenderService)}}return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===C.SetWorksheetActiveOperation.id){const o=r.params,{unitId:n,subUnitId:e}=o,t=this._drawingManagerService.drawingManagerData,i=[],a=[];Object.keys(t).forEach(s=>{const c=t[s];Object.keys(c).forEach(u=>{const l=c[u].data;l!=null&&Object.keys(l).forEach(d=>{s===n&&u===e?i.push(l[d]):a.push(l[d])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(i)}}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{hn.includes(r.id)&&requestIdleCallback(()=>{const o=r.params,{unitId:n,subUnitId:e,ranges:t}=o;this._refreshDrawingTransform(n,e,t)})}))}_refreshDrawingTransform(r,o,n){const e=this._drawingManagerService.getDrawingData(r,o),t=[];Object.keys(e).forEach(i=>{const a=e[i],{sheetTransform:s,anchorType:c=m.SheetDrawingAnchorType.Position}=a;if(c===m.SheetDrawingAnchorType.None)return!0;const{from:u,to:l}=s,{row:d,column:g}=u,{row:p,column:S}=l;for(let f=0;f<n.length;f++){const _=n[f],{startRow:R,endRow:y,startColumn:I,endColumn:T}=_;if(h.Rectangle.intersects({startRow:R,endRow:y,startColumn:I,endColumn:T},{startRow:d,endRow:p,startColumn:g,endColumn:S})||d>y||g>T){t.push({...a,transform:V(s,this._selectionRenderService)});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(L.id,[r]))}};he=pn([h.OnLifecycle(h.LifecycleStages.Rendered,he),ee(0,h.ICommandService),ee(1,j.Inject(C.SheetInterceptorService)),ee(2,m.ISheetDrawingService),ee(3,P.IDrawingManagerService),ee(4,k.ISelectionRenderService),ee(5,h.IUniverInstanceService)],he);var fn=Object.defineProperty,Sn=Object.getOwnPropertyDescriptor,vn=(r,o,n,e)=>{for(var t=e>1?void 0:e?Sn(o,n):o,i=r.length-1,a;i>=0;i--)(a=r[i])&&(t=(e?a(o,n,t):a(t))||t);return e&&t&&fn(o,n,t),t},Z=(r,o)=>(n,e)=>o(n,e,r);function wn(r,o,n,e){const{scaleX:t,scaleY:i}=o.getAncestorScale(),a=o.getViewport(k.VIEWPORT_KEY.VIEW_MAIN),s={left:!0,top:!0};if(!a)return{...r,absolute:s};const{left:c,right:u,top:l,bottom:d}=r,g=e.getFreeze(),{startColumn:p,startRow:S,xSplit:f,ySplit:_}=g,R=n.getNoMergeCellPositionByIndexWithNoHeader(S-_,p-f),y=n.getNoMergeCellPositionByIndexWithNoHeader(S,p),{rowHeaderWidth:I,columnHeaderHeight:T}=n,w=y.startX-R.startX,O=y.startY-R.startY,{top:v,left:N,viewportScrollX:D,viewportScrollY:F}=a;let U,E;c<N?(s.left=!0,U=(w+I+(c-N))*t,E=Math.max(Math.min((w+I+(u-N))*t,(w+I)*t),(u-D)*t)):(s.left=!1,U=Math.max((c-D)*t,(w+I)*t),E=Math.max((u-D)*t,(w+I)*t));let M,G;return l<v?(s.top=!0,M=(O+T+(l-v))*i,G=Math.max(Math.min((O+T+(u-v))*i,(O+T)*i),(d-F)*i)):(s.top=!1,M=Math.max((l-F)*i,(O+T)*i),G=Math.max((d-F)*i,(O+T)*i)),{left:U,right:E,top:M,bottom:G,absolute:s}}const we=(r,o,n,e)=>{const{scene:t}=o,{left:i,top:a,width:s,height:c,angle:u}=r,l={left:i,right:i+s,top:a,bottom:a+c},d=wn(l,t,n,e);return{startX:d.left,endX:d.right,startY:d.top,endY:d.bottom,rotate:u,width:s,height:c,absolute:d.absolute}};A.SheetCanvasFloatDomManagerService=class extends h.Disposable{constructor(n,e,t,i,a,s,c,u){super();X(this,"_domLayerMap",new Map);X(this,"_domLayerInfoMap",new Map);X(this,"_transformChange$",new te.Subject);X(this,"transformChange$",this._transformChange$.asObservable());X(this,"_remove$",new te.Subject);X(this,"remove$",this._remove$.asObservable());this._renderManagerService=n,this._univerInstanceService=e,this._sheetSkeletonManagerService=t,this._commandService=i,this._drawingManagerService=a,this._selectionRenderService=s,this._canvasFloatDomService=c,this._sheetDrawingService=u,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(n,e){let t=this._domLayerMap.get(n);t||(t=new Map,this._domLayerMap.set(n,t));let i=t.get(e);return i||(i=new Map,t.set(e,i)),i}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const e=this._renderManagerService.getRenderById(n),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const i=t.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:t,transformer:i,renderObject:e,canvas:a}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(e=>{const{unitId:t,subUnitId:i,drawingId:a}=e,s=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:i}),c=this._drawingManagerService.getDrawingByParam(e),u=this._sheetSkeletonManagerService.getUnitSkeleton(t,i);if(c==null||s==null||u==null)return;const{transform:l,drawingType:d}=c;if(d!==h.DrawingTypeEnum.DRAWING_DOM)return;const g=this._getSceneAndTransformerByDrawingSearch(t);if(g==null)return;const{scene:p,canvas:S}=g;if(l==null)return!0;const{left:f,top:_,width:R,height:y,angle:I,flipX:T,flipY:w,skewX:O,skewY:v}=l,N=P.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:i,drawingId:a}),D=p.getObject(N);if(D!=null){D.transformByState({left:f,top:_,width:R,height:y,angle:I,flipX:T,flipY:w,skewX:O,skewY:v});return}const F={left:f,top:_,width:R,height:y,zIndex:this._drawingManagerService.getDrawingOrder(t,i).length-1},U=new x.Rect(N,F);p.addObject(U,x.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(U);const E=new h.DisposableCollection,M=we(U,g.renderObject,u.skeleton,s.worksheet),G=new te.BehaviorSubject(M),K={dispose:E,rect:U,position$:G,unitId:t,subUnitId:i};this._canvasFloatDomService.addFloatDom({position$:G,id:a,componentKey:c.componentKey,onPointerDown:$=>{S.dispatchEvent(new PointerEvent($.type,$))},onPointerMove:$=>{S.dispatchEvent(new PointerEvent($.type,$))},onPointerUp:$=>{S.dispatchEvent(new PointerEvent($.type,$))},onWheel:$=>{S.dispatchEvent(new WheelEvent($.type,$))}});const je=U.onTransformChangeObservable.add(()=>{const $=we(U,g.renderObject,u.skeleton,s.worksheet);G.next($)});E.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),je&&E.add(je),this._domLayerInfoMap.set(a,K)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var t,i;const e=(a,s)=>{const c=this._getSceneAndTransformerByDrawingSearch(a),u=this._ensureMap(a,s),l=Array.from(u.keys()),d=C.getSheetCommandTarget(this._univerInstanceService,{unitId:a,subUnitId:s}),g=this._sheetSkeletonManagerService.getUnitSkeleton(a,s);!c||!d||!g||l.forEach(p=>{const S=this._domLayerInfoMap.get(p);if(S){const f=we(S.rect,c.renderObject,g.skeleton,d.worksheet);S.position$.next(f)}})};if(n.id===k.SetScrollOperation.id){const a=n.params,{unitId:s,sheetId:c}=a;e(s,c)}else if(n.id===k.SetZoomRatioOperation.id){const a=n.params,{unitId:s}=a;Array.from((i=(t=this._domLayerMap.get(s))==null?void 0:t.keys())!=null?i:[]).forEach(u=>{e(s,u)})}else if(n.id===C.SetFrozenMutation.id){const{unitId:a,subUnitId:s}=n.params;e(a,s)}}))}_getPosition(n){const{startX:e,endX:t,startY:i,endY:a}=n,s=this._selectionRenderService.getSelectionCellByPosition(e,i);if(s==null)return;const c={column:s.actualColumn,columnOffset:e-s.startX,row:s.actualRow,rowOffset:i-s.startY},u=this._selectionRenderService.getSelectionCellByPosition(t,a);if(u==null)return;const l={column:u.actualColumn,columnOffset:t-u.startX,row:u.actualRow,rowOffset:a-u.startY};return{from:c,to:l}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==h.DrawingTypeEnum.DRAWING_DOM)return;const i={...t.transform};this._transformChange$.next({id:e.drawingId,value:i})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{this._removeDom(e.drawingId)})}))}addFloatDomToPosition(n){const e=C.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!e)throw new Error("cannot find current target!");const{unitId:t,subUnitId:i}=e,{initPosition:a,componentKey:s}=n,c=h.Tools.generateRandomId(),u=this._getPosition(a);if(u==null)return;const l={unitId:t,subUnitId:i,drawingId:c,drawingType:h.DrawingTypeEnum.DRAWING_DOM,componentKey:s,sheetTransform:u,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY}};return this._commandService.executeCommand(ve.id,{unitId:t,drawings:[l]}),this._ensureMap(t,i).set(c,n),{id:c,dispose:()=>{this._removeDom(c,!0)}}}_removeDom(n,e=!1){const t=this._domLayerInfoMap.get(n);if(!t)return;const{unitId:i,subUnitId:a}=t,s=this._ensureMap(i,a);this._domLayerInfoMap.delete(n),s.delete(n),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(i);if(c&&c.scene.removeObject(t.rect),e){const u=this._drawingManagerService.getDrawingByParam({unitId:i,subUnitId:a,drawingId:n});if(!u)return;const l=this._sheetDrawingService.getBatchRemoveOp([u]),{redo:d,objects:g}=l;this._commandService.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:i,subUnitId:a,op:d,objects:g,type:m.DrawingApplyType.REMOVE})}}},A.SheetCanvasFloatDomManagerService=vn([Z(0,j.Inject(x.IRenderManagerService)),Z(1,h.IUniverInstanceService),Z(2,j.Inject(k.SheetSkeletonManagerService)),Z(3,j.Inject(h.ICommandService)),Z(4,P.IDrawingManagerService),Z(5,k.ISelectionRenderService),Z(6,j.Inject(B.CanvasFloatDomService)),Z(7,m.ISheetDrawingService)],A.SheetCanvasFloatDomManagerService);var _n=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,In=(r,o,n,e)=>{for(var t=e>1?void 0:e?Cn(o,n):o,i=r.length-1,a;i>=0;i--)(a=r[i])&&(t=(e?a(o,n,t):a(t))||t);return e&&t&&_n(o,n,t),t},Ne=(r,o)=>(n,e)=>o(n,e,r);const yn="SHEETS_IMAGE_UI_PLUGIN";A.UniverSheetsDrawingUIPlugin=(fe=class extends h.Plugin{constructor(n={},e,t){super();X(this,"_pluginConfig");this._injector=e,this._localeService=t,this._pluginConfig=h.Tools.deepMerge({},dn,n)}onStarting(n){super.onStarting(n),this._initDependencies(n)}_initDependencies(n){[[A.SheetCanvasFloatDomManagerService],[ae,{useFactory:()=>this._injector.createInstance(ae,this._pluginConfig)}],[pe],[le],[he]].forEach(t=>n.add(t))}},X(fe,"type",h.UniverInstanceType.UNIVER_SHEET),X(fe,"pluginName",yn),fe),A.UniverSheetsDrawingUIPlugin=In([Ne(1,j.Inject(j.Injector)),Ne(2,j.Inject(h.LocaleService))],A.UniverSheetsDrawingUIPlugin),Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@univerjs/sheets-drawing-ui",
3
+ "version": "0.1.13",
4
+ "private": false,
5
+ "description": "",
6
+ "author": "DreamNum <developer@univer.ai>",
7
+ "license": "Apache-2.0",
8
+ "funding": {
9
+ "type": "opencollective",
10
+ "url": "https://opencollective.com/univer"
11
+ },
12
+ "homepage": "https://univer.ai",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/dream-num/univer"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/dream-num/univer/issues"
19
+ },
20
+ "keywords": [],
21
+ "sideEffects": [
22
+ "**/*.css"
23
+ ],
24
+ "exports": {
25
+ ".": {
26
+ "import": "./lib/es/index.js",
27
+ "require": "./lib/cjs/index.js",
28
+ "types": "./lib/types/index.d.ts"
29
+ },
30
+ "./*": {
31
+ "import": "./lib/es/*",
32
+ "require": "./lib/cjs/*",
33
+ "types": "./lib/types/index.d.ts"
34
+ },
35
+ "./locale/*": "./lib/locale/*.json",
36
+ "./lib/*": "./lib/*"
37
+ },
38
+ "main": "./lib/cjs/index.js",
39
+ "module": "./lib/es/index.js",
40
+ "types": "./lib/types/index.d.ts",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "directories": {
45
+ "lib": "lib"
46
+ },
47
+ "files": [
48
+ "lib"
49
+ ],
50
+ "engines": {
51
+ "node": ">=16.0.0",
52
+ "npm": ">=8.0.0"
53
+ },
54
+ "peerDependencies": {
55
+ "@wendellhu/redi": "0.15.2",
56
+ "clsx": ">=2.0.0",
57
+ "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
58
+ "rxjs": ">=7.0.0",
59
+ "@univerjs/design": "0.1.13",
60
+ "@univerjs/core": "0.1.13",
61
+ "@univerjs/drawing": "0.1.13",
62
+ "@univerjs/drawing-ui": "0.1.13",
63
+ "@univerjs/sheets": "0.1.13",
64
+ "@univerjs/engine-render": "0.1.13",
65
+ "@univerjs/sheets-ui": "0.1.13",
66
+ "@univerjs/ui": "0.1.13",
67
+ "@univerjs/sheets-drawing": "0.1.13"
68
+ },
69
+ "dependencies": {
70
+ "@univerjs/icons": "^0.1.55"
71
+ },
72
+ "devDependencies": {
73
+ "@wendellhu/redi": "0.15.2",
74
+ "clsx": "^2.1.1",
75
+ "less": "^4.2.0",
76
+ "react": "18.2.0",
77
+ "rxjs": "^7.8.1",
78
+ "typescript": "^5.4.5",
79
+ "vite": "^5.2.12",
80
+ "vitest": "^1.6.0",
81
+ "@univerjs/core": "0.1.13",
82
+ "@univerjs/design": "0.1.13",
83
+ "@univerjs/drawing": "0.1.13",
84
+ "@univerjs/drawing-ui": "0.1.13",
85
+ "@univerjs/engine-render": "0.1.13",
86
+ "@univerjs/shared": "0.1.13",
87
+ "@univerjs/sheets": "0.1.13",
88
+ "@univerjs/sheets-ui": "0.1.13",
89
+ "@univerjs/sheets-drawing": "0.1.13",
90
+ "@univerjs/ui": "0.1.13"
91
+ },
92
+ "scripts": {
93
+ "test": "vitest run",
94
+ "test:watch": "vitest",
95
+ "coverage": "vitest run --coverage",
96
+ "lint:types": "tsc --noEmit",
97
+ "build": "tsc && vite build"
98
+ }
99
+ }