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

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