@univerjs/sheets-thread-comment-ui 0.5.1-nightly.202412251606 → 0.5.1-nightly.202412271606

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Ce=Object.defineProperty;var Se=(o,t,n)=>t in o?Ce(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var D=(o,t,n)=>Se(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),T=require("@univerjs/thread-comment-ui"),I=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),k=require("rxjs"),ae=require("@univerjs/engine-render"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),R=require("react"),ce="univer.sheet.thread-comment-modal",te="comment-single",ne="SHEET_THREAD_COMMENT";var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,Ie=(o,t,n,e)=>{for(var r=e>1?void 0:e?fe(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&_e(t,n,r),r},oe=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new k.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var d;const{row:r,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((d=this.activePopup)==null?void 0:d.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:ce,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const u=new a.DisposableCollection;u.add(m),u.add({dispose:()=>{e==null||e()}}),this._lastPopup=u}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=Ie([oe(0,a.Inject(I.SheetCanvasPopManagerService)),oe(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(C.SheetsSelectionsService),n=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(T.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(n);if(!c)return!1;const{workbook:m,worksheet:u,unitId:d,subUnitId:h}=c,l={workbook:m,worksheet:u,unitId:d,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(l);const p=s.getByLocation(d,h,i.startRow,i.startColumn);return p&&r.setActiveComment({unitId:d,subUnitId:h,commentId:p,trigger:"context-menu"}),!0}},ge="sheets-thread-comment.config",Pe={};var Te=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=(o,t,n,e)=>{for(var r=e>1?void 0:e?be(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Te(t,n,r),r},H=(o,t)=>(n,e)=>t(n,e,o);let F=class extends a.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{o()}))}};F=ye([H(0,a.Inject(C.SheetInterceptorService)),H(1,a.Inject($.SheetsThreadCommentModel)),H(2,a.IUniverInstanceService),H(3,ae.IRenderManagerService)],F);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Me(t,n,r),r},K=(o,t)=>(n,e)=>t(n,e,o);const Re=(o,t,n)=>{const e=x.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return x.serializeRange(s)};let q=class extends a.Disposable{constructor(t,n,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ne,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:c}=n,m={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:u,unitId:d,subUnitId:h}=this._copyInfo,l={row:u.startRow,column:u.startColumn};if(!(i===d&&s===h)){const p=[];a.Range.foreach(u,(y,v)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(d,h,y,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(g=>{p.push(g)}):M.forEach(({children:g,...O})=>{O.parentId||p.push(O)})});const f=[],b=[],N=[],V=[],J=y=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:d,subUnitId:h,commentId:y.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:Re(y.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:d,subUnitId:h,comment:y,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return p.forEach(y=>{J(y)}),{redos:[...f,...N],undos:[...V,...b]}}}return{redos:[],undos:[]}}}))}};q=Ue([K(0,a.Inject(I.ISheetClipboardService)),K(1,a.Inject($.SheetsThreadCommentModel)),K(2,_.IThreadCommentDataSourceService)],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let G=class extends a.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const u=this._sheetsThreadCommentModel.getComment(e,r,c);u&&!u.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=je([L(0,a.Inject(I.HoverManagerService)),L(1,a.Inject(exports.SheetsThreadCommentPopupService)),L(2,a.Inject($.SheetsThreadCommentModel)),L(3,a.Inject(I.SheetPermissionInterceptorBaseController))],G);var De=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ne(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends a.Disposable{constructor(t,n,e,r,i,s,c,m,u,d){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=u,this._renderManagerService=d,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,p,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(p=i==null?void 0:i.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:p.skeleton;if(!s||!r)return;const c=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const u=c.actualRow,d=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,u,d)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(n,e,u,d);h&&this._commandService.executeCommand(T.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,r,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const h=x.singleReferenceToGrid(c.ref),{row:l,column:p}=h;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:p,endRow:l,endColumn:p}]))return;const b=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-b,0),endRow:h.row+b,startColumn:Math.max(h.column-b,0),endColumn:h.column+b}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:h.row,col:h.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var l,p;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const u=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),d=(p=u==null?void 0:u.getMergedCell(c,m))!=null?p:{startColumn:m,endColumn:m,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:d,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Z=$e([E(0,a.ICommandService),E(1,a.Inject(exports.SheetsThreadCommentPopupService)),E(2,a.Inject($.SheetsThreadCommentModel)),E(3,a.Inject(T.ThreadCommentPanelService)),E(4,a.IUniverInstanceService),E(5,a.Inject(I.SheetPermissionInterceptorBaseController)),E(6,I.IMarkSelectionService),E(7,a.Inject(C.SheetsSelectionsService)),E(8,I.IEditorBridgeService),E(9,ae.IRenderManagerService)],Z);var xe=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&xe(t,n,r),r},W=(o,t)=>(n,e)=>t(n,e,o);let z=class extends a.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===C.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),c=Array.from(s.values()).filter(l=>!l.parentId),m=c.map(l=>l.id),u=this._threadCommentDataSourceService.syncUpdateMutationToColla,d=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),h=c.map(({children:l,...p})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...p,children:u?l:void 0},sync:!u}}));return{redos:d,undos:h}}return{redos:[],undos:[]}}}))}};z=Ve([W(0,a.Inject(C.SheetInterceptorService)),W(1,a.IUniverInstanceService),W(2,a.Inject(_.ThreadCommentModel)),W(3,_.IThreadCommentDataSourceService)],z);var w=function(){return w=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},w.apply(this,arguments)},Be=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},me=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=Be(o,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Le()));return de(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},w({ref:t,className:c},s),i)});function de(o,t,n,e,r){return R.createElement(o.tag,w(w({key:t},ke(o,n,r)),e),(He(o,n).children||[]).map(function(i,s){return de(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function ke(o,t,n){var e=w({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function He(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?w(w({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?w(w({},r),{attrs:w(w({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Le(){return Math.random().toString(36).substring(2,8)}me.displayName="UniverIcon";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ue=R.forwardRef(function(o,t){return R.createElement(me,Object.assign({},o,{id:"comment-single",ref:t,icon:We}))});ue.displayName="CommentSingle";var Q={exports:{}},B={};/**
1
+ "use strict";var Se=Object.defineProperty;var _e=(o,t,n)=>t in o?Se(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var D=(o,t,n)=>_e(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),T=require("@univerjs/thread-comment-ui"),I=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),k=require("rxjs"),ce=require("@univerjs/engine-render"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),R=require("react"),me="univer.sheet.thread-comment-modal",te="comment-single",ne="SHEET_THREAD_COMMENT";var fe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ge=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ie(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&fe(t,n,r),r},oe=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new k.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var d;const{row:r,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((d=this.activePopup)==null?void 0:d.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:me,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const u=new a.DisposableCollection;u.add(m),u.add({dispose:()=>{e==null||e()}}),this._lastPopup=u}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=ge([oe(0,a.Inject(I.SheetCanvasPopManagerService)),oe(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(C.SheetsSelectionsService),n=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(T.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(n);if(!c)return!1;const{workbook:m,worksheet:u,unitId:d,subUnitId:h}=c,l={workbook:m,worksheet:u,unitId:d,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(l);const p=s.getByLocation(d,h,i.startRow,i.startColumn);return p&&r.setActiveComment({unitId:d,subUnitId:h,commentId:p,trigger:"context-menu"}),!0}},Pe="sheets-thread-comment.config",ie={};var Te=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=(o,t,n,e)=>{for(var r=e>1?void 0:e?be(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Te(t,n,r),r},H=(o,t)=>(n,e)=>t(n,e,o);let F=class extends a.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{o()}))}};F=ye([H(0,a.Inject(C.SheetInterceptorService)),H(1,a.Inject($.SheetsThreadCommentModel)),H(2,a.IUniverInstanceService),H(3,ce.IRenderManagerService)],F);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Me(t,n,r),r},K=(o,t)=>(n,e)=>t(n,e,o);const Re=(o,t,n)=>{const e=x.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return x.serializeRange(s)};let q=class extends a.Disposable{constructor(t,n,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ne,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:c}=n,m={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:u,unitId:d,subUnitId:h}=this._copyInfo,l={row:u.startRow,column:u.startColumn};if(!(i===d&&s===h)){const p=[];a.Range.foreach(u,(y,v)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(d,h,y,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(g=>{p.push(g)}):M.forEach(({children:g,...O})=>{O.parentId||p.push(O)})});const f=[],b=[],N=[],V=[],J=y=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:d,subUnitId:h,commentId:y.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:Re(y.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:d,subUnitId:h,comment:y,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return p.forEach(y=>{J(y)}),{redos:[...f,...N],undos:[...V,...b]}}}return{redos:[],undos:[]}}}))}};q=Ue([K(0,a.Inject(I.ISheetClipboardService)),K(1,a.Inject($.SheetsThreadCommentModel)),K(2,_.IThreadCommentDataSourceService)],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let G=class extends a.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const u=this._sheetsThreadCommentModel.getComment(e,r,c);u&&!u.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=je([L(0,a.Inject(I.HoverManagerService)),L(1,a.Inject(exports.SheetsThreadCommentPopupService)),L(2,a.Inject($.SheetsThreadCommentModel)),L(3,a.Inject(I.SheetPermissionInterceptorBaseController))],G);var De=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,$e=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ne(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends a.Disposable{constructor(t,n,e,r,i,s,c,m,u,d){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=u,this._renderManagerService=d,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,p,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(p=i==null?void 0:i.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:p.skeleton;if(!s||!r)return;const c=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const u=c.actualRow,d=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,u,d)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(n,e,u,d);h&&this._commandService.executeCommand(T.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,r,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const h=x.singleReferenceToGrid(c.ref),{row:l,column:p}=h;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:p,endRow:l,endColumn:p}]))return;const b=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-b,0),endRow:h.row+b,startColumn:Math.max(h.column-b,0),endColumn:h.column+b}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:h.row,col:h.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var l,p;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const u=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),d=(p=u==null?void 0:u.getMergedCell(c,m))!=null?p:{startColumn:m,endColumn:m,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:d,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Z=$e([E(0,a.ICommandService),E(1,a.Inject(exports.SheetsThreadCommentPopupService)),E(2,a.Inject($.SheetsThreadCommentModel)),E(3,a.Inject(T.ThreadCommentPanelService)),E(4,a.IUniverInstanceService),E(5,a.Inject(I.SheetPermissionInterceptorBaseController)),E(6,I.IMarkSelectionService),E(7,a.Inject(C.SheetsSelectionsService)),E(8,I.IEditorBridgeService),E(9,ce.IRenderManagerService)],Z);var xe=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&xe(t,n,r),r},W=(o,t)=>(n,e)=>t(n,e,o);let z=class extends a.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===C.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),c=Array.from(s.values()).filter(l=>!l.parentId),m=c.map(l=>l.id),u=this._threadCommentDataSourceService.syncUpdateMutationToColla,d=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),h=c.map(({children:l,...p})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...p,children:u?l:void 0},sync:!u}}));return{redos:d,undos:h}}return{redos:[],undos:[]}}}))}};z=Ve([W(0,a.Inject(C.SheetInterceptorService)),W(1,a.IUniverInstanceService),W(2,a.Inject(_.ThreadCommentModel)),W(3,_.IThreadCommentDataSourceService)],z);var w=function(){return w=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},w.apply(this,arguments)},Be=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},de=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=Be(o,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Le()));return ue(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},w({ref:t,className:c},s),i)});function ue(o,t,n,e,r){return R.createElement(o.tag,w(w({key:t},ke(o,n,r)),e),(He(o,n).children||[]).map(function(i,s){return ue(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function ke(o,t,n){var e=w({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function He(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?w(w({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?w(w({},r),{attrs:w(w({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Le(){return Math.random().toString(36).substring(2,8)}de.displayName="UniverIcon";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},he=R.forwardRef(function(o,t){return R.createElement(de,Object.assign({},o,{id:"comment-single",ref:t,icon:We}))});he.displayName="CommentSingle";var Q={exports:{}},B={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ie;function Fe(){if(ie)return B;ie=1;var o=R,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(c,m,u){var d,h={},l=null,p=null;u!==void 0&&(l=""+u),m.key!==void 0&&(l=""+m.key),m.ref!==void 0&&(p=m.ref);for(d in m)e.call(m,d)&&!i.hasOwnProperty(d)&&(h[d]=m[d]);if(c&&c.defaultProps)for(d in m=c.defaultProps,m)h[d]===void 0&&(h[d]=m[d]);return{$$typeof:t,type:c,key:l,ref:p,props:h,_owner:r.current}}return B.Fragment=n,B.jsx=s,B.jsxs=s,B}var se;function qe(){return se||(se=1,Q.exports=Fe()),Q.exports}var he=qe();const Ge=()=>{const o=a.useDependency(a.IUniverInstanceService),t=a.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(t.activePopup$),e=a.useDependency($.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:c,trigger:m}=n,u=e.getByLocation(s,c,r,i),d=`${a.Tools.chatAtABC(i)}${r+1}`,h=()=>{t.hidePopup()},l=p=>{var f,b,N;return(N=(b=(f=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(p))==null?void 0:b.getName())!=null?N:""};return he.jsx(T.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:u,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:d,onClose:h,getSubUnitName:l,autoFocus:m==="context-menu"})},Ze=()=>{var y;const o=a.useDependency(I.IMarkSelectionService),t=a.useDependency(a.IUniverInstanceService),n=a.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),i=a.useDependency(a.ICommandService),s=R.useMemo(()=>e.activeSheet$.pipe(k.map(v=>v==null?void 0:v.getSheetId())),[e.activeSheet$]),c=S.useObservable(s,(y=e.getActiveSheet())==null?void 0:y.getSheetId()),m=R.useRef(),u=a.useDependency(T.ThreadCommentPanelService),d=S.useObservable(u.activeCommentId$),h=S.useObservable(u.panelVisible$,u.panelVisible),l=R.useCallback(v=>{const M=e.getSheets(),g={};M.forEach((U,P)=>{g[U.getSheetId()]=P});const O=U=>U.map(P=>{var re;const j=x.singleReferenceToGrid(P.ref),ve=[(re=g[P.subUnitId])!=null?re:0,j.row,j.column];return{...P,p:ve}}).sort((P,j)=>P.p[0]===j.p[0]?P.p[1]===j.p[1]?P.p[2]-j.p[2]:P.p[1]-j.p[1]:P.p[0]-j.p[0]);return[...O(v.filter(U=>!U.resolved)),...O(v.filter(U=>U.resolved))]},[e]),p=R.useCallback(v=>{var M;if(v.unitId===r&&v.subUnitId===c&&!v.resolved){const{row:g,column:O}=x.singleReferenceToGrid(v.ref),U=e.getSheetBySheetId(v.subUnitId),P=(M=U==null?void 0:U.getMergedCell(g,O))!=null?M:{startColumn:O,endColumn:O,startRow:g,endRow:g};if(!Number.isNaN(g)&&!Number.isNaN(O))return o.addShape({range:P,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,c,r]),f=v=>{var M,g;return(g=(M=e.getSheetBySheetId(v))==null?void 0:M.getName())!=null?g:""},b=()=>{i.executeCommand(A.id)},N=v=>{d&&d.unitId===v.unitId&&d.subUnitId===v.subUnitId&&d.commentId===v.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=p(v))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},J=(v,M)=>{M&&n.hidePopup()};return R.useEffect(()=>{!h&&m.current&&o.removeShape(m.current)},[o,h]),he.jsx(T.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:f,onResolve:J,sortComments:l,onItemEnter:N,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},ze=o=>({id:A.id,type:S.MenuItemType.BUTTON,icon:te,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:I.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ye=o=>({id:T.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:te,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:I.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),Je={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:I.whenSheetEditorFocused},Ke={[S.RibbonStartGroup.OTHERS]:{[T.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Ye}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:ze}}}};var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(o,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Qe(t,n,r),r},X=(o,t)=>(n,e)=>t(n,e,o);let Y=class extends a.Disposable{constructor(o,t,n){super(),this._menuManagerService=o,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Je)}_initMenu(){this._menuManagerService.mergeMenu(Ke)}_initComponent(){[[ce,Ge],[T.THREAD_COMMENT_PANEL,Ze],[te,ue]].forEach(([o,t])=>{this._componentManager.register(o,t)})}};Y=et([X(0,S.IMenuManagerService),X(1,a.Inject(S.ComponentManager)),X(2,S.IShortcutService)],Y);var le=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(o,t,n)=>t in o?le(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,rt=(o,t,n,e)=>{for(var r=e>1?void 0:e?tt(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&le(t,n,r),r},ee=(o,t)=>(n,e)=>t(n,e,o),pe=(o,t,n)=>nt(o,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=Pe,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:i,...s}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ge,s)}onStarting(){[[Y],[F],[q],[G],[z],[Z],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[A].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(Y)}onReady(){this._injector.get(F),this._injector.get(z)}onRendered(){this._injector.get(q),this._injector.get(G),this._injector.get(Z)}};pe(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ne);pe(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=rt([a.DependentOn(T.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),ee(1,a.Inject(a.Injector)),ee(2,a.Inject(a.ICommandService)),ee(3,a.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>T.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=ne;exports.ShowAddSheetCommentModalOperation=A;
9
+ */var se;function Fe(){if(se)return B;se=1;var o=R,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(c,m,u){var d,h={},l=null,p=null;u!==void 0&&(l=""+u),m.key!==void 0&&(l=""+m.key),m.ref!==void 0&&(p=m.ref);for(d in m)e.call(m,d)&&!i.hasOwnProperty(d)&&(h[d]=m[d]);if(c&&c.defaultProps)for(d in m=c.defaultProps,m)h[d]===void 0&&(h[d]=m[d]);return{$$typeof:t,type:c,key:l,ref:p,props:h,_owner:r.current}}return B.Fragment=n,B.jsx=s,B.jsxs=s,B}var ae;function qe(){return ae||(ae=1,Q.exports=Fe()),Q.exports}var le=qe();const Ge=()=>{const o=a.useDependency(a.IUniverInstanceService),t=a.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(t.activePopup$),e=a.useDependency($.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:c,trigger:m}=n,u=e.getByLocation(s,c,r,i),d=`${a.Tools.chatAtABC(i)}${r+1}`,h=()=>{t.hidePopup()},l=p=>{var f,b,N;return(N=(b=(f=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(p))==null?void 0:b.getName())!=null?N:""};return le.jsx(T.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:u,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:d,onClose:h,getSubUnitName:l,autoFocus:m==="context-menu"})},Ze=()=>{var y;const o=a.useDependency(I.IMarkSelectionService),t=a.useDependency(a.IUniverInstanceService),n=a.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),i=a.useDependency(a.ICommandService),s=R.useMemo(()=>e.activeSheet$.pipe(k.map(v=>v==null?void 0:v.getSheetId())),[e.activeSheet$]),c=S.useObservable(s,(y=e.getActiveSheet())==null?void 0:y.getSheetId()),m=R.useRef(),u=a.useDependency(T.ThreadCommentPanelService),d=S.useObservable(u.activeCommentId$),h=S.useObservable(u.panelVisible$,u.panelVisible),l=R.useCallback(v=>{const M=e.getSheets(),g={};M.forEach((U,P)=>{g[U.getSheetId()]=P});const O=U=>U.map(P=>{var re;const j=x.singleReferenceToGrid(P.ref),Ce=[(re=g[P.subUnitId])!=null?re:0,j.row,j.column];return{...P,p:Ce}}).sort((P,j)=>P.p[0]===j.p[0]?P.p[1]===j.p[1]?P.p[2]-j.p[2]:P.p[1]-j.p[1]:P.p[0]-j.p[0]);return[...O(v.filter(U=>!U.resolved)),...O(v.filter(U=>U.resolved))]},[e]),p=R.useCallback(v=>{var M;if(v.unitId===r&&v.subUnitId===c&&!v.resolved){const{row:g,column:O}=x.singleReferenceToGrid(v.ref),U=e.getSheetBySheetId(v.subUnitId),P=(M=U==null?void 0:U.getMergedCell(g,O))!=null?M:{startColumn:O,endColumn:O,startRow:g,endRow:g};if(!Number.isNaN(g)&&!Number.isNaN(O))return o.addShape({range:P,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,c,r]),f=v=>{var M,g;return(g=(M=e.getSheetBySheetId(v))==null?void 0:M.getName())!=null?g:""},b=()=>{i.executeCommand(A.id)},N=v=>{d&&d.unitId===v.unitId&&d.subUnitId===v.subUnitId&&d.commentId===v.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=p(v))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},J=(v,M)=>{M&&n.hidePopup()};return R.useEffect(()=>{!h&&m.current&&o.removeShape(m.current)},[o,h]),le.jsx(T.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:f,onResolve:J,sortComments:l,onItemEnter:N,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},ze=o=>({id:A.id,type:S.MenuItemType.BUTTON,icon:te,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:I.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ye=o=>({id:T.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:te,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:I.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),Je={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:I.whenSheetEditorFocused},Ke={[S.RibbonStartGroup.OTHERS]:{[T.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Ye}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:ze}}}};var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(o,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Qe(t,n,r),r},X=(o,t)=>(n,e)=>t(n,e,o);let Y=class extends a.Disposable{constructor(o,t,n){super(),this._menuManagerService=o,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Je)}_initMenu(){this._menuManagerService.mergeMenu(Ke)}_initComponent(){[[me,Ge],[T.THREAD_COMMENT_PANEL,Ze],[te,he]].forEach(([o,t])=>{this._componentManager.register(o,t)})}};Y=et([X(0,S.IMenuManagerService),X(1,a.Inject(S.ComponentManager)),X(2,S.IShortcutService)],Y);var pe=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(o,t,n)=>t in o?pe(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,rt=(o,t,n,e)=>{for(var r=e>1?void 0:e?tt(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&pe(t,n,r),r},ee=(o,t)=>(n,e)=>t(n,e,o),ve=(o,t,n)=>nt(o,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=ie,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:i,...s}=a.merge({},ie,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Pe,s)}onStarting(){[[Y],[F],[q],[G],[z],[Z],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[A].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(Y)}onReady(){this._injector.get(F),this._injector.get(z)}onRendered(){this._injector.get(q),this._injector.get(G),this._injector.get(Z)}};ve(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ne);ve(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=rt([a.DependentOn(T.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),ee(1,a.Inject(a.Injector)),ee(2,a.Inject(a.ICommandService)),ee(3,a.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>T.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=ne;exports.ShowAddSheetCommentModalOperation=A;
package/lib/es/index.js CHANGED
@@ -1,31 +1,31 @@
1
- var He = Object.defineProperty;
2
- var Le = (o, e, n) => e in o ? He(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
- var E = (o, e, n) => Le(o, typeof e != "symbol" ? e + "" : e, n);
4
- import { Inject as _, Disposable as $, DisposableCollection as ke, CommandType as Fe, IUniverInstanceService as N, InterceptorEffectEnum as We, UniverInstanceType as b, Range as Ze, ICommandService as ae, RANGE_TYPE as he, Rectangle as ze, useDependency as R, Tools as qe, DependentOn as Ge, Injector as Je, Plugin as Ye, IConfigService as Ke } from "@univerjs/core";
5
- import { SheetsSelectionsService as Ce, getSheetCommandTarget as Qe, SheetInterceptorService as Se, INTERCEPTOR_POINT as Xe, WorkbookCommentPermission as K, WorksheetViewPermission as Q, RangeProtectionPermissionViewPoint as X, SetWorksheetActiveOperation as et, RemoveSheetCommand as tt } from "@univerjs/sheets";
6
- import { SheetsThreadCommentModel as x, UniverSheetsThreadCommentPlugin as nt } from "@univerjs/sheets-thread-comment";
7
- import { ThreadCommentPanelService as ce, SetActiveCommentOperation as te, ThreadCommentTree as rt, ThreadCommentPanel as ot, ToggleSheetCommentPanelOperation as ge, THREAD_COMMENT_PANEL as it, UniverThreadCommentUIPlugin as st } from "@univerjs/thread-comment-ui";
8
- import { UniverThreadCommentUIPlugin as Un } from "@univerjs/thread-comment-ui";
9
- import { SheetCanvasPopManagerService as at, ISheetClipboardService as ct, COPY_TYPE as ut, HoverManagerService as mt, SheetPermissionInterceptorBaseController as Ie, IMarkSelectionService as Pe, IEditorBridgeService as dt, SheetSkeletonManagerService as ht, ScrollToRangeOperation as lt, whenSheetEditorFocused as pt, getCurrentRangeDisable$ as Te } from "@univerjs/sheets-ui";
10
- import { IZenZoneService as _t, useObservable as A, KeyCode as vt, MetaKeys as le, MenuItemType as be, getMenuHiddenObservable as Me, RibbonStartGroup as ft, ContextMenuPosition as Ct, ContextMenuGroup as St, ComponentManager as gt, IMenuManagerService as It, IShortcutService as Pt } from "@univerjs/ui";
11
- import { BehaviorSubject as Tt, debounceTime as ue, map as bt } from "rxjs";
12
- import { IRenderManagerService as we } from "@univerjs/engine-render";
13
- import { singleReferenceToGrid as V, serializeRange as Mt } from "@univerjs/engine-formula";
14
- import { IThreadCommentDataSourceService as ye, DeleteCommentMutation as F, AddCommentMutation as se, ThreadCommentModel as wt } from "@univerjs/thread-comment";
15
- import { AddCommentCommand as Nn, DeleteCommentCommand as xn, DeleteCommentTreeCommand as Dn, IThreadCommentDataSourceService as jn, ResolveCommentCommand as An, UpdateCommentCommand as Vn } from "@univerjs/thread-comment";
16
- import yt, { forwardRef as Ee, useRef as Re, createElement as Oe, useMemo as Et, useCallback as pe, useEffect as Rt } from "react";
17
- const Ue = "univer.sheet.thread-comment-modal", me = "comment-single", $e = "SHEET_THREAD_COMMENT";
18
- var Ot = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, $t = (o, e, n, t) => {
19
- for (var r = t > 1 ? void 0 : t ? Ut(e, n) : e, i = o.length - 1, s; i >= 0; i--)
1
+ var Le = Object.defineProperty;
2
+ var ke = (o, e, n) => e in o ? Le(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
+ var E = (o, e, n) => ke(o, typeof e != "symbol" ? e + "" : e, n);
4
+ import { Inject as _, Disposable as $, DisposableCollection as Fe, CommandType as We, IUniverInstanceService as N, InterceptorEffectEnum as Ze, UniverInstanceType as b, Range as ze, ICommandService as ae, RANGE_TYPE as he, Rectangle as qe, useDependency as R, Tools as Ge, DependentOn as Je, Injector as Ye, Plugin as Ke, merge as Qe, IConfigService as Xe } from "@univerjs/core";
5
+ import { SheetsSelectionsService as Se, getSheetCommandTarget as et, SheetInterceptorService as ge, INTERCEPTOR_POINT as tt, WorkbookCommentPermission as K, WorksheetViewPermission as Q, RangeProtectionPermissionViewPoint as X, SetWorksheetActiveOperation as nt, RemoveSheetCommand as rt } from "@univerjs/sheets";
6
+ import { SheetsThreadCommentModel as x, UniverSheetsThreadCommentPlugin as ot } from "@univerjs/sheets-thread-comment";
7
+ import { ThreadCommentPanelService as ce, SetActiveCommentOperation as te, ThreadCommentTree as it, ThreadCommentPanel as st, ToggleSheetCommentPanelOperation as Ie, THREAD_COMMENT_PANEL as at, UniverThreadCommentUIPlugin as ct } from "@univerjs/thread-comment-ui";
8
+ import { UniverThreadCommentUIPlugin as $n } from "@univerjs/thread-comment-ui";
9
+ import { SheetCanvasPopManagerService as mt, ISheetClipboardService as ut, COPY_TYPE as dt, HoverManagerService as ht, SheetPermissionInterceptorBaseController as Pe, IMarkSelectionService as Te, IEditorBridgeService as lt, SheetSkeletonManagerService as pt, ScrollToRangeOperation as _t, whenSheetEditorFocused as vt, getCurrentRangeDisable$ as be } from "@univerjs/sheets-ui";
10
+ import { IZenZoneService as ft, useObservable as A, KeyCode as Ct, MetaKeys as le, MenuItemType as Me, getMenuHiddenObservable as we, RibbonStartGroup as St, ContextMenuPosition as gt, ContextMenuGroup as It, ComponentManager as Pt, IMenuManagerService as Tt, IShortcutService as bt } from "@univerjs/ui";
11
+ import { BehaviorSubject as Mt, debounceTime as me, map as wt } from "rxjs";
12
+ import { IRenderManagerService as ye } from "@univerjs/engine-render";
13
+ import { singleReferenceToGrid as V, serializeRange as yt } from "@univerjs/engine-formula";
14
+ import { IThreadCommentDataSourceService as Ee, DeleteCommentMutation as F, AddCommentMutation as se, ThreadCommentModel as Et } from "@univerjs/thread-comment";
15
+ import { AddCommentCommand as xn, DeleteCommentCommand as Dn, DeleteCommentTreeCommand as jn, IThreadCommentDataSourceService as An, ResolveCommentCommand as Vn, UpdateCommentCommand as Bn } from "@univerjs/thread-comment";
16
+ import Rt, { forwardRef as Re, useRef as Oe, createElement as Ue, useMemo as Ot, useCallback as pe, useEffect as Ut } from "react";
17
+ const $e = "univer.sheet.thread-comment-modal", ue = "comment-single", Ne = "SHEET_THREAD_COMMENT";
18
+ var $t = Object.defineProperty, Nt = Object.getOwnPropertyDescriptor, xt = (o, e, n, t) => {
19
+ for (var r = t > 1 ? void 0 : t ? Nt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
20
20
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
21
- return t && r && Ot(e, n, r), r;
21
+ return t && r && $t(e, n, r), r;
22
22
  }, _e = (o, e) => (n, t) => e(n, t, o);
23
23
  let O = class extends $ {
24
24
  constructor(e, n) {
25
25
  super();
26
26
  E(this, "_lastPopup", null);
27
27
  E(this, "_activePopup");
28
- E(this, "_activePopup$", new Tt(null));
28
+ E(this, "_activePopup$", new Mt(null));
29
29
  E(this, "activePopup$", this._activePopup$.asObservable());
30
30
  this._canvasPopupManagerService = e, this._zenZoneService = n, this._initZenVisible(), this.disposeWithMe(() => {
31
31
  this._activePopup$.complete();
@@ -53,7 +53,7 @@ let O = class extends $ {
53
53
  t,
54
54
  r,
55
55
  {
56
- componentKey: Ue,
56
+ componentKey: $e,
57
57
  onClickOutside: () => {
58
58
  this.hidePopup();
59
59
  },
@@ -66,7 +66,7 @@ let O = class extends $ {
66
66
  );
67
67
  if (!a)
68
68
  throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");
69
- const c = new ke();
69
+ const c = new Fe();
70
70
  c.add(a), c.add({
71
71
  dispose: () => {
72
72
  n == null || n();
@@ -83,43 +83,43 @@ let O = class extends $ {
83
83
  }, this._activePopup$.next(this._activePopup));
84
84
  }
85
85
  };
86
- O = $t([
87
- _e(0, _(at)),
88
- _e(1, _t)
86
+ O = xt([
87
+ _e(0, _(mt)),
88
+ _e(1, ft)
89
89
  ], O);
90
90
  const B = {
91
- type: Fe.OPERATION,
91
+ type: We.OPERATION,
92
92
  id: "sheets.operation.show-comment-modal",
93
93
  handler(o) {
94
94
  var v;
95
- const e = o.get(Ce), n = o.get(N), t = o.get(O), r = o.get(ce), i = (v = e.getCurrentLastSelection()) == null ? void 0 : v.primary, s = o.get(x);
95
+ const e = o.get(Se), n = o.get(N), t = o.get(O), r = o.get(ce), i = (v = e.getCurrentLastSelection()) == null ? void 0 : v.primary, s = o.get(x);
96
96
  if (!i)
97
97
  return !1;
98
- const a = Qe(n);
98
+ const a = et(n);
99
99
  if (!a)
100
100
  return !1;
101
- const { workbook: c, worksheet: d, unitId: u, subUnitId: m } = a, h = {
101
+ const { workbook: c, worksheet: d, unitId: m, subUnitId: u } = a, h = {
102
102
  workbook: c,
103
103
  worksheet: d,
104
- unitId: u,
105
- subUnitId: m,
104
+ unitId: m,
105
+ subUnitId: u,
106
106
  row: i.startRow,
107
107
  col: i.startColumn
108
108
  };
109
109
  t.showPopup(h);
110
- const l = s.getByLocation(u, m, i.startRow, i.startColumn);
110
+ const l = s.getByLocation(m, u, i.startRow, i.startColumn);
111
111
  return l && r.setActiveComment({
112
- unitId: u,
113
- subUnitId: m,
112
+ unitId: m,
113
+ subUnitId: u,
114
114
  commentId: l,
115
115
  trigger: "context-menu"
116
116
  }), !0;
117
117
  }
118
- }, Nt = "sheets-thread-comment.config", xt = {};
119
- var Dt = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, At = (o, e, n, t) => {
120
- for (var r = t > 1 ? void 0 : t ? jt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
118
+ }, Dt = "sheets-thread-comment.config", ve = {};
119
+ var jt = Object.defineProperty, At = Object.getOwnPropertyDescriptor, Vt = (o, e, n, t) => {
120
+ for (var r = t > 1 ? void 0 : t ? At(e, n) : e, i = o.length - 1, s; i >= 0; i--)
121
121
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
122
- return t && r && Dt(e, n, r), r;
122
+ return t && r && jt(e, n, r), r;
123
123
  }, H = (o, e) => (n, t) => e(n, t, o);
124
124
  let W = class extends $ {
125
125
  constructor(o, e, n, t) {
@@ -128,9 +128,9 @@ let W = class extends $ {
128
128
  _initViewModelIntercept() {
129
129
  this.disposeWithMe(
130
130
  this._sheetInterceptorService.intercept(
131
- Xe.CELL_CONTENT,
131
+ tt.CELL_CONTENT,
132
132
  {
133
- effect: We.Style,
133
+ effect: Ze.Style,
134
134
  handler: (o, e, n) => {
135
135
  const { row: t, col: r, unitId: i, subUnitId: s } = e;
136
136
  return this._sheetsThreadCommentModel.showCommentMarker(i, s, t, r) ? n({
@@ -157,30 +157,30 @@ let W = class extends $ {
157
157
  const n = e.getUnitId(), t = this._renderManagerService.getRenderById(n);
158
158
  (r = t == null ? void 0 : t.mainComponent) == null || r.makeForceDirty();
159
159
  };
160
- this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(ue(16)).subscribe(() => {
160
+ this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(me(16)).subscribe(() => {
161
161
  o();
162
162
  }));
163
163
  }
164
164
  };
165
- W = At([
166
- H(0, _(Se)),
165
+ W = Vt([
166
+ H(0, _(ge)),
167
167
  H(1, _(x)),
168
168
  H(2, N),
169
- H(3, we)
169
+ H(3, ye)
170
170
  ], W);
171
- var Vt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, Ht = (o, e, n, t) => {
172
- for (var r = t > 1 ? void 0 : t ? Bt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
171
+ var Bt = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Lt = (o, e, n, t) => {
172
+ for (var r = t > 1 ? void 0 : t ? Ht(e, n) : e, i = o.length - 1, s; i >= 0; i--)
173
173
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
174
- return t && r && Vt(e, n, r), r;
174
+ return t && r && Bt(e, n, r), r;
175
175
  }, ne = (o, e) => (n, t) => e(n, t, o);
176
- const Lt = (o, e, n) => {
176
+ const kt = (o, e, n) => {
177
177
  const t = V(o), r = n.row - e.row, i = n.column - e.column, s = {
178
178
  startColumn: t.column + i,
179
179
  startRow: t.row + r,
180
180
  endColumn: t.column + i,
181
181
  endRow: t.row + r
182
182
  };
183
- return Mt(s);
183
+ return yt(s);
184
184
  };
185
185
  let Z = class extends $ {
186
186
  constructor(e, n, t) {
@@ -192,7 +192,7 @@ let Z = class extends $ {
192
192
  _initClipboardHook() {
193
193
  this.disposeWithMe(
194
194
  this._sheetClipboardService.addClipboardHook({
195
- id: $e,
195
+ id: Ne,
196
196
  onBeforeCopy: (e, n, t) => {
197
197
  this._copyInfo = {
198
198
  unitId: e,
@@ -206,15 +206,15 @@ let Z = class extends $ {
206
206
  row: a.rows[0],
207
207
  column: a.cols[0]
208
208
  };
209
- if (r.copyType === ut.CUT && this._copyInfo) {
210
- const { range: d, unitId: u, subUnitId: m } = this._copyInfo, h = {
209
+ if (r.copyType === dt.CUT && this._copyInfo) {
210
+ const { range: d, unitId: m, subUnitId: u } = this._copyInfo, h = {
211
211
  row: d.startRow,
212
212
  column: d.startColumn
213
213
  };
214
- if (!(i === u && s === m)) {
214
+ if (!(i === m && s === u)) {
215
215
  const l = [];
216
- Ze.foreach(d, (g, p) => {
217
- const I = this._sheetsThreadCommentModel.getAllByLocation(u, m, g, p);
216
+ ze.foreach(d, (g, p) => {
217
+ const I = this._sheetsThreadCommentModel.getAllByLocation(m, u, g, p);
218
218
  this._threadCommentDataSourceService.syncUpdateMutationToColla ? I.forEach((f) => {
219
219
  l.push(f);
220
220
  }) : I.forEach(({ children: f, ...M }) => {
@@ -225,8 +225,8 @@ let Z = class extends $ {
225
225
  v.unshift({
226
226
  id: F.id,
227
227
  params: {
228
- unitId: u,
229
- subUnitId: m,
228
+ unitId: m,
229
+ subUnitId: u,
230
230
  commentId: g.id
231
231
  }
232
232
  }), U.push({
@@ -236,7 +236,7 @@ let Z = class extends $ {
236
236
  subUnitId: s,
237
237
  comment: {
238
238
  ...g,
239
- ref: Lt(g.ref, h, c),
239
+ ref: kt(g.ref, h, c),
240
240
  unitId: i,
241
241
  subUnitId: s
242
242
  },
@@ -245,8 +245,8 @@ let Z = class extends $ {
245
245
  }), S.push({
246
246
  id: se.id,
247
247
  params: {
248
- unitId: u,
249
- subUnitId: m,
248
+ unitId: m,
249
+ subUnitId: u,
250
250
  comment: g,
251
251
  sync: !0
252
252
  }
@@ -276,15 +276,15 @@ let Z = class extends $ {
276
276
  );
277
277
  }
278
278
  };
279
- Z = Ht([
280
- ne(0, _(ct)),
279
+ Z = Lt([
280
+ ne(0, _(ut)),
281
281
  ne(1, _(x)),
282
- ne(2, ye)
282
+ ne(2, Ee)
283
283
  ], Z);
284
- var kt = Object.defineProperty, Ft = Object.getOwnPropertyDescriptor, Wt = (o, e, n, t) => {
285
- for (var r = t > 1 ? void 0 : t ? Ft(e, n) : e, i = o.length - 1, s; i >= 0; i--)
284
+ var Ft = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, Zt = (o, e, n, t) => {
285
+ for (var r = t > 1 ? void 0 : t ? Wt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
286
286
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
287
- return t && r && kt(e, n, r), r;
287
+ return t && r && Ft(e, n, r), r;
288
288
  }, L = (o, e) => (n, t) => e(n, t, o);
289
289
  let z = class extends $ {
290
290
  constructor(o, e, n, t) {
@@ -292,7 +292,7 @@ let z = class extends $ {
292
292
  }
293
293
  _initHoverEvent() {
294
294
  this.disposeWithMe(
295
- this._hoverManagerService.currentCell$.pipe(ue(100)).subscribe((o) => {
295
+ this._hoverManagerService.currentCell$.pipe(me(100)).subscribe((o) => {
296
296
  const e = this._sheetsThreadCommentPopupService.activePopup;
297
297
  if (o && (e && e.temp || !e)) {
298
298
  const { location: n } = o, { unitId: t, subUnitId: r, row: i, col: s } = n, a = this._sheetsThreadCommentModel.getByLocation(t, r, i, s);
@@ -319,44 +319,44 @@ let z = class extends $ {
319
319
  );
320
320
  }
321
321
  };
322
- z = Wt([
323
- L(0, _(mt)),
322
+ z = Zt([
323
+ L(0, _(ht)),
324
324
  L(1, _(O)),
325
325
  L(2, _(x)),
326
- L(3, _(Ie))
326
+ L(3, _(Pe))
327
327
  ], z);
328
- var Zt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, qt = (o, e, n, t) => {
329
- for (var r = t > 1 ? void 0 : t ? zt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
328
+ var zt = Object.defineProperty, qt = Object.getOwnPropertyDescriptor, Gt = (o, e, n, t) => {
329
+ for (var r = t > 1 ? void 0 : t ? qt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
330
330
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
331
- return t && r && Zt(e, n, r), r;
331
+ return t && r && zt(e, n, r), r;
332
332
  }, w = (o, e) => (n, t) => e(n, t, o);
333
333
  let q = class extends $ {
334
- constructor(e, n, t, r, i, s, a, c, d, u) {
334
+ constructor(e, n, t, r, i, s, a, c, d, m) {
335
335
  super();
336
336
  E(this, "_isSwitchToCommenting", !1);
337
337
  E(this, "_selectionShapeInfo", null);
338
- this._commandService = e, this._sheetsThreadCommentPopupService = n, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = r, this._univerInstanceService = i, this._sheetPermissionInterceptorBaseController = s, this._markSelectionService = a, this._sheetSelectionService = c, this._editorBridgeService = d, this._renderManagerService = u, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
338
+ this._commandService = e, this._sheetsThreadCommentPopupService = n, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = r, this._univerInstanceService = i, this._sheetPermissionInterceptorBaseController = s, this._markSelectionService = a, this._sheetSelectionService = c, this._editorBridgeService = d, this._renderManagerService = m, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
339
339
  }
340
340
  _handleSelectionChange(e, n, t) {
341
341
  var h, l, v;
342
- const r = (h = e[0]) == null ? void 0 : h.range, i = this._renderManagerService.getRenderById(n), s = (l = i == null ? void 0 : i.with(ht).getWorksheetSkeleton(t)) == null ? void 0 : l.skeleton;
342
+ const r = (h = e[0]) == null ? void 0 : h.range, i = this._renderManagerService.getRenderById(n), s = (l = i == null ? void 0 : i.with(pt).getWorksheetSkeleton(t)) == null ? void 0 : l.skeleton;
343
343
  if (!s || !r)
344
344
  return;
345
345
  const a = s.getCellWithCoordByIndex(r.startRow, r.startColumn);
346
- if ((((v = r.rangeType) != null ? v : he.NORMAL) !== he.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((a.isMerged || a.isMergedMainCell) && ze.equals(a.mergeInfo, r))) {
346
+ if ((((v = r.rangeType) != null ? v : he.NORMAL) !== he.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((a.isMerged || a.isMergedMainCell) && qe.equals(a.mergeInfo, r))) {
347
347
  this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(te.id);
348
348
  return;
349
349
  }
350
- const d = a.actualRow, u = a.actualColumn;
351
- if (!this._sheetsThreadCommentModel.showCommentMarker(n, t, d, u)) {
350
+ const d = a.actualRow, m = a.actualColumn;
351
+ if (!this._sheetsThreadCommentModel.showCommentMarker(n, t, d, m)) {
352
352
  this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(te.id);
353
353
  return;
354
354
  }
355
- const m = this._sheetsThreadCommentModel.getByLocation(n, t, d, u);
356
- m && this._commandService.executeCommand(te.id, {
355
+ const u = this._sheetsThreadCommentModel.getByLocation(n, t, d, m);
356
+ u && this._commandService.executeCommand(te.id, {
357
357
  unitId: n,
358
358
  subUnitId: t,
359
- commentId: m
359
+ commentId: u
360
360
  });
361
361
  }
362
362
  _initSelectionUpdateListener() {
@@ -397,11 +397,11 @@ let q = class extends $ {
397
397
  const c = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
398
398
  if (!c || c.getUnitId() !== t)
399
399
  return;
400
- this._isSwitchToCommenting = !0, ((n = c.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(et.id, {
400
+ this._isSwitchToCommenting = !0, ((n = c.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(nt.id, {
401
401
  unitId: t,
402
402
  subUnitId: r
403
403
  }), this._isSwitchToCommenting = !1;
404
- const m = V(a.ref), { row: h, column: l } = m;
404
+ const u = V(a.ref), { row: h, column: l } = u;
405
405
  if (!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
406
406
  workbookTypes: [K],
407
407
  worksheetTypes: [Q],
@@ -409,20 +409,20 @@ let q = class extends $ {
409
409
  }, [{ startRow: h, startColumn: l, endRow: h, endColumn: l }]))
410
410
  return;
411
411
  const S = 1;
412
- if (await this._commandService.executeCommand(lt.id, {
412
+ if (await this._commandService.executeCommand(_t.id, {
413
413
  range: {
414
- startRow: Math.max(m.row - S, 0),
415
- endRow: m.row + S,
416
- startColumn: Math.max(m.column - S, 0),
417
- endColumn: m.column + S
414
+ startRow: Math.max(u.row - S, 0),
415
+ endRow: u.row + S,
416
+ startColumn: Math.max(u.column - S, 0),
417
+ endColumn: u.column + S
418
418
  }
419
419
  }), this._editorBridgeService.isVisible().visible)
420
420
  return;
421
421
  this._sheetsThreadCommentPopupService.showPopup({
422
422
  unitId: t,
423
423
  subUnitId: r,
424
- row: m.row,
425
- col: m.column,
424
+ row: u.row,
425
+ col: u.column,
426
426
  commentId: a.id,
427
427
  trigger: s
428
428
  });
@@ -431,7 +431,7 @@ let q = class extends $ {
431
431
  }));
432
432
  }
433
433
  _initMarkSelection() {
434
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(ue(100)).subscribe((e) => {
434
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(me(100)).subscribe((e) => {
435
435
  var h, l;
436
436
  if (!e) {
437
437
  this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
@@ -445,14 +445,14 @@ let q = class extends $ {
445
445
  const s = V(i.ref), { row: a, column: c } = s;
446
446
  if (Number.isNaN(a) || Number.isNaN(c))
447
447
  return null;
448
- const d = (h = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : h.getSheetBySheetId(t), u = (l = d == null ? void 0 : d.getMergedCell(a, c)) != null ? l : {
448
+ const d = (h = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : h.getSheetBySheetId(t), m = (l = d == null ? void 0 : d.getMergedCell(a, c)) != null ? l : {
449
449
  startColumn: c,
450
450
  endColumn: c,
451
451
  startRow: a,
452
452
  endRow: a
453
- }, m = this._markSelectionService.addShape(
453
+ }, u = this._markSelectionService.addShape(
454
454
  {
455
- range: u,
455
+ range: m,
456
456
  style: {
457
457
  // hasAutoFill: false,
458
458
  fill: "rgb(255, 189, 55, 0.35)",
@@ -465,29 +465,29 @@ let q = class extends $ {
465
465
  [],
466
466
  -1
467
467
  );
468
- m && (this._selectionShapeInfo = {
468
+ u && (this._selectionShapeInfo = {
469
469
  ...e,
470
- shapeId: m
470
+ shapeId: u
471
471
  });
472
472
  }));
473
473
  }
474
474
  };
475
- q = qt([
475
+ q = Gt([
476
476
  w(0, ae),
477
477
  w(1, _(O)),
478
478
  w(2, _(x)),
479
479
  w(3, _(ce)),
480
480
  w(4, N),
481
- w(5, _(Ie)),
482
- w(6, Pe),
483
- w(7, _(Ce)),
484
- w(8, dt),
485
- w(9, we)
481
+ w(5, _(Pe)),
482
+ w(6, Te),
483
+ w(7, _(Se)),
484
+ w(8, lt),
485
+ w(9, ye)
486
486
  ], q);
487
- var Gt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, Yt = (o, e, n, t) => {
488
- for (var r = t > 1 ? void 0 : t ? Jt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
487
+ var Jt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Kt = (o, e, n, t) => {
488
+ for (var r = t > 1 ? void 0 : t ? Yt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
489
489
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
490
- return t && r && Gt(e, n, r), r;
490
+ return t && r && Jt(e, n, r), r;
491
491
  }, k = (o, e) => (n, t) => e(n, t, o);
492
492
  let G = class extends $ {
493
493
  constructor(o, e, n, t) {
@@ -498,21 +498,21 @@ let G = class extends $ {
498
498
  this._sheetInterceptorService.interceptCommand({
499
499
  getMutations: (o) => {
500
500
  var e;
501
- if (o.id === tt.id) {
501
+ if (o.id === rt.id) {
502
502
  const n = o.params, t = n.unitId ? this._univerInstanceService.getUnit(n.unitId) : this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
503
503
  if (!t)
504
504
  return { redos: [], undos: [] };
505
505
  const r = t.getUnitId(), i = n.subUnitId || ((e = t.getActiveSheet()) == null ? void 0 : e.getSheetId());
506
506
  if (!i)
507
507
  return { redos: [], undos: [] };
508
- const s = this._threadCommentModel.ensureMap(r, i), a = Array.from(s.values()).filter((h) => !h.parentId), c = a.map((h) => h.id), d = this._threadCommentDataSourceService.syncUpdateMutationToColla, u = c.map((h) => ({
508
+ const s = this._threadCommentModel.ensureMap(r, i), a = Array.from(s.values()).filter((h) => !h.parentId), c = a.map((h) => h.id), d = this._threadCommentDataSourceService.syncUpdateMutationToColla, m = c.map((h) => ({
509
509
  id: F.id,
510
510
  params: {
511
511
  unitId: r,
512
512
  subUnitId: i,
513
513
  commentId: h
514
514
  }
515
- })), m = a.map(({ children: h, ...l }) => ({
515
+ })), u = a.map(({ children: h, ...l }) => ({
516
516
  id: se.id,
517
517
  params: {
518
518
  unitId: r,
@@ -524,7 +524,7 @@ let G = class extends $ {
524
524
  sync: !d
525
525
  }
526
526
  }));
527
- return { redos: u, undos: m };
527
+ return { redos: m, undos: u };
528
528
  }
529
529
  return { redos: [], undos: [] };
530
530
  }
@@ -532,11 +532,11 @@ let G = class extends $ {
532
532
  );
533
533
  }
534
534
  };
535
- G = Yt([
536
- k(0, _(Se)),
535
+ G = Kt([
536
+ k(0, _(ge)),
537
537
  k(1, N),
538
- k(2, _(wt)),
539
- k(3, ye)
538
+ k(2, _(Et)),
539
+ k(3, Ee)
540
540
  ], G);
541
541
  var P = function() {
542
542
  return P = Object.assign || function(o) {
@@ -546,23 +546,23 @@ var P = function() {
546
546
  }
547
547
  return o;
548
548
  }, P.apply(this, arguments);
549
- }, Kt = function(o, e) {
549
+ }, Qt = function(o, e) {
550
550
  var n = {};
551
551
  for (var t in o) Object.prototype.hasOwnProperty.call(o, t) && e.indexOf(t) < 0 && (n[t] = o[t]);
552
552
  if (o != null && typeof Object.getOwnPropertySymbols == "function")
553
553
  for (var r = 0, t = Object.getOwnPropertySymbols(o); r < t.length; r++)
554
554
  e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[r]) && (n[t[r]] = o[t[r]]);
555
555
  return n;
556
- }, Ne = Ee(function(o, e) {
557
- var n = o.icon, t = o.id, r = o.className, i = o.extend, s = Kt(o, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), c = Re("_".concat(en()));
558
- return xe(n, "".concat(t), { defIds: n.defIds, idSuffix: c.current }, P({ ref: e, className: a }, s), i);
556
+ }, xe = Re(function(o, e) {
557
+ var n = o.icon, t = o.id, r = o.className, i = o.extend, s = Qt(o, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), c = Oe("_".concat(tn()));
558
+ return De(n, "".concat(t), { defIds: n.defIds, idSuffix: c.current }, P({ ref: e, className: a }, s), i);
559
559
  });
560
- function xe(o, e, n, t, r) {
561
- return Oe(o.tag, P(P({ key: e }, Qt(o, n, r)), t), (Xt(o, n).children || []).map(function(i, s) {
562
- return xe(i, "".concat(e, "-").concat(o.tag, "-").concat(s), n, void 0, r);
560
+ function De(o, e, n, t, r) {
561
+ return Ue(o.tag, P(P({ key: e }, Xt(o, n, r)), t), (en(o, n).children || []).map(function(i, s) {
562
+ return De(i, "".concat(e, "-").concat(o.tag, "-").concat(s), n, void 0, r);
563
563
  }));
564
564
  }
565
- function Qt(o, e, n) {
565
+ function Xt(o, e, n) {
566
566
  var t = P({}, o.attrs);
567
567
  n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
568
568
  var r = e.defIds;
@@ -571,24 +571,24 @@ function Qt(o, e, n) {
571
571
  typeof a == "string" && (t[s] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
572
572
  })), t;
573
573
  }
574
- function Xt(o, e) {
574
+ function en(o, e) {
575
575
  var n, t = e.defIds;
576
576
  return !t || t.length === 0 ? o : o.tag === "defs" && (!((n = o.children) === null || n === void 0) && n.length) ? P(P({}, o), { children: o.children.map(function(r) {
577
577
  return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? P(P({}, r), { attrs: P(P({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
578
578
  }) }) : o;
579
579
  }
580
- function en() {
580
+ function tn() {
581
581
  return Math.random().toString(36).substring(2, 8);
582
582
  }
583
- Ne.displayName = "UniverIcon";
584
- var tn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, De = Ee(function(o, e) {
585
- return Oe(Ne, Object.assign({}, o, {
583
+ xe.displayName = "UniverIcon";
584
+ var nn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, je = Re(function(o, e) {
585
+ return Ue(xe, Object.assign({}, o, {
586
586
  id: "comment-single",
587
587
  ref: e,
588
- icon: tn
588
+ icon: nn
589
589
  }));
590
590
  });
591
- De.displayName = "CommentSingle";
591
+ je.displayName = "CommentSingle";
592
592
  var re = { exports: {} }, j = {};
593
593
  /**
594
594
  * @license React
@@ -599,37 +599,37 @@ var re = { exports: {} }, j = {};
599
599
  * This source code is licensed under the MIT license found in the
600
600
  * LICENSE file in the root directory of this source tree.
601
601
  */
602
- var ve;
603
- function nn() {
604
- if (ve) return j;
605
- ve = 1;
606
- var o = yt, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), t = Object.prototype.hasOwnProperty, r = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
602
+ var fe;
603
+ function rn() {
604
+ if (fe) return j;
605
+ fe = 1;
606
+ var o = Rt, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), t = Object.prototype.hasOwnProperty, r = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
607
607
  function s(a, c, d) {
608
- var u, m = {}, h = null, l = null;
608
+ var m, u = {}, h = null, l = null;
609
609
  d !== void 0 && (h = "" + d), c.key !== void 0 && (h = "" + c.key), c.ref !== void 0 && (l = c.ref);
610
- for (u in c) t.call(c, u) && !i.hasOwnProperty(u) && (m[u] = c[u]);
611
- if (a && a.defaultProps) for (u in c = a.defaultProps, c) m[u] === void 0 && (m[u] = c[u]);
612
- return { $$typeof: e, type: a, key: h, ref: l, props: m, _owner: r.current };
610
+ for (m in c) t.call(c, m) && !i.hasOwnProperty(m) && (u[m] = c[m]);
611
+ if (a && a.defaultProps) for (m in c = a.defaultProps, c) u[m] === void 0 && (u[m] = c[m]);
612
+ return { $$typeof: e, type: a, key: h, ref: l, props: u, _owner: r.current };
613
613
  }
614
614
  return j.Fragment = n, j.jsx = s, j.jsxs = s, j;
615
615
  }
616
- var fe;
617
- function rn() {
618
- return fe || (fe = 1, re.exports = nn()), re.exports;
616
+ var Ce;
617
+ function on() {
618
+ return Ce || (Ce = 1, re.exports = rn()), re.exports;
619
619
  }
620
- var je = rn();
621
- const on = () => {
620
+ var Ae = on();
621
+ const sn = () => {
622
622
  const o = R(N), e = R(O), n = A(e.activePopup$), t = R(x);
623
623
  if (A(t.commentUpdate$), !n)
624
624
  return null;
625
- const { row: r, col: i, unitId: s, subUnitId: a, trigger: c } = n, d = t.getByLocation(s, a, r, i), u = `${qe.chatAtABC(i)}${r + 1}`, m = () => {
625
+ const { row: r, col: i, unitId: s, subUnitId: a, trigger: c } = n, d = t.getByLocation(s, a, r, i), m = `${Ge.chatAtABC(i)}${r + 1}`, u = () => {
626
626
  e.hidePopup();
627
627
  }, h = (l) => {
628
628
  var v, S, U;
629
629
  return (U = (S = (v = o.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : v.getSheetBySheetId(l)) == null ? void 0 : S.getName()) != null ? U : "";
630
630
  };
631
- return /* @__PURE__ */ je.jsx(
632
- rt,
631
+ return /* @__PURE__ */ Ae.jsx(
632
+ it,
633
633
  {
634
634
  onClick: () => {
635
635
  e.persistPopup();
@@ -639,23 +639,23 @@ const on = () => {
639
639
  unitId: s,
640
640
  subUnitId: a,
641
641
  type: b.UNIVER_SHEET,
642
- refStr: u,
643
- onClose: m,
642
+ refStr: m,
643
+ onClose: u,
644
644
  getSubUnitName: h,
645
645
  autoFocus: c === "context-menu"
646
646
  }
647
647
  );
648
- }, sn = () => {
648
+ }, an = () => {
649
649
  var g;
650
- const o = R(Pe), e = R(N), n = R(O), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = R(ae), s = Et(() => t.activeSheet$.pipe(bt((p) => p == null ? void 0 : p.getSheetId())), [t.activeSheet$]), a = A(s, (g = t.getActiveSheet()) == null ? void 0 : g.getSheetId()), c = Re(), d = R(ce), u = A(d.activeCommentId$), m = A(d.panelVisible$, d.panelVisible), h = pe((p) => {
650
+ const o = R(Te), e = R(N), n = R(O), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = R(ae), s = Ot(() => t.activeSheet$.pipe(wt((p) => p == null ? void 0 : p.getSheetId())), [t.activeSheet$]), a = A(s, (g = t.getActiveSheet()) == null ? void 0 : g.getSheetId()), c = Oe(), d = R(ce), m = A(d.activeCommentId$), u = A(d.panelVisible$, d.panelVisible), h = pe((p) => {
651
651
  const I = t.getSheets(), f = {};
652
652
  I.forEach((T, C) => {
653
653
  f[T.getSheetId()] = C;
654
654
  });
655
655
  const M = (T) => T.map((C) => {
656
656
  var de;
657
- const y = V(C.ref), Be = [(de = f[C.subUnitId]) != null ? de : 0, y.row, y.column];
658
- return { ...C, p: Be };
657
+ const y = V(C.ref), He = [(de = f[C.subUnitId]) != null ? de : 0, y.row, y.column];
658
+ return { ...C, p: He };
659
659
  }).sort((C, y) => C.p[0] === y.p[0] ? C.p[1] === y.p[1] ? C.p[2] - y.p[2] : C.p[1] - y.p[1] : C.p[0] - y.p[0]);
660
660
  return [
661
661
  ...M(p.filter((T) => !T.resolved)),
@@ -689,16 +689,16 @@ const on = () => {
689
689
  }, S = () => {
690
690
  i.executeCommand(B.id);
691
691
  }, U = (p) => {
692
- u && u.unitId === p.unitId && u.subUnitId === p.subUnitId && u.commentId === p.id || (c.current && (o.removeShape(c.current), c.current = null), c.current = l(p));
692
+ m && m.unitId === p.unitId && m.subUnitId === p.subUnitId && m.commentId === p.id || (c.current && (o.removeShape(c.current), c.current = null), c.current = l(p));
693
693
  }, D = () => {
694
694
  c.current && (o.removeShape(c.current), c.current = null);
695
695
  }, ee = (p, I) => {
696
696
  I && n.hidePopup();
697
697
  };
698
- return Rt(() => {
699
- !m && c.current && o.removeShape(c.current);
700
- }, [o, m]), /* @__PURE__ */ je.jsx(
701
- ot,
698
+ return Ut(() => {
699
+ !u && c.current && o.removeShape(c.current);
700
+ }, [o, u]), /* @__PURE__ */ Ae.jsx(
701
+ st,
702
702
  {
703
703
  unitId: r,
704
704
  subUnitId$: s,
@@ -712,52 +712,52 @@ const on = () => {
712
712
  onDeleteComment: () => (D(), !0)
713
713
  }
714
714
  );
715
- }, an = (o) => ({
715
+ }, cn = (o) => ({
716
716
  id: B.id,
717
- type: be.BUTTON,
718
- icon: me,
717
+ type: Me.BUTTON,
718
+ icon: ue,
719
719
  title: "sheetThreadComment.menu.addComment",
720
- hidden$: Me(o, b.UNIVER_SHEET),
721
- disabled$: Te(o, {
720
+ hidden$: we(o, b.UNIVER_SHEET),
721
+ disabled$: be(o, {
722
722
  workbookTypes: [K],
723
723
  worksheetTypes: [Q],
724
724
  rangeTypes: [X]
725
725
  })
726
- }), cn = (o) => ({
727
- id: ge.id,
728
- type: be.BUTTON,
729
- icon: me,
726
+ }), mn = (o) => ({
727
+ id: Ie.id,
728
+ type: Me.BUTTON,
729
+ icon: ue,
730
730
  tooltip: "sheetThreadComment.menu.commentManagement",
731
- disabled$: Te(o, {
731
+ disabled$: be(o, {
732
732
  workbookTypes: [K],
733
733
  worksheetTypes: [Q],
734
734
  rangeTypes: [X]
735
735
  }),
736
- hidden$: Me(o, b.UNIVER_SHEET)
736
+ hidden$: we(o, b.UNIVER_SHEET)
737
737
  }), un = {
738
738
  id: B.id,
739
- binding: vt.M | le.CTRL_COMMAND | le.ALT,
740
- preconditions: pt
741
- }, mn = {
742
- [ft.OTHERS]: {
743
- [ge.id]: {
739
+ binding: Ct.M | le.CTRL_COMMAND | le.ALT,
740
+ preconditions: vt
741
+ }, dn = {
742
+ [St.OTHERS]: {
743
+ [Ie.id]: {
744
744
  order: 1,
745
- menuItemFactory: cn
745
+ menuItemFactory: mn
746
746
  }
747
747
  },
748
- [Ct.MAIN_AREA]: {
749
- [St.OTHERS]: {
748
+ [gt.MAIN_AREA]: {
749
+ [It.OTHERS]: {
750
750
  [B.id]: {
751
751
  order: 0,
752
- menuItemFactory: an
752
+ menuItemFactory: cn
753
753
  }
754
754
  }
755
755
  }
756
756
  };
757
- var dn = Object.defineProperty, hn = Object.getOwnPropertyDescriptor, ln = (o, e, n, t) => {
758
- for (var r = t > 1 ? void 0 : t ? hn(e, n) : e, i = o.length - 1, s; i >= 0; i--)
757
+ var hn = Object.defineProperty, ln = Object.getOwnPropertyDescriptor, pn = (o, e, n, t) => {
758
+ for (var r = t > 1 ? void 0 : t ? ln(e, n) : e, i = o.length - 1, s; i >= 0; i--)
759
759
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
760
- return t && r && dn(e, n, r), r;
760
+ return t && r && hn(e, n, r), r;
761
761
  }, oe = (o, e) => (n, t) => e(n, t, o);
762
762
  let J = class extends $ {
763
763
  constructor(o, e, n) {
@@ -767,33 +767,37 @@ let J = class extends $ {
767
767
  this._shortcutService.registerShortcut(un);
768
768
  }
769
769
  _initMenu() {
770
- this._menuManagerService.mergeMenu(mn);
770
+ this._menuManagerService.mergeMenu(dn);
771
771
  }
772
772
  _initComponent() {
773
773
  [
774
- [Ue, on],
775
- [it, sn],
776
- [me, De]
774
+ [$e, sn],
775
+ [at, an],
776
+ [ue, je]
777
777
  ].forEach(([o, e]) => {
778
778
  this._componentManager.register(o, e);
779
779
  });
780
780
  }
781
781
  };
782
- J = ln([
783
- oe(0, It),
784
- oe(1, _(gt)),
785
- oe(2, Pt)
782
+ J = pn([
783
+ oe(0, Tt),
784
+ oe(1, _(Pt)),
785
+ oe(2, bt)
786
786
  ], J);
787
- var Ae = Object.defineProperty, pn = Object.getOwnPropertyDescriptor, _n = (o, e, n) => e in o ? Ae(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, vn = (o, e, n, t) => {
788
- for (var r = t > 1 ? void 0 : t ? pn(e, n) : e, i = o.length - 1, s; i >= 0; i--)
787
+ var Ve = Object.defineProperty, _n = Object.getOwnPropertyDescriptor, vn = (o, e, n) => e in o ? Ve(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, fn = (o, e, n, t) => {
788
+ for (var r = t > 1 ? void 0 : t ? _n(e, n) : e, i = o.length - 1, s; i >= 0; i--)
789
789
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
790
- return t && r && Ae(e, n, r), r;
791
- }, ie = (o, e) => (n, t) => e(n, t, o), Ve = (o, e, n) => _n(o, typeof e != "symbol" ? e + "" : e, n);
792
- let Y = class extends Ye {
793
- constructor(o = xt, e, n, t) {
790
+ return t && r && Ve(e, n, r), r;
791
+ }, ie = (o, e) => (n, t) => e(n, t, o), Be = (o, e, n) => vn(o, typeof e != "symbol" ? e + "" : e, n);
792
+ let Y = class extends Ke {
793
+ constructor(o = ve, e, n, t) {
794
794
  super(), this._config = o, this._injector = e, this._commandService = n, this._configService = t;
795
- const { menu: r, ...i } = this._config;
796
- r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Nt, i);
795
+ const { menu: r, ...i } = Qe(
796
+ {},
797
+ ve,
798
+ this._config
799
+ );
800
+ r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Dt, i);
797
801
  }
798
802
  onStarting() {
799
803
  [
@@ -817,24 +821,24 @@ let Y = class extends Ye {
817
821
  this._injector.get(Z), this._injector.get(z), this._injector.get(q);
818
822
  }
819
823
  };
820
- Ve(Y, "pluginName", $e);
821
- Ve(Y, "type", b.UNIVER_SHEET);
822
- Y = vn([
823
- Ge(st, nt),
824
- ie(1, _(Je)),
824
+ Be(Y, "pluginName", Ne);
825
+ Be(Y, "type", b.UNIVER_SHEET);
826
+ Y = fn([
827
+ Je(ct, ot),
828
+ ie(1, _(Ye)),
825
829
  ie(2, _(ae)),
826
- ie(3, Ke)
830
+ ie(3, Xe)
827
831
  ], Y);
828
832
  export {
829
- Nn as AddCommentCommand,
830
- xn as DeleteCommentCommand,
831
- Dn as DeleteCommentTreeCommand,
832
- jn as IThreadCommentDataSourceService,
833
- An as ResolveCommentCommand,
834
- $e as SHEETS_THREAD_COMMENT,
833
+ xn as AddCommentCommand,
834
+ Dn as DeleteCommentCommand,
835
+ jn as DeleteCommentTreeCommand,
836
+ An as IThreadCommentDataSourceService,
837
+ Vn as ResolveCommentCommand,
838
+ Ne as SHEETS_THREAD_COMMENT,
835
839
  O as SheetsThreadCommentPopupService,
836
840
  B as ShowAddSheetCommentModalOperation,
837
841
  Y as UniverSheetsThreadCommentUIPlugin,
838
- Un as UniverThreadCommentUIPlugin,
839
- Vn as UpdateCommentCommand
842
+ $n as UniverThreadCommentUIPlugin,
843
+ Bn as UpdateCommentCommand
840
844
  };
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(d,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","@univerjs/engine-formula","@univerjs/thread-comment","react"],a):(d=typeof globalThis<"u"?globalThis:d||self,a(d.UniverSheetsThreadCommentUi={},d.UniverCore,d.UniverSheets,d.UniverSheetsThreadComment,d.UniverThreadCommentUi,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverEngineRender,d.UniverEngineFormula,d.UniverThreadComment,d.React))})(this,function(d,a,v,A,P,I,f,k,ie,$,C,E){"use strict";var rt=Object.defineProperty;var it=(d,a,v)=>a in d?rt(d,a,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[a]=v;var N=(d,a,v)=>it(d,typeof a!="symbol"?a+"":a,v);const oe="univer.sheet.thread-comment-modal",K="comment-single",Q="SHEET_THREAD_COMMENT";var Se=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,fe=(i,t,n,e)=>{for(var r=e>1?void 0:e?_e(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Se(t,n,r),r},se=(i,t)=>(n,e)=>t(n,e,i);d.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new k.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var m;const{row:r,col:o,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&c===((m=this.activePopup)==null?void 0:m.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const u=this._canvasPopupManagerService.attachPopupToCell(r,o,{componentKey:oe,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new a.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},d.SheetsThreadCommentPopupService=fe([se(0,a.Inject(I.SheetCanvasPopManagerService)),se(1,f.IZenZoneService)],d.SheetsThreadCommentPopupService);const B={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var g;const t=i.get(v.SheetsSelectionsService),n=i.get(a.IUniverInstanceService),e=i.get(d.SheetsThreadCommentPopupService),r=i.get(P.ThreadCommentPanelService),o=(g=t.getCurrentLastSelection())==null?void 0:g.primary,s=i.get(A.SheetsThreadCommentModel);if(!o)return!1;const c=v.getSheetCommandTarget(n);if(!c)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:l}=c,p={workbook:u,worksheet:h,unitId:m,subUnitId:l,row:o.startRow,col:o.startColumn};e.showPopup(p);const S=s.getByLocation(m,l,o.startRow,o.startColumn);return S&&r.setActiveComment({unitId:m,subUnitId:l,commentId:S,trigger:"context-menu"}),!0}},Ce="sheets-thread-comment.config",Ie={};var ge=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(i,t,n,e)=>{for(var r=e>1?void 0:e?Pe(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&ge(t,n,r),r},L=(i,t)=>(n,e)=>t(n,e,i);let W=class extends a.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(i,t,n)=>{const{row:e,col:r,unitId:o,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,s,e,r)?n({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):n(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{i()}))}};W=Te([L(0,a.Inject(v.SheetInterceptorService)),L(1,a.Inject(A.SheetsThreadCommentModel)),L(2,a.IUniverInstanceService),L(3,ie.IRenderManagerService)],W);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(i,t,n,e)=>{for(var r=e>1?void 0:e?ye(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&be(t,n,r),r},X=(i,t)=>(n,e)=>t(n,e,i);const we=(i,t,n)=>{const e=$.singleReferenceToGrid(i),r=n.row-t.row,o=n.column-t.column,s={startColumn:e.column+o,startRow:e.row+r,endColumn:e.column+o,endRow:e.row+r};return $.serializeRange(s)};let F=class extends a.Disposable{constructor(t,n,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:o,subUnitId:s,range:c}=n,u={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:m,subUnitId:l}=this._copyInfo,p={row:h.startRow,column:h.startColumn};if(!(o===m&&s===l)){const S=[];a.Range.foreach(h,(w,_)=>{const R=this._sheetsThreadCommentModel.getAllByLocation(m,l,w,_);this._threadCommentDataSourceService.syncUpdateMutationToColla?R.forEach(T=>{S.push(T)}):R.forEach(({children:T,...j})=>{j.parentId||S.push(j)})});const g=[],M=[],V=[],H=[],re=w=>{g.unshift({id:C.DeleteCommentMutation.id,params:{unitId:m,subUnitId:l,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:s,comment:{...w,ref:we(w.ref,p,u),unitId:o,subUnitId:s},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:m,subUnitId:l,comment:w,sync:!0}}),H.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:s,commentId:w.id}})};return S.forEach(w=>{re(w)}),{redos:[...g,...V],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};F=Me([X(0,a.Inject(I.ISheetClipboardService)),X(1,a.Inject(A.SheetsThreadCommentModel)),X(2,C.IThreadCommentDataSourceService)],F);var Re=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Re(t,n,r),r},G=(i,t)=>(n,e)=>t(n,e,i);let Z=class extends a.Disposable{constructor(i,t,n,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:n}=i,{unitId:e,subUnitId:r,row:o,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,o,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}]))return;const h=this._sheetsThreadCommentModel.getComment(e,r,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:o,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Oe([G(0,a.Inject(I.HoverManagerService)),G(1,a.Inject(d.SheetsThreadCommentPopupService)),G(2,a.Inject(A.SheetsThreadCommentModel)),G(3,a.Inject(I.SheetPermissionInterceptorBaseController))],Z);var Ue=Object.defineProperty,je=Object.getOwnPropertyDescriptor,De=(i,t,n,e)=>{for(var r=e>1?void 0:e?je(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Ue(t,n,r),r},U=(i,t)=>(n,e)=>t(n,e,i);let z=class extends a.Disposable{constructor(t,n,e,r,o,s,c,u,h,m){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=o,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=h,this._renderManagerService=m,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var p,S,g;const r=(p=t[0])==null?void 0:p.range,o=this._renderManagerService.getRenderById(n),s=(S=o==null?void 0:o.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:S.skeleton;if(!s||!r)return;const c=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((g=r.rangeType)!=null?g:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=c.actualRow,m=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,h,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(n,e,h,m);l&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:l})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:o,commentId:s}=e;n.unitId===r&&n.subUnitId===o&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:o,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,r,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=u.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const l=$.singleReferenceToGrid(c.ref),{row:p,column:S}=l;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const M=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-M,0),endRow:l.row+M,startColumn:Math.max(l.column-M,0),endColumn:l.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:l.row,col:l.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,r);if(!o)return;const s=$.singleReferenceToGrid(o.ref),{row:c,column:u}=s;if(Number.isNaN(c)||Number.isNaN(u))return null;const h=(p=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),m=(S=h==null?void 0:h.getMergedCell(c,u))!=null?S:{startColumn:u,endColumn:u,startRow:c,endRow:c},l=this._markSelectionService.addShape({range:m,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);l&&(this._selectionShapeInfo={...t,shapeId:l})}))}};z=De([U(0,a.ICommandService),U(1,a.Inject(d.SheetsThreadCommentPopupService)),U(2,a.Inject(A.SheetsThreadCommentModel)),U(3,a.Inject(P.ThreadCommentPanelService)),U(4,a.IUniverInstanceService),U(5,a.Inject(I.SheetPermissionInterceptorBaseController)),U(6,I.IMarkSelectionService),U(7,a.Inject(v.SheetsSelectionsService)),U(8,I.IEditorBridgeService),U(9,ie.IRenderManagerService)],z);var Ne=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Ne(t,n,r),r},q=(i,t)=>(n,e)=>t(n,e,i);let Y=class extends a.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===v.RemoveSheetCommand.id){const n=i.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,o),c=Array.from(s.values()).filter(p=>!p.parentId),u=c.map(p=>p.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,m=u.map(p=>({id:C.DeleteCommentMutation.id,params:{unitId:r,subUnitId:o,commentId:p}})),l=c.map(({children:p,...S})=>({id:C.AddCommentMutation.id,params:{unitId:r,subUnitId:o,comment:{...S,children:h?p:void 0},sync:!h}}));return{redos:m,undos:l}}return{redos:[],undos:[]}}}))}};Y=Ve([q(0,a.Inject(v.SheetInterceptorService)),q(1,a.IUniverInstanceService),q(2,a.Inject(C.ThreadCommentModel)),q(3,C.IThreadCommentDataSourceService)],Y);var y=function(){return y=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},y.apply(this,arguments)},$e=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},ae=E.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,s=$e(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),u=E.useRef("_".concat(xe()));return ce(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},y({ref:t,className:c},s),o)});function ce(i,t,n,e,r){return E.createElement(i.tag,y(y({key:t},Be(i,n,r)),e),(ke(i,n).children||[]).map(function(o,s){return ce(o,"".concat(t,"-").concat(i.tag,"-").concat(s),n,void 0,r)}))}function Be(i,t,n){var e=y({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ke(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?y(y({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function xe(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ue=E.forwardRef(function(i,t){return E.createElement(ae,Object.assign({},i,{id:"comment-single",ref:t,icon:He}))});ue.displayName="CommentSingle";var ee={exports:{}},x={};/**
1
+ (function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","@univerjs/engine-formula","@univerjs/thread-comment","react"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsThreadCommentUi={},d.UniverCore,d.UniverSheets,d.UniverSheetsThreadComment,d.UniverThreadCommentUi,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverEngineRender,d.UniverEngineFormula,d.UniverThreadComment,d.React))})(this,function(d,s,v,A,P,I,f,k,ie,$,C,E){"use strict";var rt=Object.defineProperty;var it=(d,s,v)=>s in d?rt(d,s,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[s]=v;var N=(d,s,v)=>it(d,typeof s!="symbol"?s+"":s,v);const oe="univer.sheet.thread-comment-modal",K="comment-single",Q="SHEET_THREAD_COMMENT";var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,Ce=(i,t,n,e)=>{for(var r=e>1?void 0:e?fe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&_e(t,n,r),r},se=(i,t)=>(n,e)=>t(n,e,i);d.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new k.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var m;const{row:r,col:o,unitId:a,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((m=this.activePopup)==null?void 0:m.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const u=this._canvasPopupManagerService.attachPopupToCell(r,o,{componentKey:oe,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new s.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},d.SheetsThreadCommentPopupService=Ce([se(0,s.Inject(I.SheetCanvasPopManagerService)),se(1,f.IZenZoneService)],d.SheetsThreadCommentPopupService);const B={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var g;const t=i.get(v.SheetsSelectionsService),n=i.get(s.IUniverInstanceService),e=i.get(d.SheetsThreadCommentPopupService),r=i.get(P.ThreadCommentPanelService),o=(g=t.getCurrentLastSelection())==null?void 0:g.primary,a=i.get(A.SheetsThreadCommentModel);if(!o)return!1;const c=v.getSheetCommandTarget(n);if(!c)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:l}=c,p={workbook:u,worksheet:h,unitId:m,subUnitId:l,row:o.startRow,col:o.startColumn};e.showPopup(p);const S=a.getByLocation(m,l,o.startRow,o.startColumn);return S&&r.setActiveComment({unitId:m,subUnitId:l,commentId:S,trigger:"context-menu"}),!0}},Ie="sheets-thread-comment.config",ae={};var ge=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(i,t,n,e)=>{for(var r=e>1?void 0:e?Pe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&ge(t,n,r),r},L=(i,t)=>(n,e)=>t(n,e,i);let W=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(i,t,n)=>{const{row:e,col:r,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,r)?n({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):n(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{i()}))}};W=Te([L(0,s.Inject(v.SheetInterceptorService)),L(1,s.Inject(A.SheetsThreadCommentModel)),L(2,s.IUniverInstanceService),L(3,ie.IRenderManagerService)],W);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(i,t,n,e)=>{for(var r=e>1?void 0:e?ye(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&be(t,n,r),r},X=(i,t)=>(n,e)=>t(n,e,i);const we=(i,t,n)=>{const e=$.singleReferenceToGrid(i),r=n.row-t.row,o=n.column-t.column,a={startColumn:e.column+o,startRow:e.row+r,endColumn:e.column+o,endRow:e.row+r};return $.serializeRange(a)};let F=class extends s.Disposable{constructor(t,n,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:o,subUnitId:a,range:c}=n,u={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:m,subUnitId:l}=this._copyInfo,p={row:h.startRow,column:h.startColumn};if(!(o===m&&a===l)){const S=[];s.Range.foreach(h,(w,_)=>{const R=this._sheetsThreadCommentModel.getAllByLocation(m,l,w,_);this._threadCommentDataSourceService.syncUpdateMutationToColla?R.forEach(T=>{S.push(T)}):R.forEach(({children:T,...j})=>{j.parentId||S.push(j)})});const g=[],M=[],V=[],H=[],re=w=>{g.unshift({id:C.DeleteCommentMutation.id,params:{unitId:m,subUnitId:l,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:we(w.ref,p,u),unitId:o,subUnitId:a},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:m,subUnitId:l,comment:w,sync:!0}}),H.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:a,commentId:w.id}})};return S.forEach(w=>{re(w)}),{redos:[...g,...V],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};F=Me([X(0,s.Inject(I.ISheetClipboardService)),X(1,s.Inject(A.SheetsThreadCommentModel)),X(2,C.IThreadCommentDataSourceService)],F);var Re=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Re(t,n,r),r},G=(i,t)=>(n,e)=>t(n,e,i);let Z=class extends s.Disposable{constructor(i,t,n,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:n}=i,{unitId:e,subUnitId:r,row:o,col:a}=n,c=this._sheetsThreadCommentModel.getByLocation(e,r,o,a);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:a,endRow:o,endColumn:a}]))return;const h=this._sheetsThreadCommentModel.getComment(e,r,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:o,col:a,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};Z=Oe([G(0,s.Inject(I.HoverManagerService)),G(1,s.Inject(d.SheetsThreadCommentPopupService)),G(2,s.Inject(A.SheetsThreadCommentModel)),G(3,s.Inject(I.SheetPermissionInterceptorBaseController))],Z);var Ue=Object.defineProperty,je=Object.getOwnPropertyDescriptor,De=(i,t,n,e)=>{for(var r=e>1?void 0:e?je(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ue(t,n,r),r},U=(i,t)=>(n,e)=>t(n,e,i);let z=class extends s.Disposable{constructor(t,n,e,r,o,a,c,u,h,m){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=o,this._sheetPermissionInterceptorBaseController=a,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=h,this._renderManagerService=m,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var p,S,g;const r=(p=t[0])==null?void 0:p.range,o=this._renderManagerService.getRenderById(n),a=(S=o==null?void 0:o.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:S.skeleton;if(!a||!r)return;const c=a.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((g=r.rangeType)!=null?g:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&s.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=c.actualRow,m=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,h,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(n,e,h,m);l&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:l})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:o,commentId:a}=e;n.unitId===r&&n.subUnitId===o&&n.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:o,trigger:a}=t,c=this._sheetsThreadCommentModel.getComment(e,r,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=u.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const l=$.singleReferenceToGrid(c.ref),{row:p,column:S}=l;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const M=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-M,0),endRow:l.row+M,startColumn:Math.max(l.column-M,0),endColumn:l.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:l.row,col:l.column,commentId:c.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,r);if(!o)return;const a=$.singleReferenceToGrid(o.ref),{row:c,column:u}=a;if(Number.isNaN(c)||Number.isNaN(u))return null;const h=(p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),m=(S=h==null?void 0:h.getMergedCell(c,u))!=null?S:{startColumn:u,endColumn:u,startRow:c,endRow:c},l=this._markSelectionService.addShape({range:m,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);l&&(this._selectionShapeInfo={...t,shapeId:l})}))}};z=De([U(0,s.ICommandService),U(1,s.Inject(d.SheetsThreadCommentPopupService)),U(2,s.Inject(A.SheetsThreadCommentModel)),U(3,s.Inject(P.ThreadCommentPanelService)),U(4,s.IUniverInstanceService),U(5,s.Inject(I.SheetPermissionInterceptorBaseController)),U(6,I.IMarkSelectionService),U(7,s.Inject(v.SheetsSelectionsService)),U(8,I.IEditorBridgeService),U(9,ie.IRenderManagerService)],z);var Ne=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ne(t,n,r),r},q=(i,t)=>(n,e)=>t(n,e,i);let Y=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===v.RemoveSheetCommand.id){const n=i.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(r,o),c=Array.from(a.values()).filter(p=>!p.parentId),u=c.map(p=>p.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,m=u.map(p=>({id:C.DeleteCommentMutation.id,params:{unitId:r,subUnitId:o,commentId:p}})),l=c.map(({children:p,...S})=>({id:C.AddCommentMutation.id,params:{unitId:r,subUnitId:o,comment:{...S,children:h?p:void 0},sync:!h}}));return{redos:m,undos:l}}return{redos:[],undos:[]}}}))}};Y=Ve([q(0,s.Inject(v.SheetInterceptorService)),q(1,s.IUniverInstanceService),q(2,s.Inject(C.ThreadCommentModel)),q(3,C.IThreadCommentDataSourceService)],Y);var y=function(){return y=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},y.apply(this,arguments)},$e=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},ce=E.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=$e(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),u=E.useRef("_".concat(xe()));return ue(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},y({ref:t,className:c},a),o)});function ue(i,t,n,e,r){return E.createElement(i.tag,y(y({key:t},Be(i,n,r)),e),(ke(i,n).children||[]).map(function(o,a){return ue(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function Be(i,t,n){var e=y({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ke(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?y(y({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function xe(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},de=E.forwardRef(function(i,t){return E.createElement(ce,Object.assign({},i,{id:"comment-single",ref:t,icon:He}))});de.displayName="CommentSingle";var ee={exports:{}},x={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var de;function Le(){if(de)return x;de=1;var i=E,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(c,u,h){var m,l={},p=null,S=null;h!==void 0&&(p=""+h),u.key!==void 0&&(p=""+u.key),u.ref!==void 0&&(S=u.ref);for(m in u)e.call(u,m)&&!o.hasOwnProperty(m)&&(l[m]=u[m]);if(c&&c.defaultProps)for(m in u=c.defaultProps,u)l[m]===void 0&&(l[m]=u[m]);return{$$typeof:t,type:c,key:p,ref:S,props:l,_owner:r.current}}return x.Fragment=n,x.jsx=s,x.jsxs=s,x}var me;function We(){return me||(me=1,ee.exports=Le()),ee.exports}var he=We();const Fe=()=>{const i=a.useDependency(a.IUniverInstanceService),t=a.useDependency(d.SheetsThreadCommentPopupService),n=f.useObservable(t.activePopup$),e=a.useDependency(A.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:o,unitId:s,subUnitId:c,trigger:u}=n,h=e.getByLocation(s,c,r,o),m=`${a.Tools.chatAtABC(o)}${r+1}`,l=()=>{t.hidePopup()},p=S=>{var g,M,V;return(V=(M=(g=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getSheetBySheetId(S))==null?void 0:M.getName())!=null?V:""};return he.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:h,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:m,onClose:l,getSubUnitName:p,autoFocus:u==="context-menu"})},Ge=()=>{var w;const i=a.useDependency(I.IMarkSelectionService),t=a.useDependency(a.IUniverInstanceService),n=a.useDependency(d.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),o=a.useDependency(a.ICommandService),s=E.useMemo(()=>e.activeSheet$.pipe(k.map(_=>_==null?void 0:_.getSheetId())),[e.activeSheet$]),c=f.useObservable(s,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=E.useRef(),h=a.useDependency(P.ThreadCommentPanelService),m=f.useObservable(h.activeCommentId$),l=f.useObservable(h.panelVisible$,h.panelVisible),p=E.useCallback(_=>{const R=e.getSheets(),T={};R.forEach((O,b)=>{T[O.getSheetId()]=b});const j=O=>O.map(b=>{var ve;const D=$.singleReferenceToGrid(b.ref),nt=[(ve=T[b.subUnitId])!=null?ve:0,D.row,D.column];return{...b,p:nt}}).sort((b,D)=>b.p[0]===D.p[0]?b.p[1]===D.p[1]?b.p[2]-D.p[2]:b.p[1]-D.p[1]:b.p[0]-D.p[0]);return[...j(_.filter(O=>!O.resolved)),...j(_.filter(O=>O.resolved))]},[e]),S=E.useCallback(_=>{var R;if(_.unitId===r&&_.subUnitId===c&&!_.resolved){const{row:T,column:j}=$.singleReferenceToGrid(_.ref),O=e.getSheetBySheetId(_.subUnitId),b=(R=O==null?void 0:O.getMergedCell(T,j))!=null?R:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return i.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,c,r]),g=_=>{var R,T;return(T=(R=e.getSheetBySheetId(_))==null?void 0:R.getName())!=null?T:""},M=()=>{o.executeCommand(B.id)},V=_=>{m&&m.unitId===_.unitId&&m.subUnitId===_.subUnitId&&m.commentId===_.id||(u.current&&(i.removeShape(u.current),u.current=null),u.current=S(_))},H=()=>{u.current&&(i.removeShape(u.current),u.current=null)},re=(_,R)=>{R&&n.hidePopup()};return E.useEffect(()=>{!l&&u.current&&i.removeShape(u.current)},[i,l]),he.jsx(P.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:g,onResolve:re,sortComments:p,onItemEnter:V,onItemLeave:H,onDeleteComment:()=>(H(),!0)})},Ze=i=>({id:B.id,type:f.MenuItemType.BUTTON,icon:K,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:I.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),ze=i=>({id:P.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:K,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:I.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}),qe={id:B.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:I.whenSheetEditorFocused},Ye={[f.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:ze}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[B.id]:{order:0,menuItemFactory:Ze}}}};var Je=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Qe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Je(t,n,r),r},te=(i,t)=>(n,e)=>t(n,e,i);let J=class extends a.Disposable{constructor(i,t,n){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(qe)}_initMenu(){this._menuManagerService.mergeMenu(Ye)}_initComponent(){[[oe,Fe],[P.THREAD_COMMENT_PANEL,Ge],[K,ue]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};J=Qe([te(0,f.IMenuManagerService),te(1,a.Inject(f.ComponentManager)),te(2,f.IShortcutService)],J);var le=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(i,t,n)=>t in i?le(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,tt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&le(t,n,r),r},ne=(i,t)=>(n,e)=>t(n,e,i),pe=(i,t,n)=>et(i,typeof t!="symbol"?t+"":t,n);d.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=Ie,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:o,...s}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ce,s)}onStarting(){[[J],[W],[F],[Z],[Y],[z],[d.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[B].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(J)}onReady(){this._injector.get(W),this._injector.get(Y)}onRendered(){this._injector.get(F),this._injector.get(Z),this._injector.get(z)}},pe(d.UniverSheetsThreadCommentUIPlugin,"pluginName",Q),pe(d.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentUIPlugin=tt([a.DependentOn(P.UniverThreadCommentUIPlugin,A.UniverSheetsThreadCommentPlugin),ne(1,a.Inject(a.Injector)),ne(2,a.Inject(a.ICommandService)),ne(3,a.IConfigService)],d.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(d,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin}),Object.defineProperty(d,"AddCommentCommand",{enumerable:!0,get:()=>C.AddCommentCommand}),Object.defineProperty(d,"DeleteCommentCommand",{enumerable:!0,get:()=>C.DeleteCommentCommand}),Object.defineProperty(d,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>C.DeleteCommentTreeCommand}),Object.defineProperty(d,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>C.IThreadCommentDataSourceService}),Object.defineProperty(d,"ResolveCommentCommand",{enumerable:!0,get:()=>C.ResolveCommentCommand}),Object.defineProperty(d,"UpdateCommentCommand",{enumerable:!0,get:()=>C.UpdateCommentCommand}),d.SHEETS_THREAD_COMMENT=Q,d.ShowAddSheetCommentModalOperation=B,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
9
+ */var me;function Le(){if(me)return x;me=1;var i=E,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(c,u,h){var m,l={},p=null,S=null;h!==void 0&&(p=""+h),u.key!==void 0&&(p=""+u.key),u.ref!==void 0&&(S=u.ref);for(m in u)e.call(u,m)&&!o.hasOwnProperty(m)&&(l[m]=u[m]);if(c&&c.defaultProps)for(m in u=c.defaultProps,u)l[m]===void 0&&(l[m]=u[m]);return{$$typeof:t,type:c,key:p,ref:S,props:l,_owner:r.current}}return x.Fragment=n,x.jsx=a,x.jsxs=a,x}var he;function We(){return he||(he=1,ee.exports=Le()),ee.exports}var le=We();const Fe=()=>{const i=s.useDependency(s.IUniverInstanceService),t=s.useDependency(d.SheetsThreadCommentPopupService),n=f.useObservable(t.activePopup$),e=s.useDependency(A.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:o,unitId:a,subUnitId:c,trigger:u}=n,h=e.getByLocation(a,c,r,o),m=`${s.Tools.chatAtABC(o)}${r+1}`,l=()=>{t.hidePopup()},p=S=>{var g,M,V;return(V=(M=(g=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getSheetBySheetId(S))==null?void 0:M.getName())!=null?V:""};return le.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:h,unitId:a,subUnitId:c,type:s.UniverInstanceType.UNIVER_SHEET,refStr:m,onClose:l,getSubUnitName:p,autoFocus:u==="context-menu"})},Ge=()=>{var w;const i=s.useDependency(I.IMarkSelectionService),t=s.useDependency(s.IUniverInstanceService),n=s.useDependency(d.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),o=s.useDependency(s.ICommandService),a=E.useMemo(()=>e.activeSheet$.pipe(k.map(_=>_==null?void 0:_.getSheetId())),[e.activeSheet$]),c=f.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=E.useRef(),h=s.useDependency(P.ThreadCommentPanelService),m=f.useObservable(h.activeCommentId$),l=f.useObservable(h.panelVisible$,h.panelVisible),p=E.useCallback(_=>{const R=e.getSheets(),T={};R.forEach((O,b)=>{T[O.getSheetId()]=b});const j=O=>O.map(b=>{var Se;const D=$.singleReferenceToGrid(b.ref),nt=[(Se=T[b.subUnitId])!=null?Se:0,D.row,D.column];return{...b,p:nt}}).sort((b,D)=>b.p[0]===D.p[0]?b.p[1]===D.p[1]?b.p[2]-D.p[2]:b.p[1]-D.p[1]:b.p[0]-D.p[0]);return[...j(_.filter(O=>!O.resolved)),...j(_.filter(O=>O.resolved))]},[e]),S=E.useCallback(_=>{var R;if(_.unitId===r&&_.subUnitId===c&&!_.resolved){const{row:T,column:j}=$.singleReferenceToGrid(_.ref),O=e.getSheetBySheetId(_.subUnitId),b=(R=O==null?void 0:O.getMergedCell(T,j))!=null?R:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return i.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,c,r]),g=_=>{var R,T;return(T=(R=e.getSheetBySheetId(_))==null?void 0:R.getName())!=null?T:""},M=()=>{o.executeCommand(B.id)},V=_=>{m&&m.unitId===_.unitId&&m.subUnitId===_.subUnitId&&m.commentId===_.id||(u.current&&(i.removeShape(u.current),u.current=null),u.current=S(_))},H=()=>{u.current&&(i.removeShape(u.current),u.current=null)},re=(_,R)=>{R&&n.hidePopup()};return E.useEffect(()=>{!l&&u.current&&i.removeShape(u.current)},[i,l]),le.jsx(P.ThreadCommentPanel,{unitId:r,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:g,onResolve:re,sortComments:p,onItemEnter:V,onItemLeave:H,onDeleteComment:()=>(H(),!0)})},Ze=i=>({id:B.id,type:f.MenuItemType.BUTTON,icon:K,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),disabled$:I.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),ze=i=>({id:P.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:K,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:I.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET)}),qe={id:B.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:I.whenSheetEditorFocused},Ye={[f.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:ze}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[B.id]:{order:0,menuItemFactory:Ze}}}};var Je=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Qe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Je(t,n,r),r},te=(i,t)=>(n,e)=>t(n,e,i);let J=class extends s.Disposable{constructor(i,t,n){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(qe)}_initMenu(){this._menuManagerService.mergeMenu(Ye)}_initComponent(){[[oe,Fe],[P.THREAD_COMMENT_PANEL,Ge],[K,de]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};J=Qe([te(0,f.IMenuManagerService),te(1,s.Inject(f.ComponentManager)),te(2,f.IShortcutService)],J);var pe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(i,t,n)=>t in i?pe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,tt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Xe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&pe(t,n,r),r},ne=(i,t)=>(n,e)=>t(n,e,i),ve=(i,t,n)=>et(i,typeof t!="symbol"?t+"":t,n);d.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=ae,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:o,...a}=s.merge({},ae,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ie,a)}onStarting(){[[J],[W],[F],[Z],[Y],[z],[d.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[B].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(J)}onReady(){this._injector.get(W),this._injector.get(Y)}onRendered(){this._injector.get(F),this._injector.get(Z),this._injector.get(z)}},ve(d.UniverSheetsThreadCommentUIPlugin,"pluginName",Q),ve(d.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentUIPlugin=tt([s.DependentOn(P.UniverThreadCommentUIPlugin,A.UniverSheetsThreadCommentPlugin),ne(1,s.Inject(s.Injector)),ne(2,s.Inject(s.ICommandService)),ne(3,s.IConfigService)],d.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(d,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin}),Object.defineProperty(d,"AddCommentCommand",{enumerable:!0,get:()=>C.AddCommentCommand}),Object.defineProperty(d,"DeleteCommentCommand",{enumerable:!0,get:()=>C.DeleteCommentCommand}),Object.defineProperty(d,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>C.DeleteCommentTreeCommand}),Object.defineProperty(d,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>C.IThreadCommentDataSourceService}),Object.defineProperty(d,"ResolveCommentCommand",{enumerable:!0,get:()=>C.ResolveCommentCommand}),Object.defineProperty(d,"UpdateCommentCommand",{enumerable:!0,get:()=>C.UpdateCommentCommand}),d.SHEETS_THREAD_COMMENT=Q,d.ShowAddSheetCommentModalOperation=B,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-thread-comment-ui",
3
- "version": "0.5.1-nightly.202412251606",
3
+ "version": "0.5.1-nightly.202412271606",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -54,15 +54,15 @@
54
54
  "dependencies": {
55
55
  "@univerjs/icons": "^0.2.8",
56
56
  "clsx": "^2.1.1",
57
- "@univerjs/core": "0.5.1-nightly.202412251606",
58
- "@univerjs/engine-formula": "0.5.1-nightly.202412251606",
59
- "@univerjs/engine-render": "0.5.1-nightly.202412251606",
60
- "@univerjs/sheets": "0.5.1-nightly.202412251606",
61
- "@univerjs/sheets-thread-comment": "0.5.1-nightly.202412251606",
62
- "@univerjs/thread-comment": "0.5.1-nightly.202412251606",
63
- "@univerjs/thread-comment-ui": "0.5.1-nightly.202412251606",
64
- "@univerjs/sheets-ui": "0.5.1-nightly.202412251606",
65
- "@univerjs/ui": "0.5.1-nightly.202412251606"
57
+ "@univerjs/core": "0.5.1-nightly.202412271606",
58
+ "@univerjs/engine-formula": "0.5.1-nightly.202412271606",
59
+ "@univerjs/engine-render": "0.5.1-nightly.202412271606",
60
+ "@univerjs/sheets-thread-comment": "0.5.1-nightly.202412271606",
61
+ "@univerjs/sheets": "0.5.1-nightly.202412271606",
62
+ "@univerjs/thread-comment-ui": "0.5.1-nightly.202412271606",
63
+ "@univerjs/sheets-ui": "0.5.1-nightly.202412271606",
64
+ "@univerjs/thread-comment": "0.5.1-nightly.202412271606",
65
+ "@univerjs/ui": "0.5.1-nightly.202412271606"
66
66
  },
67
67
  "devDependencies": {
68
68
  "postcss": "^8.4.49",