@univerjs/sheets-thread-comment 0.2.4 → 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.
@@ -1,5 +1,5 @@
1
1
  import { IMenuItem, IShortcutItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
2
- import { IAccessor } from '@wendellhu/redi';
2
+ import { IAccessor } from '@univerjs/core';
3
3
 
4
4
  export declare const threadCommentMenuFactory: (accessor: IAccessor) => IMenuItem;
5
5
  export declare const threadPanelMenuFactory: (accessor: IAccessor) => {
@@ -1,6 +1,5 @@
1
- import { DependencyOverride, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
1
+ import { DependencyOverride, Disposable, ICommandService, Injector, IUniverInstanceService } from '@univerjs/core';
2
2
  import { MenuConfig, ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
3
- import { Injector } from '@wendellhu/redi';
4
3
  import { ThreadCommentPanelService } from '@univerjs/thread-comment-ui';
5
4
  import { IMarkSelectionService, SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
6
5
  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 '@wendellhu/redi';
17
- export { Inject, Injector } from '@wendellhu/redi';
16
+ export type { Dependency } from '@univerjs/core';
17
+ export { Inject, Injector } from '@univerjs/core';
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,5 +1,4 @@
1
- import { Injector } from '@wendellhu/redi';
2
- import { ICommandService, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { ICommandService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
3
2
  import { IUniverSheetsThreadCommentConfig } from './controllers/sheets-thread-comment.controller';
4
3
 
5
4
  export declare class UniverSheetsThreadCommentPlugin extends Plugin {
@@ -9,5 +8,5 @@ export declare class UniverSheetsThreadCommentPlugin extends Plugin {
9
8
  static type: UniverInstanceType;
10
9
  private _pluginConfig;
11
10
  constructor(config: Partial<IUniverSheetsThreadCommentConfig> | undefined, _injector: Injector, _commandService: ICommandService);
12
- onStarting(injector: Injector): void;
11
+ onStarting(): void;
13
12
  }
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
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"})});
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&&params.subUnitId===subUnitId&&params.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&&currentRender.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&&currentPopup.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.4",
3
+ "version": "0.2.6",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -45,38 +45,36 @@
45
45
  "lib"
46
46
  ],
47
47
  "peerDependencies": {
48
- "@wendellhu/redi": "0.16.0",
49
48
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
50
49
  "rxjs": ">=7.0.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"
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"
60
59
  },
61
60
  "dependencies": {
62
- "@univerjs/icons": "^0.1.65"
61
+ "@univerjs/icons": "^0.1.70"
63
62
  },
64
63
  "devDependencies": {
65
- "@wendellhu/redi": "0.16.0",
66
64
  "clsx": "^2.1.1",
67
65
  "react": "18.3.1",
68
66
  "rxjs": "^7.8.1",
69
- "typescript": "^5.5.3",
70
- "vite": "^5.3.4",
71
- "vitest": "^2.0.3",
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"
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"
80
78
  },
81
79
  "univerSpace": {
82
80
  ".": {