@univerjs/sheets-thread-comment 0.2.4-alpha.0 → 0.2.5

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 oe=Object.defineProperty;var ie=(o,r,t)=>r in o?oe(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t;var R=(o,r,t)=>ie(o,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),y=require("@univerjs/thread-comment-ui"),S=require("@univerjs/ui"),C=require("@univerjs/sheets"),N=require("@univerjs/engine-formula"),O=require("@univerjs/thread-comment"),_=require("@univerjs/sheets-ui"),D=require("@univerjs/sheets-thread-comment-base"),T=require("react"),q=require("rxjs"),se=require("@univerjs/engine-render");var b=function(){return b=Object.assign||function(o){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(o[n]=r[n])}return o},b.apply(this,arguments)},ae=function(o,r){var t={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&r.indexOf(e)<0&&(t[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(o);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(o,e[n])&&(t[e[n]]=o[e[n]]);return t},X=T.forwardRef(function(o,r){var t=o.icon,e=o.id,n=o.className,i=o.extend,s=ae(o,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),c=T.useRef("_".concat(he()));return J(t,"".concat(e),{defIds:t.defIds,idSuffix:c.current},b({ref:r,className:m},s),i)});function J(o,r,t,e,n){return T.createElement(o.tag,b(b({key:r},ce(o,t,n)),e),(me(o,t).children||[]).map(function(i,s){return J(i,"".concat(r,"-").concat(o.tag,"-").concat(s),t,void 0,n)}))}function ce(o,r,t){var e=b({},o.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1);var n=r.defIds;return!n||n.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],m=i[1];typeof m=="string"&&(e[s]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function me(o,r){var t,e=r.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((t=o.children)===null||t===void 0)&&t.length)?b(b({},o),{children:o.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?b(b({},n),{attrs:b(b({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):o}function he(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var de={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"}}]},Q=T.forwardRef(function(o,r){return T.createElement(X,Object.assign({},o,{id:"comment-single",ref:r,icon:de}))});Q.displayName="CommentSingle";const ee="univer.sheet.thread-comment-modal",Z="comment-single",z="SHEET_THREAD_COMMENT";var ue=Object.defineProperty,le=Object.getOwnPropertyDescriptor,pe=(o,r,t,e)=>{for(var n=e>1?void 0:e?le(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&ue(r,t,n),n},K=(o,r)=>(t,e)=>r(t,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(t,e){super();R(this,"_lastPopup",null);R(this,"_activePopup");R(this,"_activePopup$",new q.BehaviorSubject(null));R(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=t,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this.hidePopup()}))}showPopup(t,e){var h;const{row:n,col:i,unitId:s,subUnitId:m}=t;if(this._activePopup&&n===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&m===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=t,this._activePopup$.next(t);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=t,this._activePopup$.next(t);const c=this._canvasPopupManagerService.attachPopupToCell(n,i,{componentKey:ee,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!c)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(c),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=pe([K(0,a.Inject(_.SheetCanvasPopManagerService)),K(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const ve=()=>{const o=a.useDependency(a.IUniverInstanceService),r=a.useDependency(exports.SheetsThreadCommentPopupService),t=S.useObservable(r.activePopup$),e=a.useDependency(D.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!t)return null;const{row:n,col:i,unitId:s,subUnitId:m,trigger:c}=t,d=e.getByLocation(s,m,n,i),h=`${a.Tools.chatAtABC(i)}${n+1}`,p=()=>{r.hidePopup()},l=v=>{var f,E,I;return(I=(E=(f=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(v))==null?void 0:E.getName())!=null?I:""};return T.createElement(y.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:m,type:a.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:p,getSubUnitName:l,autoFocus:c==="context-menu"})},A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const r=o.get(C.SheetsSelectionsService),t=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),n=o.get(y.ThreadCommentPanelService),i=(f=r.getCurrentLastSelection())==null?void 0:f.primary,s=o.get(D.SheetsThreadCommentModel);if(!i)return!1;const m=C.getSheetCommandTarget(t);if(!m)return!1;const{workbook:c,worksheet:d,unitId:h,subUnitId:p}=m,l={workbook:c,worksheet:d,unitId:h,subUnitId:p,row:i.startRow,col:i.startColumn};e.showPopup(l);const v=s.getByLocation(h,p,i.startRow,i.startColumn);return v&&n.setActiveComment({unitId:h,subUnitId:p,commentId:v,trigger:"context-menu"}),!0}},Ce=()=>{var H;const o=a.useDependency(_.IMarkSelectionService),r=a.useDependency(a.IUniverInstanceService),t=a.useDependency(exports.SheetsThreadCommentPopupService),e=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getUnitId(),i=a.useDependency(a.ICommandService),s=T.useMemo(()=>e.activeSheet$.pipe(q.map(u=>u==null?void 0:u.getSheetId())),[e.activeSheet$]),m=S.useObservable(s,(H=e.getActiveSheet())==null?void 0:H.getSheetId()),c=T.useRef(),d=a.useDependency(y.ThreadCommentPanelService),h=S.useObservable(d.activeCommentId$),p=S.useObservable(d.panelVisible$,d.panelVisible),l=T.useCallback(u=>{const g=e.getSheets(),P={};g.forEach((U,M)=>{P[U.getSheetId()]=M});const V=U=>U.map(M=>{var G;const j=N.singleReferenceToGrid(M.ref),re=[(G=P[M.subUnitId])!=null?G:0,j.row,j.column];return{...M,p:re}}).sort((M,j)=>M.p[0]===j.p[0]?M.p[1]===j.p[1]?M.p[2]-j.p[2]:M.p[1]-j.p[1]:M.p[0]-j.p[0]);return[...V(u.filter(U=>!U.resolved)),...V(u.filter(U=>U.resolved))]},[e]),v=T.useCallback(u=>{if(u.unitId===n&&u.subUnitId===m&&!u.resolved){const{row:g,column:P}=N.singleReferenceToGrid(u.ref);if(!Number.isNaN(g)&&!Number.isNaN(P))return o.addShape({range:{startColumn:P,endColumn:P,startRow:g,endRow:g},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,m,n]),f=u=>{var g,P;return(P=(g=e.getSheetBySheetId(u))==null?void 0:g.getName())!=null?P:""},E=()=>{i.executeCommand(A.id)},I=u=>{h&&h.unitId===u.unitId&&h.subUnitId===u.subUnitId&&h.commentId===u.id||(c.current&&(o.removeShape(c.current),c.current=null),c.current=v(u))},$=()=>{c.current&&(o.removeShape(c.current),c.current=null)},x=(u,g)=>{g&&t.hidePopup()};return T.useEffect(()=>{!p&&c.current&&o.removeShape(c.current)},[o,p]),T.createElement(y.ThreadCommentPanel,{unitId:n,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:E,getSubUnitName:f,onResolve:x,sortComments:l,onItemEnter:I,onItemLeave:$,onDeleteComment:()=>($(),!0)})},Se=o=>({id:A.id,type:S.MenuItemType.BUTTON,positions:[S.MenuPosition.CONTEXT_MENU],icon:Z,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),fe=o=>({id:y.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:Z,tooltip:"sheetThreadComment.menu.commentManagement",positions:S.MenuPosition.TOOLBAR_START,group:S.MenuGroup.TOOLBAR_OTHERS,disabled$:_.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),_e={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:_.whenSheetEditorFocused};var Ie=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Pe=(o,r,t,e)=>{for(var n=e>1?void 0:e?ge(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ie(r,t,n),n},w=(o,r)=>(t,e)=>r(t,e,o);const Te={};exports.SheetsThreadCommentController=class extends a.Disposable{constructor(t,e,n,i,s,m,c,d,h,p,l,v){super();R(this,"_isSwitchToCommenting",!1);R(this,"_selectionShapeInfo",null);this._config=t,this._menuService=e,this._injector=n,this._componentManager=i,this._commandService=s,this._sheetsThreadCommentPopupService=m,this._sheetsThreadCommentModel=c,this._threadCommentPanelService=d,this._shortcutService=h,this._univerInstanceService=p,this._sheetPermissionInterceptorBaseController=l,this._markSelectionService=v,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection()}_initShortcut(){this._shortcutService.registerShortcut(_e)}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.SetSelectionsOperation.id){if(this._isSwitchToCommenting)return;const e=t.params,{unitId:n,subUnitId:i,selections:s,type:m}=e;if((m===C.SelectionMoveType.MOVE_END||m===void 0)&&s[0].primary){const c=s[0].range;if(c.endColumn-c.startColumn>0||c.endRow-c.startRow>0)return;const d=s[0].primary.actualRow,h=s[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,i,d,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(y.SetActiveCommentOperation.id);return}const p=this._sheetsThreadCommentModel.getByLocation(n,i,d,h);p&&this._commandService.executeCommand(y.SetActiveCommentOperation.id,{unitId:n,subUnitId:i,commentId:p})}}if(t.id===O.DeleteCommentMutation.id){const e=t.params,n=this._sheetsThreadCommentPopupService.activePopup;if(!n)return;const{unitId:i,subUnitId:s,commentId:m}=n;e.unitId===i&&e.subUnitId===s&&e.commentId===m&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:t={}}=this._config;[Se,fe].forEach(e=>{this._menuService.addMenuItem(e(this._injector),t)})}_initComponent(){[[ee,ve],[y.THREAD_COMMENT_PANEL,Ce],[Z,Q]].forEach(([t,e])=>{this._componentManager.register(t,e)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var e;if(t){const{unitId:n,subUnitId:i,commentId:s,trigger:m}=t,c=this._sheetsThreadCommentModel.getComment(n,i,s);if(!c||c.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==n)return;this._isSwitchToCommenting=!0,((e=d.getActiveSheet())==null?void 0:e.getSheetId())!==i&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:i}),this._isSwitchToCommenting=!1;const l=N.singleReferenceToGrid(c.ref),{row:v,column:f}=l;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:v,startColumn:f,endRow:v,endColumn:f}]))return;const I=1;await this._commandService.executeCommand(_.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-I,0),endRow:l.row+I,startColumn:Math.max(l.column-I,0),endColumn:l.column+I}}),this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:i,row:l.row,col:l.column,commentId:c.id,trigger:m})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(t=>{if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:e,subUnitId:n,commentId:i}=t;if(this._selectionShapeInfo){if(this._selectionShapeInfo.unitId===e&&this._selectionShapeInfo.subUnitId===n&&this._selectionShapeInfo.commentId===i)return;this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null}const s=this._sheetsThreadCommentModel.getComment(e,n,i);if(!s)return;const m=N.singleReferenceToGrid(s.ref),{row:c,column:d}=m;if(Number.isNaN(c)||Number.isNaN(d))return;const h=this._markSelectionService.addShape({range:{startColumn:d,endColumn:d,startRow:c,endRow:c},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null});h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};exports.SheetsThreadCommentController=Pe([a.OnLifecycle(a.LifecycleStages.Starting,exports.SheetsThreadCommentController),w(1,S.IMenuService),w(2,a.Inject(a.Injector)),w(3,a.Inject(S.ComponentManager)),w(4,a.ICommandService),w(5,a.Inject(exports.SheetsThreadCommentPopupService)),w(6,a.Inject(D.SheetsThreadCommentModel)),w(7,a.Inject(y.ThreadCommentPanelService)),w(8,S.IShortcutService),w(9,a.IUniverInstanceService),w(10,a.Inject(_.SheetPermissionInterceptorBaseController)),w(11,_.IMarkSelectionService)],exports.SheetsThreadCommentController);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(o,r,t,e)=>{for(var n=e>1?void 0:e?ye(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&be(r,t,n),n},L=(o,r)=>(t,e)=>r(t,e,o);let F=class extends a.Disposable{constructor(o,r,t,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=r,this._univerInstanceService=t,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(o,r,t)=>{const{row:e,col:n,unitId:i,subUnitId:s}=r;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,n)?t({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):t(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var s;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return;const t=r.getUnitId(),e=(s=r.getActiveSheet())==null?void 0:s.getSheetId();if(!e){console.warn("No active sheet found");return}const n=this._renderManagerService.getRenderById(t),i=n==null?void 0:n.with(_.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});i==null||i.makeDirty(!0),i==null||i.calculate(),n&&n.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(r=>{o()}))}};F=Me([a.OnLifecycle(a.LifecycleStages.Ready,F),L(0,a.Inject(C.SheetInterceptorService)),L(1,a.Inject(D.SheetsThreadCommentModel)),L(2,a.IUniverInstanceService),L(3,se.IRenderManagerService)],F);var we=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Ue=(o,r,t,e)=>{for(var n=e>1?void 0:e?Oe(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&we(r,t,n),n},W=(o,r)=>(t,e)=>r(t,e,o);const Re=(o,r,t)=>{const e=N.singleReferenceToGrid(o),n=t.row-r.row,i=t.column-r.column,s={startColumn:e.column+i,startRow:e.row+n,endColumn:e.column+i,endRow:e.row+n};return N.serializeRange(s)};exports.SheetsThreadCommentCopyPasteController=class extends a.Disposable{constructor(t,e,n){super();R(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=n,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:z,onBeforeCopy:(t,e,n)=>{this._copyInfo={unitId:t,subUnitId:e,range:n}},onPasteCells:(t,e,n,i)=>{const{unitId:s,subUnitId:m,range:c}=e,d={row:c.rows[0],column:c.cols[0]};if(i.copyType===_.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:p,subUnitId:l}=this._copyInfo,v={row:h.startRow,column:h.startColumn};if(!(s===p&&m===l)){const f=[];a.Range.foreach(h,(u,g)=>{const P=this._sheetsThreadCommentModel.getAllByLocation(p,l,u,g);this._threadCommentDataSourceService.syncUpdateMutationToColla?P.forEach(V=>{f.push(V)}):P.forEach(({children:V,...U})=>{U.parentId||f.push(U)})});const E=[],I=[],$=[],x=[],H=u=>{E.unshift({id:O.DeleteCommentMutation.id,params:{unitId:p,subUnitId:l,commentId:u.id}}),$.push({id:O.AddCommentMutation.id,params:{unitId:s,subUnitId:m,comment:{...u,ref:Re(u.ref,v,d),unitId:s,subUnitId:m},sync:!0}}),I.push({id:O.AddCommentMutation.id,params:{unitId:p,subUnitId:l,comment:u,sync:!0}}),x.unshift({id:O.DeleteCommentMutation.id,params:{unitId:s,subUnitId:m,commentId:u.id}})};return f.forEach(u=>{H(u)}),{redos:[...E,...$],undos:[...x,...I]}}}return{redos:[],undos:[]}}}))}};exports.SheetsThreadCommentCopyPasteController=Ue([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentCopyPasteController),W(0,a.Inject(_.ISheetClipboardService)),W(1,a.Inject(D.SheetsThreadCommentModel)),W(2,O.IThreadCommentDataSourceService)],exports.SheetsThreadCommentCopyPasteController);var Ee=Object.defineProperty,je=Object.getOwnPropertyDescriptor,De=(o,r,t,e)=>{for(var n=e>1?void 0:e?je(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ee(r,t,n),n},k=(o,r)=>(t,e)=>r(t,e,o);exports.SheetsThreadCommentHoverController=class extends a.Disposable{constructor(r,t,e,n){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=n,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(q.debounceTime(100)).subscribe(r=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(r&&(t&&t.temp||!t)){const{location:e}=r,{unitId:n,subUnitId:i,row:s,col:m}=e,c=this._sheetsThreadCommentModel.getByLocation(n,i,s,m);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:s,startColumn:m,endRow:s,endColumn:m}]))return;const h=this._sheetsThreadCommentModel.getComment(n,i,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:i,row:s,col:m,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};exports.SheetsThreadCommentHoverController=De([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentHoverController),k(0,a.Inject(_.HoverManagerService)),k(1,a.Inject(exports.SheetsThreadCommentPopupService)),k(2,a.Inject(D.SheetsThreadCommentModel)),k(3,a.Inject(_.SheetPermissionInterceptorBaseController))],exports.SheetsThreadCommentHoverController);var Ne=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ve=(o,r,t,e)=>{for(var n=e>1?void 0:e?$e(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ne(r,t,n),n},B=(o,r)=>(t,e)=>r(t,e,o);exports.ThreadCommentRemoveSheetsController=class extends a.Disposable{constructor(r,t,e,n){super(),this._sheetInterceptorService=r,this._univerInstanceService=t,this._threadCommentModel=e,this._threadCommentDataSourceService=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===C.RemoveSheetCommand.id){const e=r.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const i=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const{commentMap:m}=this._threadCommentModel.ensureMap(i,s),c=Array.from(Object.values(m)).filter(v=>!v.parentId),d=c.map(v=>v.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,p=d.map(v=>({id:O.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:v}})),l=c.map(({children:v,...f})=>({id:O.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...f,children:h?v:void 0},sync:!h}}));return{redos:p,undos:l}}return{redos:[],undos:[]}}}))}};exports.ThreadCommentRemoveSheetsController=Ve([a.OnLifecycle(a.LifecycleStages.Ready,exports.ThreadCommentRemoveSheetsController),B(0,a.Inject(C.SheetInterceptorService)),B(1,a.IUniverInstanceService),B(2,a.Inject(O.ThreadCommentModel)),B(3,O.IThreadCommentDataSourceService)],exports.ThreadCommentRemoveSheetsController);var te=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,xe=(o,r,t)=>r in o?te(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,He=(o,r,t,e)=>{for(var n=e>1?void 0:e?Ae(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&te(r,t,n),n},Y=(o,r)=>(t,e)=>r(t,e,o),ne=(o,r,t)=>xe(o,typeof r!="symbol"?r+"":r,t);exports.UniverSheetsThreadCommentPlugin=class extends a.Plugin{constructor(t={},e,n){super();R(this,"_pluginConfig");this._injector=e,this._commandService=n,this._pluginConfig=a.Tools.deepMerge({},Te,t)}onStarting(t){[[exports.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(exports.SheetsThreadCommentController,this._pluginConfig)}],[F],[exports.SheetsThreadCommentCopyPasteController],[exports.SheetsThreadCommentHoverController],[exports.ThreadCommentRemoveSheetsController],[exports.SheetsThreadCommentPopupService]].forEach(e=>{t.add(e)}),[A].forEach(e=>{this._commandService.registerCommand(e)})}};ne(exports.UniverSheetsThreadCommentPlugin,"pluginName",z);ne(exports.UniverSheetsThreadCommentPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentPlugin=He([a.DependentOn(y.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentBasePlugin),Y(1,a.Inject(a.Injector)),Y(2,a.Inject(a.ICommandService))],exports.UniverSheetsThreadCommentPlugin);Object.defineProperty(exports,"ICommandService",{enumerable:!0,get:()=>a.ICommandService});Object.defineProperty(exports,"Inject",{enumerable:!0,get:()=>a.Inject});Object.defineProperty(exports,"Injector",{enumerable:!0,get:()=>a.Injector});Object.defineProperty(exports,"Plugin",{enumerable:!0,get:()=>a.Plugin});Object.defineProperty(exports,"UniverInstanceType",{enumerable:!0,get:()=>a.UniverInstanceType});Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>y.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>y.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>O.IThreadCommentDataSourceService});Object.defineProperty(exports,"SheetsThreadCommentModel",{enumerable:!0,get:()=>D.SheetsThreadCommentModel});exports.SHEETS_THREAD_COMMENT=z;exports.ShowAddSheetCommentModalOperation=A;
1
+ "use strict";var oe=Object.defineProperty;var ie=(o,r,t)=>r in o?oe(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t;var R=(o,r,t)=>ie(o,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),y=require("@univerjs/thread-comment-ui"),S=require("@univerjs/ui"),C=require("@univerjs/sheets"),N=require("@univerjs/engine-formula"),O=require("@univerjs/thread-comment"),_=require("@univerjs/sheets-ui"),D=require("@univerjs/sheets-thread-comment-base"),P=require("react"),W=require("rxjs"),se=require("@univerjs/engine-render");var b=function(){return b=Object.assign||function(o){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(o[n]=r[n])}return o},b.apply(this,arguments)},ae=function(o,r){var t={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&r.indexOf(e)<0&&(t[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(o);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(o,e[n])&&(t[e[n]]=o[e[n]]);return t},X=P.forwardRef(function(o,r){var t=o.icon,e=o.id,n=o.className,i=o.extend,s=ae(o,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),c=P.useRef("_".concat(he()));return J(t,"".concat(e),{defIds:t.defIds,idSuffix:c.current},b({ref:r,className:m},s),i)});function J(o,r,t,e,n){return P.createElement(o.tag,b(b({key:r},ce(o,t,n)),e),(me(o,t).children||[]).map(function(i,s){return J(i,"".concat(r,"-").concat(o.tag,"-").concat(s),t,void 0,n)}))}function ce(o,r,t){var e=b({},o.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1);var n=r.defIds;return!n||n.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],m=i[1];typeof m=="string"&&(e[s]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function me(o,r){var t,e=r.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((t=o.children)===null||t===void 0)&&t.length)?b(b({},o),{children:o.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?b(b({},n),{attrs:b(b({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):o}function he(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var de={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"}}]},Q=P.forwardRef(function(o,r){return P.createElement(X,Object.assign({},o,{id:"comment-single",ref:r,icon:de}))});Q.displayName="CommentSingle";const ee="univer.sheet.thread-comment-modal",Z="comment-single",z="SHEET_THREAD_COMMENT";var ue=Object.defineProperty,le=Object.getOwnPropertyDescriptor,pe=(o,r,t,e)=>{for(var n=e>1?void 0:e?le(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&ue(r,t,n),n},K=(o,r)=>(t,e)=>r(t,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(t,e){super();R(this,"_lastPopup",null);R(this,"_activePopup");R(this,"_activePopup$",new W.BehaviorSubject(null));R(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=t,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this.hidePopup()}))}showPopup(t,e){var h;const{row:n,col:i,unitId:s,subUnitId:m}=t;if(this._activePopup&&n===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&m===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=t,this._activePopup$.next(t);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=t,this._activePopup$.next(t);const c=this._canvasPopupManagerService.attachPopupToCell(n,i,{componentKey:ee,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!c)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(c),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=pe([K(0,a.Inject(_.SheetCanvasPopManagerService)),K(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const ve=()=>{const o=a.useDependency(a.IUniverInstanceService),r=a.useDependency(exports.SheetsThreadCommentPopupService),t=S.useObservable(r.activePopup$),e=a.useDependency(D.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!t)return null;const{row:n,col:i,unitId:s,subUnitId:m,trigger:c}=t,d=e.getByLocation(s,m,n,i),h=`${a.Tools.chatAtABC(i)}${n+1}`,p=()=>{r.hidePopup()},l=v=>{var f,E,I;return(I=(E=(f=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(v))==null?void 0:E.getName())!=null?I:""};return P.createElement(y.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:m,type:a.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:p,getSubUnitName:l,autoFocus:c==="context-menu"})},A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const r=o.get(C.SheetsSelectionsService),t=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),n=o.get(y.ThreadCommentPanelService),i=(f=r.getCurrentLastSelection())==null?void 0:f.primary,s=o.get(D.SheetsThreadCommentModel);if(!i)return!1;const m=C.getSheetCommandTarget(t);if(!m)return!1;const{workbook:c,worksheet:d,unitId:h,subUnitId:p}=m,l={workbook:c,worksheet:d,unitId:h,subUnitId:p,row:i.startRow,col:i.startColumn};e.showPopup(l);const v=s.getByLocation(h,p,i.startRow,i.startColumn);return v&&n.setActiveComment({unitId:h,subUnitId:p,commentId:v,trigger:"context-menu"}),!0}},Ce=()=>{var H;const o=a.useDependency(_.IMarkSelectionService),r=a.useDependency(a.IUniverInstanceService),t=a.useDependency(exports.SheetsThreadCommentPopupService),e=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getUnitId(),i=a.useDependency(a.ICommandService),s=P.useMemo(()=>e.activeSheet$.pipe(W.map(u=>u==null?void 0:u.getSheetId())),[e.activeSheet$]),m=S.useObservable(s,(H=e.getActiveSheet())==null?void 0:H.getSheetId()),c=P.useRef(),d=a.useDependency(y.ThreadCommentPanelService),h=S.useObservable(d.activeCommentId$),p=S.useObservable(d.panelVisible$,d.panelVisible),l=P.useCallback(u=>{const g=e.getSheets(),T={};g.forEach((U,M)=>{T[U.getSheetId()]=M});const V=U=>U.map(M=>{var G;const j=N.singleReferenceToGrid(M.ref),re=[(G=T[M.subUnitId])!=null?G:0,j.row,j.column];return{...M,p:re}}).sort((M,j)=>M.p[0]===j.p[0]?M.p[1]===j.p[1]?M.p[2]-j.p[2]:M.p[1]-j.p[1]:M.p[0]-j.p[0]);return[...V(u.filter(U=>!U.resolved)),...V(u.filter(U=>U.resolved))]},[e]),v=P.useCallback(u=>{if(u.unitId===n&&u.subUnitId===m&&!u.resolved){const{row:g,column:T}=N.singleReferenceToGrid(u.ref);if(!Number.isNaN(g)&&!Number.isNaN(T))return o.addShape({range:{startColumn:T,endColumn:T,startRow:g,endRow:g},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,m,n]),f=u=>{var g,T;return(T=(g=e.getSheetBySheetId(u))==null?void 0:g.getName())!=null?T:""},E=()=>{i.executeCommand(A.id)},I=u=>{h&&h.unitId===u.unitId&&h.subUnitId===u.subUnitId&&h.commentId===u.id||(c.current&&(o.removeShape(c.current),c.current=null),c.current=v(u))},$=()=>{c.current&&(o.removeShape(c.current),c.current=null)},x=(u,g)=>{g&&t.hidePopup()};return P.useEffect(()=>{!p&&c.current&&o.removeShape(c.current)},[o,p]),P.createElement(y.ThreadCommentPanel,{unitId:n,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:E,getSubUnitName:f,onResolve:x,sortComments:l,onItemEnter:I,onItemLeave:$,onDeleteComment:()=>($(),!0)})},Se=o=>({id:A.id,type:S.MenuItemType.BUTTON,positions:[S.MenuPosition.CONTEXT_MENU],icon:Z,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),fe=o=>({id:y.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:Z,tooltip:"sheetThreadComment.menu.commentManagement",positions:S.MenuPosition.TOOLBAR_START,group:S.MenuGroup.TOOLBAR_OTHERS,disabled$:_.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),_e={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:_.whenSheetEditorFocused};var Ie=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Te=(o,r,t,e)=>{for(var n=e>1?void 0:e?ge(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ie(r,t,n),n},w=(o,r)=>(t,e)=>r(t,e,o);const Pe={};exports.SheetsThreadCommentController=class extends a.Disposable{constructor(t,e,n,i,s,m,c,d,h,p,l,v){super();R(this,"_isSwitchToCommenting",!1);R(this,"_selectionShapeInfo",null);this._config=t,this._menuService=e,this._injector=n,this._componentManager=i,this._commandService=s,this._sheetsThreadCommentPopupService=m,this._sheetsThreadCommentModel=c,this._threadCommentPanelService=d,this._shortcutService=h,this._univerInstanceService=p,this._sheetPermissionInterceptorBaseController=l,this._markSelectionService=v,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection()}_initShortcut(){this._shortcutService.registerShortcut(_e)}_initCommandListener(){this._commandService.onCommandExecuted(t=>{var e;if(t.id===C.SetSelectionsOperation.id){if(this._isSwitchToCommenting)return;const n=t.params,{unitId:i,subUnitId:s,selections:m,type:c}=n;if((c===C.SelectionMoveType.MOVE_END||c===void 0)&&((e=m[0])!=null&&e.primary)){const d=m[0].range;if(d.endColumn-d.startColumn>0||d.endRow-d.startRow>0)return;const h=m[0].primary.actualRow,p=m[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(i,s,h,p)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(y.SetActiveCommentOperation.id);return}const l=this._sheetsThreadCommentModel.getByLocation(i,s,h,p);l&&this._commandService.executeCommand(y.SetActiveCommentOperation.id,{unitId:i,subUnitId:s,commentId:l})}}if(t.id===O.DeleteCommentMutation.id){const n=t.params,i=this._sheetsThreadCommentPopupService.activePopup;if(!i)return;const{unitId:s,subUnitId:m,commentId:c}=i;n.unitId===s&&n.subUnitId===m&&n.commentId===c&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:t={}}=this._config;[Se,fe].forEach(e=>{this._menuService.addMenuItem(e(this._injector),t)})}_initComponent(){[[ee,ve],[y.THREAD_COMMENT_PANEL,Ce],[Z,Q]].forEach(([t,e])=>{this._componentManager.register(t,e)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var e;if(t){const{unitId:n,subUnitId:i,commentId:s,trigger:m}=t,c=this._sheetsThreadCommentModel.getComment(n,i,s);if(!c||c.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==n)return;this._isSwitchToCommenting=!0,((e=d.getActiveSheet())==null?void 0:e.getSheetId())!==i&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:i}),this._isSwitchToCommenting=!1;const l=N.singleReferenceToGrid(c.ref),{row:v,column:f}=l;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:v,startColumn:f,endRow:v,endColumn:f}]))return;const I=1;await this._commandService.executeCommand(_.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-I,0),endRow:l.row+I,startColumn:Math.max(l.column-I,0),endColumn:l.column+I}}),this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:i,row:l.row,col:l.column,commentId:c.id,trigger:m})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(t=>{if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:e,subUnitId:n,commentId:i}=t;if(this._selectionShapeInfo){if(this._selectionShapeInfo.unitId===e&&this._selectionShapeInfo.subUnitId===n&&this._selectionShapeInfo.commentId===i)return;this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null}const s=this._sheetsThreadCommentModel.getComment(e,n,i);if(!s)return;const m=N.singleReferenceToGrid(s.ref),{row:c,column:d}=m;if(Number.isNaN(c)||Number.isNaN(d))return;const h=this._markSelectionService.addShape({range:{startColumn:d,endColumn:d,startRow:c,endRow:c},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null});h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};exports.SheetsThreadCommentController=Te([a.OnLifecycle(a.LifecycleStages.Starting,exports.SheetsThreadCommentController),w(1,S.IMenuService),w(2,a.Inject(a.Injector)),w(3,a.Inject(S.ComponentManager)),w(4,a.ICommandService),w(5,a.Inject(exports.SheetsThreadCommentPopupService)),w(6,a.Inject(D.SheetsThreadCommentModel)),w(7,a.Inject(y.ThreadCommentPanelService)),w(8,S.IShortcutService),w(9,a.IUniverInstanceService),w(10,a.Inject(_.SheetPermissionInterceptorBaseController)),w(11,_.IMarkSelectionService)],exports.SheetsThreadCommentController);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(o,r,t,e)=>{for(var n=e>1?void 0:e?ye(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&be(r,t,n),n},L=(o,r)=>(t,e)=>r(t,e,o);let F=class extends a.Disposable{constructor(o,r,t,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=r,this._univerInstanceService=t,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(o,r,t)=>{const{row:e,col:n,unitId:i,subUnitId:s}=r;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,n)?t({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):t(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var s;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return;const t=r.getUnitId(),e=(s=r.getActiveSheet())==null?void 0:s.getSheetId();if(!e){console.warn("No active sheet found");return}const n=this._renderManagerService.getRenderById(t),i=n==null?void 0:n.with(_.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});i==null||i.makeDirty(!0),i==null||i.calculate(),n&&n.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(W.debounceTime(16)).subscribe(r=>{o()}))}};F=Me([a.OnLifecycle(a.LifecycleStages.Ready,F),L(0,a.Inject(C.SheetInterceptorService)),L(1,a.Inject(D.SheetsThreadCommentModel)),L(2,a.IUniverInstanceService),L(3,se.IRenderManagerService)],F);var we=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Ue=(o,r,t,e)=>{for(var n=e>1?void 0:e?Oe(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&we(r,t,n),n},q=(o,r)=>(t,e)=>r(t,e,o);const Re=(o,r,t)=>{const e=N.singleReferenceToGrid(o),n=t.row-r.row,i=t.column-r.column,s={startColumn:e.column+i,startRow:e.row+n,endColumn:e.column+i,endRow:e.row+n};return N.serializeRange(s)};exports.SheetsThreadCommentCopyPasteController=class extends a.Disposable{constructor(t,e,n){super();R(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=n,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:z,onBeforeCopy:(t,e,n)=>{this._copyInfo={unitId:t,subUnitId:e,range:n}},onPasteCells:(t,e,n,i)=>{const{unitId:s,subUnitId:m,range:c}=e,d={row:c.rows[0],column:c.cols[0]};if(i.copyType===_.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:p,subUnitId:l}=this._copyInfo,v={row:h.startRow,column:h.startColumn};if(!(s===p&&m===l)){const f=[];a.Range.foreach(h,(u,g)=>{const T=this._sheetsThreadCommentModel.getAllByLocation(p,l,u,g);this._threadCommentDataSourceService.syncUpdateMutationToColla?T.forEach(V=>{f.push(V)}):T.forEach(({children:V,...U})=>{U.parentId||f.push(U)})});const E=[],I=[],$=[],x=[],H=u=>{E.unshift({id:O.DeleteCommentMutation.id,params:{unitId:p,subUnitId:l,commentId:u.id}}),$.push({id:O.AddCommentMutation.id,params:{unitId:s,subUnitId:m,comment:{...u,ref:Re(u.ref,v,d),unitId:s,subUnitId:m},sync:!0}}),I.push({id:O.AddCommentMutation.id,params:{unitId:p,subUnitId:l,comment:u,sync:!0}}),x.unshift({id:O.DeleteCommentMutation.id,params:{unitId:s,subUnitId:m,commentId:u.id}})};return f.forEach(u=>{H(u)}),{redos:[...E,...$],undos:[...x,...I]}}}return{redos:[],undos:[]}}}))}};exports.SheetsThreadCommentCopyPasteController=Ue([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentCopyPasteController),q(0,a.Inject(_.ISheetClipboardService)),q(1,a.Inject(D.SheetsThreadCommentModel)),q(2,O.IThreadCommentDataSourceService)],exports.SheetsThreadCommentCopyPasteController);var Ee=Object.defineProperty,je=Object.getOwnPropertyDescriptor,De=(o,r,t,e)=>{for(var n=e>1?void 0:e?je(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ee(r,t,n),n},k=(o,r)=>(t,e)=>r(t,e,o);exports.SheetsThreadCommentHoverController=class extends a.Disposable{constructor(r,t,e,n){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=n,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(W.debounceTime(100)).subscribe(r=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(r&&(t&&t.temp||!t)){const{location:e}=r,{unitId:n,subUnitId:i,row:s,col:m}=e,c=this._sheetsThreadCommentModel.getByLocation(n,i,s,m);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:s,startColumn:m,endRow:s,endColumn:m}]))return;const h=this._sheetsThreadCommentModel.getComment(n,i,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:i,row:s,col:m,commentId:c,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};exports.SheetsThreadCommentHoverController=De([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentHoverController),k(0,a.Inject(_.HoverManagerService)),k(1,a.Inject(exports.SheetsThreadCommentPopupService)),k(2,a.Inject(D.SheetsThreadCommentModel)),k(3,a.Inject(_.SheetPermissionInterceptorBaseController))],exports.SheetsThreadCommentHoverController);var Ne=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ve=(o,r,t,e)=>{for(var n=e>1?void 0:e?$e(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&Ne(r,t,n),n},B=(o,r)=>(t,e)=>r(t,e,o);exports.ThreadCommentRemoveSheetsController=class extends a.Disposable{constructor(r,t,e,n){super(),this._sheetInterceptorService=r,this._univerInstanceService=t,this._threadCommentModel=e,this._threadCommentDataSourceService=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===C.RemoveSheetCommand.id){const e=r.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const i=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const{commentMap:m}=this._threadCommentModel.ensureMap(i,s),c=Array.from(Object.values(m)).filter(v=>!v.parentId),d=c.map(v=>v.id),h=this._threadCommentDataSourceService.syncUpdateMutationToColla,p=d.map(v=>({id:O.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:v}})),l=c.map(({children:v,...f})=>({id:O.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...f,children:h?v:void 0},sync:!h}}));return{redos:p,undos:l}}return{redos:[],undos:[]}}}))}};exports.ThreadCommentRemoveSheetsController=Ve([a.OnLifecycle(a.LifecycleStages.Ready,exports.ThreadCommentRemoveSheetsController),B(0,a.Inject(C.SheetInterceptorService)),B(1,a.IUniverInstanceService),B(2,a.Inject(O.ThreadCommentModel)),B(3,O.IThreadCommentDataSourceService)],exports.ThreadCommentRemoveSheetsController);var te=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,xe=(o,r,t)=>r in o?te(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,He=(o,r,t,e)=>{for(var n=e>1?void 0:e?Ae(r,t):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(n=(e?s(r,t,n):s(n))||n);return e&&n&&te(r,t,n),n},Y=(o,r)=>(t,e)=>r(t,e,o),ne=(o,r,t)=>xe(o,typeof r!="symbol"?r+"":r,t);exports.UniverSheetsThreadCommentPlugin=class extends a.Plugin{constructor(t={},e,n){super();R(this,"_pluginConfig");this._injector=e,this._commandService=n,this._pluginConfig=a.Tools.deepMerge({},Pe,t)}onStarting(t){[[exports.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(exports.SheetsThreadCommentController,this._pluginConfig)}],[F],[exports.SheetsThreadCommentCopyPasteController],[exports.SheetsThreadCommentHoverController],[exports.ThreadCommentRemoveSheetsController],[exports.SheetsThreadCommentPopupService]].forEach(e=>{t.add(e)}),[A].forEach(e=>{this._commandService.registerCommand(e)})}};ne(exports.UniverSheetsThreadCommentPlugin,"pluginName",z);ne(exports.UniverSheetsThreadCommentPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentPlugin=He([a.DependentOn(y.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentBasePlugin),Y(1,a.Inject(a.Injector)),Y(2,a.Inject(a.ICommandService))],exports.UniverSheetsThreadCommentPlugin);Object.defineProperty(exports,"ICommandService",{enumerable:!0,get:()=>a.ICommandService});Object.defineProperty(exports,"Inject",{enumerable:!0,get:()=>a.Inject});Object.defineProperty(exports,"Injector",{enumerable:!0,get:()=>a.Injector});Object.defineProperty(exports,"Plugin",{enumerable:!0,get:()=>a.Plugin});Object.defineProperty(exports,"UniverInstanceType",{enumerable:!0,get:()=>a.UniverInstanceType});Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>y.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>y.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>O.IThreadCommentDataSourceService});Object.defineProperty(exports,"SheetsThreadCommentModel",{enumerable:!0,get:()=>D.SheetsThreadCommentModel});exports.SHEETS_THREAD_COMMENT=z;exports.ShowAddSheetCommentModalOperation=A;
package/lib/es/index.js CHANGED
@@ -1,20 +1,20 @@
1
- var De = Object.defineProperty;
2
- var xe = (o, e, n) => e in o ? De(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
- var w = (o, e, n) => xe(o, typeof e != "symbol" ? e + "" : e, n);
4
- import { Inject as l, Disposable as R, DisposableCollection as Ve, useDependency as y, IUniverInstanceService as N, Tools as me, UniverInstanceType as b, CommandType as Ae, ICommandService as re, OnLifecycle as B, LifecycleStages as H, Injector as pe, Range as je, DependentOn as Be, Plugin as He } from "@univerjs/core";
1
+ var xe = Object.defineProperty;
2
+ var Ve = (o, e, n) => e in o ? xe(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
+ var w = (o, e, n) => Ve(o, typeof e != "symbol" ? e + "" : e, n);
4
+ import { Inject as l, Disposable as R, DisposableCollection as Ae, useDependency as y, IUniverInstanceService as N, Tools as me, UniverInstanceType as b, CommandType as je, ICommandService as re, OnLifecycle as B, LifecycleStages as H, Injector as pe, Range as Be, DependentOn as He, Plugin as Le } from "@univerjs/core";
5
5
  import { ICommandService as vn, Inject as _n, Injector as fn, Plugin as Cn, UniverInstanceType as Sn } from "@univerjs/core";
6
- import { ThreadCommentTree as Le, ThreadCommentPanelService as oe, ThreadCommentPanel as ke, ToggleSheetCommentPanelOperation as Fe, SetActiveCommentOperation as ae, THREAD_COMMENT_PANEL as We, UniverThreadCommentUIPlugin as Ze } from "@univerjs/thread-comment-ui";
6
+ import { ThreadCommentTree as ke, ThreadCommentPanelService as oe, ThreadCommentPanel as Fe, ToggleSheetCommentPanelOperation as We, SetActiveCommentOperation as ae, THREAD_COMMENT_PANEL as Ze, UniverThreadCommentUIPlugin as ze } from "@univerjs/thread-comment-ui";
7
7
  import { IThreadCommentMentionDataService as gn, UniverThreadCommentUIPlugin as Pn } from "@univerjs/thread-comment-ui";
8
- import { IZenZoneService as ze, useObservable as V, KeyCode as Ge, MetaKeys as ce, MenuItemType as le, MenuPosition as ve, getMenuHiddenObservable as _e, MenuGroup as Ke, ComponentManager as Ye, IMenuService as qe, IShortcutService as Xe } from "@univerjs/ui";
9
- import { SheetsSelectionsService as Je, getSheetCommandTarget as Qe, WorkbookCommentPermission as q, WorksheetViewPermission as X, RangeProtectionPermissionViewPoint as J, SetSelectionsOperation as et, SelectionMoveType as tt, SetWorksheetActiveOperation as nt, SheetInterceptorService as fe, INTERCEPTOR_POINT as rt, RemoveSheetCommand as ot } from "@univerjs/sheets";
10
- import { singleReferenceToGrid as j, serializeRange as it } from "@univerjs/engine-formula";
11
- import { DeleteCommentMutation as K, IThreadCommentDataSourceService as Ce, AddCommentMutation as ne, ThreadCommentModel as st } from "@univerjs/thread-comment";
8
+ import { IZenZoneService as Ge, useObservable as V, KeyCode as Ke, MetaKeys as ce, MenuItemType as le, MenuPosition as ve, getMenuHiddenObservable as _e, MenuGroup as Ye, ComponentManager as qe, IMenuService as Xe, IShortcutService as Je } from "@univerjs/ui";
9
+ import { SheetsSelectionsService as Qe, getSheetCommandTarget as et, WorkbookCommentPermission as q, WorksheetViewPermission as X, RangeProtectionPermissionViewPoint as J, SetSelectionsOperation as tt, SelectionMoveType as nt, SetWorksheetActiveOperation as rt, SheetInterceptorService as fe, INTERCEPTOR_POINT as ot, RemoveSheetCommand as it } from "@univerjs/sheets";
10
+ import { singleReferenceToGrid as j, serializeRange as st } from "@univerjs/engine-formula";
11
+ import { DeleteCommentMutation as K, IThreadCommentDataSourceService as Ce, AddCommentMutation as ne, ThreadCommentModel as at } from "@univerjs/thread-comment";
12
12
  import { IThreadCommentDataSourceService as bn } from "@univerjs/thread-comment";
13
- import { SheetCanvasPopManagerService as at, IMarkSelectionService as Se, whenSheetEditorFocused as ct, getCurrentRangeDisable$ as Ie, SheetPermissionInterceptorBaseController as ge, ScrollToRangeOperation as ut, SheetSkeletonManagerService as dt, ISheetClipboardService as ht, COPY_TYPE as mt, HoverManagerService as pt } from "@univerjs/sheets-ui";
14
- import { SheetsThreadCommentModel as $, UniverSheetsThreadCommentBasePlugin as lt } from "@univerjs/sheets-thread-comment-base";
13
+ import { SheetCanvasPopManagerService as ct, IMarkSelectionService as Se, whenSheetEditorFocused as ut, getCurrentRangeDisable$ as Ie, SheetPermissionInterceptorBaseController as ge, ScrollToRangeOperation as dt, SheetSkeletonManagerService as ht, ISheetClipboardService as mt, COPY_TYPE as pt, HoverManagerService as lt } from "@univerjs/sheets-ui";
14
+ import { SheetsThreadCommentModel as $, UniverSheetsThreadCommentBasePlugin as vt } from "@univerjs/sheets-thread-comment-base";
15
15
  import { SheetsThreadCommentModel as Mn } from "@univerjs/sheets-thread-comment-base";
16
- import Pe, { forwardRef as Te, useRef as be, createElement as we, useMemo as vt, useCallback as ue, useEffect as _t } from "react";
17
- import { BehaviorSubject as ft, map as Ct, debounceTime as St } from "rxjs";
16
+ import Pe, { forwardRef as Te, useRef as be, createElement as we, useMemo as _t, useCallback as ue, useEffect as ft } from "react";
17
+ import { BehaviorSubject as Ct, map as St, debounceTime as Me } from "rxjs";
18
18
  import { IRenderManagerService as It } from "@univerjs/engine-render";
19
19
  var I = function() {
20
20
  return I = Object.assign || function(o) {
@@ -31,13 +31,13 @@ var I = function() {
31
31
  for (var r = 0, t = Object.getOwnPropertySymbols(o); r < t.length; r++)
32
32
  e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[r]) && (n[t[r]] = o[t[r]]);
33
33
  return n;
34
- }, Me = Te(function(o, e) {
34
+ }, ye = Te(function(o, e) {
35
35
  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 = be("_".concat(bt()));
36
- return ye(n, "".concat(t), { defIds: n.defIds, idSuffix: c.current }, I({ ref: e, className: a }, s), i);
36
+ return Oe(n, "".concat(t), { defIds: n.defIds, idSuffix: c.current }, I({ ref: e, className: a }, s), i);
37
37
  });
38
- function ye(o, e, n, t, r) {
38
+ function Oe(o, e, n, t, r) {
39
39
  return we(o.tag, I(I({ key: e }, Pt(o, n, r)), t), (Tt(o, n).children || []).map(function(i, s) {
40
- return ye(i, "".concat(e, "-").concat(o.tag, "-").concat(s), n, void 0, r);
40
+ return Oe(i, "".concat(e, "-").concat(o.tag, "-").concat(s), n, void 0, r);
41
41
  }));
42
42
  }
43
43
  function Pt(o, e, n) {
@@ -58,16 +58,16 @@ function Tt(o, e) {
58
58
  function bt() {
59
59
  return Math.random().toString(36).substring(2, 8);
60
60
  }
61
- Me.displayName = "UniverIcon";
62
- var wt = { 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" } }] }, Oe = Te(function(o, e) {
63
- return we(Me, Object.assign({}, o, {
61
+ ye.displayName = "UniverIcon";
62
+ var wt = { 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" } }] }, Ee = Te(function(o, e) {
63
+ return we(ye, Object.assign({}, o, {
64
64
  id: "comment-single",
65
65
  ref: e,
66
66
  icon: wt
67
67
  }));
68
68
  });
69
- Oe.displayName = "CommentSingle";
70
- const Ee = "univer.sheet.thread-comment-modal", ie = "comment-single", Ue = "SHEET_THREAD_COMMENT";
69
+ Ee.displayName = "CommentSingle";
70
+ const Ue = "univer.sheet.thread-comment-modal", ie = "comment-single", Re = "SHEET_THREAD_COMMENT";
71
71
  var Mt = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, Ot = (o, e, n, t) => {
72
72
  for (var r = t > 1 ? void 0 : t ? yt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
73
73
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
@@ -78,7 +78,7 @@ let O = class extends R {
78
78
  super();
79
79
  w(this, "_lastPopup", null);
80
80
  w(this, "_activePopup");
81
- w(this, "_activePopup$", new ft(null));
81
+ w(this, "_activePopup$", new Ct(null));
82
82
  w(this, "activePopup$", this._activePopup$.asObservable());
83
83
  this._canvasPopupManagerService = e, this._zenZoneService = n, this._initZenVisible(), this.disposeWithMe(() => {
84
84
  this._activePopup$.complete();
@@ -106,7 +106,7 @@ let O = class extends R {
106
106
  t,
107
107
  r,
108
108
  {
109
- componentKey: Ee,
109
+ componentKey: Ue,
110
110
  onClickOutside: () => {
111
111
  this.hidePopup();
112
112
  },
@@ -119,7 +119,7 @@ let O = class extends R {
119
119
  );
120
120
  if (!a)
121
121
  throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");
122
- const c = new Ve();
122
+ const c = new Ae();
123
123
  c.add(a), c.add({
124
124
  dispose: () => {
125
125
  n == null || n();
@@ -137,8 +137,8 @@ let O = class extends R {
137
137
  }
138
138
  };
139
139
  O = Ot([
140
- de(0, l(at)),
141
- de(1, ze)
140
+ de(0, l(ct)),
141
+ de(1, Ge)
142
142
  ], O);
143
143
  const Et = () => {
144
144
  const o = y(N), e = y(O), n = V(e.activePopup$), t = y($);
@@ -151,7 +151,7 @@ const Et = () => {
151
151
  return (E = (f = (g = o.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : g.getSheetBySheetId(v)) == null ? void 0 : f.getName()) != null ? E : "";
152
152
  };
153
153
  return /* @__PURE__ */ Pe.createElement(
154
- Le,
154
+ ke,
155
155
  {
156
156
  onClick: () => {
157
157
  e.persistPopup();
@@ -168,14 +168,14 @@ const Et = () => {
168
168
  }
169
169
  );
170
170
  }, Q = {
171
- type: Ae.OPERATION,
171
+ type: je.OPERATION,
172
172
  id: "sheets.operation.show-comment-modal",
173
173
  handler(o) {
174
174
  var g;
175
- const e = o.get(Je), n = o.get(N), t = o.get(O), r = o.get(oe), i = (g = e.getCurrentLastSelection()) == null ? void 0 : g.primary, s = o.get($);
175
+ const e = o.get(Qe), n = o.get(N), t = o.get(O), r = o.get(oe), i = (g = e.getCurrentLastSelection()) == null ? void 0 : g.primary, s = o.get($);
176
176
  if (!i)
177
177
  return !1;
178
- const a = Qe(n);
178
+ const a = et(n);
179
179
  if (!a)
180
180
  return !1;
181
181
  const { workbook: c, worksheet: u, unitId: h, subUnitId: d } = a, p = {
@@ -197,15 +197,15 @@ const Et = () => {
197
197
  }
198
198
  }, Ut = () => {
199
199
  var C;
200
- const o = y(Se), e = y(N), n = y(O), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = y(re), s = vt(() => t.activeSheet$.pipe(Ct((m) => m == null ? void 0 : m.getSheetId())), [t.activeSheet$]), a = V(s, (C = t.getActiveSheet()) == null ? void 0 : C.getSheetId()), c = be(), u = y(oe), h = V(u.activeCommentId$), d = V(u.panelVisible$, u.panelVisible), p = ue((m) => {
200
+ const o = y(Se), e = y(N), n = y(O), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = y(re), s = _t(() => t.activeSheet$.pipe(St((m) => m == null ? void 0 : m.getSheetId())), [t.activeSheet$]), a = V(s, (C = t.getActiveSheet()) == null ? void 0 : C.getSheetId()), c = be(), u = y(oe), h = V(u.activeCommentId$), d = V(u.panelVisible$, u.panelVisible), p = ue((m) => {
201
201
  const _ = t.getSheets(), S = {};
202
202
  _.forEach((U, P) => {
203
203
  S[U.getSheetId()] = P;
204
204
  });
205
205
  const x = (U) => U.map((P) => {
206
206
  var se;
207
- const M = j(P.ref), $e = [(se = S[P.subUnitId]) != null ? se : 0, M.row, M.column];
208
- return { ...P, p: $e };
207
+ const M = j(P.ref), De = [(se = S[P.subUnitId]) != null ? se : 0, M.row, M.column];
208
+ return { ...P, p: De };
209
209
  }).sort((P, M) => P.p[0] === M.p[0] ? P.p[1] === M.p[1] ? P.p[2] - M.p[2] : P.p[1] - M.p[1] : P.p[0] - M.p[0]);
210
210
  return [
211
211
  ...x(m.filter((U) => !U.resolved)),
@@ -244,10 +244,10 @@ const Et = () => {
244
244
  }, ee = (m, _) => {
245
245
  _ && n.hidePopup();
246
246
  };
247
- return _t(() => {
247
+ return ft(() => {
248
248
  !d && c.current && o.removeShape(c.current);
249
249
  }, [o, d]), /* @__PURE__ */ Pe.createElement(
250
- ke,
250
+ Fe,
251
251
  {
252
252
  unitId: r,
253
253
  subUnitId$: s,
@@ -274,12 +274,12 @@ const Et = () => {
274
274
  rangeTypes: [J]
275
275
  })
276
276
  }), Nt = (o) => ({
277
- id: Fe.id,
277
+ id: We.id,
278
278
  type: le.BUTTON,
279
279
  icon: ie,
280
280
  tooltip: "sheetThreadComment.menu.commentManagement",
281
281
  positions: ve.TOOLBAR_START,
282
- group: Ke.TOOLBAR_OTHERS,
282
+ group: Ye.TOOLBAR_OTHERS,
283
283
  disabled$: Ie(o, {
284
284
  workbookTypes: [q],
285
285
  worksheetTypes: [X],
@@ -288,8 +288,8 @@ const Et = () => {
288
288
  hidden$: _e(o, b.UNIVER_SHEET)
289
289
  }), $t = {
290
290
  id: Q.id,
291
- binding: Ge.M | ce.CTRL_COMMAND | ce.ALT,
292
- preconditions: ct
291
+ binding: Ke.M | ce.CTRL_COMMAND | ce.ALT,
292
+ preconditions: ut
293
293
  };
294
294
  var Dt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, Vt = (o, e, n, t) => {
295
295
  for (var r = t > 1 ? void 0 : t ? xt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
@@ -309,33 +309,34 @@ let A = class extends R {
309
309
  }
310
310
  _initCommandListener() {
311
311
  this._commandService.onCommandExecuted((e) => {
312
- if (e.id === et.id) {
312
+ var n;
313
+ if (e.id === tt.id) {
313
314
  if (this._isSwitchToCommenting)
314
315
  return;
315
- const n = e.params, { unitId: t, subUnitId: r, selections: i, type: s } = n;
316
- if ((s === tt.MOVE_END || s === void 0) && i[0].primary) {
317
- const a = i[0].range;
318
- if (a.endColumn - a.startColumn > 0 || a.endRow - a.startRow > 0)
316
+ const t = e.params, { unitId: r, subUnitId: i, selections: s, type: a } = t;
317
+ if ((a === nt.MOVE_END || a === void 0) && ((n = s[0]) != null && n.primary)) {
318
+ const c = s[0].range;
319
+ if (c.endColumn - c.startColumn > 0 || c.endRow - c.startRow > 0)
319
320
  return;
320
- const c = i[0].primary.actualRow, u = i[0].primary.actualColumn;
321
- if (!this._sheetsThreadCommentModel.showCommentMarker(t, r, c, u)) {
321
+ const u = s[0].primary.actualRow, h = s[0].primary.actualColumn;
322
+ if (!this._sheetsThreadCommentModel.showCommentMarker(r, i, u, h)) {
322
323
  this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(ae.id);
323
324
  return;
324
325
  }
325
- const h = this._sheetsThreadCommentModel.getByLocation(t, r, c, u);
326
- h && this._commandService.executeCommand(ae.id, {
327
- unitId: t,
328
- subUnitId: r,
329
- commentId: h
326
+ const d = this._sheetsThreadCommentModel.getByLocation(r, i, u, h);
327
+ d && this._commandService.executeCommand(ae.id, {
328
+ unitId: r,
329
+ subUnitId: i,
330
+ commentId: d
330
331
  });
331
332
  }
332
333
  }
333
334
  if (e.id === K.id) {
334
- const n = e.params, t = this._sheetsThreadCommentPopupService.activePopup;
335
- if (!t)
335
+ const t = e.params, r = this._sheetsThreadCommentPopupService.activePopup;
336
+ if (!r)
336
337
  return;
337
- const { unitId: r, subUnitId: i, commentId: s } = t;
338
- n.unitId === r && n.subUnitId === i && n.commentId === s && this._sheetsThreadCommentPopupService.hidePopup();
338
+ const { unitId: i, subUnitId: s, commentId: a } = r;
339
+ t.unitId === i && t.subUnitId === s && t.commentId === a && this._sheetsThreadCommentPopupService.hidePopup();
339
340
  }
340
341
  });
341
342
  }
@@ -350,9 +351,9 @@ let A = class extends R {
350
351
  }
351
352
  _initComponent() {
352
353
  [
353
- [Ee, Et],
354
- [We, Ut],
355
- [ie, Oe]
354
+ [Ue, Et],
355
+ [Ze, Ut],
356
+ [ie, Ee]
356
357
  ].forEach(([e, n]) => {
357
358
  this._componentManager.register(e, n);
358
359
  });
@@ -367,7 +368,7 @@ let A = class extends R {
367
368
  const c = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
368
369
  if (!c || c.getUnitId() !== t)
369
370
  return;
370
- this._isSwitchToCommenting = !0, ((n = c.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(nt.id, {
371
+ this._isSwitchToCommenting = !0, ((n = c.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(rt.id, {
371
372
  unitId: t,
372
373
  subUnitId: r
373
374
  }), this._isSwitchToCommenting = !1;
@@ -379,7 +380,7 @@ let A = class extends R {
379
380
  }, [{ startRow: p, startColumn: v, endRow: p, endColumn: v }]))
380
381
  return;
381
382
  const f = 1;
382
- await this._commandService.executeCommand(ut.id, {
383
+ await this._commandService.executeCommand(dt.id, {
383
384
  range: {
384
385
  startRow: Math.max(d.row - f, 0),
385
386
  endRow: d.row + f,
@@ -441,14 +442,14 @@ let A = class extends R {
441
442
  };
442
443
  A = Vt([
443
444
  B(H.Starting, A),
444
- T(1, qe),
445
+ T(1, Xe),
445
446
  T(2, l(pe)),
446
- T(3, l(Ye)),
447
+ T(3, l(qe)),
447
448
  T(4, re),
448
449
  T(5, l(O)),
449
450
  T(6, l($)),
450
451
  T(7, l(oe)),
451
- T(8, Xe),
452
+ T(8, Je),
452
453
  T(9, N),
453
454
  T(10, l(ge)),
454
455
  T(11, Se)
@@ -465,7 +466,7 @@ let W = class extends R {
465
466
  _initViewModelIntercept() {
466
467
  this.disposeWithMe(
467
468
  this._sheetInterceptorService.intercept(
468
- rt.CELL_CONTENT,
469
+ ot.CELL_CONTENT,
469
470
  {
470
471
  handler: (o, e, n) => {
471
472
  const { row: t, col: r, unitId: i, subUnitId: s } = e;
@@ -495,10 +496,10 @@ let W = class extends R {
495
496
  console.warn("No active sheet found");
496
497
  return;
497
498
  }
498
- const r = this._renderManagerService.getRenderById(n), i = r == null ? void 0 : r.with(dt).getOrCreateSkeleton({ sheetId: t });
499
+ const r = this._renderManagerService.getRenderById(n), i = r == null ? void 0 : r.with(ht).getOrCreateSkeleton({ sheetId: t });
499
500
  i == null || i.makeDirty(!0), i == null || i.calculate(), r && r.mainComponent.makeForceDirty();
500
501
  };
501
- this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe((e) => {
502
+ this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(Me(16)).subscribe((e) => {
502
503
  o();
503
504
  }));
504
505
  }
@@ -522,7 +523,7 @@ const Wt = (o, e, n) => {
522
523
  endColumn: t.column + i,
523
524
  endRow: t.row + r
524
525
  };
525
- return it(s);
526
+ return st(s);
526
527
  };
527
528
  let Z = class extends R {
528
529
  constructor(e, n, t) {
@@ -534,7 +535,7 @@ let Z = class extends R {
534
535
  _initClipboardHook() {
535
536
  this.disposeWithMe(
536
537
  this._sheetClipboardService.addClipboardHook({
537
- id: Ue,
538
+ id: Re,
538
539
  onBeforeCopy: (e, n, t) => {
539
540
  this._copyInfo = {
540
541
  unitId: e,
@@ -548,14 +549,14 @@ let Z = class extends R {
548
549
  row: a.rows[0],
549
550
  column: a.cols[0]
550
551
  };
551
- if (r.copyType === mt.CUT && this._copyInfo) {
552
+ if (r.copyType === pt.CUT && this._copyInfo) {
552
553
  const { range: u, unitId: h, subUnitId: d } = this._copyInfo, p = {
553
554
  row: u.startRow,
554
555
  column: u.startColumn
555
556
  };
556
557
  if (!(i === h && s === d)) {
557
558
  const v = [];
558
- je.foreach(u, (C, m) => {
559
+ Be.foreach(u, (C, m) => {
559
560
  const _ = this._sheetsThreadCommentModel.getAllByLocation(h, d, C, m);
560
561
  this._threadCommentDataSourceService.syncUpdateMutationToColla ? _.forEach((S) => {
561
562
  v.push(S);
@@ -620,7 +621,7 @@ let Z = class extends R {
620
621
  };
621
622
  Z = Ft([
622
623
  B(H.Rendered, Z),
623
- te(0, l(ht)),
624
+ te(0, l(mt)),
624
625
  te(1, l($)),
625
626
  te(2, Ce)
626
627
  ], Z);
@@ -635,7 +636,7 @@ let z = class extends R {
635
636
  }
636
637
  _initHoverEvent() {
637
638
  this.disposeWithMe(
638
- this._hoverManagerService.currentCell$.pipe(St(100)).subscribe((o) => {
639
+ this._hoverManagerService.currentCell$.pipe(Me(100)).subscribe((o) => {
639
640
  const e = this._sheetsThreadCommentPopupService.activePopup;
640
641
  if (o && (e && e.temp || !e)) {
641
642
  const { location: n } = o, { unitId: t, subUnitId: r, row: i, col: s } = n, a = this._sheetsThreadCommentModel.getByLocation(t, r, i, s);
@@ -664,7 +665,7 @@ let z = class extends R {
664
665
  };
665
666
  z = Gt([
666
667
  B(H.Rendered, z),
667
- k(0, l(pt)),
668
+ k(0, l(lt)),
668
669
  k(1, l(O)),
669
670
  k(2, l($)),
670
671
  k(3, l(ge))
@@ -683,7 +684,7 @@ let G = class extends R {
683
684
  this._sheetInterceptorService.interceptCommand({
684
685
  getMutations: (o) => {
685
686
  var e;
686
- if (o.id === ot.id) {
687
+ if (o.id === it.id) {
687
688
  const n = o.params, t = n.unitId ? this._univerInstanceService.getUnit(n.unitId) : this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
688
689
  if (!t)
689
690
  return { redos: [], undos: [] };
@@ -721,15 +722,15 @@ G = qt([
721
722
  B(H.Ready, G),
722
723
  F(0, l(fe)),
723
724
  F(1, N),
724
- F(2, l(st)),
725
+ F(2, l(at)),
725
726
  F(3, Ce)
726
727
  ], G);
727
- var Re = Object.defineProperty, Xt = Object.getOwnPropertyDescriptor, Jt = (o, e, n) => e in o ? Re(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, Qt = (o, e, n, t) => {
728
+ var Ne = Object.defineProperty, Xt = Object.getOwnPropertyDescriptor, Jt = (o, e, n) => e in o ? Ne(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, Qt = (o, e, n, t) => {
728
729
  for (var r = t > 1 ? void 0 : t ? Xt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
729
730
  (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
730
- return t && r && Re(e, n, r), r;
731
- }, he = (o, e) => (n, t) => e(n, t, o), Ne = (o, e, n) => Jt(o, typeof e != "symbol" ? e + "" : e, n);
732
- let Y = class extends He {
731
+ return t && r && Ne(e, n, r), r;
732
+ }, he = (o, e) => (n, t) => e(n, t, o), $e = (o, e, n) => Jt(o, typeof e != "symbol" ? e + "" : e, n);
733
+ let Y = class extends Le {
733
734
  constructor(e = {}, n, t) {
734
735
  super();
735
736
  w(this, "_pluginConfig");
@@ -755,10 +756,10 @@ let Y = class extends He {
755
756
  });
756
757
  }
757
758
  };
758
- Ne(Y, "pluginName", Ue);
759
- Ne(Y, "type", b.UNIVER_SHEET);
759
+ $e(Y, "pluginName", Re);
760
+ $e(Y, "type", b.UNIVER_SHEET);
760
761
  Y = Qt([
761
- Be(Ze, lt),
762
+ He(ze, vt),
762
763
  he(1, l(pe)),
763
764
  he(2, l(re))
764
765
  ], Y);
@@ -769,7 +770,7 @@ export {
769
770
  _n as Inject,
770
771
  fn as Injector,
771
772
  Cn as Plugin,
772
- Ue as SHEETS_THREAD_COMMENT,
773
+ Re as SHEETS_THREAD_COMMENT,
773
774
  A as SheetsThreadCommentController,
774
775
  Z as SheetsThreadCommentCopyPasteController,
775
776
  z as SheetsThreadCommentHoverController,
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/thread-comment-ui"),require("@univerjs/ui"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("@univerjs/sheets-ui"),require("@univerjs/sheets-thread-comment-base"),require("react"),require("rxjs"),require("@univerjs/engine-render")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment-ui","@univerjs/ui","@univerjs/sheets","@univerjs/engine-formula","@univerjs/thread-comment","@univerjs/sheets-ui","@univerjs/sheets-thread-comment-base","react","rxjs","@univerjs/engine-render"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverSheetsThreadComment={},c.UniverCore,c.UniverThreadCommentUi,c.UniverUi,c.UniverSheets,c.UniverEngineFormula,c.UniverThreadComment,c.UniverSheetsUi,c.UniverSheetsThreadCommentBase,c.React,c.rxjs,c.UniverEngineRender))})(this,function(c,o,_,f,v,$,w,P,R,T,Z,ie){"use strict";var Le=Object.defineProperty;var ke=(c,o,_)=>o in c?Le(c,o,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[o]=_;var j=(c,o,_)=>ke(c,typeof o!="symbol"?o+"":o,_);var g=function(){return g=Object.assign||function(r){for(var i,n=1,e=arguments.length;n<e;n++){i=arguments[n];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(r[t]=i[t])}return r},g.apply(this,arguments)},oe=function(r,i){var n={};for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&i.indexOf(e)<0&&(n[e]=r[e]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(r);t<e.length;t++)i.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(r,e[t])&&(n[e[t]]=r[e[t]]);return n},Y=T.forwardRef(function(r,i){var n=r.icon,e=r.id,t=r.className,s=r.extend,a=oe(r,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),u=T.useRef("_".concat(ce()));return X(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},g({ref:i,className:d},a),s)});function X(r,i,n,e,t){return T.createElement(r.tag,g(g({key:i},se(r,n,t)),e),(ae(r,n).children||[]).map(function(s,a){return X(s,"".concat(i,"-").concat(r.tag,"-").concat(a),n,void 0,t)}))}function se(r,i,n){var e=g({},r.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=i.defIds;return!t||t.length===0||(r.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+i.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],d=s[1];typeof d=="string"&&(e[a]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),e}function ae(r,i){var n,e=i.defIds;return!e||e.length===0?r:r.tag==="defs"&&(!((n=r.children)===null||n===void 0)&&n.length)?g(g({},r),{children:r.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?g(g({},t),{attrs:g(g({},t.attrs),{id:t.attrs.id+i.idSuffix})}):t})}):r}function ce(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";var ue={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"}}]},J=T.forwardRef(function(r,i){return T.createElement(Y,Object.assign({},r,{id:"comment-single",ref:i,icon:ue}))});J.displayName="CommentSingle";const Q="univer.sheet.thread-comment-modal",z="comment-single",G="SHEET_THREAD_COMMENT";var de=Object.defineProperty,me=Object.getOwnPropertyDescriptor,he=(r,i,n,e)=>{for(var t=e>1?void 0:e?me(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&de(i,n,t),t},x=(r,i)=>(n,e)=>i(n,e,r);c.SheetsThreadCommentPopupService=class extends o.Disposable{constructor(n,e){super();j(this,"_lastPopup",null);j(this,"_activePopup");j(this,"_activePopup$",new Z.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 m;const{row:t,col:s,unitId:a,subUnitId:d}=n;if(this._activePopup&&t===this._activePopup.row&&s===this._activePopup.col&&a===this._activePopup.unitId&&d===((m=this.activePopup)==null?void 0:m.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const u=this._canvasPopupManagerService.attachPopupToCell(t,s,{componentKey:Q,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new o.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},c.SheetsThreadCommentPopupService=he([x(0,o.Inject(P.SheetCanvasPopManagerService)),x(1,f.IZenZoneService)],c.SheetsThreadCommentPopupService);const le=()=>{const r=o.useDependency(o.IUniverInstanceService),i=o.useDependency(c.SheetsThreadCommentPopupService),n=f.useObservable(i.activePopup$),e=o.useDependency(R.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:t,col:s,unitId:a,subUnitId:d,trigger:u}=n,h=e.getByLocation(a,d,t,s),m=`${o.Tools.chatAtABC(s)}${t+1}`,S=()=>{i.hidePopup()},p=C=>{var I,D,b;return(b=(D=(I=r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(C))==null?void 0:D.getName())!=null?b:""};return T.createElement(_.ThreadCommentTree,{onClick:()=>{i.persistPopup()},prefix:"cell",id:h,unitId:a,subUnitId:d,type:o.UniverInstanceType.UNIVER_SHEET,refStr:m,onClose:S,getSubUnitName:p,autoFocus:u==="context-menu"})},V={type:o.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(r){var I;const i=r.get(v.SheetsSelectionsService),n=r.get(o.IUniverInstanceService),e=r.get(c.SheetsThreadCommentPopupService),t=r.get(_.ThreadCommentPanelService),s=(I=i.getCurrentLastSelection())==null?void 0:I.primary,a=r.get(R.SheetsThreadCommentModel);if(!s)return!1;const d=v.getSheetCommandTarget(n);if(!d)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:S}=d,p={workbook:u,worksheet:h,unitId:m,subUnitId:S,row:s.startRow,col:s.startColumn};e.showPopup(p);const C=a.getByLocation(m,S,s.startRow,s.startColumn);return C&&t.setActiveComment({unitId:m,subUnitId:S,commentId:C,trigger:"context-menu"}),!0}},pe=()=>{var q;const r=o.useDependency(P.IMarkSelectionService),i=o.useDependency(o.IUniverInstanceService),n=o.useDependency(c.SheetsThreadCommentPopupService),e=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),t=e.getUnitId(),s=o.useDependency(o.ICommandService),a=T.useMemo(()=>e.activeSheet$.pipe(Z.map(l=>l==null?void 0:l.getSheetId())),[e.activeSheet$]),d=f.useObservable(a,(q=e.getActiveSheet())==null?void 0:q.getSheetId()),u=T.useRef(),h=o.useDependency(_.ThreadCommentPanelService),m=f.useObservable(h.activeCommentId$),S=f.useObservable(h.panelVisible$,h.panelVisible),p=T.useCallback(l=>{const y=e.getSheets(),M={};y.forEach((E,U)=>{M[E.getSheetId()]=U});const H=E=>E.map(U=>{var re;const N=$.singleReferenceToGrid(U.ref),He=[(re=M[U.subUnitId])!=null?re:0,N.row,N.column];return{...U,p:He}}).sort((U,N)=>U.p[0]===N.p[0]?U.p[1]===N.p[1]?U.p[2]-N.p[2]:U.p[1]-N.p[1]:U.p[0]-N.p[0]);return[...H(l.filter(E=>!E.resolved)),...H(l.filter(E=>E.resolved))]},[e]),C=T.useCallback(l=>{if(l.unitId===t&&l.subUnitId===d&&!l.resolved){const{row:y,column:M}=$.singleReferenceToGrid(l.ref);if(!Number.isNaN(y)&&!Number.isNaN(M))return r.addShape({range:{startColumn:M,endColumn:M,startRow:y,endRow:y},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[r,d,t]),I=l=>{var y,M;return(M=(y=e.getSheetBySheetId(l))==null?void 0:y.getName())!=null?M:""},D=()=>{s.executeCommand(V.id)},b=l=>{m&&m.unitId===l.unitId&&m.subUnitId===l.subUnitId&&m.commentId===l.id||(u.current&&(r.removeShape(u.current),u.current=null),u.current=C(l))},A=()=>{u.current&&(r.removeShape(u.current),u.current=null)},F=(l,y)=>{y&&n.hidePopup()};return T.useEffect(()=>{!S&&u.current&&r.removeShape(u.current)},[r,S]),T.createElement(_.ThreadCommentPanel,{unitId:t,subUnitId$:a,type:o.UniverInstanceType.UNIVER_SHEET,onAdd:D,getSubUnitName:I,onResolve:F,sortComments:p,onItemEnter:b,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},ve=r=>({id:V.id,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.CONTEXT_MENU],icon:z,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),Se=r=>({id:_.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:z,tooltip:"sheetThreadComment.menu.commentManagement",positions:f.MenuPosition.TOOLBAR_START,group:f.MenuGroup.TOOLBAR_OTHERS,disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET)}),Ce={id:V.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused};var fe=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ie=(r,i,n,e)=>{for(var t=e>1?void 0:e?_e(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&fe(i,n,t),t},O=(r,i)=>(n,e)=>i(n,e,r);const Pe={};c.SheetsThreadCommentController=class extends o.Disposable{constructor(n,e,t,s,a,d,u,h,m,S,p,C){super();j(this,"_isSwitchToCommenting",!1);j(this,"_selectionShapeInfo",null);this._config=n,this._menuService=e,this._injector=t,this._componentManager=s,this._commandService=a,this._sheetsThreadCommentPopupService=d,this._sheetsThreadCommentModel=u,this._threadCommentPanelService=h,this._shortcutService=m,this._univerInstanceService=S,this._sheetPermissionInterceptorBaseController=p,this._markSelectionService=C,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection()}_initShortcut(){this._shortcutService.registerShortcut(Ce)}_initCommandListener(){this._commandService.onCommandExecuted(n=>{if(n.id===v.SetSelectionsOperation.id){if(this._isSwitchToCommenting)return;const e=n.params,{unitId:t,subUnitId:s,selections:a,type:d}=e;if((d===v.SelectionMoveType.MOVE_END||d===void 0)&&a[0].primary){const u=a[0].range;if(u.endColumn-u.startColumn>0||u.endRow-u.startRow>0)return;const h=a[0].primary.actualRow,m=a[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(t,s,h,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(_.SetActiveCommentOperation.id);return}const S=this._sheetsThreadCommentModel.getByLocation(t,s,h,m);S&&this._commandService.executeCommand(_.SetActiveCommentOperation.id,{unitId:t,subUnitId:s,commentId:S})}}if(n.id===w.DeleteCommentMutation.id){const e=n.params,t=this._sheetsThreadCommentPopupService.activePopup;if(!t)return;const{unitId:s,subUnitId:a,commentId:d}=t;e.unitId===s&&e.subUnitId===a&&e.commentId===d&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:n={}}=this._config;[ve,Se].forEach(e=>{this._menuService.addMenuItem(e(this._injector),n)})}_initComponent(){[[Q,le],[_.THREAD_COMMENT_PANEL,pe],[z,J]].forEach(([n,e])=>{this._componentManager.register(n,e)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async n=>{var e;if(n){const{unitId:t,subUnitId:s,commentId:a,trigger:d}=n,u=this._sheetsThreadCommentModel.getComment(t,s,a);if(!u||u.resolved)return;const h=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!h||h.getUnitId()!==t)return;this._isSwitchToCommenting=!0,((e=h.getActiveSheet())==null?void 0:e.getSheetId())!==s&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:s}),this._isSwitchToCommenting=!1;const p=$.singleReferenceToGrid(u.ref),{row:C,column:I}=p;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:C,startColumn:I,endRow:C,endColumn:I}]))return;const b=1;await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(p.row-b,0),endRow:p.row+b,startColumn:Math.max(p.column-b,0),endColumn:p.column+b}}),this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:s,row:p.row,col:p.column,commentId:u.id,trigger:d})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(n=>{if(!n){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:e,subUnitId:t,commentId:s}=n;if(this._selectionShapeInfo){if(this._selectionShapeInfo.unitId===e&&this._selectionShapeInfo.subUnitId===t&&this._selectionShapeInfo.commentId===s)return;this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null}const a=this._sheetsThreadCommentModel.getComment(e,t,s);if(!a)return;const d=$.singleReferenceToGrid(a.ref),{row:u,column:h}=d;if(Number.isNaN(u)||Number.isNaN(h))return;const m=this._markSelectionService.addShape({range:{startColumn:h,endColumn:h,startRow:u,endRow:u},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null});m&&(this._selectionShapeInfo={...n,shapeId:m})}))}},c.SheetsThreadCommentController=Ie([o.OnLifecycle(o.LifecycleStages.Starting,c.SheetsThreadCommentController),O(1,f.IMenuService),O(2,o.Inject(o.Injector)),O(3,o.Inject(f.ComponentManager)),O(4,o.ICommandService),O(5,o.Inject(c.SheetsThreadCommentPopupService)),O(6,o.Inject(R.SheetsThreadCommentModel)),O(7,o.Inject(_.ThreadCommentPanelService)),O(8,f.IShortcutService),O(9,o.IUniverInstanceService),O(10,o.Inject(P.SheetPermissionInterceptorBaseController)),O(11,P.IMarkSelectionService)],c.SheetsThreadCommentController);var Te=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,be=(r,i,n,e)=>{for(var t=e>1?void 0:e?ge(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Te(i,n,t),t},L=(r,i)=>(n,e)=>i(n,e,r);let k=class extends o.Disposable{constructor(r,i,n,e){super(),this._sheetInterceptorService=r,this._sheetsThreadCommentModel=i,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(r,i,n)=>{const{row:e,col:t,unitId:s,subUnitId:a}=i;return this._sheetsThreadCommentModel.showCommentMarker(s,a,e,t)?n({...r,markers:{...r==null?void 0:r.markers,tr:{color:"#FFBD37",size:6}}}):n(r)},priority:100}))}_initSkeletonChange(){const r=()=>{var a;const i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const n=i.getUnitId(),e=(a=i.getActiveSheet())==null?void 0:a.getSheetId();if(!e){console.warn("No active sheet found");return}const t=this._renderManagerService.getRenderById(n),s=t==null?void 0:t.with(P.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});s==null||s.makeDirty(!0),s==null||s.calculate(),t&&t.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(i=>{r()}))}};k=be([o.OnLifecycle(o.LifecycleStages.Ready,k),L(0,o.Inject(v.SheetInterceptorService)),L(1,o.Inject(R.SheetsThreadCommentModel)),L(2,o.IUniverInstanceService),L(3,ie.IRenderManagerService)],k);var ye=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,we=(r,i,n,e)=>{for(var t=e>1?void 0:e?Me(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&ye(i,n,t),t},K=(r,i)=>(n,e)=>i(n,e,r);const Oe=(r,i,n)=>{const e=$.singleReferenceToGrid(r),t=n.row-i.row,s=n.column-i.column,a={startColumn:e.column+s,startRow:e.row+t,endColumn:e.column+s,endRow:e.row+t};return $.serializeRange(a)};c.SheetsThreadCommentCopyPasteController=class extends o.Disposable{constructor(n,e,t){super();j(this,"_copyInfo");this._sheetClipboardService=n,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:G,onBeforeCopy:(n,e,t)=>{this._copyInfo={unitId:n,subUnitId:e,range:t}},onPasteCells:(n,e,t,s)=>{const{unitId:a,subUnitId:d,range:u}=e,h={row:u.rows[0],column:u.cols[0]};if(s.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:S,subUnitId:p}=this._copyInfo,C={row:m.startRow,column:m.startColumn};if(!(a===S&&d===p)){const I=[];o.Range.foreach(m,(l,y)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(S,p,l,y);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(H=>{I.push(H)}):M.forEach(({children:H,...E})=>{E.parentId||I.push(E)})});const D=[],b=[],A=[],F=[],q=l=>{D.unshift({id:w.DeleteCommentMutation.id,params:{unitId:S,subUnitId:p,commentId:l.id}}),A.push({id:w.AddCommentMutation.id,params:{unitId:a,subUnitId:d,comment:{...l,ref:Oe(l.ref,C,h),unitId:a,subUnitId:d},sync:!0}}),b.push({id:w.AddCommentMutation.id,params:{unitId:S,subUnitId:p,comment:l,sync:!0}}),F.unshift({id:w.DeleteCommentMutation.id,params:{unitId:a,subUnitId:d,commentId:l.id}})};return I.forEach(l=>{q(l)}),{redos:[...D,...A],undos:[...F,...b]}}}return{redos:[],undos:[]}}}))}},c.SheetsThreadCommentCopyPasteController=we([o.OnLifecycle(o.LifecycleStages.Rendered,c.SheetsThreadCommentCopyPasteController),K(0,o.Inject(P.ISheetClipboardService)),K(1,o.Inject(R.SheetsThreadCommentModel)),K(2,w.IThreadCommentDataSourceService)],c.SheetsThreadCommentCopyPasteController);var Ue=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(r,i,n,e)=>{for(var t=e>1?void 0:e?Ee(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Ue(i,n,t),t},B=(r,i)=>(n,e)=>i(n,e,r);c.SheetsThreadCommentHoverController=class extends o.Disposable{constructor(i,n,e,t){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(Z.debounceTime(100)).subscribe(i=>{const n=this._sheetsThreadCommentPopupService.activePopup;if(i&&(n&&n.temp||!n)){const{location:e}=i,{unitId:t,subUnitId:s,row:a,col:d}=e,u=this._sheetsThreadCommentModel.getByLocation(t,s,a,d);if(u){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:a,startColumn:d,endRow:a,endColumn:d}]))return;const m=this._sheetsThreadCommentModel.getComment(t,s,u);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:s,row:a,col:d,commentId:u,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},c.SheetsThreadCommentHoverController=je([o.OnLifecycle(o.LifecycleStages.Rendered,c.SheetsThreadCommentHoverController),B(0,o.Inject(P.HoverManagerService)),B(1,o.Inject(c.SheetsThreadCommentPopupService)),B(2,o.Inject(R.SheetsThreadCommentModel)),B(3,o.Inject(P.SheetPermissionInterceptorBaseController))],c.SheetsThreadCommentHoverController);var Re=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ne=(r,i,n,e)=>{for(var t=e>1?void 0:e?De(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Re(i,n,t),t},W=(r,i)=>(n,e)=>i(n,e,r);c.ThreadCommentRemoveSheetsController=class extends o.Disposable{constructor(i,n,e,t){super(),this._sheetInterceptorService=i,this._univerInstanceService=n,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var n;if(i.id===v.RemoveSheetCommand.id){const e=i.params,t=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const s=t.getUnitId(),a=e.subUnitId||((n=t.getActiveSheet())==null?void 0:n.getSheetId());if(!a)return{redos:[],undos:[]};const{commentMap:d}=this._threadCommentModel.ensureMap(s,a),u=Array.from(Object.values(d)).filter(C=>!C.parentId),h=u.map(C=>C.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,S=h.map(C=>({id:w.DeleteCommentMutation.id,params:{unitId:s,subUnitId:a,commentId:C}})),p=u.map(({children:C,...I})=>({id:w.AddCommentMutation.id,params:{unitId:s,subUnitId:a,comment:{...I,children:m?C:void 0},sync:!m}}));return{redos:S,undos:p}}return{redos:[],undos:[]}}}))}},c.ThreadCommentRemoveSheetsController=Ne([o.OnLifecycle(o.LifecycleStages.Ready,c.ThreadCommentRemoveSheetsController),W(0,o.Inject(v.SheetInterceptorService)),W(1,o.IUniverInstanceService),W(2,o.Inject(w.ThreadCommentModel)),W(3,w.IThreadCommentDataSourceService)],c.ThreadCommentRemoveSheetsController);var ee=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ve=(r,i,n)=>i in r?ee(r,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[i]=n,Ae=(r,i,n,e)=>{for(var t=e>1?void 0:e?$e(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&ee(i,n,t),t},te=(r,i)=>(n,e)=>i(n,e,r),ne=(r,i,n)=>Ve(r,typeof i!="symbol"?i+"":i,n);c.UniverSheetsThreadCommentPlugin=class extends o.Plugin{constructor(n={},e,t){super();j(this,"_pluginConfig");this._injector=e,this._commandService=t,this._pluginConfig=o.Tools.deepMerge({},Pe,n)}onStarting(n){[[c.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(c.SheetsThreadCommentController,this._pluginConfig)}],[k],[c.SheetsThreadCommentCopyPasteController],[c.SheetsThreadCommentHoverController],[c.ThreadCommentRemoveSheetsController],[c.SheetsThreadCommentPopupService]].forEach(e=>{n.add(e)}),[V].forEach(e=>{this._commandService.registerCommand(e)})}},ne(c.UniverSheetsThreadCommentPlugin,"pluginName",G),ne(c.UniverSheetsThreadCommentPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentPlugin=Ae([o.DependentOn(_.UniverThreadCommentUIPlugin,R.UniverSheetsThreadCommentBasePlugin),te(1,o.Inject(o.Injector)),te(2,o.Inject(o.ICommandService))],c.UniverSheetsThreadCommentPlugin),Object.defineProperty(c,"ICommandService",{enumerable:!0,get:()=>o.ICommandService}),Object.defineProperty(c,"Inject",{enumerable:!0,get:()=>o.Inject}),Object.defineProperty(c,"Injector",{enumerable:!0,get:()=>o.Injector}),Object.defineProperty(c,"Plugin",{enumerable:!0,get:()=>o.Plugin}),Object.defineProperty(c,"UniverInstanceType",{enumerable:!0,get:()=>o.UniverInstanceType}),Object.defineProperty(c,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>_.IThreadCommentMentionDataService}),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>_.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>w.IThreadCommentDataSourceService}),Object.defineProperty(c,"SheetsThreadCommentModel",{enumerable:!0,get:()=>R.SheetsThreadCommentModel}),c.SHEETS_THREAD_COMMENT=G,c.ShowAddSheetCommentModalOperation=V,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/thread-comment-ui"),require("@univerjs/ui"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("@univerjs/sheets-ui"),require("@univerjs/sheets-thread-comment-base"),require("react"),require("rxjs"),require("@univerjs/engine-render")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment-ui","@univerjs/ui","@univerjs/sheets","@univerjs/engine-formula","@univerjs/thread-comment","@univerjs/sheets-ui","@univerjs/sheets-thread-comment-base","react","rxjs","@univerjs/engine-render"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverSheetsThreadComment={},c.UniverCore,c.UniverThreadCommentUi,c.UniverUi,c.UniverSheets,c.UniverEngineFormula,c.UniverThreadComment,c.UniverSheetsUi,c.UniverSheetsThreadCommentBase,c.React,c.rxjs,c.UniverEngineRender))})(this,function(c,o,_,f,v,$,w,P,R,T,L,ie){"use strict";var Le=Object.defineProperty;var ke=(c,o,_)=>o in c?Le(c,o,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[o]=_;var j=(c,o,_)=>ke(c,typeof o!="symbol"?o+"":o,_);var g=function(){return g=Object.assign||function(r){for(var i,n=1,e=arguments.length;n<e;n++){i=arguments[n];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(r[t]=i[t])}return r},g.apply(this,arguments)},oe=function(r,i){var n={};for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&i.indexOf(e)<0&&(n[e]=r[e]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(r);t<e.length;t++)i.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(r,e[t])&&(n[e[t]]=r[e[t]]);return n},Y=T.forwardRef(function(r,i){var n=r.icon,e=r.id,t=r.className,s=r.extend,a=oe(r,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),u=T.useRef("_".concat(ce()));return X(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},g({ref:i,className:d},a),s)});function X(r,i,n,e,t){return T.createElement(r.tag,g(g({key:i},se(r,n,t)),e),(ae(r,n).children||[]).map(function(s,a){return X(s,"".concat(i,"-").concat(r.tag,"-").concat(a),n,void 0,t)}))}function se(r,i,n){var e=g({},r.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=i.defIds;return!t||t.length===0||(r.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+i.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],d=s[1];typeof d=="string"&&(e[a]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),e}function ae(r,i){var n,e=i.defIds;return!e||e.length===0?r:r.tag==="defs"&&(!((n=r.children)===null||n===void 0)&&n.length)?g(g({},r),{children:r.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?g(g({},t),{attrs:g(g({},t.attrs),{id:t.attrs.id+i.idSuffix})}):t})}):r}function ce(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";var ue={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"}}]},J=T.forwardRef(function(r,i){return T.createElement(Y,Object.assign({},r,{id:"comment-single",ref:i,icon:ue}))});J.displayName="CommentSingle";const Q="univer.sheet.thread-comment-modal",z="comment-single",G="SHEET_THREAD_COMMENT";var de=Object.defineProperty,me=Object.getOwnPropertyDescriptor,he=(r,i,n,e)=>{for(var t=e>1?void 0:e?me(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&de(i,n,t),t},x=(r,i)=>(n,e)=>i(n,e,r);c.SheetsThreadCommentPopupService=class extends o.Disposable{constructor(n,e){super();j(this,"_lastPopup",null);j(this,"_activePopup");j(this,"_activePopup$",new L.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 m;const{row:t,col:s,unitId:a,subUnitId:d}=n;if(this._activePopup&&t===this._activePopup.row&&s===this._activePopup.col&&a===this._activePopup.unitId&&d===((m=this.activePopup)==null?void 0:m.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const u=this._canvasPopupManagerService.attachPopupToCell(t,s,{componentKey:Q,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new o.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},c.SheetsThreadCommentPopupService=he([x(0,o.Inject(P.SheetCanvasPopManagerService)),x(1,f.IZenZoneService)],c.SheetsThreadCommentPopupService);const le=()=>{const r=o.useDependency(o.IUniverInstanceService),i=o.useDependency(c.SheetsThreadCommentPopupService),n=f.useObservable(i.activePopup$),e=o.useDependency(R.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:t,col:s,unitId:a,subUnitId:d,trigger:u}=n,h=e.getByLocation(a,d,t,s),m=`${o.Tools.chatAtABC(s)}${t+1}`,S=()=>{i.hidePopup()},p=C=>{var I,D,b;return(b=(D=(I=r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(C))==null?void 0:D.getName())!=null?b:""};return T.createElement(_.ThreadCommentTree,{onClick:()=>{i.persistPopup()},prefix:"cell",id:h,unitId:a,subUnitId:d,type:o.UniverInstanceType.UNIVER_SHEET,refStr:m,onClose:S,getSubUnitName:p,autoFocus:u==="context-menu"})},V={type:o.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(r){var I;const i=r.get(v.SheetsSelectionsService),n=r.get(o.IUniverInstanceService),e=r.get(c.SheetsThreadCommentPopupService),t=r.get(_.ThreadCommentPanelService),s=(I=i.getCurrentLastSelection())==null?void 0:I.primary,a=r.get(R.SheetsThreadCommentModel);if(!s)return!1;const d=v.getSheetCommandTarget(n);if(!d)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:S}=d,p={workbook:u,worksheet:h,unitId:m,subUnitId:S,row:s.startRow,col:s.startColumn};e.showPopup(p);const C=a.getByLocation(m,S,s.startRow,s.startColumn);return C&&t.setActiveComment({unitId:m,subUnitId:S,commentId:C,trigger:"context-menu"}),!0}},pe=()=>{var Z;const r=o.useDependency(P.IMarkSelectionService),i=o.useDependency(o.IUniverInstanceService),n=o.useDependency(c.SheetsThreadCommentPopupService),e=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),t=e.getUnitId(),s=o.useDependency(o.ICommandService),a=T.useMemo(()=>e.activeSheet$.pipe(L.map(l=>l==null?void 0:l.getSheetId())),[e.activeSheet$]),d=f.useObservable(a,(Z=e.getActiveSheet())==null?void 0:Z.getSheetId()),u=T.useRef(),h=o.useDependency(_.ThreadCommentPanelService),m=f.useObservable(h.activeCommentId$),S=f.useObservable(h.panelVisible$,h.panelVisible),p=T.useCallback(l=>{const y=e.getSheets(),M={};y.forEach((E,U)=>{M[E.getSheetId()]=U});const H=E=>E.map(U=>{var re;const N=$.singleReferenceToGrid(U.ref),He=[(re=M[U.subUnitId])!=null?re:0,N.row,N.column];return{...U,p:He}}).sort((U,N)=>U.p[0]===N.p[0]?U.p[1]===N.p[1]?U.p[2]-N.p[2]:U.p[1]-N.p[1]:U.p[0]-N.p[0]);return[...H(l.filter(E=>!E.resolved)),...H(l.filter(E=>E.resolved))]},[e]),C=T.useCallback(l=>{if(l.unitId===t&&l.subUnitId===d&&!l.resolved){const{row:y,column:M}=$.singleReferenceToGrid(l.ref);if(!Number.isNaN(y)&&!Number.isNaN(M))return r.addShape({range:{startColumn:M,endColumn:M,startRow:y,endRow:y},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[r,d,t]),I=l=>{var y,M;return(M=(y=e.getSheetBySheetId(l))==null?void 0:y.getName())!=null?M:""},D=()=>{s.executeCommand(V.id)},b=l=>{m&&m.unitId===l.unitId&&m.subUnitId===l.subUnitId&&m.commentId===l.id||(u.current&&(r.removeShape(u.current),u.current=null),u.current=C(l))},A=()=>{u.current&&(r.removeShape(u.current),u.current=null)},q=(l,y)=>{y&&n.hidePopup()};return T.useEffect(()=>{!S&&u.current&&r.removeShape(u.current)},[r,S]),T.createElement(_.ThreadCommentPanel,{unitId:t,subUnitId$:a,type:o.UniverInstanceType.UNIVER_SHEET,onAdd:D,getSubUnitName:I,onResolve:q,sortComments:p,onItemEnter:b,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},ve=r=>({id:V.id,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.CONTEXT_MENU],icon:z,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),Se=r=>({id:_.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:z,tooltip:"sheetThreadComment.menu.commentManagement",positions:f.MenuPosition.TOOLBAR_START,group:f.MenuGroup.TOOLBAR_OTHERS,disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET)}),Ce={id:V.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused};var fe=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ie=(r,i,n,e)=>{for(var t=e>1?void 0:e?_e(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&fe(i,n,t),t},O=(r,i)=>(n,e)=>i(n,e,r);const Pe={};c.SheetsThreadCommentController=class extends o.Disposable{constructor(n,e,t,s,a,d,u,h,m,S,p,C){super();j(this,"_isSwitchToCommenting",!1);j(this,"_selectionShapeInfo",null);this._config=n,this._menuService=e,this._injector=t,this._componentManager=s,this._commandService=a,this._sheetsThreadCommentPopupService=d,this._sheetsThreadCommentModel=u,this._threadCommentPanelService=h,this._shortcutService=m,this._univerInstanceService=S,this._sheetPermissionInterceptorBaseController=p,this._markSelectionService=C,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection()}_initShortcut(){this._shortcutService.registerShortcut(Ce)}_initCommandListener(){this._commandService.onCommandExecuted(n=>{var e;if(n.id===v.SetSelectionsOperation.id){if(this._isSwitchToCommenting)return;const t=n.params,{unitId:s,subUnitId:a,selections:d,type:u}=t;if((u===v.SelectionMoveType.MOVE_END||u===void 0)&&((e=d[0])!=null&&e.primary)){const h=d[0].range;if(h.endColumn-h.startColumn>0||h.endRow-h.startRow>0)return;const m=d[0].primary.actualRow,S=d[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(s,a,m,S)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(_.SetActiveCommentOperation.id);return}const p=this._sheetsThreadCommentModel.getByLocation(s,a,m,S);p&&this._commandService.executeCommand(_.SetActiveCommentOperation.id,{unitId:s,subUnitId:a,commentId:p})}}if(n.id===w.DeleteCommentMutation.id){const t=n.params,s=this._sheetsThreadCommentPopupService.activePopup;if(!s)return;const{unitId:a,subUnitId:d,commentId:u}=s;t.unitId===a&&t.subUnitId===d&&t.commentId===u&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:n={}}=this._config;[ve,Se].forEach(e=>{this._menuService.addMenuItem(e(this._injector),n)})}_initComponent(){[[Q,le],[_.THREAD_COMMENT_PANEL,pe],[z,J]].forEach(([n,e])=>{this._componentManager.register(n,e)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async n=>{var e;if(n){const{unitId:t,subUnitId:s,commentId:a,trigger:d}=n,u=this._sheetsThreadCommentModel.getComment(t,s,a);if(!u||u.resolved)return;const h=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!h||h.getUnitId()!==t)return;this._isSwitchToCommenting=!0,((e=h.getActiveSheet())==null?void 0:e.getSheetId())!==s&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:s}),this._isSwitchToCommenting=!1;const p=$.singleReferenceToGrid(u.ref),{row:C,column:I}=p;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:C,startColumn:I,endRow:C,endColumn:I}]))return;const b=1;await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(p.row-b,0),endRow:p.row+b,startColumn:Math.max(p.column-b,0),endColumn:p.column+b}}),this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:s,row:p.row,col:p.column,commentId:u.id,trigger:d})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(n=>{if(!n){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:e,subUnitId:t,commentId:s}=n;if(this._selectionShapeInfo){if(this._selectionShapeInfo.unitId===e&&this._selectionShapeInfo.subUnitId===t&&this._selectionShapeInfo.commentId===s)return;this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null}const a=this._sheetsThreadCommentModel.getComment(e,t,s);if(!a)return;const d=$.singleReferenceToGrid(a.ref),{row:u,column:h}=d;if(Number.isNaN(u)||Number.isNaN(h))return;const m=this._markSelectionService.addShape({range:{startColumn:h,endColumn:h,startRow:u,endRow:u},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null});m&&(this._selectionShapeInfo={...n,shapeId:m})}))}},c.SheetsThreadCommentController=Ie([o.OnLifecycle(o.LifecycleStages.Starting,c.SheetsThreadCommentController),O(1,f.IMenuService),O(2,o.Inject(o.Injector)),O(3,o.Inject(f.ComponentManager)),O(4,o.ICommandService),O(5,o.Inject(c.SheetsThreadCommentPopupService)),O(6,o.Inject(R.SheetsThreadCommentModel)),O(7,o.Inject(_.ThreadCommentPanelService)),O(8,f.IShortcutService),O(9,o.IUniverInstanceService),O(10,o.Inject(P.SheetPermissionInterceptorBaseController)),O(11,P.IMarkSelectionService)],c.SheetsThreadCommentController);var Te=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,be=(r,i,n,e)=>{for(var t=e>1?void 0:e?ge(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Te(i,n,t),t},k=(r,i)=>(n,e)=>i(n,e,r);let B=class extends o.Disposable{constructor(r,i,n,e){super(),this._sheetInterceptorService=r,this._sheetsThreadCommentModel=i,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(r,i,n)=>{const{row:e,col:t,unitId:s,subUnitId:a}=i;return this._sheetsThreadCommentModel.showCommentMarker(s,a,e,t)?n({...r,markers:{...r==null?void 0:r.markers,tr:{color:"#FFBD37",size:6}}}):n(r)},priority:100}))}_initSkeletonChange(){const r=()=>{var a;const i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const n=i.getUnitId(),e=(a=i.getActiveSheet())==null?void 0:a.getSheetId();if(!e){console.warn("No active sheet found");return}const t=this._renderManagerService.getRenderById(n),s=t==null?void 0:t.with(P.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});s==null||s.makeDirty(!0),s==null||s.calculate(),t&&t.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(L.debounceTime(16)).subscribe(i=>{r()}))}};B=be([o.OnLifecycle(o.LifecycleStages.Ready,B),k(0,o.Inject(v.SheetInterceptorService)),k(1,o.Inject(R.SheetsThreadCommentModel)),k(2,o.IUniverInstanceService),k(3,ie.IRenderManagerService)],B);var ye=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,we=(r,i,n,e)=>{for(var t=e>1?void 0:e?Me(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&ye(i,n,t),t},K=(r,i)=>(n,e)=>i(n,e,r);const Oe=(r,i,n)=>{const e=$.singleReferenceToGrid(r),t=n.row-i.row,s=n.column-i.column,a={startColumn:e.column+s,startRow:e.row+t,endColumn:e.column+s,endRow:e.row+t};return $.serializeRange(a)};c.SheetsThreadCommentCopyPasteController=class extends o.Disposable{constructor(n,e,t){super();j(this,"_copyInfo");this._sheetClipboardService=n,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:G,onBeforeCopy:(n,e,t)=>{this._copyInfo={unitId:n,subUnitId:e,range:t}},onPasteCells:(n,e,t,s)=>{const{unitId:a,subUnitId:d,range:u}=e,h={row:u.rows[0],column:u.cols[0]};if(s.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:S,subUnitId:p}=this._copyInfo,C={row:m.startRow,column:m.startColumn};if(!(a===S&&d===p)){const I=[];o.Range.foreach(m,(l,y)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(S,p,l,y);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(H=>{I.push(H)}):M.forEach(({children:H,...E})=>{E.parentId||I.push(E)})});const D=[],b=[],A=[],q=[],Z=l=>{D.unshift({id:w.DeleteCommentMutation.id,params:{unitId:S,subUnitId:p,commentId:l.id}}),A.push({id:w.AddCommentMutation.id,params:{unitId:a,subUnitId:d,comment:{...l,ref:Oe(l.ref,C,h),unitId:a,subUnitId:d},sync:!0}}),b.push({id:w.AddCommentMutation.id,params:{unitId:S,subUnitId:p,comment:l,sync:!0}}),q.unshift({id:w.DeleteCommentMutation.id,params:{unitId:a,subUnitId:d,commentId:l.id}})};return I.forEach(l=>{Z(l)}),{redos:[...D,...A],undos:[...q,...b]}}}return{redos:[],undos:[]}}}))}},c.SheetsThreadCommentCopyPasteController=we([o.OnLifecycle(o.LifecycleStages.Rendered,c.SheetsThreadCommentCopyPasteController),K(0,o.Inject(P.ISheetClipboardService)),K(1,o.Inject(R.SheetsThreadCommentModel)),K(2,w.IThreadCommentDataSourceService)],c.SheetsThreadCommentCopyPasteController);var Ue=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(r,i,n,e)=>{for(var t=e>1?void 0:e?Ee(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Ue(i,n,t),t},W=(r,i)=>(n,e)=>i(n,e,r);c.SheetsThreadCommentHoverController=class extends o.Disposable{constructor(i,n,e,t){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(L.debounceTime(100)).subscribe(i=>{const n=this._sheetsThreadCommentPopupService.activePopup;if(i&&(n&&n.temp||!n)){const{location:e}=i,{unitId:t,subUnitId:s,row:a,col:d}=e,u=this._sheetsThreadCommentModel.getByLocation(t,s,a,d);if(u){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:a,startColumn:d,endRow:a,endColumn:d}]))return;const m=this._sheetsThreadCommentModel.getComment(t,s,u);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:s,row:a,col:d,commentId:u,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},c.SheetsThreadCommentHoverController=je([o.OnLifecycle(o.LifecycleStages.Rendered,c.SheetsThreadCommentHoverController),W(0,o.Inject(P.HoverManagerService)),W(1,o.Inject(c.SheetsThreadCommentPopupService)),W(2,o.Inject(R.SheetsThreadCommentModel)),W(3,o.Inject(P.SheetPermissionInterceptorBaseController))],c.SheetsThreadCommentHoverController);var Re=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ne=(r,i,n,e)=>{for(var t=e>1?void 0:e?De(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Re(i,n,t),t},F=(r,i)=>(n,e)=>i(n,e,r);c.ThreadCommentRemoveSheetsController=class extends o.Disposable{constructor(i,n,e,t){super(),this._sheetInterceptorService=i,this._univerInstanceService=n,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var n;if(i.id===v.RemoveSheetCommand.id){const e=i.params,t=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const s=t.getUnitId(),a=e.subUnitId||((n=t.getActiveSheet())==null?void 0:n.getSheetId());if(!a)return{redos:[],undos:[]};const{commentMap:d}=this._threadCommentModel.ensureMap(s,a),u=Array.from(Object.values(d)).filter(C=>!C.parentId),h=u.map(C=>C.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,S=h.map(C=>({id:w.DeleteCommentMutation.id,params:{unitId:s,subUnitId:a,commentId:C}})),p=u.map(({children:C,...I})=>({id:w.AddCommentMutation.id,params:{unitId:s,subUnitId:a,comment:{...I,children:m?C:void 0},sync:!m}}));return{redos:S,undos:p}}return{redos:[],undos:[]}}}))}},c.ThreadCommentRemoveSheetsController=Ne([o.OnLifecycle(o.LifecycleStages.Ready,c.ThreadCommentRemoveSheetsController),F(0,o.Inject(v.SheetInterceptorService)),F(1,o.IUniverInstanceService),F(2,o.Inject(w.ThreadCommentModel)),F(3,w.IThreadCommentDataSourceService)],c.ThreadCommentRemoveSheetsController);var ee=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ve=(r,i,n)=>i in r?ee(r,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[i]=n,Ae=(r,i,n,e)=>{for(var t=e>1?void 0:e?$e(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&ee(i,n,t),t},te=(r,i)=>(n,e)=>i(n,e,r),ne=(r,i,n)=>Ve(r,typeof i!="symbol"?i+"":i,n);c.UniverSheetsThreadCommentPlugin=class extends o.Plugin{constructor(n={},e,t){super();j(this,"_pluginConfig");this._injector=e,this._commandService=t,this._pluginConfig=o.Tools.deepMerge({},Pe,n)}onStarting(n){[[c.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(c.SheetsThreadCommentController,this._pluginConfig)}],[B],[c.SheetsThreadCommentCopyPasteController],[c.SheetsThreadCommentHoverController],[c.ThreadCommentRemoveSheetsController],[c.SheetsThreadCommentPopupService]].forEach(e=>{n.add(e)}),[V].forEach(e=>{this._commandService.registerCommand(e)})}},ne(c.UniverSheetsThreadCommentPlugin,"pluginName",G),ne(c.UniverSheetsThreadCommentPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentPlugin=Ae([o.DependentOn(_.UniverThreadCommentUIPlugin,R.UniverSheetsThreadCommentBasePlugin),te(1,o.Inject(o.Injector)),te(2,o.Inject(o.ICommandService))],c.UniverSheetsThreadCommentPlugin),Object.defineProperty(c,"ICommandService",{enumerable:!0,get:()=>o.ICommandService}),Object.defineProperty(c,"Inject",{enumerable:!0,get:()=>o.Inject}),Object.defineProperty(c,"Injector",{enumerable:!0,get:()=>o.Injector}),Object.defineProperty(c,"Plugin",{enumerable:!0,get:()=>o.Plugin}),Object.defineProperty(c,"UniverInstanceType",{enumerable:!0,get:()=>o.UniverInstanceType}),Object.defineProperty(c,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>_.IThreadCommentMentionDataService}),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>_.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>w.IThreadCommentDataSourceService}),Object.defineProperty(c,"SheetsThreadCommentModel",{enumerable:!0,get:()=>R.SheetsThreadCommentModel}),c.SHEETS_THREAD_COMMENT=G,c.ShowAddSheetCommentModalOperation=V,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-thread-comment",
3
- "version": "0.2.4-alpha.0",
3
+ "version": "0.2.5",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -47,18 +47,18 @@
47
47
  "peerDependencies": {
48
48
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
49
49
  "rxjs": ">=7.0.0",
50
- "@univerjs/core": "0.2.4-alpha.0",
51
- "@univerjs/sheets-thread-comment-base": "0.2.4-alpha.0",
52
- "@univerjs/engine-formula": "0.2.4-alpha.0",
53
- "@univerjs/engine-render": "0.2.4-alpha.0",
54
- "@univerjs/sheets": "0.2.4-alpha.0",
55
- "@univerjs/sheets-ui": "0.2.4-alpha.0",
56
- "@univerjs/thread-comment-ui": "0.2.4-alpha.0",
57
- "@univerjs/thread-comment": "0.2.4-alpha.0",
58
- "@univerjs/ui": "0.2.4-alpha.0"
50
+ "@univerjs/core": "0.2.5",
51
+ "@univerjs/engine-render": "0.2.5",
52
+ "@univerjs/engine-formula": "0.2.5",
53
+ "@univerjs/sheets": "0.2.5",
54
+ "@univerjs/sheets-thread-comment-base": "0.2.5",
55
+ "@univerjs/sheets-ui": "0.2.5",
56
+ "@univerjs/thread-comment": "0.2.5",
57
+ "@univerjs/ui": "0.2.5",
58
+ "@univerjs/thread-comment-ui": "0.2.5"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/icons": "^0.1.64"
61
+ "@univerjs/icons": "^0.1.65"
62
62
  },
63
63
  "devDependencies": {
64
64
  "clsx": "^2.1.1",
@@ -67,14 +67,14 @@
67
67
  "typescript": "^5.5.3",
68
68
  "vite": "^5.3.4",
69
69
  "vitest": "^2.0.3",
70
- "@univerjs/core": "0.2.4-alpha.0",
71
- "@univerjs/design": "0.2.4-alpha.0",
72
- "@univerjs/shared": "0.2.4-alpha.0",
73
- "@univerjs/engine-formula": "0.2.4-alpha.0",
74
- "@univerjs/sheets-thread-comment-base": "0.2.4-alpha.0",
75
- "@univerjs/thread-comment": "0.2.4-alpha.0",
76
- "@univerjs/thread-comment-ui": "0.2.4-alpha.0",
77
- "@univerjs/ui": "0.2.4-alpha.0"
70
+ "@univerjs/core": "0.2.5",
71
+ "@univerjs/design": "0.2.5",
72
+ "@univerjs/engine-formula": "0.2.5",
73
+ "@univerjs/shared": "0.2.5",
74
+ "@univerjs/thread-comment": "0.2.5",
75
+ "@univerjs/sheets-thread-comment-base": "0.2.5",
76
+ "@univerjs/thread-comment-ui": "0.2.5",
77
+ "@univerjs/ui": "0.2.5"
78
78
  },
79
79
  "univerSpace": {
80
80
  ".": {