@univerjs/sheets-thread-comment 0.2.5 → 0.2.6
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 +1 -1
- package/lib/es/index.js +547 -540
- package/lib/types/plugin.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +22 -22
package/lib/types/plugin.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export declare class UniverSheetsThreadCommentPlugin extends Plugin {
|
|
|
8
8
|
static type: UniverInstanceType;
|
|
9
9
|
private _pluginConfig;
|
|
10
10
|
constructor(config: Partial<IUniverSheetsThreadCommentConfig> | undefined, _injector: Injector, _commandService: ICommandService);
|
|
11
|
-
onStarting(
|
|
11
|
+
onStarting(): void;
|
|
12
12
|
}
|
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,L,ie){"use strict";var Le=Object.defineProperty;var ke=(c,o,_)=>o in c?Le(c,o,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[o]=_;var j=(c,o,_)=>ke(c,typeof o!="symbol"?o+"":o,_);var g=function(){return g=Object.assign||function(r){for(var i,n=1,e=arguments.length;n<e;n++){i=arguments[n];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(r[t]=i[t])}return r},g.apply(this,arguments)},oe=function(r,i){var n={};for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&i.indexOf(e)<0&&(n[e]=r[e]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(r);t<e.length;t++)i.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(r,e[t])&&(n[e[t]]=r[e[t]]);return n},Y=T.forwardRef(function(r,i){var n=r.icon,e=r.id,t=r.className,s=r.extend,a=oe(r,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),u=T.useRef("_".concat(ce()));return X(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},g({ref:i,className:d},a),s)});function X(r,i,n,e,t){return T.createElement(r.tag,g(g({key:i},se(r,n,t)),e),(ae(r,n).children||[]).map(function(s,a){return X(s,"".concat(i,"-").concat(r.tag,"-").concat(a),n,void 0,t)}))}function se(r,i,n){var e=g({},r.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=i.defIds;return!t||t.length===0||(r.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+i.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],d=s[1];typeof d=="string"&&(e[a]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),e}function ae(r,i){var n,e=i.defIds;return!e||e.length===0?r:r.tag==="defs"&&(!((n=r.children)===null||n===void 0)&&n.length)?g(g({},r),{children:r.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?g(g({},t),{attrs:g(g({},t.attrs),{id:t.attrs.id+i.idSuffix})}):t})}):r}function ce(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";var ue={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},J=T.forwardRef(function(r,i){return T.createElement(Y,Object.assign({},r,{id:"comment-single",ref:i,icon:ue}))});J.displayName="CommentSingle";const Q="univer.sheet.thread-comment-modal",z="comment-single",G="SHEET_THREAD_COMMENT";var de=Object.defineProperty,me=Object.getOwnPropertyDescriptor,he=(r,i,n,e)=>{for(var t=e>1?void 0:e?me(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&de(i,n,t),t},x=(r,i)=>(n,e)=>i(n,e,r);c.SheetsThreadCommentPopupService=class extends o.Disposable{constructor(n,e){super();j(this,"_lastPopup",null);j(this,"_activePopup");j(this,"_activePopup$",new L.BehaviorSubject(null));j(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var m;const{row:t,col:s,unitId:a,subUnitId:d}=n;if(this._activePopup&&t===this._activePopup.row&&s===this._activePopup.col&&a===this._activePopup.unitId&&d===((m=this.activePopup)==null?void 0:m.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const u=this._canvasPopupManagerService.attachPopupToCell(t,s,{componentKey:Q,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new o.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},c.SheetsThreadCommentPopupService=he([x(0,o.Inject(P.SheetCanvasPopManagerService)),x(1,f.IZenZoneService)],c.SheetsThreadCommentPopupService);const le=()=>{const r=o.useDependency(o.IUniverInstanceService),i=o.useDependency(c.SheetsThreadCommentPopupService),n=f.useObservable(i.activePopup$),e=o.useDependency(R.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:t,col:s,unitId:a,subUnitId:d,trigger:u}=n,h=e.getByLocation(a,d,t,s),m=`${o.Tools.chatAtABC(s)}${t+1}`,S=()=>{i.hidePopup()},p=C=>{var I,D,b;return(b=(D=(I=r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(C))==null?void 0:D.getName())!=null?b:""};return T.createElement(_.ThreadCommentTree,{onClick:()=>{i.persistPopup()},prefix:"cell",id:h,unitId:a,subUnitId:d,type:o.UniverInstanceType.UNIVER_SHEET,refStr:m,onClose:S,getSubUnitName:p,autoFocus:u==="context-menu"})},V={type:o.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(r){var I;const i=r.get(v.SheetsSelectionsService),n=r.get(o.IUniverInstanceService),e=r.get(c.SheetsThreadCommentPopupService),t=r.get(_.ThreadCommentPanelService),s=(I=i.getCurrentLastSelection())==null?void 0:I.primary,a=r.get(R.SheetsThreadCommentModel);if(!s)return!1;const d=v.getSheetCommandTarget(n);if(!d)return!1;const{workbook:u,worksheet:h,unitId:m,subUnitId:S}=d,p={workbook:u,worksheet:h,unitId:m,subUnitId:S,row:s.startRow,col:s.startColumn};e.showPopup(p);const C=a.getByLocation(m,S,s.startRow,s.startColumn);return C&&t.setActiveComment({unitId:m,subUnitId:S,commentId:C,trigger:"context-menu"}),!0}},pe=()=>{var Z;const r=o.useDependency(P.IMarkSelectionService),i=o.useDependency(o.IUniverInstanceService),n=o.useDependency(c.SheetsThreadCommentPopupService),e=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),t=e.getUnitId(),s=o.useDependency(o.ICommandService),a=T.useMemo(()=>e.activeSheet$.pipe(L.map(l=>l==null?void 0:l.getSheetId())),[e.activeSheet$]),d=f.useObservable(a,(Z=e.getActiveSheet())==null?void 0:Z.getSheetId()),u=T.useRef(),h=o.useDependency(_.ThreadCommentPanelService),m=f.useObservable(h.activeCommentId$),S=f.useObservable(h.panelVisible$,h.panelVisible),p=T.useCallback(l=>{const y=e.getSheets(),M={};y.forEach((E,U)=>{M[E.getSheetId()]=U});const H=E=>E.map(U=>{var re;const N=$.singleReferenceToGrid(U.ref),He=[(re=M[U.subUnitId])!=null?re:0,N.row,N.column];return{...U,p:He}}).sort((U,N)=>U.p[0]===N.p[0]?U.p[1]===N.p[1]?U.p[2]-N.p[2]:U.p[1]-N.p[1]:U.p[0]-N.p[0]);return[...H(l.filter(E=>!E.resolved)),...H(l.filter(E=>E.resolved))]},[e]),C=T.useCallback(l=>{if(l.unitId===t&&l.subUnitId===d&&!l.resolved){const{row:y,column:M}=$.singleReferenceToGrid(l.ref);if(!Number.isNaN(y)&&!Number.isNaN(M))return r.addShape({range:{startColumn:M,endColumn:M,startRow:y,endRow:y},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[r,d,t]),I=l=>{var y,M;return(M=(y=e.getSheetBySheetId(l))==null?void 0:y.getName())!=null?M:""},D=()=>{s.executeCommand(V.id)},b=l=>{m&&m.unitId===l.unitId&&m.subUnitId===l.subUnitId&&m.commentId===l.id||(u.current&&(r.removeShape(u.current),u.current=null),u.current=C(l))},A=()=>{u.current&&(r.removeShape(u.current),u.current=null)},q=(l,y)=>{y&&n.hidePopup()};return T.useEffect(()=>{!S&&u.current&&r.removeShape(u.current)},[r,S]),T.createElement(_.ThreadCommentPanel,{unitId:t,subUnitId$:a,type:o.UniverInstanceType.UNIVER_SHEET,onAdd:D,getSubUnitName:I,onResolve:q,sortComments:p,onItemEnter:b,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},ve=r=>({id:V.id,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.CONTEXT_MENU],icon:z,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),Se=r=>({id:_.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:z,tooltip:"sheetThreadComment.menu.commentManagement",positions:f.MenuPosition.TOOLBAR_START,group:f.MenuGroup.TOOLBAR_OTHERS,disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET)}),Ce={id:V.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused};var fe=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ie=(r,i,n,e)=>{for(var t=e>1?void 0:e?_e(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&fe(i,n,t),t},O=(r,i)=>(n,e)=>i(n,e,r);const Pe={};c.SheetsThreadCommentController=class extends o.Disposable{constructor(n,e,t,s,a,d,u,h,m,S,p,C){super();j(this,"_isSwitchToCommenting",!1);j(this,"_selectionShapeInfo",null);this._config=n,this._menuService=e,this._injector=t,this._componentManager=s,this._commandService=a,this._sheetsThreadCommentPopupService=d,this._sheetsThreadCommentModel=u,this._threadCommentPanelService=h,this._shortcutService=m,this._univerInstanceService=S,this._sheetPermissionInterceptorBaseController=p,this._markSelectionService=C,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection()}_initShortcut(){this._shortcutService.registerShortcut(Ce)}_initCommandListener(){this._commandService.onCommandExecuted(n=>{var e;if(n.id===v.SetSelectionsOperation.id){if(this._isSwitchToCommenting)return;const t=n.params,{unitId:s,subUnitId:a,selections:d,type:u}=t;if((u===v.SelectionMoveType.MOVE_END||u===void 0)&&((e=d[0])!=null&&e.primary)){const h=d[0].range;if(h.endColumn-h.startColumn>0||h.endRow-h.startRow>0)return;const m=d[0].primary.actualRow,S=d[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(s,a,m,S)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(_.SetActiveCommentOperation.id);return}const p=this._sheetsThreadCommentModel.getByLocation(s,a,m,S);p&&this._commandService.executeCommand(_.SetActiveCommentOperation.id,{unitId:s,subUnitId:a,commentId:p})}}if(n.id===w.DeleteCommentMutation.id){const t=n.params,s=this._sheetsThreadCommentPopupService.activePopup;if(!s)return;const{unitId:a,subUnitId:d,commentId:u}=s;t.unitId===a&&t.subUnitId===d&&t.commentId===u&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:n={}}=this._config;[ve,Se].forEach(e=>{this._menuService.addMenuItem(e(this._injector),n)})}_initComponent(){[[Q,le],[_.THREAD_COMMENT_PANEL,pe],[z,J]].forEach(([n,e])=>{this._componentManager.register(n,e)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async n=>{var e;if(n){const{unitId:t,subUnitId:s,commentId:a,trigger:d}=n,u=this._sheetsThreadCommentModel.getComment(t,s,a);if(!u||u.resolved)return;const h=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!h||h.getUnitId()!==t)return;this._isSwitchToCommenting=!0,((e=h.getActiveSheet())==null?void 0:e.getSheetId())!==s&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:s}),this._isSwitchToCommenting=!1;const p=$.singleReferenceToGrid(u.ref),{row:C,column:I}=p;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:C,startColumn:I,endRow:C,endColumn:I}]))return;const b=1;await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(p.row-b,0),endRow:p.row+b,startColumn:Math.max(p.column-b,0),endColumn:p.column+b}}),this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:s,row:p.row,col:p.column,commentId:u.id,trigger:d})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(n=>{if(!n){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:e,subUnitId:t,commentId:s}=n;if(this._selectionShapeInfo){if(this._selectionShapeInfo.unitId===e&&this._selectionShapeInfo.subUnitId===t&&this._selectionShapeInfo.commentId===s)return;this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null}const a=this._sheetsThreadCommentModel.getComment(e,t,s);if(!a)return;const d=$.singleReferenceToGrid(a.ref),{row:u,column:h}=d;if(Number.isNaN(u)||Number.isNaN(h))return;const m=this._markSelectionService.addShape({range:{startColumn:h,endColumn:h,startRow:u,endRow:u},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null});m&&(this._selectionShapeInfo={...n,shapeId:m})}))}},c.SheetsThreadCommentController=Ie([o.OnLifecycle(o.LifecycleStages.Starting,c.SheetsThreadCommentController),O(1,f.IMenuService),O(2,o.Inject(o.Injector)),O(3,o.Inject(f.ComponentManager)),O(4,o.ICommandService),O(5,o.Inject(c.SheetsThreadCommentPopupService)),O(6,o.Inject(R.SheetsThreadCommentModel)),O(7,o.Inject(_.ThreadCommentPanelService)),O(8,f.IShortcutService),O(9,o.IUniverInstanceService),O(10,o.Inject(P.SheetPermissionInterceptorBaseController)),O(11,P.IMarkSelectionService)],c.SheetsThreadCommentController);var Te=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,be=(r,i,n,e)=>{for(var t=e>1?void 0:e?ge(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Te(i,n,t),t},k=(r,i)=>(n,e)=>i(n,e,r);let B=class extends o.Disposable{constructor(r,i,n,e){super(),this._sheetInterceptorService=r,this._sheetsThreadCommentModel=i,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(r,i,n)=>{const{row:e,col:t,unitId:s,subUnitId:a}=i;return this._sheetsThreadCommentModel.showCommentMarker(s,a,e,t)?n({...r,markers:{...r==null?void 0:r.markers,tr:{color:"#FFBD37",size:6}}}):n(r)},priority:100}))}_initSkeletonChange(){const r=()=>{var a;const i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const n=i.getUnitId(),e=(a=i.getActiveSheet())==null?void 0:a.getSheetId();if(!e){console.warn("No active sheet found");return}const t=this._renderManagerService.getRenderById(n),s=t==null?void 0:t.with(P.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});s==null||s.makeDirty(!0),s==null||s.calculate(),t&&t.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(L.debounceTime(16)).subscribe(i=>{r()}))}};B=be([o.OnLifecycle(o.LifecycleStages.Ready,B),k(0,o.Inject(v.SheetInterceptorService)),k(1,o.Inject(R.SheetsThreadCommentModel)),k(2,o.IUniverInstanceService),k(3,ie.IRenderManagerService)],B);var ye=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,we=(r,i,n,e)=>{for(var t=e>1?void 0:e?Me(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&ye(i,n,t),t},K=(r,i)=>(n,e)=>i(n,e,r);const Oe=(r,i,n)=>{const e=$.singleReferenceToGrid(r),t=n.row-i.row,s=n.column-i.column,a={startColumn:e.column+s,startRow:e.row+t,endColumn:e.column+s,endRow:e.row+t};return $.serializeRange(a)};c.SheetsThreadCommentCopyPasteController=class extends o.Disposable{constructor(n,e,t){super();j(this,"_copyInfo");this._sheetClipboardService=n,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:G,onBeforeCopy:(n,e,t)=>{this._copyInfo={unitId:n,subUnitId:e,range:t}},onPasteCells:(n,e,t,s)=>{const{unitId:a,subUnitId:d,range:u}=e,h={row:u.rows[0],column:u.cols[0]};if(s.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:S,subUnitId:p}=this._copyInfo,C={row:m.startRow,column:m.startColumn};if(!(a===S&&d===p)){const I=[];o.Range.foreach(m,(l,y)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(S,p,l,y);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(H=>{I.push(H)}):M.forEach(({children:H,...E})=>{E.parentId||I.push(E)})});const D=[],b=[],A=[],q=[],Z=l=>{D.unshift({id:w.DeleteCommentMutation.id,params:{unitId:S,subUnitId:p,commentId:l.id}}),A.push({id:w.AddCommentMutation.id,params:{unitId:a,subUnitId:d,comment:{...l,ref:Oe(l.ref,C,h),unitId:a,subUnitId:d},sync:!0}}),b.push({id:w.AddCommentMutation.id,params:{unitId:S,subUnitId:p,comment:l,sync:!0}}),q.unshift({id:w.DeleteCommentMutation.id,params:{unitId:a,subUnitId:d,commentId:l.id}})};return I.forEach(l=>{Z(l)}),{redos:[...D,...A],undos:[...q,...b]}}}return{redos:[],undos:[]}}}))}},c.SheetsThreadCommentCopyPasteController=we([o.OnLifecycle(o.LifecycleStages.Rendered,c.SheetsThreadCommentCopyPasteController),K(0,o.Inject(P.ISheetClipboardService)),K(1,o.Inject(R.SheetsThreadCommentModel)),K(2,w.IThreadCommentDataSourceService)],c.SheetsThreadCommentCopyPasteController);var Ue=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(r,i,n,e)=>{for(var t=e>1?void 0:e?Ee(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Ue(i,n,t),t},W=(r,i)=>(n,e)=>i(n,e,r);c.SheetsThreadCommentHoverController=class extends o.Disposable{constructor(i,n,e,t){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(L.debounceTime(100)).subscribe(i=>{const n=this._sheetsThreadCommentPopupService.activePopup;if(i&&(n&&n.temp||!n)){const{location:e}=i,{unitId:t,subUnitId:s,row:a,col:d}=e,u=this._sheetsThreadCommentModel.getByLocation(t,s,a,d);if(u){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:a,startColumn:d,endRow:a,endColumn:d}]))return;const m=this._sheetsThreadCommentModel.getComment(t,s,u);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:s,row:a,col:d,commentId:u,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},c.SheetsThreadCommentHoverController=je([o.OnLifecycle(o.LifecycleStages.Rendered,c.SheetsThreadCommentHoverController),W(0,o.Inject(P.HoverManagerService)),W(1,o.Inject(c.SheetsThreadCommentPopupService)),W(2,o.Inject(R.SheetsThreadCommentModel)),W(3,o.Inject(P.SheetPermissionInterceptorBaseController))],c.SheetsThreadCommentHoverController);var Re=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ne=(r,i,n,e)=>{for(var t=e>1?void 0:e?De(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&Re(i,n,t),t},F=(r,i)=>(n,e)=>i(n,e,r);c.ThreadCommentRemoveSheetsController=class extends o.Disposable{constructor(i,n,e,t){super(),this._sheetInterceptorService=i,this._univerInstanceService=n,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var n;if(i.id===v.RemoveSheetCommand.id){const e=i.params,t=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const s=t.getUnitId(),a=e.subUnitId||((n=t.getActiveSheet())==null?void 0:n.getSheetId());if(!a)return{redos:[],undos:[]};const{commentMap:d}=this._threadCommentModel.ensureMap(s,a),u=Array.from(Object.values(d)).filter(C=>!C.parentId),h=u.map(C=>C.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,S=h.map(C=>({id:w.DeleteCommentMutation.id,params:{unitId:s,subUnitId:a,commentId:C}})),p=u.map(({children:C,...I})=>({id:w.AddCommentMutation.id,params:{unitId:s,subUnitId:a,comment:{...I,children:m?C:void 0},sync:!m}}));return{redos:S,undos:p}}return{redos:[],undos:[]}}}))}},c.ThreadCommentRemoveSheetsController=Ne([o.OnLifecycle(o.LifecycleStages.Ready,c.ThreadCommentRemoveSheetsController),F(0,o.Inject(v.SheetInterceptorService)),F(1,o.IUniverInstanceService),F(2,o.Inject(w.ThreadCommentModel)),F(3,w.IThreadCommentDataSourceService)],c.ThreadCommentRemoveSheetsController);var ee=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ve=(r,i,n)=>i in r?ee(r,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[i]=n,Ae=(r,i,n,e)=>{for(var t=e>1?void 0:e?$e(i,n):i,s=r.length-1,a;s>=0;s--)(a=r[s])&&(t=(e?a(i,n,t):a(t))||t);return e&&t&&ee(i,n,t),t},te=(r,i)=>(n,e)=>i(n,e,r),ne=(r,i,n)=>Ve(r,typeof i!="symbol"?i+"":i,n);c.UniverSheetsThreadCommentPlugin=class extends o.Plugin{constructor(n={},e,t){super();j(this,"_pluginConfig");this._injector=e,this._commandService=t,this._pluginConfig=o.Tools.deepMerge({},Pe,n)}onStarting(n){[[c.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(c.SheetsThreadCommentController,this._pluginConfig)}],[B],[c.SheetsThreadCommentCopyPasteController],[c.SheetsThreadCommentHoverController],[c.ThreadCommentRemoveSheetsController],[c.SheetsThreadCommentPopupService]].forEach(e=>{n.add(e)}),[V].forEach(e=>{this._commandService.registerCommand(e)})}},ne(c.UniverSheetsThreadCommentPlugin,"pluginName",G),ne(c.UniverSheetsThreadCommentPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentPlugin=Ae([o.DependentOn(_.UniverThreadCommentUIPlugin,R.UniverSheetsThreadCommentBasePlugin),te(1,o.Inject(o.Injector)),te(2,o.Inject(o.ICommandService))],c.UniverSheetsThreadCommentPlugin),Object.defineProperty(c,"ICommandService",{enumerable:!0,get:()=>o.ICommandService}),Object.defineProperty(c,"Inject",{enumerable:!0,get:()=>o.Inject}),Object.defineProperty(c,"Injector",{enumerable:!0,get:()=>o.Injector}),Object.defineProperty(c,"Plugin",{enumerable:!0,get:()=>o.Plugin}),Object.defineProperty(c,"UniverInstanceType",{enumerable:!0,get:()=>o.UniverInstanceType}),Object.defineProperty(c,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>_.IThreadCommentMentionDataService}),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>_.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>w.IThreadCommentDataSourceService}),Object.defineProperty(c,"SheetsThreadCommentModel",{enumerable:!0,get:()=>R.SheetsThreadCommentModel}),c.SHEETS_THREAD_COMMENT=G,c.ShowAddSheetCommentModalOperation=V,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(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"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsThreadComment={},global.UniverCore,global.UniverThreadCommentUi,global.UniverUi,global.UniverSheets,global.UniverEngineFormula,global.UniverThreadComment,global.UniverSheetsUi,global.UniverSheetsThreadCommentBase,global.React,global.rxjs,global.UniverEngineRender))})(this,function(exports2,core,threadCommentUi,ui,sheets,engineFormula,threadComment,sheetsUi,sheetsThreadCommentBase,React,rxjs,engineRender){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e,_f,_g;var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element={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"}}]},CommentSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"comment-single",ref,icon:element}))});CommentSingle.displayName="CommentSingle";const SHEETS_THREAD_COMMENT_MODAL="univer.sheet.thread-comment-modal",COMMENT_SINGLE_ICON="comment-single",SHEETS_THREAD_COMMENT="SHEET_THREAD_COMMENT";var __defProp$6=Object.defineProperty,__getOwnPropDesc$6=Object.getOwnPropertyDescriptor,__decorateClass$6=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$6(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$6(target,key,result),result},"__decorateClass$6"),__decorateParam$6=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$6");exports2.SheetsThreadCommentPopupService=(_a=class extends core.Disposable{constructor(_canvasPopupManagerService,_zenZoneService){super();__publicField(this,"_lastPopup",null);__publicField(this,"_activePopup");__publicField(this,"_activePopup$",new rxjs.BehaviorSubject(null));__publicField(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=_canvasPopupManagerService,this._zenZoneService=_zenZoneService,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(visible=>{visible&&this.hidePopup()}))}showPopup(location,onHide){var _a2;const{row,col,unitId,subUnitId}=location;if(this._activePopup&&row===this._activePopup.row&&col===this._activePopup.col&&unitId===this._activePopup.unitId&&subUnitId===((_a2=this.activePopup)==null?void 0:_a2.subUnitId)){this._activePopup=location,this._activePopup$.next(location);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=location,this._activePopup$.next(location);const popupDisposable=this._canvasPopupManagerService.attachPopupToCell(row,col,{componentKey:SHEETS_THREAD_COMMENT_MODAL,onClickOutside:__name(()=>{this.hidePopup()},"onClickOutside"),direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!popupDisposable)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const disposableCollection=new core.DisposableCollection;disposableCollection.add(popupDisposable),disposableCollection.add({dispose:__name(()=>{onHide==null||onHide()},"dispose")}),this._lastPopup=disposableCollection}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))}},__name(_a,"SheetsThreadCommentPopupService"),_a),exports2.SheetsThreadCommentPopupService=__decorateClass$6([__decorateParam$6(0,core.Inject(sheetsUi.SheetCanvasPopManagerService)),__decorateParam$6(1,ui.IZenZoneService)],exports2.SheetsThreadCommentPopupService);const SheetsThreadCommentCell=__name(()=>{const univerInstanceService=core.useDependency(core.IUniverInstanceService),sheetsThreadCommentPopupService=core.useDependency(exports2.SheetsThreadCommentPopupService),activePopup=ui.useObservable(sheetsThreadCommentPopupService.activePopup$),sheetThreadCommentModel=core.useDependency(sheetsThreadCommentBase.SheetsThreadCommentModel);if(ui.useObservable(sheetThreadCommentModel.commentUpdate$),!activePopup)return null;const{row,col,unitId,subUnitId,trigger}=activePopup,rootId=sheetThreadCommentModel.getByLocation(unitId,subUnitId,row,col),ref=`${core.Tools.chatAtABC(col)}${row+1}`,onClose=__name(()=>{sheetsThreadCommentPopupService.hidePopup()},"onClose"),getSubUnitName=__name(id=>{var _a2,_b2,_c2;return(_c2=(_b2=(_a2=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a2.getSheetBySheetId(id))==null?void 0:_b2.getName())!=null?_c2:""},"getSubUnitName");return React.createElement(threadCommentUi.ThreadCommentTree,{onClick:__name(()=>{sheetsThreadCommentPopupService.persistPopup()},"onClick"),prefix:"cell",id:rootId,unitId,subUnitId,type:core.UniverInstanceType.UNIVER_SHEET,refStr:ref,onClose,getSubUnitName,autoFocus:trigger==="context-menu"})},"SheetsThreadCommentCell"),ShowAddSheetCommentModalOperation={type:core.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(accessor){var _a2;const selectionManagerService=accessor.get(sheets.SheetsSelectionsService),univerInstanceService=accessor.get(core.IUniverInstanceService),sheetsThreadCommentPopupService=accessor.get(exports2.SheetsThreadCommentPopupService),threadCommentPanelService=accessor.get(threadCommentUi.ThreadCommentPanelService),activeCell=(_a2=selectionManagerService.getCurrentLastSelection())==null?void 0:_a2.primary,model=accessor.get(sheetsThreadCommentBase.SheetsThreadCommentModel);if(!activeCell)return!1;const result=sheets.getSheetCommandTarget(univerInstanceService);if(!result)return!1;const{workbook,worksheet,unitId,subUnitId}=result,location={workbook,worksheet,unitId,subUnitId,row:activeCell.startRow,col:activeCell.startColumn};sheetsThreadCommentPopupService.showPopup(location);const rootId=model.getByLocation(unitId,subUnitId,activeCell.startRow,activeCell.startColumn);return rootId&&threadCommentPanelService.setActiveComment({unitId,subUnitId,commentId:rootId,trigger:"context-menu"}),!0}},SheetsThreadCommentPanel=__name(()=>{var _a2;const markSelectionService=core.useDependency(sheetsUi.IMarkSelectionService),univerInstanceService=core.useDependency(core.IUniverInstanceService),sheetsThreadCommentPopupService=core.useDependency(exports2.SheetsThreadCommentPopupService),workbook=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET),unitId=workbook.getUnitId(),commandService=core.useDependency(core.ICommandService),subUnitId$=React.useMemo(()=>workbook.activeSheet$.pipe(rxjs.map(i=>i==null?void 0:i.getSheetId())),[workbook.activeSheet$]),subUnitId=ui.useObservable(subUnitId$,(_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId()),hoverShapeId=React.useRef(),panelService=core.useDependency(threadCommentUi.ThreadCommentPanelService),activeCommentId=ui.useObservable(panelService.activeCommentId$),panelVisible=ui.useObservable(panelService.panelVisible$,panelService.panelVisible),sortComments=React.useCallback(comments=>{const worksheets=workbook.getSheets(),sheetIndex={};worksheets.forEach((sheet,i)=>{sheetIndex[sheet.getSheetId()]=i});const sort=__name(comments2=>comments2.map(comment=>{var _a3;const ref=engineFormula.singleReferenceToGrid(comment.ref),p=[(_a3=sheetIndex[comment.subUnitId])!=null?_a3:0,ref.row,ref.column];return{...comment,p}}).sort((pre,aft)=>pre.p[0]===aft.p[0]?pre.p[1]===aft.p[1]?pre.p[2]-aft.p[2]:pre.p[1]-aft.p[1]:pre.p[0]-aft.p[0]),"sort");return[...sort(comments.filter(comment=>!comment.resolved)),...sort(comments.filter(comment=>comment.resolved))]},[workbook]),showShape=React.useCallback(comment=>{if(comment.unitId===unitId&&comment.subUnitId===subUnitId&&!comment.resolved){const{row,column}=engineFormula.singleReferenceToGrid(comment.ref);if(!Number.isNaN(row)&&!Number.isNaN(column))return markSelectionService.addShape({range:{startColumn:column,endColumn:column,startRow:row,endRow:row},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[markSelectionService,subUnitId,unitId]),getSubUnitName=__name(id=>{var _a3,_b2;return(_b2=(_a3=workbook.getSheetBySheetId(id))==null?void 0:_a3.getName())!=null?_b2:""},"getSubUnitName"),handleAdd=__name(()=>{commandService.executeCommand(ShowAddSheetCommentModalOperation.id)},"handleAdd"),handleHover=__name(comment=>{activeCommentId&&activeCommentId.unitId===comment.unitId&&activeCommentId.subUnitId===comment.subUnitId&&activeCommentId.commentId===comment.id||(hoverShapeId.current&&(markSelectionService.removeShape(hoverShapeId.current),hoverShapeId.current=null),hoverShapeId.current=showShape(comment))},"handleHover"),handleLeave=__name(()=>{hoverShapeId.current&&(markSelectionService.removeShape(hoverShapeId.current),hoverShapeId.current=null)},"handleLeave"),handleResolve=__name((id,resolved)=>{resolved&&sheetsThreadCommentPopupService.hidePopup()},"handleResolve");return React.useEffect(()=>{!panelVisible&&hoverShapeId.current&&markSelectionService.removeShape(hoverShapeId.current)},[markSelectionService,panelVisible]),React.createElement(threadCommentUi.ThreadCommentPanel,{unitId,subUnitId$,type:core.UniverInstanceType.UNIVER_SHEET,onAdd:handleAdd,getSubUnitName,onResolve:handleResolve,sortComments,onItemEnter:handleHover,onItemLeave:handleLeave,onDeleteComment:__name(()=>(handleLeave(),!0),"onDeleteComment")})},"SheetsThreadCommentPanel"),threadCommentMenuFactory=__name(accessor=>({id:ShowAddSheetCommentModalOperation.id,type:ui.MenuItemType.BUTTON,positions:[ui.MenuPosition.CONTEXT_MENU],icon:COMMENT_SINGLE_ICON,title:"sheetThreadComment.menu.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]})}),"threadCommentMenuFactory"),threadPanelMenuFactory=__name(accessor=>({id:threadCommentUi.ToggleSheetCommentPanelOperation.id,type:ui.MenuItemType.BUTTON,icon:COMMENT_SINGLE_ICON,tooltip:"sheetThreadComment.menu.commentManagement",positions:ui.MenuPosition.TOOLBAR_START,group:ui.MenuGroup.TOOLBAR_OTHERS,disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]}),hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET)}),"threadPanelMenuFactory"),AddCommentShortcut={id:ShowAddSheetCommentModalOperation.id,binding:ui.KeyCode.M|ui.MetaKeys.CTRL_COMMAND|ui.MetaKeys.ALT,preconditions:sheetsUi.whenSheetEditorFocused};var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");const DefaultSheetsThreadCommentConfig={};exports2.SheetsThreadCommentController=(_b=class extends core.Disposable{constructor(_config,_menuService,_injector,_componentManager,_commandService,_sheetsThreadCommentPopupService,_sheetsThreadCommentModel,_threadCommentPanelService,_shortcutService,_univerInstanceService,_sheetPermissionInterceptorBaseController,_markSelectionService){super();__publicField(this,"_isSwitchToCommenting",!1);__publicField(this,"_selectionShapeInfo",null);this._config=_config,this._menuService=_menuService,this._injector=_injector,this._componentManager=_componentManager,this._commandService=_commandService,this._sheetsThreadCommentPopupService=_sheetsThreadCommentPopupService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._threadCommentPanelService=_threadCommentPanelService,this._shortcutService=_shortcutService,this._univerInstanceService=_univerInstanceService,this._sheetPermissionInterceptorBaseController=_sheetPermissionInterceptorBaseController,this._markSelectionService=_markSelectionService,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection()}_initShortcut(){this._shortcutService.registerShortcut(AddCommentShortcut)}_initCommandListener(){this._commandService.onCommandExecuted(commandInfo=>{var _a2;if(commandInfo.id===sheets.SetSelectionsOperation.id){if(this._isSwitchToCommenting)return;const params=commandInfo.params,{unitId,subUnitId,selections,type}=params;if((type===sheets.SelectionMoveType.MOVE_END||type===void 0)&&((_a2=selections[0])!=null&&_a2.primary)){const range=selections[0].range;if(range.endColumn-range.startColumn>0||range.endRow-range.startRow>0)return;const row=selections[0].primary.actualRow,col=selections[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(unitId,subUnitId,row,col)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id);return}const commentId=this._sheetsThreadCommentModel.getByLocation(unitId,subUnitId,row,col);commentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id,{unitId,subUnitId,commentId})}}if(commandInfo.id===threadComment.DeleteCommentMutation.id){const params=commandInfo.params,active=this._sheetsThreadCommentPopupService.activePopup;if(!active)return;const{unitId,subUnitId,commentId}=active;params.unitId===unitId&¶ms.subUnitId===subUnitId&¶ms.commentId===commentId&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu={}}=this._config;[threadCommentMenuFactory,threadPanelMenuFactory].forEach(menuFactory=>{this._menuService.addMenuItem(menuFactory(this._injector),menu)})}_initComponent(){[[SHEETS_THREAD_COMMENT_MODAL,SheetsThreadCommentCell],[threadCommentUi.THREAD_COMMENT_PANEL,SheetsThreadCommentPanel],[COMMENT_SINGLE_ICON,CommentSingle]].forEach(([key,comp])=>{this._componentManager.register(key,comp)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async commentInfo=>{var _a2;if(commentInfo){const{unitId,subUnitId,commentId,trigger}=commentInfo,comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment||comment.resolved)return;const currentUnit=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!currentUnit||currentUnit.getUnitId()!==unitId)return;this._isSwitchToCommenting=!0,((_a2=currentUnit.getActiveSheet())==null?void 0:_a2.getSheetId())!==subUnitId&&await this._commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId,subUnitId}),this._isSwitchToCommenting=!1;const location=engineFormula.singleReferenceToGrid(comment.ref),{row,column:col}=location;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:row,startColumn:col,endRow:row,endColumn:col}]))return;const GAP=1;await this._commandService.executeCommand(sheetsUi.ScrollToRangeOperation.id,{range:{startRow:Math.max(location.row-GAP,0),endRow:location.row+GAP,startColumn:Math.max(location.column-GAP,0),endColumn:location.column+GAP}}),this._sheetsThreadCommentPopupService.showPopup({unitId,subUnitId,row:location.row,col:location.column,commentId:comment.id,trigger})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(activeComment=>{if(!activeComment){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId,subUnitId,commentId}=activeComment;if(this._selectionShapeInfo){if(this._selectionShapeInfo.unitId===unitId&&this._selectionShapeInfo.subUnitId===subUnitId&&this._selectionShapeInfo.commentId===commentId)return;this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null}const comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment)return;const location=engineFormula.singleReferenceToGrid(comment.ref),{row,column}=location;if(Number.isNaN(row)||Number.isNaN(column))return;const shapeId=this._markSelectionService.addShape({range:{startColumn:column,endColumn:column,startRow:row,endRow:row},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null});shapeId&&(this._selectionShapeInfo={...activeComment,shapeId})}))}},__name(_b,"SheetsThreadCommentController"),_b),exports2.SheetsThreadCommentController=__decorateClass$5([core.OnLifecycle(core.LifecycleStages.Starting,exports2.SheetsThreadCommentController),__decorateParam$5(1,ui.IMenuService),__decorateParam$5(2,core.Inject(core.Injector)),__decorateParam$5(3,core.Inject(ui.ComponentManager)),__decorateParam$5(4,core.ICommandService),__decorateParam$5(5,core.Inject(exports2.SheetsThreadCommentPopupService)),__decorateParam$5(6,core.Inject(sheetsThreadCommentBase.SheetsThreadCommentModel)),__decorateParam$5(7,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$5(8,ui.IShortcutService),__decorateParam$5(9,core.IUniverInstanceService),__decorateParam$5(10,core.Inject(sheetsUi.SheetPermissionInterceptorBaseController)),__decorateParam$5(11,sheetsUi.IMarkSelectionService)],exports2.SheetsThreadCommentController);var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");let SheetsThreadCommentRenderController=(_c=class extends core.Disposable{constructor(_sheetInterceptorService,_sheetsThreadCommentModel,_univerInstanceService,_renderManagerService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._univerInstanceService=_univerInstanceService,this._renderManagerService=_renderManagerService,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(sheets.INTERCEPTOR_POINT.CELL_CONTENT,{handler:__name((cell,pos,next)=>{const{row,col,unitId,subUnitId}=pos;return this._sheetsThreadCommentModel.showCommentMarker(unitId,subUnitId,row,col)?next({...cell,markers:{...cell==null?void 0:cell.markers,tr:{color:"#FFBD37",size:6}}}):next(cell)},"handler"),priority:100}))}_initSkeletonChange(){const markSkeletonDirty=__name(()=>{var _a2;const workbook=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return;const unitId=workbook.getUnitId(),subUnitId=(_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId();if(!subUnitId){console.warn("No active sheet found");return}const currentRender=this._renderManagerService.getRenderById(unitId),skeleton=currentRender==null?void 0:currentRender.with(sheetsUi.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:subUnitId});skeleton==null||skeleton.makeDirty(!0),skeleton==null||skeleton.calculate(),currentRender&¤tRender.mainComponent.makeForceDirty()},"markSkeletonDirty");this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(rxjs.debounceTime(16)).subscribe(update=>{markSkeletonDirty()}))}},__name(_c,"SheetsThreadCommentRenderController"),_c);SheetsThreadCommentRenderController=__decorateClass$4([core.OnLifecycle(core.LifecycleStages.Ready,SheetsThreadCommentRenderController),__decorateParam$4(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$4(1,core.Inject(sheetsThreadCommentBase.SheetsThreadCommentModel)),__decorateParam$4(2,core.IUniverInstanceService),__decorateParam$4(3,engineRender.IRenderManagerService)],SheetsThreadCommentRenderController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");const transformRef=__name((ref,source,target)=>{const refObj=engineFormula.singleReferenceToGrid(ref),offsetRow=target.row-source.row,offsetCol=target.column-source.column,targetRange={startColumn:refObj.column+offsetCol,startRow:refObj.row+offsetRow,endColumn:refObj.column+offsetCol,endRow:refObj.row+offsetRow};return engineFormula.serializeRange(targetRange)},"transformRef");exports2.SheetsThreadCommentCopyPasteController=(_d=class extends core.Disposable{constructor(_sheetClipboardService,_sheetsThreadCommentModel,_threadCommentDataSourceService){super();__publicField(this,"_copyInfo");this._sheetClipboardService=_sheetClipboardService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:SHEETS_THREAD_COMMENT,onBeforeCopy:__name((unitId,subUnitId,range)=>{this._copyInfo={unitId,subUnitId,range}},"onBeforeCopy"),onPasteCells:__name((_pasteFrom,pasteTo,_data,payload)=>{const{unitId:targetUnitId,subUnitId:targetSubUnitId,range}=pasteTo,targetPos={row:range.rows[0],column:range.cols[0]};if(payload.copyType===sheetsUi.COPY_TYPE.CUT&&this._copyInfo){const{range:range2,unitId:sourceUnitId,subUnitId:sourceSubUnitId}=this._copyInfo,sourcePos={row:range2.startRow,column:range2.startColumn};if(!(targetUnitId===sourceUnitId&&targetSubUnitId===sourceSubUnitId)){const roots=[];core.Range.foreach(range2,(row,col)=>{const comments=this._sheetsThreadCommentModel.getAllByLocation(sourceUnitId,sourceSubUnitId,row,col);this._threadCommentDataSourceService.syncUpdateMutationToColla?comments.forEach(comment=>{roots.push(comment)}):comments.forEach(({children,...comment})=>{comment.parentId||roots.push(comment)})});const sourceRedos=[],sourceUndos=[],targetRedos=[],targetUndos=[],handleCommentItem=__name(item=>{sourceRedos.unshift({id:threadComment.DeleteCommentMutation.id,params:{unitId:sourceUnitId,subUnitId:sourceSubUnitId,commentId:item.id}}),targetRedos.push({id:threadComment.AddCommentMutation.id,params:{unitId:targetUnitId,subUnitId:targetSubUnitId,comment:{...item,ref:transformRef(item.ref,sourcePos,targetPos),unitId:targetUnitId,subUnitId:targetSubUnitId},sync:!0}}),sourceUndos.push({id:threadComment.AddCommentMutation.id,params:{unitId:sourceUnitId,subUnitId:sourceSubUnitId,comment:item,sync:!0}}),targetUndos.unshift({id:threadComment.DeleteCommentMutation.id,params:{unitId:targetUnitId,subUnitId:targetSubUnitId,commentId:item.id}})},"handleCommentItem");return roots.forEach(root=>{handleCommentItem(root)}),{redos:[...sourceRedos,...targetRedos],undos:[...targetUndos,...sourceUndos]}}}return{redos:[],undos:[]}},"onPasteCells")}))}},__name(_d,"SheetsThreadCommentCopyPasteController"),_d),exports2.SheetsThreadCommentCopyPasteController=__decorateClass$3([core.OnLifecycle(core.LifecycleStages.Rendered,exports2.SheetsThreadCommentCopyPasteController),__decorateParam$3(0,core.Inject(sheetsUi.ISheetClipboardService)),__decorateParam$3(1,core.Inject(sheetsThreadCommentBase.SheetsThreadCommentModel)),__decorateParam$3(2,threadComment.IThreadCommentDataSourceService)],exports2.SheetsThreadCommentCopyPasteController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");exports2.SheetsThreadCommentHoverController=(_e=class extends core.Disposable{constructor(_hoverManagerService,_sheetsThreadCommentPopupService,_sheetsThreadCommentModel,_sheetPermissionInterceptorBaseController){super(),this._hoverManagerService=_hoverManagerService,this._sheetsThreadCommentPopupService=_sheetsThreadCommentPopupService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._sheetPermissionInterceptorBaseController=_sheetPermissionInterceptorBaseController,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(rxjs.debounceTime(100)).subscribe(cell=>{const currentPopup=this._sheetsThreadCommentPopupService.activePopup;if(cell&&(currentPopup&¤tPopup.temp||!currentPopup)){const{location}=cell,{unitId,subUnitId,row,col}=location,commentId=this._sheetsThreadCommentModel.getByLocation(unitId,subUnitId,row,col);if(commentId){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:row,startColumn:col,endRow:row,endColumn:col}]))return;const comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);comment&&!comment.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId,subUnitId,row,col,commentId,temp:!0})}else currentPopup&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},__name(_e,"SheetsThreadCommentHoverController"),_e),exports2.SheetsThreadCommentHoverController=__decorateClass$2([core.OnLifecycle(core.LifecycleStages.Rendered,exports2.SheetsThreadCommentHoverController),__decorateParam$2(0,core.Inject(sheetsUi.HoverManagerService)),__decorateParam$2(1,core.Inject(exports2.SheetsThreadCommentPopupService)),__decorateParam$2(2,core.Inject(sheetsThreadCommentBase.SheetsThreadCommentModel)),__decorateParam$2(3,core.Inject(sheetsUi.SheetPermissionInterceptorBaseController))],exports2.SheetsThreadCommentHoverController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");exports2.ThreadCommentRemoveSheetsController=(_f=class extends core.Disposable{constructor(_sheetInterceptorService,_univerInstanceService,_threadCommentModel,_threadCommentDataSourceService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._univerInstanceService=_univerInstanceService,this._threadCommentModel=_threadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(commandInfo=>{var _a2;if(commandInfo.id===sheets.RemoveSheetCommand.id){const params=commandInfo.params,workbook=params.unitId?this._univerInstanceService.getUnit(params.unitId):this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return{redos:[],undos:[]};const unitId=workbook.getUnitId(),subUnitId=params.subUnitId||((_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId());if(!subUnitId)return{redos:[],undos:[]};const{commentMap}=this._threadCommentModel.ensureMap(unitId,subUnitId),comments=Array.from(Object.values(commentMap)).filter(comment=>!comment.parentId),ids=comments.map(comment=>comment.id),shouldSync=this._threadCommentDataSourceService.syncUpdateMutationToColla,redos=ids.map(id=>({id:threadComment.DeleteCommentMutation.id,params:{unitId,subUnitId,commentId:id}})),undos=comments.map(({children,...comment})=>({id:threadComment.AddCommentMutation.id,params:{unitId,subUnitId,comment:{...comment,children:shouldSync?children:void 0},sync:!shouldSync}}));return{redos,undos}}return{redos:[],undos:[]}},"getMutations")}))}},__name(_f,"ThreadCommentRemoveSheetsController"),_f),exports2.ThreadCommentRemoveSheetsController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Ready,exports2.ThreadCommentRemoveSheetsController),__decorateParam$1(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$1(1,core.IUniverInstanceService),__decorateParam$1(2,core.Inject(threadComment.ThreadCommentModel)),__decorateParam$1(3,threadComment.IThreadCommentDataSourceService)],exports2.ThreadCommentRemoveSheetsController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverSheetsThreadCommentPlugin=(_g=class extends core.Plugin{constructor(config={},_injector,_commandService){super();__publicField(this,"_pluginConfig");this._injector=_injector,this._commandService=_commandService,this._pluginConfig=core.Tools.deepMerge({},DefaultSheetsThreadCommentConfig,config)}onStarting(){[[exports2.SheetsThreadCommentController,{useFactory:__name(()=>this._injector.createInstance(exports2.SheetsThreadCommentController,this._pluginConfig),"useFactory")}],[SheetsThreadCommentRenderController],[exports2.SheetsThreadCommentCopyPasteController],[exports2.SheetsThreadCommentHoverController],[exports2.ThreadCommentRemoveSheetsController],[exports2.SheetsThreadCommentPopupService]].forEach(dep=>{this._injector.add(dep)}),[ShowAddSheetCommentModalOperation].forEach(command=>{this._commandService.registerCommand(command)})}},__name(_g,"UniverSheetsThreadCommentPlugin"),_g),__publicField2(exports2.UniverSheetsThreadCommentPlugin,"pluginName",SHEETS_THREAD_COMMENT),__publicField2(exports2.UniverSheetsThreadCommentPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),exports2.UniverSheetsThreadCommentPlugin=__decorateClass([core.DependentOn(threadCommentUi.UniverThreadCommentUIPlugin,sheetsThreadCommentBase.UniverSheetsThreadCommentBasePlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.Inject(core.ICommandService))],exports2.UniverSheetsThreadCommentPlugin),Object.defineProperty(exports2,"ICommandService",{enumerable:!0,get:__name(()=>core.ICommandService,"get")}),Object.defineProperty(exports2,"Inject",{enumerable:!0,get:__name(()=>core.Inject,"get")}),Object.defineProperty(exports2,"Injector",{enumerable:!0,get:__name(()=>core.Injector,"get")}),Object.defineProperty(exports2,"Plugin",{enumerable:!0,get:__name(()=>core.Plugin,"get")}),Object.defineProperty(exports2,"UniverInstanceType",{enumerable:!0,get:__name(()=>core.UniverInstanceType,"get")}),Object.defineProperty(exports2,"IThreadCommentMentionDataService",{enumerable:!0,get:__name(()=>threadCommentUi.IThreadCommentMentionDataService,"get")}),Object.defineProperty(exports2,"UniverThreadCommentUIPlugin",{enumerable:!0,get:__name(()=>threadCommentUi.UniverThreadCommentUIPlugin,"get")}),Object.defineProperty(exports2,"IThreadCommentDataSourceService",{enumerable:!0,get:__name(()=>threadComment.IThreadCommentDataSourceService,"get")}),Object.defineProperty(exports2,"SheetsThreadCommentModel",{enumerable:!0,get:__name(()=>sheetsThreadCommentBase.SheetsThreadCommentModel,"get")}),exports2.SHEETS_THREAD_COMMENT=SHEETS_THREAD_COMMENT,exports2.ShowAddSheetCommentModalOperation=ShowAddSheetCommentModalOperation,Object.defineProperty(exports2,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.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -47,34 +47,34 @@
|
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
49
49
|
"rxjs": ">=7.0.0",
|
|
50
|
-
"@univerjs/core": "0.2.
|
|
51
|
-
"@univerjs/engine-
|
|
52
|
-
"@univerjs/
|
|
53
|
-
"@univerjs/
|
|
54
|
-
"@univerjs/sheets-thread-comment-base": "0.2.
|
|
55
|
-
"@univerjs/sheets-ui": "0.2.
|
|
56
|
-
"@univerjs/thread-comment": "0.2.
|
|
57
|
-
"@univerjs/ui": "0.2.
|
|
58
|
-
"@univerjs/thread-comment
|
|
50
|
+
"@univerjs/core": "0.2.6",
|
|
51
|
+
"@univerjs/engine-formula": "0.2.6",
|
|
52
|
+
"@univerjs/sheets": "0.2.6",
|
|
53
|
+
"@univerjs/engine-render": "0.2.6",
|
|
54
|
+
"@univerjs/sheets-thread-comment-base": "0.2.6",
|
|
55
|
+
"@univerjs/sheets-ui": "0.2.6",
|
|
56
|
+
"@univerjs/thread-comment-ui": "0.2.6",
|
|
57
|
+
"@univerjs/ui": "0.2.6",
|
|
58
|
+
"@univerjs/thread-comment": "0.2.6"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/icons": "^0.1.
|
|
61
|
+
"@univerjs/icons": "^0.1.70"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"clsx": "^2.1.1",
|
|
65
65
|
"react": "18.3.1",
|
|
66
66
|
"rxjs": "^7.8.1",
|
|
67
|
-
"typescript": "^5.5.
|
|
68
|
-
"vite": "^5.3.
|
|
69
|
-
"vitest": "^2.0.
|
|
70
|
-
"@univerjs/core": "0.2.
|
|
71
|
-
"@univerjs/
|
|
72
|
-
"@univerjs/
|
|
73
|
-
"@univerjs/
|
|
74
|
-
"@univerjs/thread-comment": "0.2.
|
|
75
|
-
"@univerjs/
|
|
76
|
-
"@univerjs/thread-comment-ui": "0.2.
|
|
77
|
-
"@univerjs/
|
|
67
|
+
"typescript": "^5.5.4",
|
|
68
|
+
"vite": "^5.3.5",
|
|
69
|
+
"vitest": "^2.0.4",
|
|
70
|
+
"@univerjs/core": "0.2.6",
|
|
71
|
+
"@univerjs/engine-formula": "0.2.6",
|
|
72
|
+
"@univerjs/design": "0.2.6",
|
|
73
|
+
"@univerjs/sheets-thread-comment-base": "0.2.6",
|
|
74
|
+
"@univerjs/thread-comment": "0.2.6",
|
|
75
|
+
"@univerjs/ui": "0.2.6",
|
|
76
|
+
"@univerjs/thread-comment-ui": "0.2.6",
|
|
77
|
+
"@univerjs/shared": "0.2.6"
|
|
78
78
|
},
|
|
79
79
|
"univerSpace": {
|
|
80
80
|
".": {
|