@univerjs/sheets-thread-comment-ui 0.7.0 → 0.8.0-nightly.202505261607

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 +1 @@
1
- "use strict";var he=Object.defineProperty;var le=(n,t,r)=>t in n?he(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var D=(n,t,r)=>le(n,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),N=require("@univerjs/sheets-thread-comment"),P=require("@univerjs/thread-comment-ui"),T=require("@univerjs/sheets-ui"),l=require("@univerjs/ui"),V=require("rxjs"),oe=require("@univerjs/engine-render"),$=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),ie=require("react/jsx-runtime"),O=require("react"),se="univer.sheet.thread-comment-modal",ee="comment-single",te="SHEET_THREAD_COMMENT";var pe=Object.getOwnPropertyDescriptor,ve=(n,t,r,e)=>{for(var o=e>1?void 0:e?pe(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},Y=(n,t)=>(r,e)=>t(r,e,n);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(r,e,o){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new V.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._cellPopupManagerService=o,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}showPopup(r,e){var h;const{row:o,col:i,unitId:s,subUnitId:c}=r;if(this._activePopup&&o===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const m=this._cellPopupManagerService.showPopup({row:o,col:i,unitId:s,subUnitId:c},{componentKey:se,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(m),d.add({dispose:()=>{e==null||e()}}),this._lastPopup=d}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=ve([Y(0,a.Inject(T.SheetCanvasPopManagerService)),Y(1,l.IZenZoneService),Y(2,a.Inject(T.CellPopupManagerService))],exports.SheetsThreadCommentPopupService);const x={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(n){var g;const t=n.get(C.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),e=n.get(exports.SheetsThreadCommentPopupService),o=n.get(P.ThreadCommentPanelService),i=(g=t.getCurrentLastSelection())==null?void 0:g.primary,s=n.get(N.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(r);if(!c)return!1;const{workbook:m,worksheet:d,unitId:h,subUnitId:u}=c,p={workbook:m,worksheet:d,unitId:h,subUnitId:u,row:i.startRow,col:i.startColumn};e.showPopup(p);const S=s.getByLocation(h,u,i.startRow,i.startColumn);return S&&o.setActiveComment({unitId:h,subUnitId:u,commentId:S,trigger:"context-menu"}),!0}},Ce="sheets-thread-comment.config",re={};var Se=Object.getOwnPropertyDescriptor,_e=(n,t,r,e)=>{for(var o=e>1?void 0:e?Se(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},H=(n,t)=>(r,e)=>t(r,e,n);let W=class extends a.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(n,t,r)=>{const{row:e,col:o,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,o)?r({...n,markers:{...n==null?void 0:n.markers,tr:{color:"#FFBD37",size:6}}}):r(n)},priority:100}))}_initSkeletonChange(){const n=()=>{var o;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(o=e==null?void 0:e.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(V.debounceTime(16)).subscribe(()=>{n()}))}};W=_e([H(0,a.Inject(C.SheetInterceptorService)),H(1,a.Inject(N.SheetsThreadCommentModel)),H(2,a.IUniverInstanceService),H(3,oe.IRenderManagerService)],W);var ge=Object.getOwnPropertyDescriptor,fe=(n,t,r,e)=>{for(var o=e>1?void 0:e?ge(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},J=(n,t)=>(r,e)=>t(r,e,n);const Ie=(n,t,r)=>{const e=$.singleReferenceToGrid(n),o=r.row-t.row,i=r.column-t.column,s={startColumn:e.column+i,startRow:e.row+o,endColumn:e.column+i,endRow:e.row+o};return $.serializeRange(s)};let F=class extends a.Disposable{constructor(t,r,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:te,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,o)=>{const{unitId:i,subUnitId:s,range:c}=r,m={row:c.rows[0],column:c.cols[0]};if(o.copyType===T.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:h,subUnitId:u}=this._copyInfo,p={row:d.startRow,column:d.startColumn};if(!(i===h&&s===u)){const S=[];a.Range.foreach(d,(y,v)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(h,u,y,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(f=>{S.push(f)}):M.forEach(({children:f,...E})=>{E.parentId||S.push(E)})});const g=[],b=[],j=[],A=[],K=y=>{g.unshift({id:_.DeleteCommentMutation.id,params:{unitId:h,subUnitId:u,commentId:y.id}}),j.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:Ie(y.ref,p,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:h,subUnitId:u,comment:y,sync:!0}}),A.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return S.forEach(y=>{K(y)}),{redos:[...g,...j],undos:[...A,...b]}}}return{redos:[],undos:[]}}}))}};F=fe([J(0,a.Inject(T.ISheetClipboardService)),J(1,a.Inject(N.SheetsThreadCommentModel)),J(2,_.IThreadCommentDataSourceService)],F);var Pe=Object.getOwnPropertyDescriptor,Te=(n,t,r,e)=>{for(var o=e>1?void 0:e?Pe(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},B=(n,t)=>(r,e)=>t(r,e,n);let q=class extends a.Disposable{constructor(n,t,r,e){super(),this._hoverManagerService=n,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(V.debounceTime(100)).subscribe(n=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(n&&(t&&t.temp||!t)){const{location:r}=n,{unitId:e,subUnitId:o,row:i,col:s}=r,c=this._sheetsThreadCommentModel.getByLocation(e,o,i,s);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(e,o,c);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:o,row:i,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};q=Te([B(0,a.Inject(T.HoverManagerService)),B(1,a.Inject(exports.SheetsThreadCommentPopupService)),B(2,a.Inject(N.SheetsThreadCommentModel)),B(3,a.Inject(C.SheetPermissionCheckController))],q);var be=Object.getOwnPropertyDescriptor,ye=(n,t,r,e)=>{for(var o=e>1?void 0:e?be(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},R=(n,t)=>(r,e)=>t(r,e,n);let G=class extends a.Disposable{constructor(t,r,e,o,i,s,c,m,d,h){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=o,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=h,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var p,S,g;const o=(p=t[0])==null?void 0:p.range,i=this._renderManagerService.getRenderById(r),s=(S=i==null?void 0:i.with(T.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:S.skeleton;if(!s||!o)return;const c=s.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((g=o.rangeType)!=null?g:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,o))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=c.actualRow,h=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,d,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const u=this._sheetsThreadCommentModel.getByLocation(r,e,d,h);u&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:u})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.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 r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:o,subUnitId:i,commentId:s}=e;r.unitId===o&&r.subUnitId===i&&r.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:o,commentId:i,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,o,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=m.getActiveSheet())==null?void 0:r.getSheetId())!==o&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:o}),this._isSwitchToCommenting=!1;const u=$.singleReferenceToGrid(c.ref),{row:p,column:S}=u;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const b=1;if(await this._commandService.executeCommand(T.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-b,0),endRow:u.row+b,startColumn:Math.max(u.column-b,0),endColumn:u.column+b}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:o,row:u.row,col:u.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(V.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:o}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(r,e,o);if(!i)return;const s=$.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const d=(p=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),h=(S=d==null?void 0:d.getMergedCell(c,m))!=null?S:{startColumn:m,endColumn:m,startRow:c,endRow:c},u=this._markSelectionService.addShape({range:h,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);u&&(this._selectionShapeInfo={...t,shapeId:u})}))}};G=ye([R(0,a.ICommandService),R(1,a.Inject(exports.SheetsThreadCommentPopupService)),R(2,a.Inject(N.SheetsThreadCommentModel)),R(3,a.Inject(P.ThreadCommentPanelService)),R(4,a.IUniverInstanceService),R(5,a.Inject(C.SheetPermissionCheckController)),R(6,T.IMarkSelectionService),R(7,a.Inject(C.SheetsSelectionsService)),R(8,T.IEditorBridgeService),R(9,oe.IRenderManagerService)],G);var Me=Object.getOwnPropertyDescriptor,we=(n,t,r,e)=>{for(var o=e>1?void 0:e?Me(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},L=(n,t)=>(r,e)=>t(r,e,n);let Z=class extends a.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{var t;if(n.id===C.RemoveSheetCommand.id){const r=n.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const o=e.getUnitId(),i=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(o,i),c=Array.from(s.values()).filter(p=>!p.parentId),m=c.map(p=>p.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,h=m.map(p=>({id:_.DeleteCommentMutation.id,params:{unitId:o,subUnitId:i,commentId:p}})),u=c.map(({children:p,...S})=>({id:_.AddCommentMutation.id,params:{unitId:o,subUnitId:i,comment:{...S,children:d?p:void 0},sync:!d}}));return{redos:h,undos:u}}return{redos:[],undos:[]}}}))}};Z=we([L(0,a.Inject(C.SheetInterceptorService)),L(1,a.IUniverInstanceService),L(2,a.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],Z);var w=function(){return w=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},w.apply(this,arguments)},Ue=function(n,t){var r={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(r[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,e=Object.getOwnPropertySymbols(n);o<e.length;o++)t.indexOf(e[o])<0&&Object.prototype.propertyIsEnumerable.call(n,e[o])&&(r[e[o]]=n[e[o]]);return r},ae=O.forwardRef(function(n,t){var r=n.icon,e=n.id,o=n.className,i=n.extend,s=Ue(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(o||"").trim(),m=O.useRef("_".concat(Oe()));return ce(r,"".concat(e),{defIds:r.defIds,idSuffix:m.current},w({ref:t,className:c},s),i)});function ce(n,t,r,e,o){return O.createElement(n.tag,w(w({key:t},Ee(n,r,o)),e),(Re(n,r).children||[]).map(function(i,s){return ce(i,"".concat(t,"-").concat(n.tag,"-").concat(s),r,void 0,o)}))}function Ee(n,t,r){var e=w({},n.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1),n.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];s==="mask"&&typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(n.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 Re(n,t){var r,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?w(w({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&e&&e.indexOf(o.attrs.id)>-1?w(w({},o),{attrs:w(w({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):n}function Oe(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var ke={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"}}]},me=O.forwardRef(function(n,t){return O.createElement(ae,Object.assign({},n,{id:"comment-single",ref:t,icon:ke}))});me.displayName="CommentSingle";const De=()=>{const n=l.useDependency(a.IUniverInstanceService),t=l.useDependency(exports.SheetsThreadCommentPopupService),r=l.useObservable(t.activePopup$),e=l.useDependency(N.SheetsThreadCommentModel);if(l.useObservable(e.commentUpdate$),!r)return null;const{row:o,col:i,unitId:s,subUnitId:c,trigger:m}=r,d=e.getByLocation(s,c,o,i),h=`${a.Tools.chatAtABC(i)}${o+1}`,u=()=>{t.hidePopup()},p=S=>{var g,b,j;return(j=(b=(g=n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getSheetBySheetId(S))==null?void 0:b.getName())!=null?j:""};return ie.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:u,getSubUnitName:p,autoFocus:m==="context-menu"})},je=()=>{var y;const n=l.useDependency(T.IMarkSelectionService),t=l.useDependency(a.IUniverInstanceService),r=l.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=e.getUnitId(),i=l.useDependency(a.ICommandService),s=O.useMemo(()=>e.activeSheet$.pipe(V.map(v=>v==null?void 0:v.getSheetId())),[e.activeSheet$]),c=l.useObservable(s,(y=e.getActiveSheet())==null?void 0:y.getSheetId()),m=O.useRef(null),d=l.useDependency(P.ThreadCommentPanelService),h=l.useObservable(d.activeCommentId$),u=l.useObservable(d.panelVisible$,d.panelVisible),p=O.useCallback(v=>{const M=e.getSheets(),f={};M.forEach((U,I)=>{f[U.getSheetId()]=I});const E=U=>U.map(I=>{var ne;const k=$.singleReferenceToGrid(I.ref),ue=[(ne=f[I.subUnitId])!=null?ne:0,k.row,k.column];return{...I,p:ue}}).sort((I,k)=>I.p[0]===k.p[0]?I.p[1]===k.p[1]?I.p[2]-k.p[2]:I.p[1]-k.p[1]:I.p[0]-k.p[0]);return[...E(v.filter(U=>!U.resolved)),...E(v.filter(U=>U.resolved))]},[e]),S=O.useCallback(v=>{var M;if(v.unitId===o&&v.subUnitId===c&&!v.resolved){const{row:f,column:E}=$.singleReferenceToGrid(v.ref),U=e.getSheetBySheetId(v.subUnitId),I=(M=U==null?void 0:U.getMergedCell(f,E))!=null?M:{startColumn:E,endColumn:E,startRow:f,endRow:f};if(!Number.isNaN(f)&&!Number.isNaN(E))return n.addShape({range:I,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[n,c,o]),g=v=>{var M,f;return(f=(M=e.getSheetBySheetId(v))==null?void 0:M.getName())!=null?f:""},b=()=>{i.executeCommand(x.id)},j=v=>{h&&h.unitId===v.unitId&&h.subUnitId===v.subUnitId&&h.commentId===v.id||(m.current&&(n.removeShape(m.current),m.current=null),m.current=S(v))},A=()=>{m.current&&(n.removeShape(m.current),m.current=null)},K=(v,M)=>{M&&r.hidePopup()};return O.useEffect(()=>{!u&&m.current&&n.removeShape(m.current)},[n,u]),ie.jsx(P.ThreadCommentPanel,{unitId:o,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:g,onResolve:K,sortComments:p,onItemEnter:j,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},Ne=n=>({id:x.id,type:l.MenuItemType.BUTTON,icon:ee,title:"sheetThreadComment.menu.addComment",hidden$:l.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:T.getCurrentRangeDisable$(n,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),$e=n=>({id:P.ToggleSheetCommentPanelOperation.id,type:l.MenuItemType.BUTTON,icon:ee,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:T.getCurrentRangeDisable$(n,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:l.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}),xe={id:x.id,binding:l.KeyCode.M|l.MetaKeys.CTRL_COMMAND|l.MetaKeys.ALT,preconditions:T.whenSheetEditorFocused},Ae={[l.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:$e}},[l.ContextMenuPosition.MAIN_AREA]:{[l.ContextMenuGroup.OTHERS]:{[x.id]:{order:0,menuItemFactory:Ne}}}};var Ve=Object.getOwnPropertyDescriptor,He=(n,t,r,e)=>{for(var o=e>1?void 0:e?Ve(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},Q=(n,t)=>(r,e)=>t(r,e,n);let z=class extends a.Disposable{constructor(n,t,r){super(),this._menuManagerService=n,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(xe)}_initMenu(){this._menuManagerService.mergeMenu(Ae)}_initComponent(){[[se,De],[P.THREAD_COMMENT_PANEL,je],[ee,me]].forEach(([n,t])=>{this._componentManager.register(n,t)})}};z=He([Q(0,l.IMenuManagerService),Q(1,a.Inject(l.ComponentManager)),Q(2,l.IShortcutService)],z);var Be=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,We=(n,t,r)=>t in n?Be(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,Fe=(n,t,r,e)=>{for(var o=e>1?void 0:e?Le(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},X=(n,t)=>(r,e)=>t(r,e,n),de=(n,t,r)=>We(n,typeof t!="symbol"?t+"":t,r);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=re,r,e,o){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=o;const{menu:i,...s}=a.merge({},re,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ce,s)}onStarting(){[[z],[W],[F],[q],[Z],[G],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[x].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(z)}onReady(){this._injector.get(W),this._injector.get(Z)}onRendered(){this._injector.get(F),this._injector.get(q),this._injector.get(G)}};de(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",te);de(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=Fe([a.DependentOn(P.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),X(1,a.Inject(a.Injector)),X(2,a.Inject(a.ICommandService)),X(3,a.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.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=te;exports.ShowAddSheetCommentModalOperation=x;
1
+ "use strict";var ue=Object.defineProperty;var le=(n,t,r)=>t in n?ue(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var D=(n,t,r)=>le(n,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),N=require("@univerjs/sheets-thread-comment"),P=require("@univerjs/thread-comment-ui"),T=require("@univerjs/sheets-ui"),l=require("@univerjs/ui"),V=require("rxjs"),oe=require("@univerjs/engine-render"),$=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),ie=require("react/jsx-runtime"),O=require("react"),se="univer.sheet.thread-comment-modal",ee="comment-single",te="SHEET_THREAD_COMMENT";var pe=Object.getOwnPropertyDescriptor,ve=(n,t,r,e)=>{for(var o=e>1?void 0:e?pe(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},Y=(n,t)=>(r,e)=>t(r,e,n);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(r,e,o){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new V.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._cellPopupManagerService=o,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}showPopup(r,e){var u;const{row:o,col:i,unitId:s,subUnitId:c}=r;if(this._activePopup&&o===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((u=this.activePopup)==null?void 0:u.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const m=this._cellPopupManagerService.showPopup({row:o,col:i,unitId:s,subUnitId:c},{componentKey:se,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(m),d.add({dispose:()=>{e==null||e()}}),this._lastPopup=d}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=ve([Y(0,a.Inject(T.SheetCanvasPopManagerService)),Y(1,l.IZenZoneService),Y(2,a.Inject(T.CellPopupManagerService))],exports.SheetsThreadCommentPopupService);const x={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(n){var g;const t=n.get(C.SheetsSelectionsService),r=n.get(a.IUniverInstanceService),e=n.get(exports.SheetsThreadCommentPopupService),o=n.get(P.ThreadCommentPanelService),i=(g=t.getCurrentLastSelection())==null?void 0:g.primary,s=n.get(N.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(r);if(!c)return!1;const{workbook:m,worksheet:d,unitId:u,subUnitId:h}=c,p={workbook:m,worksheet:d,unitId:u,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(p);const S=s.getByLocation(u,h,i.startRow,i.startColumn);return S&&o.setActiveComment({unitId:u,subUnitId:h,commentId:S,trigger:"context-menu"}),!0}},Ce="sheets-thread-comment.config",re={};var Se=Object.getOwnPropertyDescriptor,_e=(n,t,r,e)=>{for(var o=e>1?void 0:e?Se(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},H=(n,t)=>(r,e)=>t(r,e,n);let W=class extends a.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(n,t,r)=>{const{row:e,col:o,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,o)?r({...n,markers:{...n==null?void 0:n.markers,tr:{color:"#FFBD37",size:6}}}):r(n)},priority:100}))}_initSkeletonChange(){const n=()=>{var o;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(o=e==null?void 0:e.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(V.debounceTime(16)).subscribe(()=>{n()}))}};W=_e([H(0,a.Inject(C.SheetInterceptorService)),H(1,a.Inject(N.SheetsThreadCommentModel)),H(2,a.IUniverInstanceService),H(3,oe.IRenderManagerService)],W);var ge=Object.getOwnPropertyDescriptor,fe=(n,t,r,e)=>{for(var o=e>1?void 0:e?ge(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},J=(n,t)=>(r,e)=>t(r,e,n);const Ie=(n,t,r)=>{const e=$.singleReferenceToGrid(n),o=r.row-t.row,i=r.column-t.column,s={startColumn:e.column+i,startRow:e.row+o,endColumn:e.column+i,endRow:e.row+o};return $.serializeRange(s)};let F=class extends a.Disposable{constructor(t,r,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:te,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,o)=>{const{unitId:i,subUnitId:s,range:c}=r,m={row:c.rows[0],column:c.cols[0]};if(o.copyType===T.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:u,subUnitId:h}=this._copyInfo,p={row:d.startRow,column:d.startColumn};if(!(i===u&&s===h)){const S=[];a.Range.foreach(d,(y,v)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(u,h,y,v);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(f=>{S.push(f)}):M.forEach(({children:f,...E})=>{E.parentId||S.push(E)})});const g=[],b=[],j=[],A=[],K=y=>{g.unshift({id:_.DeleteCommentMutation.id,params:{unitId:u,subUnitId:h,commentId:y.id}}),j.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:Ie(y.ref,p,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:u,subUnitId:h,comment:y,sync:!0}}),A.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return S.forEach(y=>{K(y)}),{redos:[...g,...j],undos:[...A,...b]}}}return{redos:[],undos:[]}}}))}};F=fe([J(0,a.Inject(T.ISheetClipboardService)),J(1,a.Inject(N.SheetsThreadCommentModel)),J(2,_.IThreadCommentDataSourceService)],F);var Pe=Object.getOwnPropertyDescriptor,Te=(n,t,r,e)=>{for(var o=e>1?void 0:e?Pe(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},B=(n,t)=>(r,e)=>t(r,e,n);let q=class extends a.Disposable{constructor(n,t,r,e){super(),this._hoverManagerService=n,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(V.debounceTime(100)).subscribe(n=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(n&&(t&&t.temp||!t)){const{location:r}=n,{unitId:e,subUnitId:o,row:i,col:s}=r,c=this._sheetsThreadCommentModel.getByLocation(e,o,i,s);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(e,o,c);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:o,row:i,col:s,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};q=Te([B(0,a.Inject(T.HoverManagerService)),B(1,a.Inject(exports.SheetsThreadCommentPopupService)),B(2,a.Inject(N.SheetsThreadCommentModel)),B(3,a.Inject(C.SheetPermissionCheckController))],q);var be=Object.getOwnPropertyDescriptor,ye=(n,t,r,e)=>{for(var o=e>1?void 0:e?be(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},R=(n,t)=>(r,e)=>t(r,e,n);let G=class extends a.Disposable{constructor(t,r,e,o,i,s,c,m,d,u){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=o,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=u,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var p,S,g;const o=(p=t[0])==null?void 0:p.range,i=this._renderManagerService.getRenderById(r),s=(S=i==null?void 0:i.with(T.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:S.skeleton;if(!s||!o)return;const c=s.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((g=o.rangeType)!=null?g:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,o))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=c.actualRow,u=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,d,u)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,d,u);h&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.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 r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:o,subUnitId:i,commentId:s}=e;r.unitId===o&&r.subUnitId===i&&r.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:o,commentId:i,trigger:s}=t,c=this._sheetsThreadCommentModel.getComment(e,o,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=m.getActiveSheet())==null?void 0:r.getSheetId())!==o&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:o}),this._isSwitchToCommenting=!1;const h=$.singleReferenceToGrid(c.ref),{row:p,column:S}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:S,endRow:p,endColumn:S}]))return;const b=1;if(await this._commandService.executeCommand(T.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:o,row:h.row,col:h.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(V.debounceTime(100)).subscribe(t=>{var p,S;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:o}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(r,e,o);if(!i)return;const s=$.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const d=(p=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getSheetBySheetId(e),u=(S=d==null?void 0:d.getMergedCell(c,m))!=null?S:{startColumn:m,endColumn:m,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:u,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};G=ye([R(0,a.ICommandService),R(1,a.Inject(exports.SheetsThreadCommentPopupService)),R(2,a.Inject(N.SheetsThreadCommentModel)),R(3,a.Inject(P.ThreadCommentPanelService)),R(4,a.IUniverInstanceService),R(5,a.Inject(C.SheetPermissionCheckController)),R(6,T.IMarkSelectionService),R(7,a.Inject(C.SheetsSelectionsService)),R(8,T.IEditorBridgeService),R(9,oe.IRenderManagerService)],G);var Me=Object.getOwnPropertyDescriptor,we=(n,t,r,e)=>{for(var o=e>1?void 0:e?Me(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},L=(n,t)=>(r,e)=>t(r,e,n);let Z=class extends a.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{var t;if(n.id===C.RemoveSheetCommand.id){const r=n.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const o=e.getUnitId(),i=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(o,i),c=Array.from(s.values()).filter(p=>!p.parentId),m=c.map(p=>p.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=m.map(p=>({id:_.DeleteCommentMutation.id,params:{unitId:o,subUnitId:i,commentId:p}})),h=c.map(({children:p,...S})=>({id:_.AddCommentMutation.id,params:{unitId:o,subUnitId:i,comment:{...S,children:d?p:void 0},sync:!d}}));return{redos:u,undos:h}}return{redos:[],undos:[]}}}))}};Z=we([L(0,a.Inject(C.SheetInterceptorService)),L(1,a.IUniverInstanceService),L(2,a.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],Z);var w=function(){return w=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},w.apply(this,arguments)},Ue=function(n,t){var r={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(r[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,e=Object.getOwnPropertySymbols(n);o<e.length;o++)t.indexOf(e[o])<0&&Object.prototype.propertyIsEnumerable.call(n,e[o])&&(r[e[o]]=n[e[o]]);return r},ae=O.forwardRef(function(n,t){var r=n.icon,e=n.id,o=n.className,i=n.extend,s=Ue(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(o||"").trim(),m=O.useRef("_".concat(Oe()));return ce(r,"".concat(e),{defIds:r.defIds,idSuffix:m.current},w({ref:t,className:c},s),i)});function ce(n,t,r,e,o){return O.createElement(n.tag,w(w({key:t},Ee(n,r,o)),e),(Re(n,r).children||[]).map(function(i,s){return ce(i,"".concat(t,"-").concat(n.tag,"-").concat(s),r,void 0,o)}))}function Ee(n,t,r){var e=w({},n.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1),n.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];s==="mask"&&typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(n.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 Re(n,t){var r,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?w(w({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&e&&e.indexOf(o.attrs.id)>-1?w(w({},o),{attrs:w(w({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):n}function Oe(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var ke={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"}}]},me=O.forwardRef(function(n,t){return O.createElement(ae,Object.assign({},n,{id:"comment-single",ref:t,icon:ke}))});me.displayName="CommentSingle";const De=()=>{const n=l.useDependency(a.IUniverInstanceService),t=l.useDependency(exports.SheetsThreadCommentPopupService),r=l.useObservable(t.activePopup$),e=l.useDependency(N.SheetsThreadCommentModel);if(l.useObservable(e.commentUpdate$),!r)return null;const{row:o,col:i,unitId:s,subUnitId:c,trigger:m}=r,d=e.getByLocation(s,c,o,i),u=`${a.Tools.chatAtABC(i)}${o+1}`,h=()=>{t.hidePopup()},p=S=>{var g,b,j;return(j=(b=(g=n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getSheetBySheetId(S))==null?void 0:b.getName())!=null?j:""};return ie.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:u,onClose:h,getSubUnitName:p,autoFocus:m==="context-menu"})},je=()=>{var y;const n=l.useDependency(T.IMarkSelectionService),t=l.useDependency(a.IUniverInstanceService),r=l.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=e.getUnitId(),i=l.useDependency(a.ICommandService),s=O.useMemo(()=>e.activeSheet$.pipe(V.map(v=>v==null?void 0:v.getSheetId())),[e.activeSheet$]),c=l.useObservable(s,(y=e.getActiveSheet())==null?void 0:y.getSheetId()),m=O.useRef(null),d=l.useDependency(P.ThreadCommentPanelService),u=l.useObservable(d.activeCommentId$),h=l.useObservable(d.panelVisible$,d.panelVisible),p=O.useCallback(v=>{const M=e.getSheets(),f={};M.forEach((U,I)=>{f[U.getSheetId()]=I});const E=U=>U.map(I=>{var ne;const k=$.singleReferenceToGrid(I.ref),he=[(ne=f[I.subUnitId])!=null?ne:0,k.row,k.column];return{...I,p:he}}).sort((I,k)=>I.p[0]===k.p[0]?I.p[1]===k.p[1]?I.p[2]-k.p[2]:I.p[1]-k.p[1]:I.p[0]-k.p[0]);return[...E(v.filter(U=>!U.resolved)),...E(v.filter(U=>U.resolved))]},[e]),S=O.useCallback(v=>{var M;if(v.unitId===o&&v.subUnitId===c&&!v.resolved){const{row:f,column:E}=$.singleReferenceToGrid(v.ref),U=e.getSheetBySheetId(v.subUnitId),I=(M=U==null?void 0:U.getMergedCell(f,E))!=null?M:{startColumn:E,endColumn:E,startRow:f,endRow:f};if(!Number.isNaN(f)&&!Number.isNaN(E))return n.addShape({range:I,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[n,c,o]),g=v=>{var M,f;return(f=(M=e.getSheetBySheetId(v))==null?void 0:M.getName())!=null?f:""},b=()=>{i.executeCommand(x.id)},j=v=>{u&&u.unitId===v.unitId&&u.subUnitId===v.subUnitId&&u.commentId===v.id||(m.current&&(n.removeShape(m.current),m.current=null),m.current=S(v))},A=()=>{m.current&&(n.removeShape(m.current),m.current=null)},K=(v,M)=>{M&&r.hidePopup()};return O.useEffect(()=>{!h&&m.current&&n.removeShape(m.current)},[n,h]),ie.jsx(P.ThreadCommentPanel,{unitId:o,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:g,onResolve:K,sortComments:p,onItemEnter:j,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},Ne=n=>({id:x.id,type:l.MenuItemType.BUTTON,icon:ee,title:"sheetThreadComment.menu.addComment",hidden$:l.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:T.getCurrentRangeDisable$(n,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),$e=n=>({id:P.ToggleSheetCommentPanelOperation.id,type:l.MenuItemType.BUTTON,icon:ee,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:T.getCurrentRangeDisable$(n,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:l.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}),xe={id:x.id,binding:l.KeyCode.M|l.MetaKeys.CTRL_COMMAND|l.MetaKeys.ALT,preconditions:T.whenSheetEditorFocused},Ae={[l.RibbonInsertGroup.MEDIA]:{[P.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:$e}},[l.ContextMenuPosition.MAIN_AREA]:{[l.ContextMenuGroup.OTHERS]:{[x.id]:{order:0,menuItemFactory:Ne}}}};var Ve=Object.getOwnPropertyDescriptor,He=(n,t,r,e)=>{for(var o=e>1?void 0:e?Ve(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},Q=(n,t)=>(r,e)=>t(r,e,n);let z=class extends a.Disposable{constructor(n,t,r){super(),this._menuManagerService=n,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(xe)}_initMenu(){this._menuManagerService.mergeMenu(Ae)}_initComponent(){[[se,De],[P.THREAD_COMMENT_PANEL,je],[ee,me]].forEach(([n,t])=>{this.disposeWithMe(this._componentManager.register(n,t))})}};z=He([Q(0,l.IMenuManagerService),Q(1,a.Inject(l.ComponentManager)),Q(2,l.IShortcutService)],z);var Be=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,We=(n,t,r)=>t in n?Be(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,Fe=(n,t,r,e)=>{for(var o=e>1?void 0:e?Le(t,r):t,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=s(o)||o);return o},X=(n,t)=>(r,e)=>t(r,e,n),de=(n,t,r)=>We(n,typeof t!="symbol"?t+"":t,r);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=re,r,e,o){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=o;const{menu:i,...s}=a.merge({},re,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ce,s)}onStarting(){[[z],[W],[F],[q],[Z],[G],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[x].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(z)}onReady(){this._injector.get(W),this._injector.get(Z)}onRendered(){this._injector.get(F),this._injector.get(q),this._injector.get(G)}};de(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",te);de(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=Fe([a.DependentOn(P.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),X(1,a.Inject(a.Injector)),X(2,a.Inject(a.ICommandService)),X(3,a.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.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=te;exports.ShowAddSheetCommentModalOperation=x;
package/lib/es/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  var De = Object.defineProperty;
2
2
  var Ae = (n, e, r) => e in n ? De(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r;
3
3
  var E = (n, e, r) => Ae(n, typeof e != "symbol" ? e + "" : e, r);
4
- import { Inject as v, Disposable as k, DisposableCollection as Ve, CommandType as He, IUniverInstanceService as N, InterceptorEffectEnum as je, UniverInstanceType as b, Range as Be, ICommandService as se, RANGE_TYPE as me, Rectangle as Le, Tools as Fe, DependentOn as We, Injector as Ze, IConfigService as ze, Plugin as Ge, merge as Ke } from "@univerjs/core";
4
+ import { Inject as v, Disposable as k, DisposableCollection as Ve, CommandType as je, IUniverInstanceService as N, InterceptorEffectEnum as He, UniverInstanceType as b, Range as Be, ICommandService as se, RANGE_TYPE as me, Rectangle as Le, Tools as Fe, DependentOn as We, Injector as Ze, IConfigService as ze, Plugin as Ge, merge as Ke } from "@univerjs/core";
5
5
  import { SheetsSelectionsService as ve, getSheetCommandTarget as Ye, SheetInterceptorService as _e, INTERCEPTOR_POINT as qe, SheetPermissionCheckController as Ce, RangeProtectionPermissionViewPoint as q, WorksheetViewPermission as J, WorkbookCommentPermission as Q, SetWorksheetActiveOperation as Je, RemoveSheetCommand as Qe } from "@univerjs/sheets";
6
6
  import { SheetsThreadCommentModel as $, UniverSheetsThreadCommentPlugin as Xe } from "@univerjs/sheets-thread-comment";
7
7
  import { ThreadCommentPanelService as ae, SetActiveCommentOperation as ee, ThreadCommentTree as et, ThreadCommentPanel as tt, ToggleSheetCommentPanelOperation as Se, THREAD_COMMENT_PANEL as nt, UniverThreadCommentUIPlugin as rt } from "@univerjs/thread-comment-ui";
8
8
  import { UniverThreadCommentUIPlugin as gn } from "@univerjs/thread-comment-ui";
9
9
  import { SheetCanvasPopManagerService as ot, CellPopupManagerService as it, ISheetClipboardService as st, COPY_TYPE as at, HoverManagerService as ct, IMarkSelectionService as fe, IEditorBridgeService as dt, SheetSkeletonManagerService as ht, ScrollToRangeOperation as mt, whenSheetEditorFocused as ut, getCurrentRangeDisable$ as ge } from "@univerjs/sheets-ui";
10
- import { IZenZoneService as lt, useDependency as U, useObservable as D, KeyCode as pt, MetaKeys as ue, getMenuHiddenObservable as Ie, MenuItemType as Pe, ContextMenuPosition as vt, ContextMenuGroup as _t, RibbonStartGroup as Ct, IMenuManagerService as St, ComponentManager as ft, IShortcutService as gt } from "@univerjs/ui";
10
+ import { IZenZoneService as lt, useDependency as U, useObservable as D, KeyCode as pt, MetaKeys as ue, getMenuHiddenObservable as Ie, MenuItemType as Pe, ContextMenuPosition as vt, ContextMenuGroup as _t, RibbonInsertGroup as Ct, IMenuManagerService as St, ComponentManager as ft, IShortcutService as gt } from "@univerjs/ui";
11
11
  import { BehaviorSubject as It, debounceTime as ce, map as Pt } from "rxjs";
12
12
  import { IRenderManagerService as Te } from "@univerjs/engine-render";
13
13
  import { singleReferenceToGrid as A, serializeRange as Tt } from "@univerjs/engine-formula";
@@ -95,7 +95,7 @@ R = Et([
95
95
  te(2, v(it))
96
96
  ], R);
97
97
  const V = {
98
- type: He.OPERATION,
98
+ type: je.OPERATION,
99
99
  id: "sheets.operation.show-comment-modal",
100
100
  handler(n) {
101
101
  var _;
@@ -127,7 +127,7 @@ var Rt = Object.getOwnPropertyDescriptor, Ot = (n, e, r, t) => {
127
127
  for (var o = t > 1 ? void 0 : t ? Rt(e, r) : e, i = n.length - 1, s; i >= 0; i--)
128
128
  (s = n[i]) && (o = s(o) || o);
129
129
  return o;
130
- }, H = (n, e) => (r, t) => e(r, t, n);
130
+ }, j = (n, e) => (r, t) => e(r, t, n);
131
131
  let F = class extends k {
132
132
  constructor(n, e, r, t) {
133
133
  super(), this._sheetInterceptorService = n, this._sheetsThreadCommentModel = e, this._univerInstanceService = r, this._renderManagerService = t, this._initViewModelIntercept(), this._initSkeletonChange();
@@ -137,7 +137,7 @@ let F = class extends k {
137
137
  this._sheetInterceptorService.intercept(
138
138
  qe.CELL_CONTENT,
139
139
  {
140
- effect: je.Style,
140
+ effect: He.Style,
141
141
  handler: (n, e, r) => {
142
142
  const { row: t, col: o, unitId: i, subUnitId: s } = e;
143
143
  return this._sheetsThreadCommentModel.showCommentMarker(i, s, t, o) ? r({
@@ -170,10 +170,10 @@ let F = class extends k {
170
170
  }
171
171
  };
172
172
  F = Ot([
173
- H(0, v(_e)),
174
- H(1, v($)),
175
- H(2, N),
176
- H(3, Te)
173
+ j(0, v(_e)),
174
+ j(1, v($)),
175
+ j(2, N),
176
+ j(3, Te)
177
177
  ], F);
178
178
  var kt = Object.getOwnPropertyDescriptor, Nt = (n, e, r, t) => {
179
179
  for (var o = t > 1 ? void 0 : t ? kt(e, r) : e, i = n.length - 1, s; i >= 0; i--)
@@ -292,7 +292,7 @@ var xt = Object.getOwnPropertyDescriptor, Dt = (n, e, r, t) => {
292
292
  for (var o = t > 1 ? void 0 : t ? xt(e, r) : e, i = n.length - 1, s; i >= 0; i--)
293
293
  (s = n[i]) && (o = s(o) || o);
294
294
  return o;
295
- }, j = (n, e) => (r, t) => e(r, t, n);
295
+ }, H = (n, e) => (r, t) => e(r, t, n);
296
296
  let Z = class extends k {
297
297
  constructor(n, e, r, t) {
298
298
  super(), this._hoverManagerService = n, this._sheetsThreadCommentPopupService = e, this._sheetsThreadCommentModel = r, this._sheetPermissionCheckController = t, this._initHoverEvent();
@@ -327,10 +327,10 @@ let Z = class extends k {
327
327
  }
328
328
  };
329
329
  Z = Dt([
330
- j(0, v(ct)),
331
- j(1, v(R)),
332
- j(2, v($)),
333
- j(3, v(Ce))
330
+ H(0, v(ct)),
331
+ H(1, v(R)),
332
+ H(2, v($)),
333
+ H(3, v(Ce))
334
334
  ], Z);
335
335
  var At = Object.getOwnPropertyDescriptor, Vt = (n, e, r, t) => {
336
336
  for (var o = t > 1 ? void 0 : t ? At(e, r) : e, i = n.length - 1, s; i >= 0; i--)
@@ -491,8 +491,8 @@ z = Vt([
491
491
  w(8, dt),
492
492
  w(9, Te)
493
493
  ], z);
494
- var Ht = Object.getOwnPropertyDescriptor, jt = (n, e, r, t) => {
495
- for (var o = t > 1 ? void 0 : t ? Ht(e, r) : e, i = n.length - 1, s; i >= 0; i--)
494
+ var jt = Object.getOwnPropertyDescriptor, Ht = (n, e, r, t) => {
495
+ for (var o = t > 1 ? void 0 : t ? jt(e, r) : e, i = n.length - 1, s; i >= 0; i--)
496
496
  (s = n[i]) && (o = s(o) || o);
497
497
  return o;
498
498
  }, B = (n, e) => (r, t) => e(r, t, n);
@@ -539,7 +539,7 @@ let G = class extends k {
539
539
  );
540
540
  }
541
541
  };
542
- G = jt([
542
+ G = Ht([
543
543
  B(0, v(_e)),
544
544
  B(1, N),
545
545
  B(2, v(bt)),
@@ -721,9 +721,9 @@ const zt = () => {
721
721
  binding: pt.M | ue.CTRL_COMMAND | ue.ALT,
722
722
  preconditions: ut
723
723
  }, Jt = {
724
- [Ct.OTHERS]: {
724
+ [Ct.MEDIA]: {
725
725
  [Se.id]: {
726
- order: 1,
726
+ order: 2,
727
727
  menuItemFactory: Yt
728
728
  }
729
729
  },
@@ -757,7 +757,9 @@ let K = class extends k {
757
757
  [nt, Gt],
758
758
  [de, Ne]
759
759
  ].forEach(([n, e]) => {
760
- this._componentManager.register(n, e);
760
+ this.disposeWithMe(
761
+ this._componentManager.register(n, e)
762
+ );
761
763
  });
762
764
  }
763
765
  };
package/lib/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  var De = Object.defineProperty;
2
2
  var Ae = (n, e, r) => e in n ? De(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r;
3
3
  var E = (n, e, r) => Ae(n, typeof e != "symbol" ? e + "" : e, r);
4
- import { Inject as v, Disposable as k, DisposableCollection as Ve, CommandType as He, IUniverInstanceService as N, InterceptorEffectEnum as je, UniverInstanceType as b, Range as Be, ICommandService as se, RANGE_TYPE as me, Rectangle as Le, Tools as Fe, DependentOn as We, Injector as Ze, IConfigService as ze, Plugin as Ge, merge as Ke } from "@univerjs/core";
4
+ import { Inject as v, Disposable as k, DisposableCollection as Ve, CommandType as je, IUniverInstanceService as N, InterceptorEffectEnum as He, UniverInstanceType as b, Range as Be, ICommandService as se, RANGE_TYPE as me, Rectangle as Le, Tools as Fe, DependentOn as We, Injector as Ze, IConfigService as ze, Plugin as Ge, merge as Ke } from "@univerjs/core";
5
5
  import { SheetsSelectionsService as ve, getSheetCommandTarget as Ye, SheetInterceptorService as _e, INTERCEPTOR_POINT as qe, SheetPermissionCheckController as Ce, RangeProtectionPermissionViewPoint as q, WorksheetViewPermission as J, WorkbookCommentPermission as Q, SetWorksheetActiveOperation as Je, RemoveSheetCommand as Qe } from "@univerjs/sheets";
6
6
  import { SheetsThreadCommentModel as $, UniverSheetsThreadCommentPlugin as Xe } from "@univerjs/sheets-thread-comment";
7
7
  import { ThreadCommentPanelService as ae, SetActiveCommentOperation as ee, ThreadCommentTree as et, ThreadCommentPanel as tt, ToggleSheetCommentPanelOperation as Se, THREAD_COMMENT_PANEL as nt, UniverThreadCommentUIPlugin as rt } from "@univerjs/thread-comment-ui";
8
8
  import { UniverThreadCommentUIPlugin as gn } from "@univerjs/thread-comment-ui";
9
9
  import { SheetCanvasPopManagerService as ot, CellPopupManagerService as it, ISheetClipboardService as st, COPY_TYPE as at, HoverManagerService as ct, IMarkSelectionService as fe, IEditorBridgeService as dt, SheetSkeletonManagerService as ht, ScrollToRangeOperation as mt, whenSheetEditorFocused as ut, getCurrentRangeDisable$ as ge } from "@univerjs/sheets-ui";
10
- import { IZenZoneService as lt, useDependency as U, useObservable as D, KeyCode as pt, MetaKeys as ue, getMenuHiddenObservable as Ie, MenuItemType as Pe, ContextMenuPosition as vt, ContextMenuGroup as _t, RibbonStartGroup as Ct, IMenuManagerService as St, ComponentManager as ft, IShortcutService as gt } from "@univerjs/ui";
10
+ import { IZenZoneService as lt, useDependency as U, useObservable as D, KeyCode as pt, MetaKeys as ue, getMenuHiddenObservable as Ie, MenuItemType as Pe, ContextMenuPosition as vt, ContextMenuGroup as _t, RibbonInsertGroup as Ct, IMenuManagerService as St, ComponentManager as ft, IShortcutService as gt } from "@univerjs/ui";
11
11
  import { BehaviorSubject as It, debounceTime as ce, map as Pt } from "rxjs";
12
12
  import { IRenderManagerService as Te } from "@univerjs/engine-render";
13
13
  import { singleReferenceToGrid as A, serializeRange as Tt } from "@univerjs/engine-formula";
@@ -95,7 +95,7 @@ R = Et([
95
95
  te(2, v(it))
96
96
  ], R);
97
97
  const V = {
98
- type: He.OPERATION,
98
+ type: je.OPERATION,
99
99
  id: "sheets.operation.show-comment-modal",
100
100
  handler(n) {
101
101
  var _;
@@ -127,7 +127,7 @@ var Rt = Object.getOwnPropertyDescriptor, Ot = (n, e, r, t) => {
127
127
  for (var o = t > 1 ? void 0 : t ? Rt(e, r) : e, i = n.length - 1, s; i >= 0; i--)
128
128
  (s = n[i]) && (o = s(o) || o);
129
129
  return o;
130
- }, H = (n, e) => (r, t) => e(r, t, n);
130
+ }, j = (n, e) => (r, t) => e(r, t, n);
131
131
  let F = class extends k {
132
132
  constructor(n, e, r, t) {
133
133
  super(), this._sheetInterceptorService = n, this._sheetsThreadCommentModel = e, this._univerInstanceService = r, this._renderManagerService = t, this._initViewModelIntercept(), this._initSkeletonChange();
@@ -137,7 +137,7 @@ let F = class extends k {
137
137
  this._sheetInterceptorService.intercept(
138
138
  qe.CELL_CONTENT,
139
139
  {
140
- effect: je.Style,
140
+ effect: He.Style,
141
141
  handler: (n, e, r) => {
142
142
  const { row: t, col: o, unitId: i, subUnitId: s } = e;
143
143
  return this._sheetsThreadCommentModel.showCommentMarker(i, s, t, o) ? r({
@@ -170,10 +170,10 @@ let F = class extends k {
170
170
  }
171
171
  };
172
172
  F = Ot([
173
- H(0, v(_e)),
174
- H(1, v($)),
175
- H(2, N),
176
- H(3, Te)
173
+ j(0, v(_e)),
174
+ j(1, v($)),
175
+ j(2, N),
176
+ j(3, Te)
177
177
  ], F);
178
178
  var kt = Object.getOwnPropertyDescriptor, Nt = (n, e, r, t) => {
179
179
  for (var o = t > 1 ? void 0 : t ? kt(e, r) : e, i = n.length - 1, s; i >= 0; i--)
@@ -292,7 +292,7 @@ var xt = Object.getOwnPropertyDescriptor, Dt = (n, e, r, t) => {
292
292
  for (var o = t > 1 ? void 0 : t ? xt(e, r) : e, i = n.length - 1, s; i >= 0; i--)
293
293
  (s = n[i]) && (o = s(o) || o);
294
294
  return o;
295
- }, j = (n, e) => (r, t) => e(r, t, n);
295
+ }, H = (n, e) => (r, t) => e(r, t, n);
296
296
  let Z = class extends k {
297
297
  constructor(n, e, r, t) {
298
298
  super(), this._hoverManagerService = n, this._sheetsThreadCommentPopupService = e, this._sheetsThreadCommentModel = r, this._sheetPermissionCheckController = t, this._initHoverEvent();
@@ -327,10 +327,10 @@ let Z = class extends k {
327
327
  }
328
328
  };
329
329
  Z = Dt([
330
- j(0, v(ct)),
331
- j(1, v(R)),
332
- j(2, v($)),
333
- j(3, v(Ce))
330
+ H(0, v(ct)),
331
+ H(1, v(R)),
332
+ H(2, v($)),
333
+ H(3, v(Ce))
334
334
  ], Z);
335
335
  var At = Object.getOwnPropertyDescriptor, Vt = (n, e, r, t) => {
336
336
  for (var o = t > 1 ? void 0 : t ? At(e, r) : e, i = n.length - 1, s; i >= 0; i--)
@@ -491,8 +491,8 @@ z = Vt([
491
491
  w(8, dt),
492
492
  w(9, Te)
493
493
  ], z);
494
- var Ht = Object.getOwnPropertyDescriptor, jt = (n, e, r, t) => {
495
- for (var o = t > 1 ? void 0 : t ? Ht(e, r) : e, i = n.length - 1, s; i >= 0; i--)
494
+ var jt = Object.getOwnPropertyDescriptor, Ht = (n, e, r, t) => {
495
+ for (var o = t > 1 ? void 0 : t ? jt(e, r) : e, i = n.length - 1, s; i >= 0; i--)
496
496
  (s = n[i]) && (o = s(o) || o);
497
497
  return o;
498
498
  }, B = (n, e) => (r, t) => e(r, t, n);
@@ -539,7 +539,7 @@ let G = class extends k {
539
539
  );
540
540
  }
541
541
  };
542
- G = jt([
542
+ G = Ht([
543
543
  B(0, v(_e)),
544
544
  B(1, N),
545
545
  B(2, v(bt)),
@@ -721,9 +721,9 @@ const zt = () => {
721
721
  binding: pt.M | ue.CTRL_COMMAND | ue.ALT,
722
722
  preconditions: ut
723
723
  }, Jt = {
724
- [Ct.OTHERS]: {
724
+ [Ct.MEDIA]: {
725
725
  [Se.id]: {
726
- order: 1,
726
+ order: 2,
727
727
  menuItemFactory: Yt
728
728
  }
729
729
  },
@@ -757,7 +757,9 @@ let K = class extends k {
757
757
  [nt, Gt],
758
758
  [de, Ne]
759
759
  ].forEach(([n, e]) => {
760
- this._componentManager.register(n, e);
760
+ this.disposeWithMe(
761
+ this._componentManager.register(n, e)
762
+ );
761
763
  });
762
764
  }
763
765
  };
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
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/jsx-runtime"),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/jsx-runtime","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,d.React))})(this,function(d,s,p,N,I,P,v,H,re,A,f,ie,O){"use strict";var Fe=Object.defineProperty;var qe=(d,s,p)=>s in d?Fe(d,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):d[s]=p;var D=(d,s,p)=>qe(d,typeof s!="symbol"?s+"":s,p);const oe="univer.sheet.thread-comment-modal",Y="comment-single",J="SHEET_THREAD_COMMENT";var he=Object.getOwnPropertyDescriptor,le=(n,t,r,e)=>{for(var i=e>1?void 0:e?he(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},Q=(n,t)=>(r,e)=>t(r,e,n);d.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(r,e,i){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new H.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}showPopup(r,e){var l;const{row:i,col:o,unitId:a,subUnitId:c}=r;if(this._activePopup&&i===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const u=this._cellPopupManagerService.showPopup({row:i,col:o,unitId:a,subUnitId:c},{componentKey:oe,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const m=new s.DisposableCollection;m.add(u),m.add({dispose:()=>{e==null||e()}}),this._lastPopup=m}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=le([Q(0,s.Inject(P.SheetCanvasPopManagerService)),Q(1,v.IZenZoneService),Q(2,s.Inject(P.CellPopupManagerService))],d.SheetsThreadCommentPopupService);const V={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(n){var g;const t=n.get(p.SheetsSelectionsService),r=n.get(s.IUniverInstanceService),e=n.get(d.SheetsThreadCommentPopupService),i=n.get(I.ThreadCommentPanelService),o=(g=t.getCurrentLastSelection())==null?void 0:g.primary,a=n.get(N.SheetsThreadCommentModel);if(!o)return!1;const c=p.getSheetCommandTarget(r);if(!c)return!1;const{workbook:u,worksheet:m,unitId:l,subUnitId:h}=c,S={workbook:u,worksheet:m,unitId:l,subUnitId:h,row:o.startRow,col:o.startColumn};e.showPopup(S);const _=a.getByLocation(l,h,o.startRow,o.startColumn);return _&&i.setActiveComment({unitId:l,subUnitId:h,commentId:_,trigger:"context-menu"}),!0}},pe="sheets-thread-comment.config",se={};var ve=Object.getOwnPropertyDescriptor,Se=(n,t,r,e)=>{for(var i=e>1?void 0:e?ve(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},L=(n,t)=>(r,e)=>t(r,e,n);let W=class extends s.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(n,t,r)=>{const{row:e,col:i,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,i)?r({...n,markers:{...n==null?void 0:n.markers,tr:{color:"#FFBD37",size:6}}}):r(n)},priority:100}))}_initSkeletonChange(){const n=()=>{var i;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(i=e==null?void 0:e.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(H.debounceTime(16)).subscribe(()=>{n()}))}};W=Se([L(0,s.Inject(p.SheetInterceptorService)),L(1,s.Inject(N.SheetsThreadCommentModel)),L(2,s.IUniverInstanceService),L(3,re.IRenderManagerService)],W);var Ce=Object.getOwnPropertyDescriptor,_e=(n,t,r,e)=>{for(var i=e>1?void 0:e?Ce(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},X=(n,t)=>(r,e)=>t(r,e,n);const fe=(n,t,r)=>{const e=A.singleReferenceToGrid(n),i=r.row-t.row,o=r.column-t.column,a={startColumn:e.column+o,startRow:e.row+i,endColumn:e.column+o,endRow:e.row+i};return A.serializeRange(a)};let x=class extends s.Disposable{constructor(t,r,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:J,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,i)=>{const{unitId:o,subUnitId:a,range:c}=r,u={row:c.rows[0],column:c.cols[0]};if(i.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,S={row:m.startRow,column:m.startColumn};if(!(o===l&&a===h)){const _=[];s.Range.foreach(m,(w,C)=>{const E=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,C);this._threadCommentDataSourceService.syncUpdateMutationToColla?E.forEach(T=>{_.push(T)}):E.forEach(({children:T,...j})=>{j.parentId||_.push(j)})});const g=[],M=[],$=[],B=[],ne=w=>{g.unshift({id:f.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),$.push({id:f.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:fe(w.ref,S,u),unitId:o,subUnitId:a},sync:!0}}),M.push({id:f.AddCommentMutation.id,params:{unitId:l,subUnitId:h,comment:w,sync:!0}}),B.unshift({id:f.DeleteCommentMutation.id,params:{unitId:o,subUnitId:a,commentId:w.id}})};return _.forEach(w=>{ne(w)}),{redos:[...g,...$],undos:[...B,...M]}}}return{redos:[],undos:[]}}}))}};x=_e([X(0,s.Inject(P.ISheetClipboardService)),X(1,s.Inject(N.SheetsThreadCommentModel)),X(2,f.IThreadCommentDataSourceService)],x);var ge=Object.getOwnPropertyDescriptor,Ie=(n,t,r,e)=>{for(var i=e>1?void 0:e?ge(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},F=(n,t)=>(r,e)=>t(r,e,n);let q=class extends s.Disposable{constructor(n,t,r,e){super(),this._hoverManagerService=n,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.debounceTime(100)).subscribe(n=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(n&&(t&&t.temp||!t)){const{location:r}=n,{unitId:e,subUnitId:i,row:o,col:a}=r,c=this._sheetsThreadCommentModel.getByLocation(e,i,o,a);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:a,endRow:o,endColumn:a}]))return;const m=this._sheetsThreadCommentModel.getComment(e,i,c);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:o,col:a,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};q=Ie([F(0,s.Inject(P.HoverManagerService)),F(1,s.Inject(d.SheetsThreadCommentPopupService)),F(2,s.Inject(N.SheetsThreadCommentModel)),F(3,s.Inject(p.SheetPermissionCheckController))],q);var Pe=Object.getOwnPropertyDescriptor,Te=(n,t,r,e)=>{for(var i=e>1?void 0:e?Pe(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},R=(n,t)=>(r,e)=>t(r,e,n);let G=class extends s.Disposable{constructor(t,r,e,i,o,a,c,u,m,l){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=i,this._univerInstanceService=o,this._sheetPermissionCheckController=a,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var S,_,g;const i=(S=t[0])==null?void 0:S.range,o=this._renderManagerService.getRenderById(r),a=(_=o==null?void 0:o.with(P.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:_.skeleton;if(!a||!i)return;const c=a.getCellWithCoordByIndex(i.startRow,i.startColumn);if((((g=i.rangeType)!=null?g:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||i.endColumn-i.startColumn>0||i.endRow-i.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&s.Rectangle.equals(c.mergeInfo,i))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const m=c.actualRow,l=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,m,l);h&&this._commandService.executeCommand(I.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===f.DeleteCommentMutation.id){const r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:i,subUnitId:o,commentId:a}=e;r.unitId===i&&r.subUnitId===o&&r.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:i,commentId:o,trigger:a}=t,c=this._sheetsThreadCommentModel.getComment(e,i,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=u.getActiveSheet())==null?void 0:r.getSheetId())!==i&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:i}),this._isSwitchToCommenting=!1;const h=A.singleReferenceToGrid(c.ref),{row:S,column:_}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:S,startColumn:_,endRow:S,endColumn:_}]))return;const M=1;if(await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-M,0),endRow:h.row+M,startColumn:Math.max(h.column-M,0),endColumn:h.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:h.row,col:h.column,commentId:c.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(H.debounceTime(100)).subscribe(t=>{var S,_;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:i}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(r,e,i);if(!o)return;const a=A.singleReferenceToGrid(o.ref),{row:c,column:u}=a;if(Number.isNaN(c)||Number.isNaN(u))return null;const m=(S=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getSheetBySheetId(e),l=(_=m==null?void 0:m.getMergedCell(c,u))!=null?_:{startColumn:u,endColumn:u,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:l,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};G=Te([R(0,s.ICommandService),R(1,s.Inject(d.SheetsThreadCommentPopupService)),R(2,s.Inject(N.SheetsThreadCommentModel)),R(3,s.Inject(I.ThreadCommentPanelService)),R(4,s.IUniverInstanceService),R(5,s.Inject(p.SheetPermissionCheckController)),R(6,P.IMarkSelectionService),R(7,s.Inject(p.SheetsSelectionsService)),R(8,P.IEditorBridgeService),R(9,re.IRenderManagerService)],G);var be=Object.getOwnPropertyDescriptor,ye=(n,t,r,e)=>{for(var i=e>1?void 0:e?be(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},Z=(n,t)=>(r,e)=>t(r,e,n);let z=class extends s.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{var t;if(n.id===p.RemoveSheetCommand.id){const r=n.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const i=e.getUnitId(),o=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(i,o),c=Array.from(a.values()).filter(S=>!S.parentId),u=c.map(S=>S.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=u.map(S=>({id:f.DeleteCommentMutation.id,params:{unitId:i,subUnitId:o,commentId:S}})),h=c.map(({children:S,..._})=>({id:f.AddCommentMutation.id,params:{unitId:i,subUnitId:o,comment:{..._,children:m?S:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};z=ye([Z(0,s.Inject(p.SheetInterceptorService)),Z(1,s.IUniverInstanceService),Z(2,s.Inject(f.ThreadCommentModel)),Z(3,f.IThreadCommentDataSourceService)],z);var y=function(){return y=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},y.apply(this,arguments)},Me=function(n,t){var r={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(r[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,e=Object.getOwnPropertySymbols(n);i<e.length;i++)t.indexOf(e[i])<0&&Object.prototype.propertyIsEnumerable.call(n,e[i])&&(r[e[i]]=n[e[i]]);return r},ae=O.forwardRef(function(n,t){var r=n.icon,e=n.id,i=n.className,o=n.extend,a=Me(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(i||"").trim(),u=O.useRef("_".concat(Ue()));return ce(r,"".concat(e),{defIds:r.defIds,idSuffix:u.current},y({ref:t,className:c},a),o)});function ce(n,t,r,e,i){return O.createElement(n.tag,y(y({key:t},we(n,r,i)),e),(Ee(n,r).children||[]).map(function(o,a){return ce(o,"".concat(t,"-").concat(n.tag,"-").concat(a),r,void 0,i)}))}function we(n,t,r){var e=y({},n.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1),n.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];a==="mask"&&typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(n.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 Ee(n,t){var r,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?y(y({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&e&&e.indexOf(i.attrs.id)>-1?y(y({},i),{attrs:y(y({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):n}function Ue(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var Oe={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=O.forwardRef(function(n,t){return O.createElement(ae,Object.assign({},n,{id:"comment-single",ref:t,icon:Oe}))});de.displayName="CommentSingle";const Re=()=>{const n=v.useDependency(s.IUniverInstanceService),t=v.useDependency(d.SheetsThreadCommentPopupService),r=v.useObservable(t.activePopup$),e=v.useDependency(N.SheetsThreadCommentModel);if(v.useObservable(e.commentUpdate$),!r)return null;const{row:i,col:o,unitId:a,subUnitId:c,trigger:u}=r,m=e.getByLocation(a,c,i,o),l=`${s.Tools.chatAtABC(o)}${i+1}`,h=()=>{t.hidePopup()},S=_=>{var g,M,$;return($=(M=(g=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getSheetBySheetId(_))==null?void 0:M.getName())!=null?$:""};return ie.jsx(I.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:a,subUnitId:c,type:s.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:S,autoFocus:u==="context-menu"})},je=()=>{var w;const n=v.useDependency(P.IMarkSelectionService),t=v.useDependency(s.IUniverInstanceService),r=v.useDependency(d.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),i=e.getUnitId(),o=v.useDependency(s.ICommandService),a=O.useMemo(()=>e.activeSheet$.pipe(H.map(C=>C==null?void 0:C.getSheetId())),[e.activeSheet$]),c=v.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=O.useRef(null),m=v.useDependency(I.ThreadCommentPanelService),l=v.useObservable(m.activeCommentId$),h=v.useObservable(m.panelVisible$,m.panelVisible),S=O.useCallback(C=>{const E=e.getSheets(),T={};E.forEach((U,b)=>{T[U.getSheetId()]=b});const j=U=>U.map(b=>{var me;const k=A.singleReferenceToGrid(b.ref),xe=[(me=T[b.subUnitId])!=null?me:0,k.row,k.column];return{...b,p:xe}}).sort((b,k)=>b.p[0]===k.p[0]?b.p[1]===k.p[1]?b.p[2]-k.p[2]:b.p[1]-k.p[1]:b.p[0]-k.p[0]);return[...j(C.filter(U=>!U.resolved)),...j(C.filter(U=>U.resolved))]},[e]),_=O.useCallback(C=>{var E;if(C.unitId===i&&C.subUnitId===c&&!C.resolved){const{row:T,column:j}=A.singleReferenceToGrid(C.ref),U=e.getSheetBySheetId(C.subUnitId),b=(E=U==null?void 0:U.getMergedCell(T,j))!=null?E:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return n.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[n,c,i]),g=C=>{var E,T;return(T=(E=e.getSheetBySheetId(C))==null?void 0:E.getName())!=null?T:""},M=()=>{o.executeCommand(V.id)},$=C=>{l&&l.unitId===C.unitId&&l.subUnitId===C.subUnitId&&l.commentId===C.id||(u.current&&(n.removeShape(u.current),u.current=null),u.current=_(C))},B=()=>{u.current&&(n.removeShape(u.current),u.current=null)},ne=(C,E)=>{E&&r.hidePopup()};return O.useEffect(()=>{!h&&u.current&&n.removeShape(u.current)},[n,h]),ie.jsx(I.ThreadCommentPanel,{unitId:i,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:g,onResolve:ne,sortComments:S,onItemEnter:$,onItemLeave:B,onDeleteComment:()=>(B(),!0)})},ke=n=>({id:V.id,type:v.MenuItemType.BUTTON,icon:Y,title:"sheetThreadComment.menu.addComment",hidden$:v.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(n,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),De=n=>({id:I.ToggleSheetCommentPanelOperation.id,type:v.MenuItemType.BUTTON,icon:Y,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:P.getCurrentRangeDisable$(n,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:v.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET)}),Ne={id:V.id,binding:v.KeyCode.M|v.MetaKeys.CTRL_COMMAND|v.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused},$e={[v.RibbonStartGroup.OTHERS]:{[I.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:De}},[v.ContextMenuPosition.MAIN_AREA]:{[v.ContextMenuGroup.OTHERS]:{[V.id]:{order:0,menuItemFactory:ke}}}};var Ae=Object.getOwnPropertyDescriptor,Ve=(n,t,r,e)=>{for(var i=e>1?void 0:e?Ae(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},ee=(n,t)=>(r,e)=>t(r,e,n);let K=class extends s.Disposable{constructor(n,t,r){super(),this._menuManagerService=n,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Ne)}_initMenu(){this._menuManagerService.mergeMenu($e)}_initComponent(){[[oe,Re],[I.THREAD_COMMENT_PANEL,je],[Y,de]].forEach(([n,t])=>{this._componentManager.register(n,t)})}};K=Ve([ee(0,v.IMenuManagerService),ee(1,s.Inject(v.ComponentManager)),ee(2,v.IShortcutService)],K);var He=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Le=(n,t,r)=>t in n?He(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,We=(n,t,r,e)=>{for(var i=e>1?void 0:e?Be(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},te=(n,t)=>(r,e)=>t(r,e,n),ue=(n,t,r)=>Le(n,typeof t!="symbol"?t+"":t,r);d.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=se,r,e,i){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=i;const{menu:o,...a}=s.merge({},se,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(pe,a)}onStarting(){[[K],[W],[x],[q],[z],[G],[d.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[V].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(K)}onReady(){this._injector.get(W),this._injector.get(z)}onRendered(){this._injector.get(x),this._injector.get(q),this._injector.get(G)}},ue(d.UniverSheetsThreadCommentUIPlugin,"pluginName",J),ue(d.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentUIPlugin=We([s.DependentOn(I.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),te(1,s.Inject(s.Injector)),te(2,s.Inject(s.ICommandService)),te(3,s.IConfigService)],d.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(d,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>I.UniverThreadCommentUIPlugin}),Object.defineProperty(d,"AddCommentCommand",{enumerable:!0,get:()=>f.AddCommentCommand}),Object.defineProperty(d,"DeleteCommentCommand",{enumerable:!0,get:()=>f.DeleteCommentCommand}),Object.defineProperty(d,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>f.DeleteCommentTreeCommand}),Object.defineProperty(d,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>f.IThreadCommentDataSourceService}),Object.defineProperty(d,"ResolveCommentCommand",{enumerable:!0,get:()=>f.ResolveCommentCommand}),Object.defineProperty(d,"UpdateCommentCommand",{enumerable:!0,get:()=>f.UpdateCommentCommand}),d.SHEETS_THREAD_COMMENT=J,d.ShowAddSheetCommentModalOperation=V,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
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/jsx-runtime"),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/jsx-runtime","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,d.React))})(this,function(d,s,p,N,g,P,v,H,re,A,f,ie,O){"use strict";var Fe=Object.defineProperty;var qe=(d,s,p)=>s in d?Fe(d,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):d[s]=p;var D=(d,s,p)=>qe(d,typeof s!="symbol"?s+"":s,p);const oe="univer.sheet.thread-comment-modal",Y="comment-single",J="SHEET_THREAD_COMMENT";var he=Object.getOwnPropertyDescriptor,le=(n,t,r,e)=>{for(var i=e>1?void 0:e?he(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},Q=(n,t)=>(r,e)=>t(r,e,n);d.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(r,e,i){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new H.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._cellPopupManagerService=i,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}showPopup(r,e){var l;const{row:i,col:o,unitId:a,subUnitId:c}=r;if(this._activePopup&&i===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&c===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const u=this._cellPopupManagerService.showPopup({row:i,col:o,unitId:a,subUnitId:c},{componentKey:oe,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const m=new s.DisposableCollection;m.add(u),m.add({dispose:()=>{e==null||e()}}),this._lastPopup=m}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=le([Q(0,s.Inject(P.SheetCanvasPopManagerService)),Q(1,v.IZenZoneService),Q(2,s.Inject(P.CellPopupManagerService))],d.SheetsThreadCommentPopupService);const V={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(n){var I;const t=n.get(p.SheetsSelectionsService),r=n.get(s.IUniverInstanceService),e=n.get(d.SheetsThreadCommentPopupService),i=n.get(g.ThreadCommentPanelService),o=(I=t.getCurrentLastSelection())==null?void 0:I.primary,a=n.get(N.SheetsThreadCommentModel);if(!o)return!1;const c=p.getSheetCommandTarget(r);if(!c)return!1;const{workbook:u,worksheet:m,unitId:l,subUnitId:h}=c,S={workbook:u,worksheet:m,unitId:l,subUnitId:h,row:o.startRow,col:o.startColumn};e.showPopup(S);const _=a.getByLocation(l,h,o.startRow,o.startColumn);return _&&i.setActiveComment({unitId:l,subUnitId:h,commentId:_,trigger:"context-menu"}),!0}},pe="sheets-thread-comment.config",se={};var ve=Object.getOwnPropertyDescriptor,Se=(n,t,r,e)=>{for(var i=e>1?void 0:e?ve(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},L=(n,t)=>(r,e)=>t(r,e,n);let W=class extends s.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(n,t,r)=>{const{row:e,col:i,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,i)?r({...n,markers:{...n==null?void 0:n.markers,tr:{color:"#FFBD37",size:6}}}):r(n)},priority:100}))}_initSkeletonChange(){const n=()=>{var i;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(i=e==null?void 0:e.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(H.debounceTime(16)).subscribe(()=>{n()}))}};W=Se([L(0,s.Inject(p.SheetInterceptorService)),L(1,s.Inject(N.SheetsThreadCommentModel)),L(2,s.IUniverInstanceService),L(3,re.IRenderManagerService)],W);var Ce=Object.getOwnPropertyDescriptor,_e=(n,t,r,e)=>{for(var i=e>1?void 0:e?Ce(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},X=(n,t)=>(r,e)=>t(r,e,n);const fe=(n,t,r)=>{const e=A.singleReferenceToGrid(n),i=r.row-t.row,o=r.column-t.column,a={startColumn:e.column+o,startRow:e.row+i,endColumn:e.column+o,endRow:e.row+i};return A.serializeRange(a)};let x=class extends s.Disposable{constructor(t,r,e){super();D(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:J,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,i)=>{const{unitId:o,subUnitId:a,range:c}=r,u={row:c.rows[0],column:c.cols[0]};if(i.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,S={row:m.startRow,column:m.startColumn};if(!(o===l&&a===h)){const _=[];s.Range.foreach(m,(w,C)=>{const E=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,C);this._threadCommentDataSourceService.syncUpdateMutationToColla?E.forEach(T=>{_.push(T)}):E.forEach(({children:T,...j})=>{j.parentId||_.push(j)})});const I=[],M=[],$=[],B=[],ne=w=>{I.unshift({id:f.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),$.push({id:f.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:fe(w.ref,S,u),unitId:o,subUnitId:a},sync:!0}}),M.push({id:f.AddCommentMutation.id,params:{unitId:l,subUnitId:h,comment:w,sync:!0}}),B.unshift({id:f.DeleteCommentMutation.id,params:{unitId:o,subUnitId:a,commentId:w.id}})};return _.forEach(w=>{ne(w)}),{redos:[...I,...$],undos:[...B,...M]}}}return{redos:[],undos:[]}}}))}};x=_e([X(0,s.Inject(P.ISheetClipboardService)),X(1,s.Inject(N.SheetsThreadCommentModel)),X(2,f.IThreadCommentDataSourceService)],x);var Ie=Object.getOwnPropertyDescriptor,ge=(n,t,r,e)=>{for(var i=e>1?void 0:e?Ie(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},F=(n,t)=>(r,e)=>t(r,e,n);let q=class extends s.Disposable{constructor(n,t,r,e){super(),this._hoverManagerService=n,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.debounceTime(100)).subscribe(n=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(n&&(t&&t.temp||!t)){const{location:r}=n,{unitId:e,subUnitId:i,row:o,col:a}=r,c=this._sheetsThreadCommentModel.getByLocation(e,i,o,a);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:a,endRow:o,endColumn:a}]))return;const m=this._sheetsThreadCommentModel.getComment(e,i,c);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:o,col:a,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};q=ge([F(0,s.Inject(P.HoverManagerService)),F(1,s.Inject(d.SheetsThreadCommentPopupService)),F(2,s.Inject(N.SheetsThreadCommentModel)),F(3,s.Inject(p.SheetPermissionCheckController))],q);var Pe=Object.getOwnPropertyDescriptor,Te=(n,t,r,e)=>{for(var i=e>1?void 0:e?Pe(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},R=(n,t)=>(r,e)=>t(r,e,n);let G=class extends s.Disposable{constructor(t,r,e,i,o,a,c,u,m,l){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=i,this._univerInstanceService=o,this._sheetPermissionCheckController=a,this._markSelectionService=c,this._sheetSelectionService=u,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var S,_,I;const i=(S=t[0])==null?void 0:S.range,o=this._renderManagerService.getRenderById(r),a=(_=o==null?void 0:o.with(P.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:_.skeleton;if(!a||!i)return;const c=a.getCellWithCoordByIndex(i.startRow,i.startColumn);if((((I=i.rangeType)!=null?I:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||i.endColumn-i.startColumn>0||i.endRow-i.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&s.Rectangle.equals(c.mergeInfo,i))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const m=c.actualRow,l=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,m,l);h&&this._commandService.executeCommand(g.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===f.DeleteCommentMutation.id){const r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:i,subUnitId:o,commentId:a}=e;r.unitId===i&&r.subUnitId===o&&r.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:i,commentId:o,trigger:a}=t,c=this._sheetsThreadCommentModel.getComment(e,i,o);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=u.getActiveSheet())==null?void 0:r.getSheetId())!==i&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:i}),this._isSwitchToCommenting=!1;const h=A.singleReferenceToGrid(c.ref),{row:S,column:_}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:S,startColumn:_,endRow:S,endColumn:_}]))return;const M=1;if(await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-M,0),endRow:h.row+M,startColumn:Math.max(h.column-M,0),endColumn:h.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:i,row:h.row,col:h.column,commentId:c.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(H.debounceTime(100)).subscribe(t=>{var S,_;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:i}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(r,e,i);if(!o)return;const a=A.singleReferenceToGrid(o.ref),{row:c,column:u}=a;if(Number.isNaN(c)||Number.isNaN(u))return null;const m=(S=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getSheetBySheetId(e),l=(_=m==null?void 0:m.getMergedCell(c,u))!=null?_:{startColumn:u,endColumn:u,startRow:c,endRow:c},h=this._markSelectionService.addShape({range:l,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};G=Te([R(0,s.ICommandService),R(1,s.Inject(d.SheetsThreadCommentPopupService)),R(2,s.Inject(N.SheetsThreadCommentModel)),R(3,s.Inject(g.ThreadCommentPanelService)),R(4,s.IUniverInstanceService),R(5,s.Inject(p.SheetPermissionCheckController)),R(6,P.IMarkSelectionService),R(7,s.Inject(p.SheetsSelectionsService)),R(8,P.IEditorBridgeService),R(9,re.IRenderManagerService)],G);var be=Object.getOwnPropertyDescriptor,ye=(n,t,r,e)=>{for(var i=e>1?void 0:e?be(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},Z=(n,t)=>(r,e)=>t(r,e,n);let z=class extends s.Disposable{constructor(n,t,r,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{var t;if(n.id===p.RemoveSheetCommand.id){const r=n.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const i=e.getUnitId(),o=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(i,o),c=Array.from(a.values()).filter(S=>!S.parentId),u=c.map(S=>S.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=u.map(S=>({id:f.DeleteCommentMutation.id,params:{unitId:i,subUnitId:o,commentId:S}})),h=c.map(({children:S,..._})=>({id:f.AddCommentMutation.id,params:{unitId:i,subUnitId:o,comment:{..._,children:m?S:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};z=ye([Z(0,s.Inject(p.SheetInterceptorService)),Z(1,s.IUniverInstanceService),Z(2,s.Inject(f.ThreadCommentModel)),Z(3,f.IThreadCommentDataSourceService)],z);var y=function(){return y=Object.assign||function(n){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},y.apply(this,arguments)},Me=function(n,t){var r={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(r[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,e=Object.getOwnPropertySymbols(n);i<e.length;i++)t.indexOf(e[i])<0&&Object.prototype.propertyIsEnumerable.call(n,e[i])&&(r[e[i]]=n[e[i]]);return r},ae=O.forwardRef(function(n,t){var r=n.icon,e=n.id,i=n.className,o=n.extend,a=Me(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(i||"").trim(),u=O.useRef("_".concat(Ue()));return ce(r,"".concat(e),{defIds:r.defIds,idSuffix:u.current},y({ref:t,className:c},a),o)});function ce(n,t,r,e,i){return O.createElement(n.tag,y(y({key:t},we(n,r,i)),e),(Ee(n,r).children||[]).map(function(o,a){return ce(o,"".concat(t,"-").concat(n.tag,"-").concat(a),r,void 0,i)}))}function we(n,t,r){var e=y({},n.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1),n.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];a==="mask"&&typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(n.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 Ee(n,t){var r,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?y(y({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&e&&e.indexOf(i.attrs.id)>-1?y(y({},i),{attrs:y(y({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):n}function Ue(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var Oe={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=O.forwardRef(function(n,t){return O.createElement(ae,Object.assign({},n,{id:"comment-single",ref:t,icon:Oe}))});de.displayName="CommentSingle";const Re=()=>{const n=v.useDependency(s.IUniverInstanceService),t=v.useDependency(d.SheetsThreadCommentPopupService),r=v.useObservable(t.activePopup$),e=v.useDependency(N.SheetsThreadCommentModel);if(v.useObservable(e.commentUpdate$),!r)return null;const{row:i,col:o,unitId:a,subUnitId:c,trigger:u}=r,m=e.getByLocation(a,c,i,o),l=`${s.Tools.chatAtABC(o)}${i+1}`,h=()=>{t.hidePopup()},S=_=>{var I,M,$;return($=(M=(I=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(_))==null?void 0:M.getName())!=null?$:""};return ie.jsx(g.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:a,subUnitId:c,type:s.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:S,autoFocus:u==="context-menu"})},je=()=>{var w;const n=v.useDependency(P.IMarkSelectionService),t=v.useDependency(s.IUniverInstanceService),r=v.useDependency(d.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),i=e.getUnitId(),o=v.useDependency(s.ICommandService),a=O.useMemo(()=>e.activeSheet$.pipe(H.map(C=>C==null?void 0:C.getSheetId())),[e.activeSheet$]),c=v.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=O.useRef(null),m=v.useDependency(g.ThreadCommentPanelService),l=v.useObservable(m.activeCommentId$),h=v.useObservable(m.panelVisible$,m.panelVisible),S=O.useCallback(C=>{const E=e.getSheets(),T={};E.forEach((U,b)=>{T[U.getSheetId()]=b});const j=U=>U.map(b=>{var me;const k=A.singleReferenceToGrid(b.ref),xe=[(me=T[b.subUnitId])!=null?me:0,k.row,k.column];return{...b,p:xe}}).sort((b,k)=>b.p[0]===k.p[0]?b.p[1]===k.p[1]?b.p[2]-k.p[2]:b.p[1]-k.p[1]:b.p[0]-k.p[0]);return[...j(C.filter(U=>!U.resolved)),...j(C.filter(U=>U.resolved))]},[e]),_=O.useCallback(C=>{var E;if(C.unitId===i&&C.subUnitId===c&&!C.resolved){const{row:T,column:j}=A.singleReferenceToGrid(C.ref),U=e.getSheetBySheetId(C.subUnitId),b=(E=U==null?void 0:U.getMergedCell(T,j))!=null?E:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return n.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[n,c,i]),I=C=>{var E,T;return(T=(E=e.getSheetBySheetId(C))==null?void 0:E.getName())!=null?T:""},M=()=>{o.executeCommand(V.id)},$=C=>{l&&l.unitId===C.unitId&&l.subUnitId===C.subUnitId&&l.commentId===C.id||(u.current&&(n.removeShape(u.current),u.current=null),u.current=_(C))},B=()=>{u.current&&(n.removeShape(u.current),u.current=null)},ne=(C,E)=>{E&&r.hidePopup()};return O.useEffect(()=>{!h&&u.current&&n.removeShape(u.current)},[n,h]),ie.jsx(g.ThreadCommentPanel,{unitId:i,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:I,onResolve:ne,sortComments:S,onItemEnter:$,onItemLeave:B,onDeleteComment:()=>(B(),!0)})},ke=n=>({id:V.id,type:v.MenuItemType.BUTTON,icon:Y,title:"sheetThreadComment.menu.addComment",hidden$:v.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(n,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),De=n=>({id:g.ToggleSheetCommentPanelOperation.id,type:v.MenuItemType.BUTTON,icon:Y,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:P.getCurrentRangeDisable$(n,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:v.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET)}),Ne={id:V.id,binding:v.KeyCode.M|v.MetaKeys.CTRL_COMMAND|v.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused},$e={[v.RibbonInsertGroup.MEDIA]:{[g.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:De}},[v.ContextMenuPosition.MAIN_AREA]:{[v.ContextMenuGroup.OTHERS]:{[V.id]:{order:0,menuItemFactory:ke}}}};var Ae=Object.getOwnPropertyDescriptor,Ve=(n,t,r,e)=>{for(var i=e>1?void 0:e?Ae(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},ee=(n,t)=>(r,e)=>t(r,e,n);let K=class extends s.Disposable{constructor(n,t,r){super(),this._menuManagerService=n,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Ne)}_initMenu(){this._menuManagerService.mergeMenu($e)}_initComponent(){[[oe,Re],[g.THREAD_COMMENT_PANEL,je],[Y,de]].forEach(([n,t])=>{this.disposeWithMe(this._componentManager.register(n,t))})}};K=Ve([ee(0,v.IMenuManagerService),ee(1,s.Inject(v.ComponentManager)),ee(2,v.IShortcutService)],K);var He=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Le=(n,t,r)=>t in n?He(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,We=(n,t,r,e)=>{for(var i=e>1?void 0:e?Be(t,r):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(i=a(i)||i);return i},te=(n,t)=>(r,e)=>t(r,e,n),ue=(n,t,r)=>Le(n,typeof t!="symbol"?t+"":t,r);d.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=se,r,e,i){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=i;const{menu:o,...a}=s.merge({},se,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(pe,a)}onStarting(){[[K],[W],[x],[q],[z],[G],[d.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[V].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(K)}onReady(){this._injector.get(W),this._injector.get(z)}onRendered(){this._injector.get(x),this._injector.get(q),this._injector.get(G)}},ue(d.UniverSheetsThreadCommentUIPlugin,"pluginName",J),ue(d.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentUIPlugin=We([s.DependentOn(g.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),te(1,s.Inject(s.Injector)),te(2,s.Inject(s.ICommandService)),te(3,s.IConfigService)],d.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(d,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>g.UniverThreadCommentUIPlugin}),Object.defineProperty(d,"AddCommentCommand",{enumerable:!0,get:()=>f.AddCommentCommand}),Object.defineProperty(d,"DeleteCommentCommand",{enumerable:!0,get:()=>f.DeleteCommentCommand}),Object.defineProperty(d,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>f.DeleteCommentTreeCommand}),Object.defineProperty(d,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>f.IThreadCommentDataSourceService}),Object.defineProperty(d,"ResolveCommentCommand",{enumerable:!0,get:()=>f.ResolveCommentCommand}),Object.defineProperty(d,"UpdateCommentCommand",{enumerable:!0,get:()=>f.UpdateCommentCommand}),d.SHEETS_THREAD_COMMENT=J,d.ShowAddSheetCommentModalOperation=V,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.7.0",
3
+ "version": "0.8.0-nightly.202505261607",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,15 +53,15 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@univerjs/icons": "^0.3.24",
56
- "@univerjs/core": "0.7.0",
57
- "@univerjs/engine-formula": "0.7.0",
58
- "@univerjs/engine-render": "0.7.0",
59
- "@univerjs/sheets": "0.7.0",
60
- "@univerjs/sheets-ui": "0.7.0",
61
- "@univerjs/thread-comment-ui": "0.7.0",
62
- "@univerjs/thread-comment": "0.7.0",
63
- "@univerjs/ui": "0.7.0",
64
- "@univerjs/sheets-thread-comment": "0.7.0"
56
+ "@univerjs/core": "0.8.0-nightly.202505261607",
57
+ "@univerjs/engine-formula": "0.8.0-nightly.202505261607",
58
+ "@univerjs/engine-render": "0.8.0-nightly.202505261607",
59
+ "@univerjs/sheets": "0.8.0-nightly.202505261607",
60
+ "@univerjs/sheets-ui": "0.8.0-nightly.202505261607",
61
+ "@univerjs/sheets-thread-comment": "0.8.0-nightly.202505261607",
62
+ "@univerjs/thread-comment-ui": "0.8.0-nightly.202505261607",
63
+ "@univerjs/ui": "0.8.0-nightly.202505261607",
64
+ "@univerjs/thread-comment": "0.8.0-nightly.202505261607"
65
65
  },
66
66
  "devDependencies": {
67
67
  "postcss": "^8.5.3",
@@ -70,8 +70,8 @@
70
70
  "tailwindcss": "^3.4.17",
71
71
  "typescript": "^5.8.3",
72
72
  "vite": "^6.3.5",
73
- "vitest": "^3.1.3",
74
- "@univerjs-infra/shared": "0.7.0"
73
+ "vitest": "^3.1.4",
74
+ "@univerjs-infra/shared": "0.8.0-beta.0"
75
75
  },
76
76
  "scripts": {
77
77
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS