@univerjs/sheets-drawing-ui 0.1.13-nightly.202406041140
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/README.md +16 -0
- package/lib/cjs/index.js +1 -0
- package/lib/es/index.js +2056 -0
- package/lib/index.css +1 -0
- package/lib/locale/en-US.json +31 -0
- package/lib/locale/ru-RU.json +31 -0
- package/lib/locale/zh-CN.json +31 -0
- package/lib/types/basics/transform-position.d.ts +6 -0
- package/lib/types/commands/commands/delete-drawings.command.d.ts +3 -0
- package/lib/types/commands/commands/group-sheet-drawing.command.d.ts +6 -0
- package/lib/types/commands/commands/insert-sheet-drawing.command.d.ts +6 -0
- package/lib/types/commands/commands/interfaces.d.ts +21 -0
- package/lib/types/commands/commands/move-drawings.command.d.ts +6 -0
- package/lib/types/commands/commands/remove-sheet-drawing.command.d.ts +6 -0
- package/lib/types/commands/commands/set-drawing-arrange.command.d.ts +10 -0
- package/lib/types/commands/commands/set-sheet-drawing.command.d.ts +6 -0
- package/lib/types/commands/commands/ungroup-sheet-drawing.command.d.ts +6 -0
- package/lib/types/commands/commands/utils.d.ts +4 -0
- package/lib/types/commands/operations/clear-drawing-transformer.operation.d.ts +3 -0
- package/lib/types/commands/operations/edit-sheet-drawing.operation.d.ts +4 -0
- package/lib/types/commands/operations/insert-image.operation.d.ts +7 -0
- package/lib/types/commands/operations/open-drawing-panel.operation.d.ts +6 -0
- package/lib/types/controllers/drawing-popup-menu.controller.d.ts +24 -0
- package/lib/types/controllers/sheet-drawing-transform-affected.controller.d.ts +34 -0
- package/lib/types/controllers/sheet-drawing-update.controller.d.ts +35 -0
- package/lib/types/controllers/sheet-drawing.controller.d.ts +23 -0
- package/lib/types/controllers/shortcuts/drawing.shortcut.d.ts +10 -0
- package/lib/types/index.d.ts +17 -0
- package/lib/types/locale/en-US.d.ts +4 -0
- package/lib/types/locale/ru-RU.d.ts +4 -0
- package/lib/types/locale/zh-CN.d.ts +47 -0
- package/lib/types/plugin.d.ts +14 -0
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +60 -0
- package/lib/types/views/menu/image.menu.d.ts +7 -0
- package/lib/types/views/sheet-image-panel/SheetDrawingAnchor.d.ts +7 -0
- package/lib/types/views/sheet-image-panel/SheetDrawingPanel.d.ts +3 -0
- package/lib/types/views/sheet-image-panel/component-name.d.ts +16 -0
- package/lib/types/views/upload-component/UploadFile.d.ts +9 -0
- package/lib/types/views/upload-component/component-name.d.ts +20 -0
- package/lib/types/views/upload-loading/UploadLoading.d.ts +3 -0
- package/lib/umd/index.js +1 -0
- package/package.json +99 -0
package/lib/umd/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(A,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/ui"),require("@wendellhu/redi/react-bindings"),require("@univerjs/sheets"),require("react"),require("@univerjs/design"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/drawing-ui","@univerjs/sheets-drawing","@univerjs/drawing","@univerjs/engine-render","@univerjs/sheets-ui","rxjs","@univerjs/ui","@wendellhu/redi/react-bindings","@univerjs/sheets","react","@univerjs/design","clsx"],h):(A=typeof globalThis<"u"?globalThis:A||self,h(A.UniverSheetsDrawingUi={},A.UniverCore,A["@wendellhu/redi"],A.UniverDrawingUi,A.UniverSheetsDrawing,A.UniverDrawing,A.UniverEngineRender,A.UniverSheetsUi,A.rxjs,A.UniverUi,A["@wendellhu/redi/react-bindings"],A.UniverSheets,A.React,A.UniverDesign,A.clsx))})(this,function(A,h,j,ee,m,E,F,X,te,k,$,C,b,q,se){"use strict";var gn=Object.defineProperty;var hn=(A,h,j)=>h in A?gn(A,h,{enumerable:!0,configurable:!0,writable:!0,value:j}):A[h]=j;var K=(A,h,j)=>(hn(A,typeof h!="symbol"?h+"":h,j),j);const L={id:"sheet.operation.clear-drawing-transformer",type:h.CommandType.MUTATION,handler:(e,t)=>{const n=e.get(F.IRenderManagerService);return t.forEach(i=>{var r,o;(o=(r=n.getRenderById(i))==null?void 0:r.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},fe={id:"sheet.command.remove-sheet-image",type:h.CommandType.COMMAND,handler:(e,t)=>{const n=e.get(h.ICommandService),i=e.get(h.IUndoRedoService),r=e.get(m.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,a=[];o.forEach(S=>{const{unitId:f}=S;a.push(f)});const s=r.getBatchRemoveOp(o),{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})?(i.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}},we="COMPONENT_SHEET_DRAWING_PANEL",_e={id:"sidebar.operation.sheet-image",type:h.CommandType.COMMAND,handler:async(e,t)=>{const n=e.get(k.ISidebarService),i=e.get(h.LocaleService),r=e.get(h.IUniverInstanceService),o=e.get(E.IDrawingManagerService);if(!C.getSheetCommandTarget(r))return!1;switch(t.value){case"open":n.open({header:{title:i.t("sheetImage.panel.title")},children:{label:we},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:n.close();break}return!0}},Ce={id:"sheet.operation.edit-sheet-image",type:h.CommandType.OPERATION,handler:(e,t)=>{const n=e.get(E.IDrawingManagerService),i=e.get(h.ICommandService);return t==null?!1:(n.focusDrawing([t]),i.executeCommand(_e.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 e=$.useDependency(E.IImageIoService),t=$.useDependency(h.LocaleService),[n,i]=b.useState(0);return b.useEffect(()=>{const r=e.change$.subscribe(o=>{i(o)});return()=>{r.unsubscribe()}},[e]),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},`${t.t("uploadLoading.loading")}: ${n}`)))};var We=(e,t,n,i)=>{for(var r=t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(r=a(r)||r);return r},Q=(e,t)=>(n,i)=>t(n,i,e);let le=class extends h.RxDisposable{constructor(t,n,i,r,o,a,s){super();K(this,"_initImagePopupMenu",new Set);this._injector=t,this._drawingManagerService=n,this._canvasPopManagerService=i,this._renderManagerService=r,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=s,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET).pipe(te.takeUntil(this.dispose$)).subscribe(t=>this._create(t)),this._univerInstanceService.getTypeOfUnitDisposed$(h.UniverInstanceType.UNIVER_SHEET).pipe(te.takeUntil(this.dispose$)).subscribe(t=>this._dispose(t)),this._univerInstanceService.getAllUnitsForType(h.UniverInstanceType.UNIVER_SHEET).forEach(t=>this._create(t)),this._uiPartsService.registerComponent(k.BuiltInUIPart.CONTENT,()=>$.connectInjector(Le,this._injector))}_dispose(t){const n=t.getUnitId();this._renderManagerService.removeRender(n)}_create(t){if(!t)return;const n=t.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(t){const n=t.getAllObjects();for(const i of n)if(i instanceof ee.ImageCropperObject)return!0;return!1}_popupMenuListener(t){var o;const n=(o=this._renderManagerService.getRenderById(t))==null?void 0:o.scene;if(!n)return;const i=n.getTransformerByCreate();if(!i)return;const r=[];this.disposeWithMe(h.toDisposable(i.onCreateControlObservable.add(()=>{if(this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=i.getSelectedObjectMap();if(a.size>1){r.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;r.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s,{componentKey:ee.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(i.onClearControlObservable.add(()=>{r.forEach(a=>a.dispose()),this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)}))),this.disposeWithMe(h.toDisposable(i.onChangingObservable.add(()=>{r.forEach(a=>a.dispose())})))}_getImageMenuItems(t,n,i){return[{label:"image-popup.edit",index:0,commandId:Ce.id,commandParams:{unitId:t,subUnitId:n,drawingId:i},disable:!1},{label:"image-popup.delete",index:1,commandId:fe.id,commandParams:{unitId:t,drawings:[{unitId:t,subUnitId:n,drawingId:i}]},disable:!1},{label:"image-popup.crop",index:2,commandId:ee.OpenImageCropOperation.id,commandParams:{unitId:t,subUnitId:n,drawingId:i},disable:!1},{label:"image-popup.reset",index:3,commandId:ee.ImageResetSizeOperation.id,commandParams:[{unitId:t,subUnitId:n,drawingId:i}],disable:!1}]}};le=We([h.OnLifecycle(h.LifecycleStages.Steady,le),Q(0,j.Inject(j.Injector)),Q(1,E.IDrawingManagerService),Q(2,j.Inject(X.SheetCanvasPopManagerService)),Q(3,F.IRenderManagerService),Q(4,h.IUniverInstanceService),Q(5,h.IContextService),Q(6,j.Inject(k.IUIPartsService))],le);const de={id:"sheet.operation.insert-float-image",type:h.CommandType.OPERATION,handler:(e,t)=>!0},ue={id:"sheet.operation.insert-cell-image",type:h.CommandType.OPERATION,handler:(e,t)=>!0},Se={id:"sheet.command.insert-sheet-image",type:h.CommandType.COMMAND,handler:(e,t)=>{const n=e.get(h.ICommandService),i=e.get(h.IUndoRedoService),r=e.get(m.ISheetDrawingService);if(!t)return!1;const o=t.drawings,a=o.map(S=>S.unitId),s=r.getBatchAddOp(o),{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})?(i.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:(e,t)=>{const n=e.get(h.ICommandService),i=e.get(h.IUndoRedoService),r=e.get(m.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,a=r.getBatchUpdateOp(o),{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})?(i.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}},Ie={id:"sheet.command.set-drawing-arrange",type:h.CommandType.COMMAND,handler:(e,t)=>{const n=e.get(h.ICommandService),i=e.get(h.IUndoRedoService);if(!t)return!1;const r=e.get(m.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:s,arrangeType:c}=t,u={unitId:o,subUnitId:a,drawingIds:s};let l;if(c===E.ArrangeTypeEnum.forward?l=r.getForwardDrawingsOp(u):c===E.ArrangeTypeEnum.backward?l=r.getBackwardDrawingOp(u):c===E.ArrangeTypeEnum.front?l=r.getFrontDrawingsOp(u):c===E.ArrangeTypeEnum.back&&(l=r.getBackDrawingsOp(u)),l==null)return!1;const{objects:d,redo:g,undo:p}=l;return n.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:g,unitId:o,subUnitId:a,objects:d,type:m.DrawingApplyType.ARRANGE})?(i.pushUndoRedo({unitID:o,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:p,unitId:o,subUnitId:a,objects:d,type:m.DrawingApplyType.ARRANGE}}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:d,type:m.DrawingApplyType.ARRANGE}}]}),!0):!1}};function Ge(e){const t=[];return e.forEach(n=>{const{parent:i,children:r}=n,{unitId:o,subUnitId:a,drawingId:s}=i,c=F.getGroupState(0,0,r.map(d=>d.transform||{})),u=r.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:o,subUnitId:a,drawingId:s,drawingType:E.DrawingTypeEnum.DRAWING_GROUP,transform:c};t.push({parent:l,children:u})}),t}function ke(e){const t=[];return e.forEach(n=>{const{parent:i,children:r}=n,{unitId:o,subUnitId:a,drawingId:s,transform:c={width:0,height:0}}=i;if(c==null)return;const u=r.map(d=>{const{transform:g}=d,{unitId:p,subUnitId:S,drawingId:f}=d,_=F.transformObjectOutOfGroup(g||{},c,c.width||0,c.height||0);return{unitId:p,subUnitId:S,drawingId:f,transform:_,groupId:void 0}}),l={unitId:o,subUnitId:a,drawingId:s,drawingType:E.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};t.push({parent:l,children:u})}),t}const ye={id:"sheet.command.group-sheet-image",type:h.CommandType.COMMAND,handler:(e,t)=>{const n=e.get(h.ICommandService),i=e.get(h.IUndoRedoService),r=e.get(m.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:p,children:S})=>{o.push(p.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=r.getGroupDrawingOp(t),{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})?(i.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:c,objects:ke(d),type:m.DrawingApplyType.UNGROUP}},{id:L.id,params:o}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:m.DrawingApplyType.GROUP}},{id:L.id,params:o}]}),!0):!1}},Me={id:"sheet.command.ungroup-sheet-image",type:h.CommandType.COMMAND,handler:(e,t)=>{const n=e.get(h.ICommandService),i=e.get(h.IUndoRedoService),r=e.get(m.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:p,children:S})=>{o.push(p.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=r.getUngroupDrawingOp(t),{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})?(i.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:c,objects:Ge(d),type:m.DrawingApplyType.GROUP}},{id:L.id,params:o}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:l,unitId:s,subUnitId:c,objects:d,type:m.DrawingApplyType.UNGROUP}},{id:L.id,params:o}]}),!0):!1}};function x(e,t){const{from:n,to:i}=e,{column:r,columnOffset:o,row:a,rowOffset:s}=n,{column:c,columnOffset:u,row:l,rowOffset:d}=i,g=t.attachRangeWithCoord({startColumn:r,endColumn:r,startRow:a,endRow:a});if(g==null)return;const p=t.attachRangeWithCoord({startColumn:c,endColumn:c,startRow:l,endRow:l});if(p==null)return;const{startX:S,startY:f}=g,{startX:_,startY:R}=p,y=F.precisionTo(S+o,1),I=F.precisionTo(f+s,1);let T=F.precisionTo(_+u-y,1),w=F.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(e,t){const{left:n=0,top:i=0,width:r=0,height:o=0}=e,a=t.getSelectionCellByPosition(n,i);if(a==null)return;const s={column:a.actualColumn,columnOffset:F.precisionTo(n-a.startX,1),row:a.actualRow,rowOffset:F.precisionTo(i-a.startY,1)},c=t.getSelectionCellByPosition(n+r,i+o);if(c==null)return;const u={column:c.actualColumn,columnOffset:F.precisionTo(n+r-c.startX,1),row:c.actualRow,rowOffset:F.precisionTo(i+o-c.startY,1)};return{from:s,to:u}}var Be=(e,t,n,i)=>{for(var r=t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(r=a(r)||r);return r},Y=(e,t)=>(n,i)=>t(n,i,e);let pe=class extends h.Disposable{constructor(e,t,n,i,r,o,a,s,c,u,l){super(),this._commandService=e,this._univerInstanceService=t,this._selectionManagerService=n,this._selectionRenderService=i,this._imageIoService=r,this._sheetDrawingService=o,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 e=>{if(e.id===ue.id||e.id===de.id){const t=e.params;if(t.files==null)return;const n=t.files.length;if(n>E.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(E.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(n),e.id===ue.id?t.files.forEach(async i=>{await this._insertCellImage(i)}):t.files.forEach(async i=>{await this._insertFloatImage(i)})}}))}async _insertCellImage(e){}async _insertFloatImage(e){let t;try{t=await this._imageIoService.saveImage(e)}catch(y){const I=y.message;I===E.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(E.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):I===E.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===E.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(t==null)return;const n=this._getUnitInfo();if(n==null)return;const{unitId:i,subUnitId:r}=n,{imageId:o,imageSourceType:a,source:s,base64Cache:c}=t,{width:u,height:l,image:d}=await E.getImageSize(c||""),g=this._renderManagerService.getRenderById(i);if(g==null)return;const{width:p,height:S}=g.scene;this._imageIoService.addImageSourceCache(s,a,d);let f=1;if(u>E.DRAWING_IMAGE_WIDTH_LIMIT||l>E.DRAWING_IMAGE_HEIGHT_LIMIT){const y=E.DRAWING_IMAGE_WIDTH_LIMIT/u,I=E.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:i,subUnitId:r,drawingId:o,drawingType:E.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a,source:s,transform:x(_,this._selectionRenderService),sheetTransform:_};this._commandService.executeCommand(Se.id,{unitId:i,drawings:[R]})}_getUnitInfo(){const e=this._univerInstanceService.getCurrentUnitForType(h.UniverInstanceType.UNIVER_SHEET);if(e==null)return;const t=e.getActiveSheet();if(t==null)return;const n=e.getUnitId(),i=t.getSheetId();return{unitId:n,subUnitId:i}}_getImagePosition(e,t,n,i){const r=this._selectionManagerService.getSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};r&&r.length>0&&(o=r[r.length-1].range);const a=this._selectionRenderService.attachRangeWithCoord(o);if(a==null)return;let{startColumn:s,startRow:c,startX:u,startY:l}=a,d=!1;if(u+e>n&&(u=n-e,u<0&&(u=0,e=n),d=!0),l+t>i&&(l=i-t,l<0&&(l=0,t=i),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+e,l+t);if(p==null)return;const S={column:p.actualColumn,columnOffset:u+e-p.startX,row:p.actualRow,rowOffset:l+t-p.startY};return{from:g,to:S}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(e=>{const{unitId:t,subUnitId:n,drawingIds:i,arrangeType:r}=e;this._commandService.executeCommand(Ie.id,{unitId:t,subUnitId:n,drawingIds:i,arrangeType:r})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(e=>{const t=[];e.length!==0&&(e.forEach(n=>{const{unitId:i,subUnitId:r,drawingId:o,drawingType:a,transform:s}=n;if(s==null)return;const c=this._sheetDrawingService.getDrawingByParam({unitId:i,subUnitId:r,drawingId:o});if(c==null)return;const u=W({...c.transform,...s},this._selectionRenderService);if(u==null)return;const l={...n,transform:{...c.transform,...s,...x(u,this._selectionRenderService)},sheetTransform:{...u}};t.push(l)}),t.length>0&&this._commandService.executeCommand(me.id,{unitId:e[0].unitId,drawings:t}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{this._commandService.executeCommand(ye.id,e);const{unitId:t,subUnitId:n,drawingId:i}=e[0].parent;this._drawingManagerService.focusDrawing([{unitId:t,subUnitId:n,drawingId:i}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{this._commandService.executeCommand(Me.id,e)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{e==null||e.length===0?(this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(h.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(e))}))}};pe=Be([h.OnLifecycle(h.LifecycleStages.Rendered,pe),Y(0,h.ICommandService),Y(1,h.IUniverInstanceService),Y(2,j.Inject(C.SelectionManagerService)),Y(3,X.ISelectionRenderService),Y(4,E.IImageIoService),Y(5,m.ISheetDrawingService),Y(6,E.IDrawingManagerService),Y(7,h.IContextService),Y(8,k.IMessageService),Y(9,j.Inject(h.LocaleService)),Y(10,F.IRenderManagerService)],pe);var H=function(){return H=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},H.apply(this,arguments)},Fe=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n},Te=b.forwardRef(function(e,t){var n=e.icon,i=e.id,r=e.className,o=e.extend,a=Fe(e,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),c=b.useRef("_".concat(He()));return Re(n,"".concat(i),{defIds:n.defIds,idSuffix:c.current},H({ref:t,className:s},a),o)});function Re(e,t,n,i,r){return b.createElement(e.tag,H(H({key:t},xe(e,n,r)),i),(Ve(e,n).children||[]).map(function(o,a){return Re(o,"".concat(t,"-").concat(e.tag,"-").concat(a),n,void 0,r)}))}function xe(e,t,n){var i=H({},e.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+t.idSuffix),Object.entries(i).forEach(function(o){var a=o[0],s=o[1];typeof s=="string"&&(i[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),i}function Ve(e,t){var n,i=t.defIds;return!i||i.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?H(H({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?H(H({},r),{attrs:H(H({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function He(){return Math.random().toString(36).substring(2,8)}Te.displayName="UniverIcon";var Ye={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"}}]},De=b.forwardRef(function(e,t){return b.createElement(Te,Object.assign({},e,{id:"add-image-single",ref:t,icon:Ye}))});De.displayName="AddImageSingle";const Ae={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},Oe="COMPONENT_UPLOAD_FILE_MENU";var ge=(e=>(e[e.cellImage=0]="cellImage",e[e.floatImage=1]="floatImage",e))(ge||{});const Xe=e=>{const{type:t}=e,n=$.useDependency(h.ICommandService),i=b.useRef(null),r=()=>{var s;(s=i.current)==null||s.click()},o=E.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);t===ge.floatImage?n.executeCommand(de.id,{files:u}):t===ge.cellImage&&n.executeCommand(ue.id,{files:u}),i.current&&(i.current.value="")};return b.createElement("div",{onClick:r,className:Ae.uploadFileMenu},b.createElement("input",{type:"file",className:Ae.uploadFileMenuInput,ref:i,onChange:a,accept:o,multiple:!0}))},be="addition-and-subtraction-single",Ee="sheet.menu.image";function $e(e){return{id:Ee,type:k.MenuItemType.SUBITEMS,positions:[k.MenuPosition.TOOLBAR_START],group:k.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:be,tooltip:"sheetImage.title",hidden$:k.getMenuHiddenObservable(e,h.UniverInstanceType.UNIVER_SHEET)}}function ze(e){return{id:de.id,title:"sheetImage.upload.float",type:k.MenuItemType.SELECTOR,label:{name:Oe,props:{type:ge.floatImage}},positions:[Ee],hidden$:k.getMenuHiddenObservable(e,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"},Ke=e=>{var I;const t=$.useDependency(h.ICommandService),n=$.useDependency(h.LocaleService),i=$.useDependency(E.IDrawingManagerService),r=$.useDependency(F.IRenderManagerService),{drawings:o}=e,a=o[0];if(a==null)return;const{unitId:s}=a,c=r.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:B,subUnitId:P,drawingId:U,drawingType:M,anchorType:G,sheetTransform:z}=D;O.push({unitId:B,subUnitId:P,drawingId:U,anchorType:G,sheetTransform:z,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,i);if(N.length===0)g(!1);else if(N.length>=1){g(!0);const B=((D=N[0])==null?void 0:D.anchorType)||m.SheetDrawingAnchorType.Position;f(B)}});return()=>{w==null||w.dispose(),T==null||T.dispose()}},[]);function R(T){f(T);const w=i.getFocusDrawings();if(w.length===0)return;const O=w.map(v=>({unitId:v.unitId,subUnitId:v.subUnitId,drawingId:v.drawingId,anchorType:T}));t.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"))))))},qe=()=>{const e=$.useDependency(E.IDrawingManagerService),t=e.getFocusDrawings();if(t==null||t.length===0)return;const[n,i]=b.useState(t);return b.useEffect(()=>{const r=e.focus$.subscribe(o=>{i(o)});return()=>{r.unsubscribe()}},[]),b.createElement("div",{className:J.imageCommonPanel},b.createElement(ee.DrawingCommonPanel,{drawings:n}),b.createElement(Ke,{drawings:n}))},ie={id:"sheet.command.move-drawing",type:h.CommandType.COMMAND,handler:(e,t)=>{const n=e.get(h.ICommandService),i=e.get(m.ISheetDrawingService),r=e.get(X.ISelectionRenderService),{direction:o}=t,a=i.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 o===h.Direction.UP?g.top=S-1:o===h.Direction.DOWN?g.top=S+1:o===h.Direction.LEFT?g.left=p-1:o===h.Direction.RIGHT&&(g.left=p+1),{...l,transform:g,sheetTransform:W(g,r)}}).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:e=>{const t=e.get(h.ICommandService),i=e.get(m.ISheetDrawingService).getFocusDrawings();if(i.length===0)return!1;const r=i[0].unitId,o=i.map(a=>{const{unitId:s,subUnitId:c,drawingId:u,drawingType:l}=a;return{unitId:s,subUnitId:c,drawingId:u,drawingType:l}});return t.executeCommand(fe.id,{unitId:r,drawings:o})}};function re(e){return!e.getContextValue(h.FOCUSING_FORMULA_EDITOR)&&!e.getContextValue(h.EDITOR_ACTIVATED)&&e.getContextValue(h.FOCUSING_COMMON_DRAWINGS)}const Je={id:ie.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_DOWN,priority:100,preconditions:re,staticParameters:{direction:h.Direction.DOWN}},Ze={id:ie.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_UP,priority:100,preconditions:re,staticParameters:{direction:h.Direction.UP}},Qe={id:ie.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_LEFT,priority:100,preconditions:re,staticParameters:{direction:h.Direction.LEFT}},en={id:ie.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_RIGHT,priority:100,preconditions:re,staticParameters:{direction:h.Direction.RIGHT}},nn={id:Ue.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:re,binding:k.KeyCode.DELETE,mac:k.KeyCode.BACKSPACE};var tn=(e,t,n,i)=>{for(var r=t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(r=a(r)||r);return r},oe=(e,t)=>(n,i)=>t(n,i,e);const rn={};let ae=class extends h.Disposable{constructor(e,t,n,i,r,o){super(),this._config=e,this._injector=t,this._componentManager=n,this._menuService=i,this._commandService=r,this._shortcutService=o,this._init()}_initCustomComponents(){const e=this._componentManager;this.disposeWithMe(e.register(be,De)),this.disposeWithMe(e.register(Oe,Xe)),this.disposeWithMe(e.register(we,qe))}_initMenus(){const{menu:e={}}=this._config;[$e,ze].forEach(t=>{this._menuService.addMenuItem(t(this._injector),e)})}_initCommands(){[de,ue,Se,fe,me,_e,L,Ce,ye,Me,ie,Ue,Ie].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initShortcuts(){[Je,Ze,Qe,en,nn].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};ae=tn([h.OnLifecycle(h.LifecycleStages.Rendered,ae),oe(1,j.Inject(j.Injector)),oe(2,j.Inject(k.ComponentManager)),oe(3,k.IMenuService),oe(4,h.ICommandService),oe(5,k.IShortcutService)],ae);var on=(e,t,n,i)=>{for(var r=t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(r=a(r)||r);return r},ne=(e,t)=>(n,i)=>t(n,i,e);const an=[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],sn=[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(e,t,n,i,r,o){super(),this._commandService=e,this._sheetInterceptorService=t,this._sheetDrawingService=n,this._drawingManagerService=i,this._selectionRenderService=r,this._univerInstanceService=o,this._init()}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(!an.includes(e.id))return{redos:[],undos:[]};if(e.params==null)return{redos:[],undos:[]};const t=e.id;if(t===C.InsertRowCommand.id)return this._moveRowInterceptor(e.params,"insert");if(t===C.InsertColCommand.id)return this._moveColInterceptor(e.params,"insert");if(t===C.RemoveRowCommand.id)return this._moveRowInterceptor(e.params,"remove");if(t===C.RemoveColCommand.id)return this._moveColInterceptor(e.params,"remove");if(t===C.DeleteRangeMoveLeftCommand.id){const{range:n}=e.params;return this._getRangeMoveUndo(n,0)}else if(t===C.DeleteRangeMoveUpCommand.id){const{range:n}=e.params;return this._getRangeMoveUndo(n,1)}else if(t===C.InsertRangeMoveDownCommand.id){const{range:n}=e.params;return this._getRangeMoveUndo(n,2)}else if(t===C.InsertRangeMoveRightCommand.id){const{range:n}=e.params;return this._getRangeMoveUndo(n,3)}else if(t===C.SetRowHiddenCommand.id||t===C.SetSpecificRowsVisibleCommand.id){const n=e.params,{unitId:i,subUnitId:r,ranges:o}=n;return this._getDrawingUndoForRowVisible(i,r,o)}else if(t===C.SetSpecificColsVisibleCommand.id||t===C.SetColHiddenCommand.id){const n=e.params,{unitId:i,subUnitId:r,ranges:o}=n;return this._getDrawingUndoForColVisible(i,r,o)}else if(t===C.DeltaRowHeightCommand.id||t===C.SetRowHeightCommand.id||t===C.DeltaColumnWidthCommand.id||t===C.SetColWidthCommand.id){const n=e.params,{unitId:i,subUnitId:r,ranges:o}=n,a=t===C.DeltaRowHeightCommand.id||t===C.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(i,r,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(e,t){const n=C.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const i=n.unitId,r=n.subUnitId,o=[],a=[],s=this._sheetDrawingService.getDrawingData(i,r),c=[],u=[];if(Object.keys(s).forEach(l=>{const d=s[l],{updateDrawings:g,deleteDrawings:p}=this._getUpdateOrDeleteDrawings(e,t,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;o.push({id:m.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:g,objects:p,type:m.DrawingApplyType.UPDATE}}),a.push({id:m.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,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;o.push({id:m.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:g,objects:p,type:m.DrawingApplyType.REMOVE}}),a.push({id:m.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:d,objects:p,type:m.DrawingApplyType.INSERT}})}return o.push({id:L.id,params:[i]}),a.push({id:L.id,params:[i]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(e,t,n){const i=[],r=[],{sheetTransform:o,anchorType:a=m.SheetDrawingAnchorType.Position,transform:s,unitId:c,subUnitId:u,drawingId:l}=n,{from:d,to:g}=o,{row:p,column:S}=d,{row:f,column:_}=g;if(o==null||s==null)return{updateDrawings:i,deleteDrawings:r};const{startRow:R,endRow:y,startColumn:I,endColumn:T}=e;let w=null,O=null;if(t===0&&p>=R&&f<=y)if(S>=I&&_<=T)r.push({unitId:c,subUnitId:u,drawingId:l});else{const v=this._shrinkCol(o,s,I,T,a);w=v==null?void 0:v.newSheetTransform,O=v==null?void 0:v.newTransform}else if(t===1&&S>=I&&_<=T)if(p>=R&&f<=y)r.push({unitId:c,subUnitId:u,drawingId:l});else{const v=this._shrinkRow(o,s,R,y,a);w=v==null?void 0:v.newSheetTransform,O=v==null?void 0:v.newTransform}else if(t===2){const v=this._expandRow(o,s,R,y,a);w=v==null?void 0:v.newSheetTransform,O=v==null?void 0:v.newTransform}else if(t===3){const v=this._expandCol(o,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=x(w,this._selectionRenderService);i.push({...n,sheetTransform:w,transform:v})}return{updateDrawings:i,deleteDrawings:r}}_remainDrawingSize(e,t,n){const i=W({...e},this._selectionRenderService);i!=null&&t.push({...n,sheetTransform:i})}_getDrawingUndoForColVisible(e,t,n){const i=this._drawingManagerService.getDrawingData(e,t),r=[],o=[];if(Object.keys(i).forEach(l=>{const d=i[l],{sheetTransform:g,transform:p,anchorType:S=m.SheetDrawingAnchorType.Position}=d;if(S===m.SheetDrawingAnchorType.None)this._remainDrawingSize(p,r,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:B}=O;if(T<D)continue;if(S===m.SheetDrawingAnchorType.Position){let M=null,G=null;if(y>=D&&y<=B){const z=this._selectionRenderService.attachRangeWithCoord({startColumn:y,endColumn:B,startRow:f.row,endRow:_.row});if(z==null)return;G={...p,left:z.startX}}if(G!=null&&(M=W(G,this._selectionRenderService),M!=null&&G!=null)){r.push({...d,sheetTransform:M,transform:G});break}this._remainDrawingSize(p,r,d);continue}if(y>=D&&T<=B)continue;let P=null,U=null;if(y>=D&&y<=B){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:y,endColumn:B,startRow:f.row,endRow:_.row});if(M==null)return;U={...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<=B){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:D,endColumn:T,startRow:f.row,endRow:_.row});if(M==null)return;U={...p,left:M.startX-((p==null?void 0:p.width)||0)}}else{const M=this._selectionRenderService.attachRangeWithCoord({startColumn:D,endColumn:B,startRow:f.row,endRow:_.row});if(M==null)return;if(U={...p,width:((p==null?void 0:p.width)||0)-M.endX+M.startX},P=W(U,this._selectionRenderService),P!=null&&U!=null){o.push({...d,sheetTransform:P,transform:U});break}}if(U!=null&&(P=W(U,this._selectionRenderService)),U!=null&&P!=null){r.push({...d,sheetTransform:P,transform:U});break}else this._remainDrawingSize(p,r,d)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(e,t,r),c=[],u=[];if(o.length>0){const{redos:l,undos:d}=this._createUndoAndRedoMutation(e,t,o);c.push(...l),u.push(...d)}return{redos:a,undos:s,preRedos:c,preUndos:u}}_createUndoAndRedoMutation(e,t,n){const i=this._sheetDrawingService.getBatchUpdateOp(n),{undo:r,redo:o,objects:a}=i,s=[{id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:o,objects:a,type:m.DrawingApplyType.UPDATE}},{id:L.id,params:[e]}],c=[{id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:r,objects:a,type:m.DrawingApplyType.UPDATE}},{id:L.id,params:[e]}];return{redos:s,undos:c}}_getDrawingUndoForRowVisible(e,t,n){const i=this._drawingManagerService.getDrawingData(e,t),r=[],o=[];if(Object.keys(i).forEach(l=>{const d=i[l],{sheetTransform:g,transform:p,anchorType:S=m.SheetDrawingAnchorType.Position}=d;if(S===m.SheetDrawingAnchorType.None)this._remainDrawingSize(p,r,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:B}=O;if(I<v)continue;if(S===m.SheetDrawingAnchorType.Position){let M=null,G=null;if(R>=v&&R<=N){const z=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:R,endRow:N});if(z==null)return;G={...p,top:z.startY}}if(G!=null&&(M=W(G,this._selectionRenderService),M!=null&&G!=null)){r.push({...d,sheetTransform:M,transform:G});break}this._remainDrawingSize(p,r,d);continue}if(R>=v&&I<=N)continue;let P=null,U=null;if(R>=v&&R<=N){const M=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:R,endRow:N});if(M==null)return;U={...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;U={...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(U={...p,height:((p==null?void 0:p.height)||0)-M.endY+M.startY},P=W(U,this._selectionRenderService),P!=null&&U!=null){o.push({...d,sheetTransform:P,transform:U});break}}if(U!=null&&(P=W(U,this._selectionRenderService)),U!=null&&P!=null){r.push({...d,sheetTransform:P,transform:U});break}else this._remainDrawingSize(p,r,d)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(e,t,r),c=[],u=[];if(o.length>0){const{redos:l,undos:d}=this._createUndoAndRedoMutation(e,t,o);c.push(...l),u.push(...d)}return{redos:a,undos:s,preRedos:c,preUndos:u}}_getDrawingUndoForRowAndColSize(e,t,n,i){const r=this._drawingManagerService.getDrawingData(e,t),o=[];return Object.keys(r).forEach(a=>{const s=r[a],{sheetTransform:c,transform:u,anchorType:l=m.SheetDrawingAnchorType.Position}=s;if(l===m.SheetDrawingAnchorType.None)this._remainDrawingSize(u,o,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,o,s);continue}const v=x({...c},this._selectionRenderService);if(v!=null){o.push({...s,transform:v});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(e,t,o)}_getUnitIdAndSubUnitId(e,t){let n,i;if(t==="insert")n=e.unitId,i=e.subUnitId;else{const r=C.getSheetCommandTarget(this._univerInstanceService);if(r==null)return;n=r.unitId,i=r.subUnitId}return{unitId:n,subUnitId:i}}_moveRowInterceptor(e,t){const n=this._getUnitIdAndSubUnitId(e,t);if(n==null)return{redos:[],undos:[]};const{unitId:i,subUnitId:r}=n,{range:o}=e,a=o.startRow,s=o.endRow,c=[],u=[],l=this._sheetDrawingService.getDrawingData(i,r),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(t==="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:i,subUnitId:r,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:i,subUnitId:r,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:i,subUnitId:r,op:f,objects:_,type:m.DrawingApplyType.UPDATE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,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:i,subUnitId:r,op:f,objects:_,type:m.DrawingApplyType.REMOVE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:S,objects:_,type:m.DrawingApplyType.INSERT}})}return c.push({id:L.id,params:[i]}),u.push({id:L.id,params:[i]}),{redos:c,undos:u}}_moveColInterceptor(e,t){const n=this._getUnitIdAndSubUnitId(e,t);if(n==null)return{redos:[],undos:[]};const{unitId:i,subUnitId:r}=n,{range:o}=e,a=o.startColumn,s=o.endColumn,c=[],u=[],l=this._sheetDrawingService.getDrawingData(i,r),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(t==="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:i,subUnitId:r,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:i,subUnitId:r,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:i,subUnitId:r,op:f,objects:_,type:m.DrawingApplyType.UPDATE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,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:i,subUnitId:r,op:f,objects:_,type:m.DrawingApplyType.REMOVE}}),u.push({id:m.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:S,objects:_,type:m.DrawingApplyType.INSERT}})}return c.push({id:L.id,params:[i]}),u.push({id:L.id,params:[i]}),{redos:c,undos:u}}_expandCol(e,t,n,i,r=m.SheetDrawingAnchorType.Position){const o=i-n+1,{from:a,to:s}=e,{column:c}=a,{column:u}=s;if(r===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};let l=null,d=null;if(c>=n){const g=this._selectionRenderService.attachRangeWithCoord({startColumn:n,endColumn:i,startRow:a.row,endRow:s.row});if(g==null)return;d={...t,left:(t.left||0)+g.endX-g.startX},l=W(d,this._selectionRenderService)}else if(u>=i)if(r===m.SheetDrawingAnchorType.Both)l={from:{...a},to:{...s,column:u+o}},d=x(l,this._selectionRenderService);else return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_shrinkCol(e,t,n,i,r=m.SheetDrawingAnchorType.Position){const o=i-n+1,{from:a,to:s}=e,{column:c}=a,{column:u}=s;if(r===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};let l=null,d=null;if(c>i)l={from:{...a,column:c-o},to:{...s,column:u-o}},d=x(l,this._selectionRenderService);else{if(c>=n&&u<=i)return null;if(c<n&&u>i)if(r===m.SheetDrawingAnchorType.Both)l={from:{...a},to:{...s,column:u-o}},d=x(l,this._selectionRenderService);else return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};else if(c>=n&&c<=i){if(c===n)d={...t,left:(t.left||0)-e.from.columnOffset};else{const g=this._selectionRenderService.attachRangeWithCoord({startColumn:n,endColumn:c-1,startRow:a.row,endRow:s.row});if(g==null)return;d={...t,left:(t.left||0)-g.endX+g.startX-e.from.columnOffset}}l=W(d,this._selectionRenderService)}else if(u>=n&&u<=i&&r===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=x(l,this._selectionRenderService)}}return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_expandRow(e,t,n,i,r=m.SheetDrawingAnchorType.Position){const o=i-n+1,{from:a,to:s}=e,{row:c}=a,{row:u}=s;if(r===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};let l=null,d=null;if(c>=n){const g=this._selectionRenderService.attachRangeWithCoord({startRow:n,endRow:i,startColumn:a.column,endColumn:s.column});if(g==null)return;d={...t,top:(t.top||0)+g.endY-g.startY},l=W(d,this._selectionRenderService)}else if(u>=i)if(r===m.SheetDrawingAnchorType.Both)l={from:{...a},to:{...s,row:u+o}},d=x(l,this._selectionRenderService);else return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_shrinkRow(e,t,n,i,r=m.SheetDrawingAnchorType.Position){const o=i-n+1,{from:a,to:s}=e,{row:c}=a,{row:u}=s;if(r===m.SheetDrawingAnchorType.None)return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};let l=null,d=null;if(c>i)l={from:{...a,row:c-o},to:{...s,row:u-o}},d=x(l,this._selectionRenderService);else{if(c>=n&&u<=i)return null;if(c<n&&u>i)if(r===m.SheetDrawingAnchorType.Both)l={from:{...a},to:{...s,row:u-o}},d=x(l,this._selectionRenderService);else return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};else if(c>=n&&c<=i){if(c===n)d={...t,top:(t.top||0)-e.from.rowOffset};else{const g=this._selectionRenderService.attachRangeWithCoord({startRow:n,endRow:c-1,startColumn:a.column,endColumn:s.column});if(g==null)return;d={...t,top:(t.top||0)-g.endY+g.startY-e.from.rowOffset}}l=W(d,this._selectionRenderService)}else if(u>=n&&u<=i&&r===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=x(l,this._selectionRenderService)}}return l!=null&&d!=null?{newSheetTransform:l,newTransform:d}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===C.SetWorksheetActiveOperation.id){const t=e.params,{unitId:n,subUnitId:i}=t,r=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(r).forEach(s=>{const c=r[s];Object.keys(c).forEach(u=>{const l=c[u].data;l!=null&&Object.keys(l).forEach(d=>{s===n&&u===i?o.push(l[d]):a.push(l[d])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)}}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{sn.includes(e.id)&&requestIdleCallback(()=>{const t=e.params,{unitId:n,subUnitId:i,ranges:r}=t;this._refreshDrawingTransform(n,i,r)})}))}_refreshDrawingTransform(e,t,n){const i=this._drawingManagerService.getDrawingData(e,t),r=[];Object.keys(i).forEach(o=>{const a=i[o],{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){r.push({...a,transform:x(s,this._selectionRenderService)});break}}}),r.length!==0&&(this._drawingManagerService.refreshTransform(r),this._commandService.syncExecuteCommand(L.id,[e]))}};he=on([h.OnLifecycle(h.LifecycleStages.Rendered,he),ne(0,h.ICommandService),ne(1,j.Inject(C.SheetInterceptorService)),ne(2,m.ISheetDrawingService),ne(3,E.IDrawingManagerService),ne(4,X.ISelectionRenderService),ne(5,h.IUniverInstanceService)],he);var cn=(e,t,n,i)=>{for(var r=t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(r=a(r)||r);return r},Z=(e,t)=>(n,i)=>t(n,i,e);function ln(e,t,n,i){const{scaleX:r,scaleY:o}=t.getAncestorScale(),a=t.getViewport(X.VIEWPORT_KEY.VIEW_MAIN),s={left:!0,top:!0};if(!a)return{...e,absolute:s};const{left:c,right:u,top:l,bottom:d}=e,g=i.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:B}=a;let P,U;c<N?(s.left=!0,P=(w+I+(c-N))*r,U=Math.max(Math.min((w+I+(u-N))*r,(w+I)*r),(u-D)*r)):(s.left=!1,P=Math.max((c-D)*r,(w+I)*r),U=Math.max((u-D)*r,(w+I)*r));let M,G;return l<v?(s.top=!0,M=(O+T+(l-v))*o,G=Math.max(Math.min((O+T+(u-v))*o,(O+T)*o),(d-B)*o)):(s.top=!1,M=Math.max((l-B)*o,(O+T)*o),G=Math.max((d-B)*o,(O+T)*o)),{left:P,right:U,top:M,bottom:G,absolute:s}}const ve=(e,t,n,i)=>{const{scene:r}=t,{left:o,top:a,width:s,height:c,angle:u}=e,l={left:o,right:o+s,top:a,bottom:a+c},d=ln(l,r,n,i);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,i,r,o,a,s,c,u){super();K(this,"_domLayerMap",new Map);K(this,"_domLayerInfoMap",new Map);K(this,"_transformChange$",new te.Subject);K(this,"transformChange$",this._transformChange$.asObservable());K(this,"_remove$",new te.Subject);K(this,"remove$",this._remove$.asObservable());this._renderManagerService=n,this._univerInstanceService=i,this._sheetSkeletonManagerService=r,this._commandService=o,this._drawingManagerService=a,this._selectionRenderService=s,this._canvasFloatDomService=c,this._sheetDrawingService=u,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(n,i){let r=this._domLayerMap.get(n);r||(r=new Map,this._domLayerMap.set(n,r));let o=r.get(i);return o||(o=new Map,r.set(i,o)),o}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const i=this._renderManagerService.getRenderById(n),r=i==null?void 0:i.scene;if(i==null||r==null)return null;const o=r.getTransformerByCreate(),a=i.engine.getCanvasElement();return{scene:r,transformer:o,renderObject:i,canvas:a}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(i=>{const{unitId:r,subUnitId:o,drawingId:a}=i,s=C.getSheetCommandTarget(this._univerInstanceService,{unitId:r,subUnitId:o}),c=this._drawingManagerService.getDrawingByParam(i),u=this._sheetSkeletonManagerService.getUnitSkeleton(r,o);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(r);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=E.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:o,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 B={left:f,top:_,width:R,height:y,zIndex:this._drawingManagerService.getDrawingOrder(r,o).length-1},P=new F.Rect(N,B);p.addObject(P,F.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(P);const U=new h.DisposableCollection,M=ve(P,g.renderObject,u.skeleton,s.worksheet),G=new te.BehaviorSubject(M),z={dispose:U,rect:P,position$:G,unitId:r,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:G,id:a,componentKey:c.componentKey,onPointerDown:V=>{S.dispatchEvent(new PointerEvent(V.type,V))},onPointerMove:V=>{S.dispatchEvent(new PointerEvent(V.type,V))},onPointerUp:V=>{S.dispatchEvent(new PointerEvent(V.type,V))},onWheel:V=>{S.dispatchEvent(new WheelEvent(V.type,V))}});const je=P.onTransformChangeObservable.add(()=>{const V=ve(P,g.renderObject,u.skeleton,s.worksheet);G.next(V)});U.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),je&&U.add(je),this._domLayerInfoMap.set(a,z)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var r,o;const i=(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=ve(S.rect,c.renderObject,g.skeleton,d.worksheet);S.position$.next(f)}})};if(n.id===X.SetScrollOperation.id){const a=n.params,{unitId:s,sheetId:c}=a;i(s,c)}else if(n.id===X.SetZoomRatioOperation.id){const a=n.params,{unitId:s}=a;Array.from((o=(r=this._domLayerMap.get(s))==null?void 0:r.keys())!=null?o:[]).forEach(u=>{i(s,u)})}else if(n.id===C.SetFrozenMutation.id){const{unitId:a,subUnitId:s}=n.params;i(a,s)}}))}_getPosition(n){const{startX:i,endX:r,startY:o,endY:a}=n,s=this._selectionRenderService.getSelectionCellByPosition(i,o);if(s==null)return;const c={column:s.actualColumn,columnOffset:i-s.startX,row:s.actualRow,rowOffset:o-s.startY},u=this._selectionRenderService.getSelectionCellByPosition(r,a);if(u==null)return;const l={column:u.actualColumn,columnOffset:r-u.startX,row:u.actualRow,rowOffset:a-u.startY};return{from:c,to:l}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(i=>{const r=this._drawingManagerService.getDrawingByParam(i);if(!r||r.drawingType!==h.DrawingTypeEnum.DRAWING_DOM)return;const o={...r.transform};this._transformChange$.next({id:i.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(i=>{this._removeDom(i.drawingId)})}))}addFloatDomToPosition(n){const i=C.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!i)throw new Error("cannot find current target!");const{unitId:r,subUnitId:o}=i,{initPosition:a,componentKey:s}=n,c=h.Tools.generateRandomId(),u=this._getPosition(a);if(u==null)return;const l={unitId:r,subUnitId:o,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(Se.id,{unitId:r,drawings:[l]}),this._ensureMap(r,o).set(c,n),{id:c,dispose:()=>{this._removeDom(c,!0)}}}_removeDom(n,i=!1){const r=this._domLayerInfoMap.get(n);if(!r)return;const{unitId:o,subUnitId:a}=r,s=this._ensureMap(o,a);this._domLayerInfoMap.delete(n),s.delete(n),r.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(r.rect),i){const u=this._drawingManagerService.getDrawingByParam({unitId:o,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:o,subUnitId:a,op:d,objects:g,type:m.DrawingApplyType.REMOVE})}}},A.SheetCanvasFloatDomManagerService=cn([Z(0,j.Inject(F.IRenderManagerService)),Z(1,h.IUniverInstanceService),Z(2,j.Inject(X.SheetSkeletonManagerService)),Z(3,j.Inject(h.ICommandService)),Z(4,E.IDrawingManagerService),Z(5,X.ISelectionRenderService),Z(6,j.Inject(k.CanvasFloatDomService)),Z(7,m.ISheetDrawingService)],A.SheetCanvasFloatDomManagerService);var dn=Object.defineProperty,un=(e,t,n)=>t in e?dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mn=(e,t,n,i)=>{for(var r=t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(r=a(r)||r);return r},Pe=(e,t)=>(n,i)=>t(n,i,e),Ne=(e,t,n)=>(un(e,typeof t!="symbol"?t+"":t,n),n);const pn="SHEET_IMAGE_UI_PLUGIN";A.UniverSheetsDrawingUIPlugin=class extends h.Plugin{constructor(n={},i,r){super();K(this,"_pluginConfig");this._injector=i,this._localeService=r,this._pluginConfig=h.Tools.deepMerge({},rn,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(r=>n.add(r))}},Ne(A.UniverSheetsDrawingUIPlugin,"type",h.UniverInstanceType.UNIVER_SHEET),Ne(A.UniverSheetsDrawingUIPlugin,"pluginName",pn),A.UniverSheetsDrawingUIPlugin=mn([h.DependentOn(E.UniverDrawingPlugin,ee.UniverDrawingUIPlugin,m.UniverSheetsDrawingPlugin),Pe(1,j.Inject(j.Injector)),Pe(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-nightly.202406041140",
|
|
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/core": "0.1.13-nightly.202406041140",
|
|
60
|
+
"@univerjs/design": "0.1.13-nightly.202406041140",
|
|
61
|
+
"@univerjs/drawing-ui": "0.1.13-nightly.202406041140",
|
|
62
|
+
"@univerjs/drawing": "0.1.13-nightly.202406041140",
|
|
63
|
+
"@univerjs/engine-render": "0.1.13-nightly.202406041140",
|
|
64
|
+
"@univerjs/sheets": "0.1.13-nightly.202406041140",
|
|
65
|
+
"@univerjs/sheets-drawing": "0.1.13-nightly.202406041140",
|
|
66
|
+
"@univerjs/sheets-ui": "0.1.13-nightly.202406041140",
|
|
67
|
+
"@univerjs/ui": "0.1.13-nightly.202406041140"
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@univerjs/icons": "^0.1.56"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@wendellhu/redi": "0.15.2",
|
|
74
|
+
"clsx": "^2.1.1",
|
|
75
|
+
"less": "^4.2.0",
|
|
76
|
+
"react": "18.3.1",
|
|
77
|
+
"rxjs": "^7.8.1",
|
|
78
|
+
"typescript": "^5.4.5",
|
|
79
|
+
"vite": "^5.2.12",
|
|
80
|
+
"vitest": "^1.6.0",
|
|
81
|
+
"@univerjs/design": "0.1.13-nightly.202406041140",
|
|
82
|
+
"@univerjs/drawing": "0.1.13-nightly.202406041140",
|
|
83
|
+
"@univerjs/drawing-ui": "0.1.13-nightly.202406041140",
|
|
84
|
+
"@univerjs/engine-render": "0.1.13-nightly.202406041140",
|
|
85
|
+
"@univerjs/sheets-drawing": "0.1.13-nightly.202406041140",
|
|
86
|
+
"@univerjs/sheets": "0.1.13-nightly.202406041140",
|
|
87
|
+
"@univerjs/sheets-ui": "0.1.13-nightly.202406041140",
|
|
88
|
+
"@univerjs/ui": "0.1.13-nightly.202406041140",
|
|
89
|
+
"@univerjs/core": "0.1.13-nightly.202406041140",
|
|
90
|
+
"@univerjs/shared": "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
|
+
}
|