@univerjs/sheets-thread-comment-ui 0.6.0-nightly.202502041606 → 0.6.0-nightly.202502061605

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 le=Object.defineProperty;var pe=(o,t,n)=>t in o?le(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var j=(o,t,n)=>pe(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),v=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),P=require("@univerjs/thread-comment-ui"),w=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),k=require("rxjs"),oe=require("@univerjs/engine-render"),A=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),ie=require("react/jsx-runtime"),R=require("react"),se="univer.sheet.thread-comment-modal",X="comment-single",ee="SHEET_THREAD_COMMENT";var ve=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,Se=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ce(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&ve(t,n,r),r},ne=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,e){super();j(this,"_lastPopup",null);j(this,"_activePopup");j(this,"_activePopup$",new k.BehaviorSubject(null));j(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var h;const{row:r,col:i,unitId:s,subUnitId:a}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&a===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:se,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new c.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=Se([ne(0,c.Inject(w.SheetCanvasPopManagerService)),ne(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const x={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(v.SheetsSelectionsService),n=o.get(c.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(P.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const a=v.getSheetCommandTarget(n);if(!a)return!1;const{workbook:m,worksheet:d,unitId:h,subUnitId:u}=a,l={workbook:m,worksheet:d,unitId:h,subUnitId:u,row:i.startRow,col:i.startColumn};e.showPopup(l);const C=s.getByLocation(h,u,i.startRow,i.startColumn);return C&&r.setActiveComment({unitId:h,subUnitId:u,commentId:C,trigger:"context-menu"}),!0}},_e="sheets-thread-comment.config",re={};var fe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ge=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ie(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&fe(t,n,r),r},H=(o,t)=>(n,e)=>t(n,e,o);let W=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{o()}))}};W=ge([H(0,c.Inject(v.SheetInterceptorService)),H(1,c.Inject($.SheetsThreadCommentModel)),H(2,c.IUniverInstanceService),H(3,oe.IRenderManagerService)],W);var Pe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(o,t,n,e)=>{for(var r=e>1?void 0:e?Te(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Pe(t,n,r),r},Y=(o,t)=>(n,e)=>t(n,e,o);const Me=(o,t,n)=>{const e=A.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return A.serializeRange(s)};let F=class extends c.Disposable{constructor(t,n,e){super();j(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ee,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:a}=n,m={row:a.rows[0],column:a.cols[0]};if(r.copyType===w.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:h,subUnitId:u}=this._copyInfo,l={row:d.startRow,column:d.startColumn};if(!(i===h&&s===u)){const C=[];c.Range.foreach(d,(b,p)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(h,u,b,p);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(I=>{C.push(I)}):M.forEach(({children:I,...O})=>{O.parentId||C.push(O)})});const f=[],T=[],N=[],V=[],K=b=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:h,subUnitId:u,commentId:b.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...b,ref:Me(b.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),T.push({id:_.AddCommentMutation.id,params:{unitId:h,subUnitId:u,comment:b,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:b.id}})};return C.forEach(b=>{K(b)}),{redos:[...f,...N],undos:[...V,...T]}}}return{redos:[],undos:[]}}}))}};F=be([Y(0,c.Inject(w.ISheetClipboardService)),Y(1,c.Inject($.SheetsThreadCommentModel)),Y(2,_.IThreadCommentDataSourceService)],F);var ye=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&ye(t,n,r),r},B=(o,t)=>(n,e)=>t(n,e,o);let q=class extends c.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,a=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(a){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(e,r,a);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:a,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};q=Ue([B(0,c.Inject(w.HoverManagerService)),B(1,c.Inject(exports.SheetsThreadCommentPopupService)),B(2,c.Inject($.SheetsThreadCommentModel)),B(3,c.Inject(v.SheetPermissionCheckController))],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Re=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let G=class extends c.Disposable{constructor(t,n,e,r,i,s,a,m,d,h){super();j(this,"_isSwitchToCommenting",!1);j(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=a,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=h,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,C,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(C=i==null?void 0:i.with(w.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:C.skeleton;if(!s||!r)return;const a=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:c.RANGE_TYPE.NORMAL)!==c.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((a.isMerged||a.isMergedMainCell)&&c.Rectangle.equals(a.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=a.actualRow,h=a.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,d,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const u=this._sheetsThreadCommentModel.getByLocation(n,e,d,h);u&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:u})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,a=this._sheetsThreadCommentModel.getComment(e,r,i);if(!a||a.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const u=A.singleReferenceToGrid(a.ref),{row:l,column:C}=u;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:C,endRow:l,endColumn:C}]))return;const T=1;if(await this._commandService.executeCommand(w.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-T,0),endRow:u.row+T,startColumn:Math.max(u.column-T,0),endColumn:u.column+T}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:u.row,col:u.column,commentId:a.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var l,C;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=A.singleReferenceToGrid(i.ref),{row:a,column:m}=s;if(Number.isNaN(a)||Number.isNaN(m))return null;const d=(l=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),h=(C=d==null?void 0:d.getMergedCell(a,m))!=null?C:{startColumn:m,endColumn:m,startRow:a,endRow:a},u=this._markSelectionService.addShape({range:h,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);u&&(this._selectionShapeInfo={...t,shapeId:u})}))}};G=Re([E(0,c.ICommandService),E(1,c.Inject(exports.SheetsThreadCommentPopupService)),E(2,c.Inject($.SheetsThreadCommentModel)),E(3,c.Inject(P.ThreadCommentPanelService)),E(4,c.IUniverInstanceService),E(5,c.Inject(v.SheetPermissionCheckController)),E(6,w.IMarkSelectionService),E(7,c.Inject(v.SheetsSelectionsService)),E(8,w.IEditorBridgeService),E(9,oe.IRenderManagerService)],G);var De=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ne=(o,t,n,e)=>{for(var r=e>1?void 0:e?je(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===v.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),a=Array.from(s.values()).filter(l=>!l.parentId),m=a.map(l=>l.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,h=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),u=a.map(({children:l,...C})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...C,children:d?l:void 0},sync:!d}}));return{redos:h,undos:u}}return{redos:[],undos:[]}}}))}};Z=Ne([L(0,c.Inject(v.SheetInterceptorService)),L(1,c.IUniverInstanceService),L(2,c.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],Z);var y=function(){return y=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},y.apply(this,arguments)},$e=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},ce=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=$e(o,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Ve()));return ae(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},y({ref:t,className:a},s),i)});function ae(o,t,n,e,r){return R.createElement(o.tag,y(y({key:t},Ae(o,n,r)),e),(xe(o,n).children||[]).map(function(i,s){return ae(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function Ae(o,t,n){var e=y({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],a=i[1];typeof a=="string"&&(e[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function xe(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?y(y({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Ve(){return Math.random().toString(36).substring(2,8)}ce.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=R.forwardRef(function(o,t){return R.createElement(ce,Object.assign({},o,{id:"comment-single",ref:t,icon:ke}))});me.displayName="CommentSingle";const He=()=>{const o=c.useDependency(c.IUniverInstanceService),t=c.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(t.activePopup$),e=c.useDependency($.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:a,trigger:m}=n,d=e.getByLocation(s,a,r,i),h=`${c.Tools.chatAtABC(i)}${r+1}`,u=()=>{t.hidePopup()},l=C=>{var f,T,N;return(N=(T=(f=o.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(C))==null?void 0:T.getName())!=null?N:""};return ie.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:a,type:c.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:u,getSubUnitName:l,autoFocus:m==="context-menu"})},Be=()=>{var b;const o=c.useDependency(w.IMarkSelectionService),t=c.useDependency(c.IUniverInstanceService),n=c.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),i=c.useDependency(c.ICommandService),s=R.useMemo(()=>e.activeSheet$.pipe(k.map(p=>p==null?void 0:p.getSheetId())),[e.activeSheet$]),a=S.useObservable(s,(b=e.getActiveSheet())==null?void 0:b.getSheetId()),m=R.useRef(null),d=c.useDependency(P.ThreadCommentPanelService),h=S.useObservable(d.activeCommentId$),u=S.useObservable(d.panelVisible$,d.panelVisible),l=R.useCallback(p=>{const M=e.getSheets(),I={};M.forEach((U,g)=>{I[U.getSheetId()]=g});const O=U=>U.map(g=>{var te;const D=A.singleReferenceToGrid(g.ref),he=[(te=I[g.subUnitId])!=null?te:0,D.row,D.column];return{...g,p:he}}).sort((g,D)=>g.p[0]===D.p[0]?g.p[1]===D.p[1]?g.p[2]-D.p[2]:g.p[1]-D.p[1]:g.p[0]-D.p[0]);return[...O(p.filter(U=>!U.resolved)),...O(p.filter(U=>U.resolved))]},[e]),C=R.useCallback(p=>{var M;if(p.unitId===r&&p.subUnitId===a&&!p.resolved){const{row:I,column:O}=A.singleReferenceToGrid(p.ref),U=e.getSheetBySheetId(p.subUnitId),g=(M=U==null?void 0:U.getMergedCell(I,O))!=null?M:{startColumn:O,endColumn:O,startRow:I,endRow:I};if(!Number.isNaN(I)&&!Number.isNaN(O))return o.addShape({range:g,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[o,a,r]),f=p=>{var M,I;return(I=(M=e.getSheetBySheetId(p))==null?void 0:M.getName())!=null?I:""},T=()=>{i.executeCommand(x.id)},N=p=>{h&&h.unitId===p.unitId&&h.subUnitId===p.subUnitId&&h.commentId===p.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=C(p))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},K=(p,M)=>{M&&n.hidePopup()};return R.useEffect(()=>{!u&&m.current&&o.removeShape(m.current)},[o,u]),ie.jsx(P.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:T,getSubUnitName:f,onResolve:K,sortComments:l,onItemEnter:N,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},Le=o=>({id:x.id,type:S.MenuItemType.BUTTON,icon:X,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),We=o=>({id:P.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:X,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET)}),Fe={id:x.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:w.whenSheetEditorFocused},qe={[S.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:We}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[x.id]:{order:0,menuItemFactory:Le}}}};var Ge=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,ze=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ze(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Ge(t,n,r),r},J=(o,t)=>(n,e)=>t(n,e,o);let z=class extends c.Disposable{constructor(o,t,n){super(),this._menuManagerService=o,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Fe)}_initMenu(){this._menuManagerService.mergeMenu(qe)}_initComponent(){[[se,He],[P.THREAD_COMMENT_PANEL,Be],[X,me]].forEach(([o,t])=>{this._componentManager.register(o,t)})}};z=ze([J(0,S.IMenuManagerService),J(1,c.Inject(S.ComponentManager)),J(2,S.IShortcutService)],z);var de=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(o,t,n)=>t in o?de(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,Je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&de(t,n,r),r},Q=(o,t)=>(n,e)=>t(n,e,o),ue=(o,t,n)=>Ye(o,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=re,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:i,...s}=c.merge({},re,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(_e,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)}};ue(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ee);ue(exports.UniverSheetsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=Je([c.DependentOn(P.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),Q(1,c.Inject(c.Injector)),Q(2,c.Inject(c.ICommandService)),Q(3,c.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=ee;exports.ShowAddSheetCommentModalOperation=x;
1
+ "use strict";var le=Object.defineProperty;var pe=(o,t,n)=>t in o?le(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var j=(o,t,n)=>pe(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),v=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),P=require("@univerjs/thread-comment-ui"),w=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),k=require("rxjs"),oe=require("@univerjs/engine-render"),A=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),ie=require("react/jsx-runtime"),R=require("react"),se="univer.sheet.thread-comment-modal",X="comment-single",ee="SHEET_THREAD_COMMENT";var ve=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,Se=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ce(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&ve(t,n,r),r},ne=(o,t)=>(n,e)=>t(n,e,o);exports.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,e){super();j(this,"_lastPopup",null);j(this,"_activePopup");j(this,"_activePopup$",new k.BehaviorSubject(null));j(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var h;const{row:r,col:i,unitId:s,subUnitId:a}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&a===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:se,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new c.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=Se([ne(0,c.Inject(w.SheetCanvasPopManagerService)),ne(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const x={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const t=o.get(v.SheetsSelectionsService),n=o.get(c.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),r=o.get(P.ThreadCommentPanelService),i=(f=t.getCurrentLastSelection())==null?void 0:f.primary,s=o.get($.SheetsThreadCommentModel);if(!i)return!1;const a=v.getSheetCommandTarget(n);if(!a)return!1;const{workbook:m,worksheet:d,unitId:h,subUnitId:u}=a,l={workbook:m,worksheet:d,unitId:h,subUnitId:u,row:i.startRow,col:i.startColumn};e.showPopup(l);const C=s.getByLocation(h,u,i.startRow,i.startColumn);return C&&r.setActiveComment({unitId:h,subUnitId:u,commentId:C,trigger:"context-menu"}),!0}},_e="sheets-thread-comment.config",re={};var fe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ge=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ie(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&fe(t,n,r),r},H=(o,t)=>(n,e)=>t(n,e,o);let W=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,t,n)=>{const{row:e,col:r,unitId:i,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{o()}))}};W=ge([H(0,c.Inject(v.SheetInterceptorService)),H(1,c.Inject($.SheetsThreadCommentModel)),H(2,c.IUniverInstanceService),H(3,oe.IRenderManagerService)],W);var Pe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(o,t,n,e)=>{for(var r=e>1?void 0:e?Te(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Pe(t,n,r),r},Y=(o,t)=>(n,e)=>t(n,e,o);const Me=(o,t,n)=>{const e=A.singleReferenceToGrid(o),r=n.row-t.row,i=n.column-t.column,s={startColumn:e.column+i,startRow:e.row+r,endColumn:e.column+i,endRow:e.row+r};return A.serializeRange(s)};let F=class extends c.Disposable{constructor(t,n,e){super();j(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:ee,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:i,subUnitId:s,range:a}=n,m={row:a.rows[0],column:a.cols[0]};if(r.copyType===w.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:h,subUnitId:u}=this._copyInfo,l={row:d.startRow,column:d.startColumn};if(!(i===h&&s===u)){const C=[];c.Range.foreach(d,(b,p)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(h,u,b,p);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(I=>{C.push(I)}):M.forEach(({children:I,...O})=>{O.parentId||C.push(O)})});const f=[],T=[],N=[],V=[],K=b=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:h,subUnitId:u,commentId:b.id}}),N.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...b,ref:Me(b.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),T.push({id:_.AddCommentMutation.id,params:{unitId:h,subUnitId:u,comment:b,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:b.id}})};return C.forEach(b=>{K(b)}),{redos:[...f,...N],undos:[...V,...T]}}}return{redos:[],undos:[]}}}))}};F=be([Y(0,c.Inject(w.ISheetClipboardService)),Y(1,c.Inject($.SheetsThreadCommentModel)),Y(2,_.IThreadCommentDataSourceService)],F);var ye=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ue=(o,t,n,e)=>{for(var r=e>1?void 0:e?we(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&ye(t,n,r),r},B=(o,t)=>(n,e)=>t(n,e,o);let q=class extends c.Disposable{constructor(o,t,n,e){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(o=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(o&&(t&&t.temp||!t)){const{location:n}=o,{unitId:e,subUnitId:r,row:i,col:s}=n,a=this._sheetsThreadCommentModel.getByLocation(e,r,i,s);if(a){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(e,r,a);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:i,col:s,commentId:a,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};q=Ue([B(0,c.Inject(w.HoverManagerService)),B(1,c.Inject(exports.SheetsThreadCommentPopupService)),B(2,c.Inject($.SheetsThreadCommentModel)),B(3,c.Inject(v.SheetPermissionCheckController))],q);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Re=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Oe(t,n,r),r},E=(o,t)=>(n,e)=>t(n,e,o);let G=class extends c.Disposable{constructor(t,n,e,r,i,s,a,m,d,h){super();j(this,"_isSwitchToCommenting",!1);j(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=a,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=h,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var l,C,f;const r=(l=t[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(C=i==null?void 0:i.with(w.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:C.skeleton;if(!s||!r)return;const a=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:c.RANGE_TYPE.NORMAL)!==c.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((a.isMerged||a.isMergedMainCell)&&c.Rectangle.equals(a.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=a.actualRow,h=a.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,d,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const u=this._sheetsThreadCommentModel.getByLocation(n,e,d,h);u&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:u})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===_.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:i,commentId:s}=e;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:i,trigger:s}=t,a=this._sheetsThreadCommentModel.getComment(e,r,i);if(!a||a.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const u=A.singleReferenceToGrid(a.ref),{row:l,column:C}=u;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:C,endRow:l,endColumn:C}]))return;const T=1;if(await this._commandService.executeCommand(w.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-T,0),endRow:u.row+T,startColumn:Math.max(u.column-T,0),endColumn:u.column+T}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:u.row,col:u.column,commentId:a.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var l,C;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,e,r);if(!i)return;const s=A.singleReferenceToGrid(i.ref),{row:a,column:m}=s;if(Number.isNaN(a)||Number.isNaN(m))return null;const d=(l=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(e),h=(C=d==null?void 0:d.getMergedCell(a,m))!=null?C:{startColumn:m,endColumn:m,startRow:a,endRow:a},u=this._markSelectionService.addShape({range:h,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);u&&(this._selectionShapeInfo={...t,shapeId:u})}))}};G=Re([E(0,c.ICommandService),E(1,c.Inject(exports.SheetsThreadCommentPopupService)),E(2,c.Inject($.SheetsThreadCommentModel)),E(3,c.Inject(P.ThreadCommentPanelService)),E(4,c.IUniverInstanceService),E(5,c.Inject(v.SheetPermissionCheckController)),E(6,w.IMarkSelectionService),E(7,c.Inject(v.SheetsSelectionsService)),E(8,w.IEditorBridgeService),E(9,oe.IRenderManagerService)],G);var De=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ne=(o,t,n,e)=>{for(var r=e>1?void 0:e?je(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},L=(o,t)=>(n,e)=>t(n,e,o);let Z=class extends c.Disposable{constructor(o,t,n,e){super(),this._sheetInterceptorService=o,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var t;if(o.id===v.RemoveSheetCommand.id){const n=o.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),i=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),a=Array.from(s.values()).filter(l=>!l.parentId),m=a.map(l=>l.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,h=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),u=a.map(({children:l,...C})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...C,children:d?l:void 0},sync:!d}}));return{redos:h,undos:u}}return{redos:[],undos:[]}}}))}};Z=Ne([L(0,c.Inject(v.SheetInterceptorService)),L(1,c.IUniverInstanceService),L(2,c.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],Z);var y=function(){return y=Object.assign||function(o){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r])}return o},y.apply(this,arguments)},$e=function(o,t){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&t.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(o);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(o,e[r])&&(n[e[r]]=o[e[r]]);return n},ce=R.forwardRef(function(o,t){var n=o.icon,e=o.id,r=o.className,i=o.extend,s=$e(o,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),m=R.useRef("_".concat(Ve()));return ae(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},y({ref:t,className:a},s),i)});function ae(o,t,n,e,r){return R.createElement(o.tag,y(y({key:t},Ae(o,n,r)),e),(xe(o,n).children||[]).map(function(i,s){return ae(i,"".concat(t,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function Ae(o,t,n){var e=y({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],a=i[1];typeof a=="string"&&(e[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function xe(o,t){var n,e=t.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?y(y({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):o}function Ve(){return Math.random().toString(36).substring(2,8)}ce.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=R.forwardRef(function(o,t){return R.createElement(ce,Object.assign({},o,{id:"comment-single",ref:t,icon:ke}))});me.displayName="CommentSingle";const He=()=>{const o=c.useDependency(c.IUniverInstanceService),t=c.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(t.activePopup$),e=c.useDependency($.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:a,trigger:m}=n,d=e.getByLocation(s,a,r,i),h=`${c.Tools.chatAtABC(i)}${r+1}`,u=()=>{t.hidePopup()},l=C=>{var f,T,N;return(N=(T=(f=o.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(C))==null?void 0:T.getName())!=null?N:""};return ie.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:a,type:c.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:u,getSubUnitName:l,autoFocus:m==="context-menu"})},Be=()=>{var b;const o=c.useDependency(w.IMarkSelectionService),t=c.useDependency(c.IUniverInstanceService),n=c.useDependency(exports.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),i=c.useDependency(c.ICommandService),s=R.useMemo(()=>e.activeSheet$.pipe(k.map(p=>p==null?void 0:p.getSheetId())),[e.activeSheet$]),a=S.useObservable(s,(b=e.getActiveSheet())==null?void 0:b.getSheetId()),m=R.useRef(null),d=c.useDependency(P.ThreadCommentPanelService),h=S.useObservable(d.activeCommentId$),u=S.useObservable(d.panelVisible$,d.panelVisible),l=R.useCallback(p=>{const M=e.getSheets(),I={};M.forEach((U,g)=>{I[U.getSheetId()]=g});const O=U=>U.map(g=>{var te;const D=A.singleReferenceToGrid(g.ref),he=[(te=I[g.subUnitId])!=null?te:0,D.row,D.column];return{...g,p:he}}).sort((g,D)=>g.p[0]===D.p[0]?g.p[1]===D.p[1]?g.p[2]-D.p[2]:g.p[1]-D.p[1]:g.p[0]-D.p[0]);return[...O(p.filter(U=>!U.resolved)),...O(p.filter(U=>U.resolved))]},[e]),C=R.useCallback(p=>{var M;if(p.unitId===r&&p.subUnitId===a&&!p.resolved){const{row:I,column:O}=A.singleReferenceToGrid(p.ref),U=e.getSheetBySheetId(p.subUnitId),g=(M=U==null?void 0:U.getMergedCell(I,O))!=null?M:{startColumn:O,endColumn:O,startRow:I,endRow:I};if(!Number.isNaN(I)&&!Number.isNaN(O))return o.addShape({range:g,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[o,a,r]),f=p=>{var M,I;return(I=(M=e.getSheetBySheetId(p))==null?void 0:M.getName())!=null?I:""},T=()=>{i.executeCommand(x.id)},N=p=>{h&&h.unitId===p.unitId&&h.subUnitId===p.subUnitId&&h.commentId===p.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=C(p))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},K=(p,M)=>{M&&n.hidePopup()};return R.useEffect(()=>{!u&&m.current&&o.removeShape(m.current)},[o,u]),ie.jsx(P.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:T,getSubUnitName:f,onResolve:K,sortComments:l,onItemEnter:N,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},Le=o=>({id:x.id,type:S.MenuItemType.BUTTON,icon:X,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),We=o=>({id:P.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:X,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET)}),Fe={id:x.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:w.whenSheetEditorFocused},qe={[S.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:We}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[x.id]:{order:0,menuItemFactory:Le}}}};var Ge=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,ze=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ze(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&Ge(t,n,r),r},J=(o,t)=>(n,e)=>t(n,e,o);let z=class extends c.Disposable{constructor(o,t,n){super(),this._menuManagerService=o,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Fe)}_initMenu(){this._menuManagerService.mergeMenu(qe)}_initComponent(){[[se,He],[P.THREAD_COMMENT_PANEL,Be],[X,me]].forEach(([o,t])=>{this._componentManager.register(o,t)})}};z=ze([J(0,S.IMenuManagerService),J(1,c.Inject(S.ComponentManager)),J(2,S.IShortcutService)],z);var de=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(o,t,n)=>t in o?de(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,Je=(o,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&de(t,n,r),r},Q=(o,t)=>(n,e)=>t(n,e,o),ue=(o,t,n)=>Ye(o,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=re,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:i,...s}=c.merge({},re,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(_e,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)}};ue(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",ee);ue(exports.UniverSheetsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=Je([c.DependentOn(P.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),Q(1,c.Inject(c.Injector)),Q(2,c.Inject(c.ICommandService)),Q(3,c.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=ee;exports.ShowAddSheetCommentModalOperation=x;
package/lib/es/index.js CHANGED
@@ -6,16 +6,16 @@ import { SheetsSelectionsService as _e, getSheetCommandTarget as qe, SheetInterc
6
6
  import { SheetsThreadCommentModel as D, UniverSheetsThreadCommentPlugin as et } from "@univerjs/sheets-thread-comment";
7
7
  import { ThreadCommentPanelService as se, SetActiveCommentOperation as ee, ThreadCommentTree as tt, ThreadCommentPanel as nt, ToggleSheetCommentPanelOperation as Ce, THREAD_COMMENT_PANEL as rt, UniverThreadCommentUIPlugin as ot } from "@univerjs/thread-comment-ui";
8
8
  import { UniverThreadCommentUIPlugin as wn } from "@univerjs/thread-comment-ui";
9
- import { SheetCanvasPopManagerService as it, ISheetClipboardService as st, COPY_TYPE as ct, HoverManagerService as at, IMarkSelectionService as Se, IEditorBridgeService as dt, SheetSkeletonManagerService as ht, ScrollToRangeOperation as mt, whenSheetEditorFocused as ut, getCurrentRangeDisable$ as ge } from "@univerjs/sheets-ui";
9
+ import { SheetCanvasPopManagerService as it, ISheetClipboardService as st, COPY_TYPE as at, HoverManagerService as ct, IMarkSelectionService as Se, IEditorBridgeService as dt, SheetSkeletonManagerService as ht, ScrollToRangeOperation as mt, whenSheetEditorFocused as ut, getCurrentRangeDisable$ as ge } from "@univerjs/sheets-ui";
10
10
  import { IZenZoneService as lt, useObservable as j, KeyCode as pt, MetaKeys as me, MenuItemType as Ie, getMenuHiddenObservable as Pe, RibbonStartGroup as _t, ContextMenuPosition as vt, ContextMenuGroup as ft, ComponentManager as Ct, IMenuManagerService as St, IShortcutService as gt } from "@univerjs/ui";
11
- import { BehaviorSubject as It, debounceTime as ce, map as Pt } from "rxjs";
11
+ import { BehaviorSubject as It, debounceTime as ae, 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";
14
14
  import { IThreadCommentDataSourceService as be, DeleteCommentMutation as k, AddCommentMutation as oe, ThreadCommentModel as bt } from "@univerjs/thread-comment";
15
15
  import { AddCommentCommand as En, DeleteCommentCommand as On, DeleteCommentTreeCommand as Un, IThreadCommentDataSourceService as Rn, ResolveCommentCommand as Nn, UpdateCommentCommand as $n } from "@univerjs/thread-comment";
16
16
  import { jsx as Me } from "react/jsx-runtime";
17
17
  import { forwardRef as we, useRef as ye, createElement as Ee, useMemo as Mt, useCallback as ue, useEffect as wt } from "react";
18
- const Oe = "univer.sheet.thread-comment-modal", ae = "comment-single", Ue = "SHEET_THREAD_COMMENT";
18
+ const Oe = "univer.sheet.thread-comment-modal", ce = "comment-single", Ue = "SHEET_THREAD_COMMENT";
19
19
  var yt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, Ot = (o, e, n, t) => {
20
20
  for (var r = t > 1 ? void 0 : t ? Et(e, n) : e, i = o.length - 1, s; i >= 0; i--)
21
21
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
@@ -50,7 +50,7 @@ let U = class extends N {
50
50
  if (this._lastPopup && this._lastPopup.dispose(), this._zenZoneService.visible)
51
51
  return;
52
52
  this._activePopup = e, this._activePopup$.next(e);
53
- const c = this._canvasPopupManagerService.attachPopupToCell(
53
+ const a = this._canvasPopupManagerService.attachPopupToCell(
54
54
  t,
55
55
  r,
56
56
  {
@@ -65,14 +65,14 @@ let U = class extends N {
65
65
  ].filter(Boolean)
66
66
  }
67
67
  );
68
- if (!c)
68
+ if (!a)
69
69
  throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");
70
- const a = new He();
71
- a.add(c), a.add({
70
+ const c = new He();
71
+ c.add(a), c.add({
72
72
  dispose: () => {
73
73
  n == null || n();
74
74
  }
75
- }), this._lastPopup = a;
75
+ }), this._lastPopup = c;
76
76
  }
77
77
  hidePopup() {
78
78
  this._activePopup && (this._lastPopup && this._lastPopup.dispose(), this._lastPopup = null, this._activePopup = null, this._activePopup$.next(null));
@@ -96,11 +96,11 @@ const V = {
96
96
  const e = o.get(_e), n = o.get($), t = o.get(U), r = o.get(se), i = (v = e.getCurrentLastSelection()) == null ? void 0 : v.primary, s = o.get(D);
97
97
  if (!i)
98
98
  return !1;
99
- const c = qe(n);
100
- if (!c)
99
+ const a = qe(n);
100
+ if (!a)
101
101
  return !1;
102
- const { workbook: a, worksheet: d, unitId: m, subUnitId: h } = c, u = {
103
- workbook: a,
102
+ const { workbook: c, worksheet: d, unitId: m, subUnitId: h } = a, u = {
103
+ workbook: c,
104
104
  worksheet: d,
105
105
  unitId: m,
106
106
  subUnitId: h,
@@ -158,7 +158,7 @@ let F = class extends N {
158
158
  const n = e.getUnitId(), t = this._renderManagerService.getRenderById(n);
159
159
  (r = t == null ? void 0 : t.mainComponent) == null || r.makeForceDirty();
160
160
  };
161
- this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(ce(16)).subscribe(() => {
161
+ this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(ae(16)).subscribe(() => {
162
162
  o();
163
163
  }));
164
164
  }
@@ -203,11 +203,11 @@ let W = class extends N {
203
203
  },
204
204
  // eslint-disable-next-line max-lines-per-function
205
205
  onPasteCells: (e, n, t, r) => {
206
- const { unitId: i, subUnitId: s, range: c } = n, a = {
207
- row: c.rows[0],
208
- column: c.cols[0]
206
+ const { unitId: i, subUnitId: s, range: a } = n, c = {
207
+ row: a.rows[0],
208
+ column: a.cols[0]
209
209
  };
210
- if (r.copyType === ct.CUT && this._copyInfo) {
210
+ if (r.copyType === at.CUT && this._copyInfo) {
211
211
  const { range: d, unitId: m, subUnitId: h } = this._copyInfo, u = {
212
212
  row: d.startRow,
213
213
  column: d.startColumn
@@ -237,7 +237,7 @@ let W = class extends N {
237
237
  subUnitId: s,
238
238
  comment: {
239
239
  ...g,
240
- ref: At(g.ref, u, a),
240
+ ref: At(g.ref, u, c),
241
241
  unitId: i,
242
242
  subUnitId: s
243
243
  },
@@ -293,24 +293,24 @@ let Z = class extends N {
293
293
  }
294
294
  _initHoverEvent() {
295
295
  this.disposeWithMe(
296
- this._hoverManagerService.currentCell$.pipe(ce(100)).subscribe((o) => {
296
+ this._hoverManagerService.currentCell$.pipe(ae(100)).subscribe((o) => {
297
297
  const e = this._sheetsThreadCommentPopupService.activePopup;
298
298
  if (o && (e && e.temp || !e)) {
299
- const { location: n } = o, { unitId: t, subUnitId: r, row: i, col: s } = n, c = this._sheetsThreadCommentModel.getByLocation(t, r, i, s);
300
- if (c) {
299
+ const { location: n } = o, { unitId: t, subUnitId: r, row: i, col: s } = n, a = this._sheetsThreadCommentModel.getByLocation(t, r, i, s);
300
+ if (a) {
301
301
  if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
302
302
  workbookTypes: [q],
303
303
  worksheetTypes: [J],
304
304
  rangeTypes: [Q]
305
305
  }, [{ startRow: i, startColumn: s, endRow: i, endColumn: s }]))
306
306
  return;
307
- const d = this._sheetsThreadCommentModel.getComment(t, r, c);
307
+ const d = this._sheetsThreadCommentModel.getComment(t, r, a);
308
308
  d && !d.resolved && this._sheetsThreadCommentPopupService.showPopup({
309
309
  unitId: t,
310
310
  subUnitId: r,
311
311
  row: i,
312
312
  col: s,
313
- commentId: c,
313
+ commentId: a,
314
314
  temp: !0
315
315
  });
316
316
  } else
@@ -321,7 +321,7 @@ let Z = class extends N {
321
321
  }
322
322
  };
323
323
  Z = Bt([
324
- B(0, _(at)),
324
+ B(0, _(ct)),
325
325
  B(1, _(U)),
326
326
  B(2, _(D)),
327
327
  B(3, _(fe))
@@ -332,23 +332,23 @@ var Lt = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, Ft = (o, e
332
332
  return t && r && Lt(e, n, r), r;
333
333
  }, w = (o, e) => (n, t) => e(n, t, o);
334
334
  let z = class extends N {
335
- constructor(e, n, t, r, i, s, c, a, d, m) {
335
+ constructor(e, n, t, r, i, s, a, c, d, m) {
336
336
  super();
337
337
  E(this, "_isSwitchToCommenting", !1);
338
338
  E(this, "_selectionShapeInfo", null);
339
- this._commandService = e, this._sheetsThreadCommentPopupService = n, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = r, this._univerInstanceService = i, this._sheetPermissionCheckController = s, this._markSelectionService = c, this._sheetSelectionService = a, this._editorBridgeService = d, this._renderManagerService = m, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
339
+ this._commandService = e, this._sheetsThreadCommentPopupService = n, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = r, this._univerInstanceService = i, this._sheetPermissionCheckController = s, this._markSelectionService = a, this._sheetSelectionService = c, this._editorBridgeService = d, this._renderManagerService = m, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
340
340
  }
341
341
  _handleSelectionChange(e, n, t) {
342
342
  var u, p, v;
343
- const r = (u = e[0]) == null ? void 0 : u.range, i = this._renderManagerService.getRenderById(n), s = (p = i == null ? void 0 : i.with(ht).getWorksheetSkeleton(t)) == null ? void 0 : p.skeleton;
343
+ const r = (u = e[0]) == null ? void 0 : u.range, i = this._renderManagerService.getRenderById(n), s = (p = i == null ? void 0 : i.with(ht).getSkeletonParam(t)) == null ? void 0 : p.skeleton;
344
344
  if (!s || !r)
345
345
  return;
346
- const c = s.getCellWithCoordByIndex(r.startRow, r.startColumn);
347
- if ((((v = r.rangeType) != null ? v : he.NORMAL) !== he.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((c.isMerged || c.isMergedMainCell) && Fe.equals(c.mergeInfo, r))) {
346
+ const a = s.getCellWithCoordByIndex(r.startRow, r.startColumn);
347
+ if ((((v = r.rangeType) != null ? v : he.NORMAL) !== he.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((a.isMerged || a.isMergedMainCell) && Fe.equals(a.mergeInfo, r))) {
348
348
  this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(ee.id);
349
349
  return;
350
350
  }
351
- const d = c.actualRow, m = c.actualColumn;
351
+ const d = a.actualRow, m = a.actualColumn;
352
352
  if (!this._sheetsThreadCommentModel.showCommentMarker(n, t, d, m)) {
353
353
  this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(ee.id);
354
354
  return;
@@ -392,17 +392,17 @@ let z = class extends N {
392
392
  this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async (e) => {
393
393
  var n;
394
394
  if (e) {
395
- const { unitId: t, subUnitId: r, commentId: i, trigger: s } = e, c = this._sheetsThreadCommentModel.getComment(t, r, i);
396
- if (!c || c.resolved)
395
+ const { unitId: t, subUnitId: r, commentId: i, trigger: s } = e, a = this._sheetsThreadCommentModel.getComment(t, r, i);
396
+ if (!a || a.resolved)
397
397
  return;
398
- const a = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
399
- if (!a || a.getUnitId() !== t)
398
+ const c = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
399
+ if (!c || c.getUnitId() !== t)
400
400
  return;
401
- this._isSwitchToCommenting = !0, ((n = a.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(Qe.id, {
401
+ this._isSwitchToCommenting = !0, ((n = c.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(Qe.id, {
402
402
  unitId: t,
403
403
  subUnitId: r
404
404
  }), this._isSwitchToCommenting = !1;
405
- const h = A(c.ref), { row: u, column: p } = h;
405
+ const h = A(a.ref), { row: u, column: p } = h;
406
406
  if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
407
407
  workbookTypes: [q],
408
408
  worksheetTypes: [J],
@@ -424,7 +424,7 @@ let z = class extends N {
424
424
  subUnitId: r,
425
425
  row: h.row,
426
426
  col: h.column,
427
- commentId: c.id,
427
+ commentId: a.id,
428
428
  trigger: s
429
429
  });
430
430
  } else
@@ -432,7 +432,7 @@ let z = class extends N {
432
432
  }));
433
433
  }
434
434
  _initMarkSelection() {
435
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(ce(100)).subscribe((e) => {
435
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(ae(100)).subscribe((e) => {
436
436
  var u, p;
437
437
  if (!e) {
438
438
  this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
@@ -443,14 +443,14 @@ let z = class extends N {
443
443
  const i = this._sheetsThreadCommentModel.getComment(n, t, r);
444
444
  if (!i)
445
445
  return;
446
- const s = A(i.ref), { row: c, column: a } = s;
447
- if (Number.isNaN(c) || Number.isNaN(a))
446
+ const s = A(i.ref), { row: a, column: c } = s;
447
+ if (Number.isNaN(a) || Number.isNaN(c))
448
448
  return null;
449
- const d = (u = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : u.getSheetBySheetId(t), m = (p = d == null ? void 0 : d.getMergedCell(c, a)) != null ? p : {
450
- startColumn: a,
451
- endColumn: a,
452
- startRow: c,
453
- endRow: c
449
+ const d = (u = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : u.getSheetBySheetId(t), m = (p = d == null ? void 0 : d.getMergedCell(a, c)) != null ? p : {
450
+ startColumn: c,
451
+ endColumn: c,
452
+ startRow: a,
453
+ endRow: a
454
454
  }, h = this._markSelectionService.addShape(
455
455
  {
456
456
  range: m,
@@ -506,14 +506,14 @@ let G = class extends N {
506
506
  const r = t.getUnitId(), i = n.subUnitId || ((e = t.getActiveSheet()) == null ? void 0 : e.getSheetId());
507
507
  if (!i)
508
508
  return { redos: [], undos: [] };
509
- const s = this._threadCommentModel.ensureMap(r, i), c = Array.from(s.values()).filter((u) => !u.parentId), a = c.map((u) => u.id), d = this._threadCommentDataSourceService.syncUpdateMutationToColla, m = a.map((u) => ({
509
+ const s = this._threadCommentModel.ensureMap(r, i), a = Array.from(s.values()).filter((u) => !u.parentId), c = a.map((u) => u.id), d = this._threadCommentDataSourceService.syncUpdateMutationToColla, m = c.map((u) => ({
510
510
  id: k.id,
511
511
  params: {
512
512
  unitId: r,
513
513
  subUnitId: i,
514
514
  commentId: u
515
515
  }
516
- })), h = c.map(({ children: u, ...p }) => ({
516
+ })), h = a.map(({ children: u, ...p }) => ({
517
517
  id: oe.id,
518
518
  params: {
519
519
  unitId: r,
@@ -555,8 +555,8 @@ var P = function() {
555
555
  e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[r]) && (n[t[r]] = o[t[r]]);
556
556
  return n;
557
557
  }, Re = we(function(o, e) {
558
- var n = o.icon, t = o.id, r = o.className, i = o.extend, s = Gt(o, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), a = ye("_".concat(qt()));
559
- return Ne(n, "".concat(t), { defIds: n.defIds, idSuffix: a.current }, P({ ref: e, className: c }, s), i);
558
+ var n = o.icon, t = o.id, r = o.className, i = o.extend, s = Gt(o, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), c = ye("_".concat(qt()));
559
+ return Ne(n, "".concat(t), { defIds: n.defIds, idSuffix: c.current }, P({ ref: e, className: a }, s), i);
560
560
  });
561
561
  function Ne(o, e, n, t, r) {
562
562
  return Ee(o.tag, P(P({ key: e }, Kt(o, n, r)), t), (Yt(o, n).children || []).map(function(i, s) {
@@ -568,8 +568,8 @@ function Kt(o, e, n) {
568
568
  n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
569
569
  var r = e.defIds;
570
570
  return !r || r.length === 0 || (o.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(i) {
571
- var s = i[0], c = i[1];
572
- typeof c == "string" && (t[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
571
+ var s = i[0], a = i[1];
572
+ typeof a == "string" && (t[s] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
573
573
  })), t;
574
574
  }
575
575
  function Yt(o, e) {
@@ -594,7 +594,7 @@ const Qt = () => {
594
594
  const o = O($), e = O(U), n = j(e.activePopup$), t = O(D);
595
595
  if (j(t.commentUpdate$), !n)
596
596
  return null;
597
- const { row: r, col: i, unitId: s, subUnitId: c, trigger: a } = n, d = t.getByLocation(s, c, r, i), m = `${We.chatAtABC(i)}${r + 1}`, h = () => {
597
+ const { row: r, col: i, unitId: s, subUnitId: a, trigger: c } = n, d = t.getByLocation(s, a, r, i), m = `${We.chatAtABC(i)}${r + 1}`, h = () => {
598
598
  e.hidePopup();
599
599
  }, u = (p) => {
600
600
  var v, S, R;
@@ -609,17 +609,17 @@ const Qt = () => {
609
609
  prefix: "cell",
610
610
  id: d,
611
611
  unitId: s,
612
- subUnitId: c,
612
+ subUnitId: a,
613
613
  type: b.UNIVER_SHEET,
614
614
  refStr: m,
615
615
  onClose: h,
616
616
  getSubUnitName: u,
617
- autoFocus: a === "context-menu"
617
+ autoFocus: c === "context-menu"
618
618
  }
619
619
  );
620
620
  }, Xt = () => {
621
621
  var g;
622
- const o = O(Se), e = O($), n = O(U), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = O(ie), s = Mt(() => t.activeSheet$.pipe(Pt((l) => l == null ? void 0 : l.getSheetId())), [t.activeSheet$]), c = j(s, (g = t.getActiveSheet()) == null ? void 0 : g.getSheetId()), a = ye(null), d = O(se), m = j(d.activeCommentId$), h = j(d.panelVisible$, d.panelVisible), u = ue((l) => {
622
+ const o = O(Se), e = O($), n = O(U), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = O(ie), s = Mt(() => t.activeSheet$.pipe(Pt((l) => l == null ? void 0 : l.getSheetId())), [t.activeSheet$]), a = j(s, (g = t.getActiveSheet()) == null ? void 0 : g.getSheetId()), c = ye(null), d = O(se), m = j(d.activeCommentId$), h = j(d.panelVisible$, d.panelVisible), u = ue((l) => {
623
623
  const I = t.getSheets(), f = {};
624
624
  I.forEach((T, C) => {
625
625
  f[T.getSheetId()] = C;
@@ -635,7 +635,7 @@ const Qt = () => {
635
635
  ];
636
636
  }, [t]), p = ue((l) => {
637
637
  var I;
638
- if (l.unitId === r && l.subUnitId === c && !l.resolved) {
638
+ if (l.unitId === r && l.subUnitId === a && !l.resolved) {
639
639
  const { row: f, column: M } = A(l.ref), T = t.getSheetBySheetId(l.subUnitId), C = (I = T == null ? void 0 : T.getMergedCell(f, M)) != null ? I : {
640
640
  startColumn: M,
641
641
  endColumn: M,
@@ -656,20 +656,20 @@ const Qt = () => {
656
656
  });
657
657
  }
658
658
  return null;
659
- }, [o, c, r]), v = (l) => {
659
+ }, [o, a, r]), v = (l) => {
660
660
  var I, f;
661
661
  return (f = (I = t.getSheetBySheetId(l)) == null ? void 0 : I.getName()) != null ? f : "";
662
662
  }, S = () => {
663
663
  i.executeCommand(V.id);
664
664
  }, R = (l) => {
665
- m && m.unitId === l.unitId && m.subUnitId === l.subUnitId && m.commentId === l.id || (a.current && (o.removeShape(a.current), a.current = null), a.current = p(l));
665
+ m && m.unitId === l.unitId && m.subUnitId === l.subUnitId && m.commentId === l.id || (c.current && (o.removeShape(c.current), c.current = null), c.current = p(l));
666
666
  }, x = () => {
667
- a.current && (o.removeShape(a.current), a.current = null);
667
+ c.current && (o.removeShape(c.current), c.current = null);
668
668
  }, X = (l, I) => {
669
669
  I && n.hidePopup();
670
670
  };
671
671
  return wt(() => {
672
- !h && a.current && o.removeShape(a.current);
672
+ !h && c.current && o.removeShape(c.current);
673
673
  }, [o, h]), /* @__PURE__ */ Me(
674
674
  nt,
675
675
  {
@@ -688,7 +688,7 @@ const Qt = () => {
688
688
  }, en = (o) => ({
689
689
  id: V.id,
690
690
  type: Ie.BUTTON,
691
- icon: ae,
691
+ icon: ce,
692
692
  title: "sheetThreadComment.menu.addComment",
693
693
  hidden$: Pe(o, b.UNIVER_SHEET),
694
694
  disabled$: ge(o, {
@@ -699,7 +699,7 @@ const Qt = () => {
699
699
  }), tn = (o) => ({
700
700
  id: Ce.id,
701
701
  type: Ie.BUTTON,
702
- icon: ae,
702
+ icon: ce,
703
703
  tooltip: "sheetThreadComment.menu.commentManagement",
704
704
  disabled$: ge(o, {
705
705
  workbookTypes: [q],
@@ -727,7 +727,7 @@ const Qt = () => {
727
727
  }
728
728
  }
729
729
  };
730
- var on = Object.defineProperty, sn = Object.getOwnPropertyDescriptor, cn = (o, e, n, t) => {
730
+ var on = Object.defineProperty, sn = Object.getOwnPropertyDescriptor, an = (o, e, n, t) => {
731
731
  for (var r = t > 1 ? void 0 : t ? sn(e, n) : e, i = o.length - 1, s; i >= 0; i--)
732
732
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
733
733
  return t && r && on(e, n, r), r;
@@ -746,19 +746,19 @@ let K = class extends N {
746
746
  [
747
747
  [Oe, Qt],
748
748
  [rt, Xt],
749
- [ae, $e]
749
+ [ce, $e]
750
750
  ].forEach(([o, e]) => {
751
751
  this._componentManager.register(o, e);
752
752
  });
753
753
  }
754
754
  };
755
- K = cn([
755
+ K = an([
756
756
  ne(0, St),
757
757
  ne(1, _(Ct)),
758
758
  ne(2, gt)
759
759
  ], K);
760
- var De = Object.defineProperty, an = Object.getOwnPropertyDescriptor, dn = (o, e, n) => e in o ? De(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, hn = (o, e, n, t) => {
761
- for (var r = t > 1 ? void 0 : t ? an(e, n) : e, i = o.length - 1, s; i >= 0; i--)
760
+ var De = Object.defineProperty, cn = Object.getOwnPropertyDescriptor, dn = (o, e, n) => e in o ? De(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, hn = (o, e, n, t) => {
761
+ for (var r = t > 1 ? void 0 : t ? cn(e, n) : e, i = o.length - 1, s; i >= 0; i--)
762
762
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
763
763
  return t && r && De(e, n, r), r;
764
764
  }, re = (o, e) => (n, t) => e(n, t, o), xe = (o, e, n) => dn(o, typeof e != "symbol" ? e + "" : e, n);
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(c,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):(c=typeof globalThis<"u"?globalThis:c||self,s(c.UniverSheetsThreadCommentUi={},c.UniverCore,c.UniverSheets,c.UniverSheetsThreadComment,c.UniverThreadCommentUi,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverEngineRender,c.UniverEngineFormula,c.UniverThreadComment,c.React,c.React))})(this,function(c,s,p,$,g,b,_,H,ne,V,f,re,U){"use strict";var Je=Object.defineProperty;var Qe=(c,s,p)=>s in c?Je(c,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[s]=p;var N=(c,s,p)=>Qe(c,typeof s!="symbol"?s+"":s,p);const ie="univer.sheet.thread-comment-modal",Y="comment-single",J="SHEET_THREAD_COMMENT";var le=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,ve=(i,t,n,e)=>{for(var r=e>1?void 0:e?pe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&le(t,n,r),r},oe=(i,t)=>(n,e)=>t(n,e,i);c.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new H.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var l;const{row:r,col:o,unitId:a,subUnitId:u}=n;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&u===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const d=this._canvasPopupManagerService.attachPopupToCell(r,o,{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!d)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const m=new s.DisposableCollection;m.add(d),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))}},c.SheetsThreadCommentPopupService=ve([oe(0,s.Inject(b.SheetCanvasPopManagerService)),oe(1,_.IZenZoneService)],c.SheetsThreadCommentPopupService);const k={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var I;const t=i.get(p.SheetsSelectionsService),n=i.get(s.IUniverInstanceService),e=i.get(c.SheetsThreadCommentPopupService),r=i.get(g.ThreadCommentPanelService),o=(I=t.getCurrentLastSelection())==null?void 0:I.primary,a=i.get($.SheetsThreadCommentModel);if(!o)return!1;const u=p.getSheetCommandTarget(n);if(!u)return!1;const{workbook:d,worksheet:m,unitId:l,subUnitId:h}=u,v={workbook:d,worksheet:m,unitId:l,subUnitId:h,row:o.startRow,col:o.startColumn};e.showPopup(v);const C=a.getByLocation(l,h,o.startRow,o.startColumn);return C&&r.setActiveComment({unitId:l,subUnitId:h,commentId:C,trigger:"context-menu"}),!0}},Se="sheets-thread-comment.config",se={};var Ce=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,fe=(i,t,n,e)=>{for(var r=e>1?void 0:e?_e(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ce(t,n,r),r},L=(i,t)=>(n,e)=>t(n,e,i);let W=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(i,t,n)=>{const{row:e,col:r,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,r)?n({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):n(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(H.debounceTime(16)).subscribe(()=>{i()}))}};W=fe([L(0,s.Inject(p.SheetInterceptorService)),L(1,s.Inject($.SheetsThreadCommentModel)),L(2,s.IUniverInstanceService),L(3,ne.IRenderManagerService)],W);var Ie=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Pe=(i,t,n,e)=>{for(var r=e>1?void 0:e?ge(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ie(t,n,r),r},Q=(i,t)=>(n,e)=>t(n,e,i);const Te=(i,t,n)=>{const e=V.singleReferenceToGrid(i),r=n.row-t.row,o=n.column-t.column,a={startColumn:e.column+o,startRow:e.row+r,endColumn:e.column+o,endRow:e.row+r};return V.serializeRange(a)};let x=class extends s.Disposable{constructor(t,n,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:J,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:o,subUnitId:a,range:u}=n,d={row:u.rows[0],column:u.cols[0]};if(r.copyType===b.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,v={row:m.startRow,column:m.startColumn};if(!(o===l&&a===h)){const C=[];s.Range.foreach(m,(w,S)=>{const E=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,S);this._threadCommentDataSourceService.syncUpdateMutationToColla?E.forEach(P=>{C.push(P)}):E.forEach(({children:P,...j})=>{j.parentId||C.push(j)})});const I=[],y=[],A=[],B=[],te=w=>{I.unshift({id:f.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),A.push({id:f.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:Te(w.ref,v,d),unitId:o,subUnitId:a},sync:!0}}),y.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 C.forEach(w=>{te(w)}),{redos:[...I,...A],undos:[...B,...y]}}}return{redos:[],undos:[]}}}))}};x=Pe([Q(0,s.Inject(b.ISheetClipboardService)),Q(1,s.Inject($.SheetsThreadCommentModel)),Q(2,f.IThreadCommentDataSourceService)],x);var be=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,ye=(i,t,n,e)=>{for(var r=e>1?void 0:e?Me(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&be(t,n,r),r},F=(i,t)=>(n,e)=>t(n,e,i);let q=class extends s.Disposable{constructor(i,t,n,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:n}=i,{unitId:e,subUnitId:r,row:o,col:a}=n,u=this._sheetsThreadCommentModel.getByLocation(e,r,o,a);if(u){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,r,u);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:o,col:a,commentId:u,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};q=ye([F(0,s.Inject(b.HoverManagerService)),F(1,s.Inject(c.SheetsThreadCommentPopupService)),F(2,s.Inject($.SheetsThreadCommentModel)),F(3,s.Inject(p.SheetPermissionCheckController))],q);var we=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&we(t,n,r),r},R=(i,t)=>(n,e)=>t(n,e,i);let G=class extends s.Disposable{constructor(t,n,e,r,o,a,u,d,m,l){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=o,this._sheetPermissionCheckController=a,this._markSelectionService=u,this._sheetSelectionService=d,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var v,C,I;const r=(v=t[0])==null?void 0:v.range,o=this._renderManagerService.getRenderById(n),a=(C=o==null?void 0:o.with(b.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:C.skeleton;if(!a||!r)return;const u=a.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((I=r.rangeType)!=null?I:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((u.isMerged||u.isMergedMainCell)&&s.Rectangle.equals(u.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const m=u.actualRow,l=u.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(n,e,m,l);h&&this._commandService.executeCommand(g.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===f.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:o,commentId:a}=e;n.unitId===r&&n.subUnitId===o&&n.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:o,trigger:a}=t,u=this._sheetsThreadCommentModel.getComment(e,r,o);if(!u||u.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=d.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const h=V.singleReferenceToGrid(u.ref),{row:v,column:C}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:v,startColumn:C,endRow:v,endColumn:C}]))return;const y=1;if(await this._commandService.executeCommand(b.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-y,0),endRow:h.row+y,startColumn:Math.max(h.column-y,0),endColumn:h.column+y}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:h.row,col:h.column,commentId:u.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(H.debounceTime(100)).subscribe(t=>{var v,C;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,r);if(!o)return;const a=V.singleReferenceToGrid(o.ref),{row:u,column:d}=a;if(Number.isNaN(u)||Number.isNaN(d))return null;const m=(v=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getSheetBySheetId(e),l=(C=m==null?void 0:m.getMergedCell(u,d))!=null?C:{startColumn:d,endColumn:d,startRow:u,endRow:u},h=this._markSelectionService.addShape({range:l,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};G=Oe([R(0,s.ICommandService),R(1,s.Inject(c.SheetsThreadCommentPopupService)),R(2,s.Inject($.SheetsThreadCommentModel)),R(3,s.Inject(g.ThreadCommentPanelService)),R(4,s.IUniverInstanceService),R(5,s.Inject(p.SheetPermissionCheckController)),R(6,b.IMarkSelectionService),R(7,s.Inject(p.SheetsSelectionsService)),R(8,b.IEditorBridgeService),R(9,ne.IRenderManagerService)],G);var Ue=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,je=(i,t,n,e)=>{for(var r=e>1?void 0:e?Re(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ue(t,n,r),r},Z=(i,t)=>(n,e)=>t(n,e,i);let z=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===p.RemoveSheetCommand.id){const n=i.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(r,o),u=Array.from(a.values()).filter(v=>!v.parentId),d=u.map(v=>v.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=d.map(v=>({id:f.DeleteCommentMutation.id,params:{unitId:r,subUnitId:o,commentId:v}})),h=u.map(({children:v,...C})=>({id:f.AddCommentMutation.id,params:{unitId:r,subUnitId:o,comment:{...C,children:m?v:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};z=je([Z(0,s.Inject(p.SheetInterceptorService)),Z(1,s.IUniverInstanceService),Z(2,s.Inject(f.ThreadCommentModel)),Z(3,f.IThreadCommentDataSourceService)],z);var M=function(){return M=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},M.apply(this,arguments)},De=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},ae=U.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=De(i,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),d=U.useRef("_".concat(Ae()));return ce(n,"".concat(e),{defIds:n.defIds,idSuffix:d.current},M({ref:t,className:u},a),o)});function ce(i,t,n,e,r){return U.createElement(i.tag,M(M({key:t},Ne(i,n,r)),e),($e(i,n).children||[]).map(function(o,a){return ce(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function Ne(i,t,n){var e=M({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],u=o[1];typeof u=="string"&&(e[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function $e(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?M(M({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?M(M({},r),{attrs:M(M({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function Ae(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ue=U.forwardRef(function(i,t){return U.createElement(ae,Object.assign({},i,{id:"comment-single",ref:t,icon:Ve}))});ue.displayName="CommentSingle";const ke=()=>{const i=s.useDependency(s.IUniverInstanceService),t=s.useDependency(c.SheetsThreadCommentPopupService),n=_.useObservable(t.activePopup$),e=s.useDependency($.SheetsThreadCommentModel);if(_.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:o,unitId:a,subUnitId:u,trigger:d}=n,m=e.getByLocation(a,u,r,o),l=`${s.Tools.chatAtABC(o)}${r+1}`,h=()=>{t.hidePopup()},v=C=>{var I,y,A;return(A=(y=(I=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(C))==null?void 0:y.getName())!=null?A:""};return re.jsx(g.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:a,subUnitId:u,type:s.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:v,autoFocus:d==="context-menu"})},He=()=>{var w;const i=s.useDependency(b.IMarkSelectionService),t=s.useDependency(s.IUniverInstanceService),n=s.useDependency(c.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),o=s.useDependency(s.ICommandService),a=U.useMemo(()=>e.activeSheet$.pipe(H.map(S=>S==null?void 0:S.getSheetId())),[e.activeSheet$]),u=_.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),d=U.useRef(null),m=s.useDependency(g.ThreadCommentPanelService),l=_.useObservable(m.activeCommentId$),h=_.useObservable(m.panelVisible$,m.panelVisible),v=U.useCallback(S=>{const E=e.getSheets(),P={};E.forEach((O,T)=>{P[O.getSheetId()]=T});const j=O=>O.map(T=>{var he;const D=V.singleReferenceToGrid(T.ref),Ye=[(he=P[T.subUnitId])!=null?he:0,D.row,D.column];return{...T,p:Ye}}).sort((T,D)=>T.p[0]===D.p[0]?T.p[1]===D.p[1]?T.p[2]-D.p[2]:T.p[1]-D.p[1]:T.p[0]-D.p[0]);return[...j(S.filter(O=>!O.resolved)),...j(S.filter(O=>O.resolved))]},[e]),C=U.useCallback(S=>{var E;if(S.unitId===r&&S.subUnitId===u&&!S.resolved){const{row:P,column:j}=V.singleReferenceToGrid(S.ref),O=e.getSheetBySheetId(S.subUnitId),T=(E=O==null?void 0:O.getMergedCell(P,j))!=null?E:{startColumn:j,endColumn:j,startRow:P,endRow:P};if(!Number.isNaN(P)&&!Number.isNaN(j))return i.addShape({range:T,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[i,u,r]),I=S=>{var E,P;return(P=(E=e.getSheetBySheetId(S))==null?void 0:E.getName())!=null?P:""},y=()=>{o.executeCommand(k.id)},A=S=>{l&&l.unitId===S.unitId&&l.subUnitId===S.subUnitId&&l.commentId===S.id||(d.current&&(i.removeShape(d.current),d.current=null),d.current=C(S))},B=()=>{d.current&&(i.removeShape(d.current),d.current=null)},te=(S,E)=>{E&&n.hidePopup()};return U.useEffect(()=>{!h&&d.current&&i.removeShape(d.current)},[i,h]),re.jsx(g.ThreadCommentPanel,{unitId:r,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:y,getSubUnitName:I,onResolve:te,sortComments:v,onItemEnter:A,onItemLeave:B,onDeleteComment:()=>(B(),!0)})},Be=i=>({id:k.id,type:_.MenuItemType.BUTTON,icon:Y,title:"sheetThreadComment.menu.addComment",hidden$:_.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),Le=i=>({id:g.ToggleSheetCommentPanelOperation.id,type:_.MenuItemType.BUTTON,icon:Y,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET)}),We={id:k.id,binding:_.KeyCode.M|_.MetaKeys.CTRL_COMMAND|_.MetaKeys.ALT,preconditions:b.whenSheetEditorFocused},xe={[_.RibbonStartGroup.OTHERS]:{[g.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Le}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.OTHERS]:{[k.id]:{order:0,menuItemFactory:Be}}}};var Fe=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Ge=(i,t,n,e)=>{for(var r=e>1?void 0:e?qe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Fe(t,n,r),r},X=(i,t)=>(n,e)=>t(n,e,i);let K=class extends s.Disposable{constructor(i,t,n){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(We)}_initMenu(){this._menuManagerService.mergeMenu(xe)}_initComponent(){[[ie,ke],[g.THREAD_COMMENT_PANEL,He],[Y,ue]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};K=Ge([X(0,_.IMenuManagerService),X(1,s.Inject(_.ComponentManager)),X(2,_.IShortcutService)],K);var de=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,ze=(i,t,n)=>t in i?de(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,Ke=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ze(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&de(t,n,r),r},ee=(i,t)=>(n,e)=>t(n,e,i),me=(i,t,n)=>ze(i,typeof t!="symbol"?t+"":t,n);c.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=se,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:o,...a}=s.merge({},se,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Se,a)}onStarting(){[[K],[W],[x],[q],[z],[G],[c.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[k].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)}},me(c.UniverSheetsThreadCommentUIPlugin,"pluginName",J),me(c.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentUIPlugin=Ke([s.DependentOn(g.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),ee(1,s.Inject(s.Injector)),ee(2,s.Inject(s.ICommandService)),ee(3,s.IConfigService)],c.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>g.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"AddCommentCommand",{enumerable:!0,get:()=>f.AddCommentCommand}),Object.defineProperty(c,"DeleteCommentCommand",{enumerable:!0,get:()=>f.DeleteCommentCommand}),Object.defineProperty(c,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>f.DeleteCommentTreeCommand}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>f.IThreadCommentDataSourceService}),Object.defineProperty(c,"ResolveCommentCommand",{enumerable:!0,get:()=>f.ResolveCommentCommand}),Object.defineProperty(c,"UpdateCommentCommand",{enumerable:!0,get:()=>f.UpdateCommentCommand}),c.SHEETS_THREAD_COMMENT=J,c.ShowAddSheetCommentModalOperation=k,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,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):(c=typeof globalThis<"u"?globalThis:c||self,s(c.UniverSheetsThreadCommentUi={},c.UniverCore,c.UniverSheets,c.UniverSheetsThreadComment,c.UniverThreadCommentUi,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverEngineRender,c.UniverEngineFormula,c.UniverThreadComment,c.React,c.React))})(this,function(c,s,p,$,g,b,_,H,ne,V,f,re,U){"use strict";var Je=Object.defineProperty;var Qe=(c,s,p)=>s in c?Je(c,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[s]=p;var N=(c,s,p)=>Qe(c,typeof s!="symbol"?s+"":s,p);const ie="univer.sheet.thread-comment-modal",Y="comment-single",J="SHEET_THREAD_COMMENT";var le=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,ve=(i,t,n,e)=>{for(var r=e>1?void 0:e?pe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&le(t,n,r),r},oe=(i,t)=>(n,e)=>t(n,e,i);c.SheetsThreadCommentPopupService=class extends s.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new H.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var l;const{row:r,col:o,unitId:a,subUnitId:u}=n;if(this._activePopup&&r===this._activePopup.row&&o===this._activePopup.col&&a===this._activePopup.unitId&&u===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const d=this._canvasPopupManagerService.attachPopupToCell(r,o,{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!d)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const m=new s.DisposableCollection;m.add(d),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))}},c.SheetsThreadCommentPopupService=ve([oe(0,s.Inject(b.SheetCanvasPopManagerService)),oe(1,_.IZenZoneService)],c.SheetsThreadCommentPopupService);const k={type:s.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var I;const t=i.get(p.SheetsSelectionsService),n=i.get(s.IUniverInstanceService),e=i.get(c.SheetsThreadCommentPopupService),r=i.get(g.ThreadCommentPanelService),o=(I=t.getCurrentLastSelection())==null?void 0:I.primary,a=i.get($.SheetsThreadCommentModel);if(!o)return!1;const u=p.getSheetCommandTarget(n);if(!u)return!1;const{workbook:d,worksheet:m,unitId:l,subUnitId:h}=u,v={workbook:d,worksheet:m,unitId:l,subUnitId:h,row:o.startRow,col:o.startColumn};e.showPopup(v);const C=a.getByLocation(l,h,o.startRow,o.startColumn);return C&&r.setActiveComment({unitId:l,subUnitId:h,commentId:C,trigger:"context-menu"}),!0}},Se="sheets-thread-comment.config",se={};var Ce=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,fe=(i,t,n,e)=>{for(var r=e>1?void 0:e?_e(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ce(t,n,r),r},L=(i,t)=>(n,e)=>t(n,e,i);let W=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(i,t,n)=>{const{row:e,col:r,unitId:o,subUnitId:a}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,a,e,r)?n({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):n(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var r;const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=t.getUnitId(),e=this._renderManagerService.getRenderById(n);(r=e==null?void 0:e.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(H.debounceTime(16)).subscribe(()=>{i()}))}};W=fe([L(0,s.Inject(p.SheetInterceptorService)),L(1,s.Inject($.SheetsThreadCommentModel)),L(2,s.IUniverInstanceService),L(3,ne.IRenderManagerService)],W);var Ie=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Pe=(i,t,n,e)=>{for(var r=e>1?void 0:e?ge(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ie(t,n,r),r},Q=(i,t)=>(n,e)=>t(n,e,i);const Te=(i,t,n)=>{const e=V.singleReferenceToGrid(i),r=n.row-t.row,o=n.column-t.column,a={startColumn:e.column+o,startRow:e.row+r,endColumn:e.column+o,endRow:e.row+r};return V.serializeRange(a)};let x=class extends s.Disposable{constructor(t,n,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:J,onBeforeCopy:(t,n,e)=>{this._copyInfo={unitId:t,subUnitId:n,range:e}},onPasteCells:(t,n,e,r)=>{const{unitId:o,subUnitId:a,range:u}=n,d={row:u.rows[0],column:u.cols[0]};if(r.copyType===b.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,v={row:m.startRow,column:m.startColumn};if(!(o===l&&a===h)){const C=[];s.Range.foreach(m,(w,S)=>{const E=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,S);this._threadCommentDataSourceService.syncUpdateMutationToColla?E.forEach(P=>{C.push(P)}):E.forEach(({children:P,...j})=>{j.parentId||C.push(j)})});const I=[],y=[],A=[],B=[],te=w=>{I.unshift({id:f.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),A.push({id:f.AddCommentMutation.id,params:{unitId:o,subUnitId:a,comment:{...w,ref:Te(w.ref,v,d),unitId:o,subUnitId:a},sync:!0}}),y.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 C.forEach(w=>{te(w)}),{redos:[...I,...A],undos:[...B,...y]}}}return{redos:[],undos:[]}}}))}};x=Pe([Q(0,s.Inject(b.ISheetClipboardService)),Q(1,s.Inject($.SheetsThreadCommentModel)),Q(2,f.IThreadCommentDataSourceService)],x);var be=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,ye=(i,t,n,e)=>{for(var r=e>1?void 0:e?Me(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&be(t,n,r),r},F=(i,t)=>(n,e)=>t(n,e,i);let q=class extends s.Disposable{constructor(i,t,n,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:n}=i,{unitId:e,subUnitId:r,row:o,col:a}=n,u=this._sheetsThreadCommentModel.getByLocation(e,r,o,a);if(u){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,r,u);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:o,col:a,commentId:u,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};q=ye([F(0,s.Inject(b.HoverManagerService)),F(1,s.Inject(c.SheetsThreadCommentPopupService)),F(2,s.Inject($.SheetsThreadCommentModel)),F(3,s.Inject(p.SheetPermissionCheckController))],q);var we=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ee(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&we(t,n,r),r},R=(i,t)=>(n,e)=>t(n,e,i);let G=class extends s.Disposable{constructor(t,n,e,r,o,a,u,d,m,l){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=r,this._univerInstanceService=o,this._sheetPermissionCheckController=a,this._markSelectionService=u,this._sheetSelectionService=d,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,e){var v,C,I;const r=(v=t[0])==null?void 0:v.range,o=this._renderManagerService.getRenderById(n),a=(C=o==null?void 0:o.with(b.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:C.skeleton;if(!a||!r)return;const u=a.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((I=r.rangeType)!=null?I:s.RANGE_TYPE.NORMAL)!==s.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((u.isMerged||u.isMergedMainCell)&&s.Rectangle.equals(u.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const m=u.actualRow,l=u.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(n,e,m,l);h&&this._commandService.executeCommand(g.SetActiveCommentOperation.id,{unitId:n,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(t,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===f.DeleteCommentMutation.id){const n=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:r,subUnitId:o,commentId:a}=e;n.unitId===r&&n.subUnitId===o&&n.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var n;if(t){const{unitId:e,subUnitId:r,commentId:o,trigger:a}=t,u=this._sheetsThreadCommentModel.getComment(e,r,o);if(!u||u.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((n=d.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r}),this._isSwitchToCommenting=!1;const h=V.singleReferenceToGrid(u.ref),{row:v,column:C}=h;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:v,startColumn:C,endRow:v,endColumn:C}]))return;const y=1;if(await this._commandService.executeCommand(b.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-y,0),endRow:h.row+y,startColumn:Math.max(h.column-y,0),endColumn:h.column+y}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:r,row:h.row,col:h.column,commentId:u.id,trigger:a})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(H.debounceTime(100)).subscribe(t=>{var v,C;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:e,commentId:r}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(n,e,r);if(!o)return;const a=V.singleReferenceToGrid(o.ref),{row:u,column:d}=a;if(Number.isNaN(u)||Number.isNaN(d))return null;const m=(v=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getSheetBySheetId(e),l=(C=m==null?void 0:m.getMergedCell(u,d))!=null?C:{startColumn:d,endColumn:d,startRow:u,endRow:u},h=this._markSelectionService.addShape({range:l,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};G=Oe([R(0,s.ICommandService),R(1,s.Inject(c.SheetsThreadCommentPopupService)),R(2,s.Inject($.SheetsThreadCommentModel)),R(3,s.Inject(g.ThreadCommentPanelService)),R(4,s.IUniverInstanceService),R(5,s.Inject(p.SheetPermissionCheckController)),R(6,b.IMarkSelectionService),R(7,s.Inject(p.SheetsSelectionsService)),R(8,b.IEditorBridgeService),R(9,ne.IRenderManagerService)],G);var Ue=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,je=(i,t,n,e)=>{for(var r=e>1?void 0:e?Re(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ue(t,n,r),r},Z=(i,t)=>(n,e)=>t(n,e,i);let z=class extends s.Disposable{constructor(i,t,n,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===p.RemoveSheetCommand.id){const n=i.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=n.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._threadCommentModel.ensureMap(r,o),u=Array.from(a.values()).filter(v=>!v.parentId),d=u.map(v=>v.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=d.map(v=>({id:f.DeleteCommentMutation.id,params:{unitId:r,subUnitId:o,commentId:v}})),h=u.map(({children:v,...C})=>({id:f.AddCommentMutation.id,params:{unitId:r,subUnitId:o,comment:{...C,children:m?v:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};z=je([Z(0,s.Inject(p.SheetInterceptorService)),Z(1,s.IUniverInstanceService),Z(2,s.Inject(f.ThreadCommentModel)),Z(3,f.IThreadCommentDataSourceService)],z);var M=function(){return M=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},M.apply(this,arguments)},De=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},ae=U.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=De(i,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),d=U.useRef("_".concat(Ae()));return ce(n,"".concat(e),{defIds:n.defIds,idSuffix:d.current},M({ref:t,className:u},a),o)});function ce(i,t,n,e,r){return U.createElement(i.tag,M(M({key:t},Ne(i,n,r)),e),($e(i,n).children||[]).map(function(o,a){return ce(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function Ne(i,t,n){var e=M({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],u=o[1];typeof u=="string"&&(e[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function $e(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?M(M({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?M(M({},r),{attrs:M(M({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function Ae(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ue=U.forwardRef(function(i,t){return U.createElement(ae,Object.assign({},i,{id:"comment-single",ref:t,icon:Ve}))});ue.displayName="CommentSingle";const ke=()=>{const i=s.useDependency(s.IUniverInstanceService),t=s.useDependency(c.SheetsThreadCommentPopupService),n=_.useObservable(t.activePopup$),e=s.useDependency($.SheetsThreadCommentModel);if(_.useObservable(e.commentUpdate$),!n)return null;const{row:r,col:o,unitId:a,subUnitId:u,trigger:d}=n,m=e.getByLocation(a,u,r,o),l=`${s.Tools.chatAtABC(o)}${r+1}`,h=()=>{t.hidePopup()},v=C=>{var I,y,A;return(A=(y=(I=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(C))==null?void 0:y.getName())!=null?A:""};return re.jsx(g.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:a,subUnitId:u,type:s.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:v,autoFocus:d==="context-menu"})},He=()=>{var w;const i=s.useDependency(b.IMarkSelectionService),t=s.useDependency(s.IUniverInstanceService),n=s.useDependency(c.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),r=e.getUnitId(),o=s.useDependency(s.ICommandService),a=U.useMemo(()=>e.activeSheet$.pipe(H.map(S=>S==null?void 0:S.getSheetId())),[e.activeSheet$]),u=_.useObservable(a,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),d=U.useRef(null),m=s.useDependency(g.ThreadCommentPanelService),l=_.useObservable(m.activeCommentId$),h=_.useObservable(m.panelVisible$,m.panelVisible),v=U.useCallback(S=>{const E=e.getSheets(),P={};E.forEach((O,T)=>{P[O.getSheetId()]=T});const j=O=>O.map(T=>{var he;const D=V.singleReferenceToGrid(T.ref),Ye=[(he=P[T.subUnitId])!=null?he:0,D.row,D.column];return{...T,p:Ye}}).sort((T,D)=>T.p[0]===D.p[0]?T.p[1]===D.p[1]?T.p[2]-D.p[2]:T.p[1]-D.p[1]:T.p[0]-D.p[0]);return[...j(S.filter(O=>!O.resolved)),...j(S.filter(O=>O.resolved))]},[e]),C=U.useCallback(S=>{var E;if(S.unitId===r&&S.subUnitId===u&&!S.resolved){const{row:P,column:j}=V.singleReferenceToGrid(S.ref),O=e.getSheetBySheetId(S.subUnitId),T=(E=O==null?void 0:O.getMergedCell(P,j))!=null?E:{startColumn:j,endColumn:j,startRow:P,endRow:P};if(!Number.isNaN(P)&&!Number.isNaN(j))return i.addShape({range:T,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[i,u,r]),I=S=>{var E,P;return(P=(E=e.getSheetBySheetId(S))==null?void 0:E.getName())!=null?P:""},y=()=>{o.executeCommand(k.id)},A=S=>{l&&l.unitId===S.unitId&&l.subUnitId===S.subUnitId&&l.commentId===S.id||(d.current&&(i.removeShape(d.current),d.current=null),d.current=C(S))},B=()=>{d.current&&(i.removeShape(d.current),d.current=null)},te=(S,E)=>{E&&n.hidePopup()};return U.useEffect(()=>{!h&&d.current&&i.removeShape(d.current)},[i,h]),re.jsx(g.ThreadCommentPanel,{unitId:r,subUnitId$:a,type:s.UniverInstanceType.UNIVER_SHEET,onAdd:y,getSubUnitName:I,onResolve:te,sortComments:v,onItemEnter:A,onItemLeave:B,onDeleteComment:()=>(B(),!0)})},Be=i=>({id:k.id,type:_.MenuItemType.BUTTON,icon:Y,title:"sheetThreadComment.menu.addComment",hidden$:_.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),Le=i=>({id:g.ToggleSheetCommentPanelOperation.id,type:_.MenuItemType.BUTTON,icon:Y,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET)}),We={id:k.id,binding:_.KeyCode.M|_.MetaKeys.CTRL_COMMAND|_.MetaKeys.ALT,preconditions:b.whenSheetEditorFocused},xe={[_.RibbonStartGroup.OTHERS]:{[g.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Le}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.OTHERS]:{[k.id]:{order:0,menuItemFactory:Be}}}};var Fe=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Ge=(i,t,n,e)=>{for(var r=e>1?void 0:e?qe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Fe(t,n,r),r},X=(i,t)=>(n,e)=>t(n,e,i);let K=class extends s.Disposable{constructor(i,t,n){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(We)}_initMenu(){this._menuManagerService.mergeMenu(xe)}_initComponent(){[[ie,ke],[g.THREAD_COMMENT_PANEL,He],[Y,ue]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};K=Ge([X(0,_.IMenuManagerService),X(1,s.Inject(_.ComponentManager)),X(2,_.IShortcutService)],K);var de=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,ze=(i,t,n)=>t in i?de(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,Ke=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ze(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&de(t,n,r),r},ee=(i,t)=>(n,e)=>t(n,e,i),me=(i,t,n)=>ze(i,typeof t!="symbol"?t+"":t,n);c.UniverSheetsThreadCommentUIPlugin=class extends s.Plugin{constructor(t=se,n,e,r){super(),this._config=t,this._injector=n,this._commandService=e,this._configService=r;const{menu:o,...a}=s.merge({},se,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Se,a)}onStarting(){[[K],[W],[x],[q],[z],[G],[c.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[k].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)}},me(c.UniverSheetsThreadCommentUIPlugin,"pluginName",J),me(c.UniverSheetsThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentUIPlugin=Ke([s.DependentOn(g.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),ee(1,s.Inject(s.Injector)),ee(2,s.Inject(s.ICommandService)),ee(3,s.IConfigService)],c.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>g.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"AddCommentCommand",{enumerable:!0,get:()=>f.AddCommentCommand}),Object.defineProperty(c,"DeleteCommentCommand",{enumerable:!0,get:()=>f.DeleteCommentCommand}),Object.defineProperty(c,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>f.DeleteCommentTreeCommand}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>f.IThreadCommentDataSourceService}),Object.defineProperty(c,"ResolveCommentCommand",{enumerable:!0,get:()=>f.ResolveCommentCommand}),Object.defineProperty(c,"UpdateCommentCommand",{enumerable:!0,get:()=>f.UpdateCommentCommand}),c.SHEETS_THREAD_COMMENT=J,c.ShowAddSheetCommentModalOperation=k,Object.defineProperty(c,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.6.0-nightly.202502041606",
3
+ "version": "0.6.0-nightly.202502061605",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -54,15 +54,15 @@
54
54
  "dependencies": {
55
55
  "@univerjs/icons": "^0.2.14",
56
56
  "clsx": "^2.1.1",
57
- "@univerjs/core": "0.6.0-nightly.202502041606",
58
- "@univerjs/engine-formula": "0.6.0-nightly.202502041606",
59
- "@univerjs/engine-render": "0.6.0-nightly.202502041606",
60
- "@univerjs/sheets-thread-comment": "0.6.0-nightly.202502041606",
61
- "@univerjs/sheets": "0.6.0-nightly.202502041606",
62
- "@univerjs/sheets-ui": "0.6.0-nightly.202502041606",
63
- "@univerjs/thread-comment": "0.6.0-nightly.202502041606",
64
- "@univerjs/ui": "0.6.0-nightly.202502041606",
65
- "@univerjs/thread-comment-ui": "0.6.0-nightly.202502041606"
57
+ "@univerjs/core": "0.6.0-nightly.202502061605",
58
+ "@univerjs/engine-formula": "0.6.0-nightly.202502061605",
59
+ "@univerjs/engine-render": "0.6.0-nightly.202502061605",
60
+ "@univerjs/sheets-thread-comment": "0.6.0-nightly.202502061605",
61
+ "@univerjs/sheets-ui": "0.6.0-nightly.202502061605",
62
+ "@univerjs/thread-comment-ui": "0.6.0-nightly.202502061605",
63
+ "@univerjs/sheets": "0.6.0-nightly.202502061605",
64
+ "@univerjs/thread-comment": "0.6.0-nightly.202502061605",
65
+ "@univerjs/ui": "0.6.0-nightly.202502061605"
66
66
  },
67
67
  "devDependencies": {
68
68
  "postcss": "^8.5.1",