@univerjs/sheets-thread-comment 0.1.14 → 0.1.16

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,7 +1,7 @@
1
1
  import { Disposable, IUniverInstanceService } from '@univerjs/core';
2
2
  import { SheetInterceptorService } from '@univerjs/sheets';
3
3
  import { IRenderManagerService } from '@univerjs/engine-render';
4
- import { SheetsThreadCommentModel } from '../../models/sheets-thread-comment.model';
4
+ import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';
5
5
 
6
6
  export declare class SheetsThreadCommentRenderController extends Disposable {
7
7
  private readonly _sheetInterceptorService;
@@ -1,6 +1,6 @@
1
1
  import { Disposable } from '@univerjs/core';
2
2
  import { ISheetClipboardService } from '@univerjs/sheets-ui';
3
- import { SheetsThreadCommentModel } from '../models/sheets-thread-comment.model';
3
+ import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';
4
4
 
5
5
  export declare class SheetsThreadCommentCopyPasteController extends Disposable {
6
6
  private _sheetClipboardService;
@@ -1,12 +1,13 @@
1
1
  import { Disposable } from '@univerjs/core';
2
- import { HoverManagerService } from '@univerjs/sheets-ui';
2
+ import { HoverManagerService, SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
3
+ import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';
3
4
  import { SheetsThreadCommentPopupService } from '../services/sheets-thread-comment-popup.service';
4
- import { SheetsThreadCommentModel } from '../models/sheets-thread-comment.model';
5
5
 
6
6
  export declare class SheetsThreadCommentHoverController extends Disposable {
7
7
  private readonly _hoverManagerService;
8
8
  private readonly _sheetsThreadCommentPopupService;
9
9
  private readonly _sheetsThreadCommentModel;
10
- constructor(_hoverManagerService: HoverManagerService, _sheetsThreadCommentPopupService: SheetsThreadCommentPopupService, _sheetsThreadCommentModel: SheetsThreadCommentModel);
10
+ private readonly _sheetPermissionInterceptorBaseController;
11
+ constructor(_hoverManagerService: HoverManagerService, _sheetsThreadCommentPopupService: SheetsThreadCommentPopupService, _sheetsThreadCommentModel: SheetsThreadCommentModel, _sheetPermissionInterceptorBaseController: SheetPermissionInterceptorBaseController);
11
12
  private _initHoverEvent;
12
13
  }
@@ -2,8 +2,9 @@ import { DependencyOverride, Disposable, ICommandService, IUniverInstanceService
2
2
  import { MenuConfig, ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
3
3
  import { Injector } from '@wendellhu/redi';
4
4
  import { ThreadCommentPanelService } from '@univerjs/thread-comment-ui';
5
+ import { SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
6
+ import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';
5
7
  import { SheetsThreadCommentPopupService } from '../services/sheets-thread-comment-popup.service';
6
- import { SheetsThreadCommentModel } from '../models/sheets-thread-comment.model';
7
8
 
8
9
  export interface IUniverSheetsThreadCommentConfig {
9
10
  menu?: MenuConfig;
@@ -22,7 +23,8 @@ export declare class SheetsThreadCommentController extends Disposable {
22
23
  private readonly _threadCommentPanelService;
23
24
  private readonly _shortcutService;
24
25
  private readonly _univerInstanceService;
25
- constructor(_config: Partial<IUniverSheetsThreadCommentConfig>, _menuService: IMenuService, _injector: Injector, _componentManager: ComponentManager, _localeService: LocaleService, _commandService: ICommandService, _sheetsThreadCommentPopupService: SheetsThreadCommentPopupService, _sheetsThreadCommentModel: SheetsThreadCommentModel, _threadCommentPanelService: ThreadCommentPanelService, _shortcutService: IShortcutService, _univerInstanceService: IUniverInstanceService);
26
+ private readonly _sheetPermissionInterceptorBaseController;
27
+ constructor(_config: Partial<IUniverSheetsThreadCommentConfig>, _menuService: IMenuService, _injector: Injector, _componentManager: ComponentManager, _localeService: LocaleService, _commandService: ICommandService, _sheetsThreadCommentPopupService: SheetsThreadCommentPopupService, _sheetsThreadCommentModel: SheetsThreadCommentModel, _threadCommentPanelService: ThreadCommentPanelService, _shortcutService: IShortcutService, _univerInstanceService: IUniverInstanceService, _sheetPermissionInterceptorBaseController: SheetPermissionInterceptorBaseController);
26
28
  private _initShortcut;
27
29
  private _initCommandListener;
28
30
  private _initMenu;
@@ -18,8 +18,6 @@ export { Inject, Injector } from '@wendellhu/redi';
18
18
  export { ICommandService, Plugin, UniverInstanceType } from '@univerjs/core';
19
19
  export { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';
20
20
  export { SheetsThreadCommentController } from './controllers/sheets-thread-comment.controller';
21
- export { SheetsThreadCommentRefRangeController } from './controllers/sheets-thread-comment-ref-range.controller';
22
- export { SheetsThreadCommentModel } from './models/sheets-thread-comment.model';
23
21
  export { SheetsThreadCommentPopupService } from './services/sheets-thread-comment-popup.service';
24
22
  export { UniverSheetsThreadCommentPlugin } from './plugin';
25
23
  export { SHEETS_THREAD_COMMENT } from './types/const';
@@ -28,3 +26,4 @@ export { SheetsThreadCommentHoverController } from './controllers/sheets-thread-
28
26
  export { ThreadCommentRemoveSheetsController } from './controllers/sheets-thread-comment-remove.controller';
29
27
  export { IThreadCommentMentionDataService } from '@univerjs/thread-comment-ui';
30
28
  export { IThreadCommentDataSourceService } from '@univerjs/thread-comment';
29
+ export { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';
@@ -15,4 +15,4 @@
15
15
  */
16
16
  export declare const SHEETS_THREAD_COMMENT_MODAL = "univer.sheet.thread-comment-modal";
17
17
  export declare const COMMENT_SINGLE_ICON = "comment-single";
18
- export declare const SHEETS_THREAD_COMMENT = "univer.sheet.thread-comment";
18
+ export declare const SHEETS_THREAD_COMMENT = "SHEET_THREAD_COMMENT";
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(a,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@wendellhu/redi"),require("@univerjs/core"),require("@univerjs/thread-comment-ui"),require("@univerjs/ui"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/sheets-ui"),require("@univerjs/thread-comment"),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/sheets-ui","@univerjs/thread-comment","@wendellhu/redi/react-bindings","react","rxjs","@univerjs/engine-render"],h):(a=typeof globalThis<"u"?globalThis:a||self,h(a.UniverSheetsThreadComment={},a["@wendellhu/redi"],a.UniverCore,a.UniverThreadCommentUi,a.UniverUi,a.UniverSheets,a.UniverEngineFormula,a.UniverSheetsUi,a.UniverThreadComment,a["@wendellhu/redi/react-bindings"],a.React,a.rxjs,a.UniverEngineRender))})(this,function(a,h,m,T,_,f,P,U,S,w,M,L,oe){"use strict";var Ge=Object.defineProperty;var Fe=(a,h,m)=>h in a?Ge(a,h,{enumerable:!0,configurable:!0,writable:!0,value:m}):a[h]=m;var y=(a,h,m)=>(Fe(a,typeof h!="symbol"?h+"":h,m),m);var b=function(){return b=Object.assign||function(i){for(var r,e=1,t=arguments.length;e<t;e++){r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},b.apply(this,arguments)},ie=function(i,r){var e={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&r.indexOf(t)<0&&(e[t]=i[t]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,t=Object.getOwnPropertySymbols(i);n<t.length;n++)r.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(i,t[n])&&(e[t[n]]=i[t[n]]);return e},k=M.forwardRef(function(i,r){var e=i.icon,t=i.id,n=i.className,o=i.extend,s=ie(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(n||"").trim(),d=M.useRef("_".concat(ce()));return K(e,"".concat(t),{defIds:e.defIds,idSuffix:d.current},b({ref:r,className:c},s),o)});function K(i,r,e,t,n){return M.createElement(i.tag,b(b({key:r},se(i,e,n)),t),(ae(i,e).children||[]).map(function(o,s){return K(o,"".concat(r,"-").concat(i.tag,"-").concat(s),e,void 0,n)}))}function se(i,r,e){var t=b({},i.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1);var n=r.defIds;return!n||n.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+r.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(t[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),t}function ae(i,r){var e,t=r.defIds;return!t||t.length===0?i:i.tag==="defs"&&(!((e=i.children)===null||e===void 0)&&e.length)?b(b({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&t&&t.indexOf(n.attrs.id)>-1?b(b({},n),{attrs:b(b({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function ce(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var me={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"}}]},Y=M.forwardRef(function(i,r){return M.createElement(k,Object.assign({},i,{id:"comment-single",ref:r,icon:me}))});Y.displayName="CommentSingle";var de=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,he=(i,r,e,t)=>{for(var n=t>1?void 0:t?ue(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&de(r,e,n),n},X=(i,r)=>(e,t)=>r(e,t,i);a.SheetsThreadCommentModel=class extends m.Disposable{constructor(e,t){super();y(this,"_matrixMap",new Map);y(this,"_locationMap",new Map);y(this,"_commentUpdate$",new L.Subject);y(this,"commentUpdate$",this._commentUpdate$.asObservable());this._threadCommentModel=e,this._univerInstanceService=t,this._init()}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,t){let n=this._matrixMap.get(e);n||(n=new Map,this._matrixMap.set(e,n));let o=n.get(t);return o||(o=new m.ObjectMatrix,n.set(t,o)),o}_ensureCommentLocationMap(e,t){let n=this._locationMap.get(e);n||(n=new Map,this._locationMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}_ensure(e,t){const n=this._ensureCommentMatrix(e,t),o=this._ensureCommentLocationMap(e,t);return{matrix:n,locationMap:o}}_initData(){const e=this._threadCommentModel.getAll();for(const t in e){const n=e[t];for(const o in n){const s=n[o];for(const c in s){const d=s[c];this._addComment(t,o,d)}}}}_addComment(e,t,n){const o=P.singleReferenceToGrid(n.ref),s=n.parentId,{row:c,column:d}=o,u=n.id,{matrix:l,locationMap:p}=this._ensure(e,t);!s&&c>=0&&d>=0&&(l.setValue(c,d,u),p.set(u,{row:c,column:d})),this._commentUpdate$.next({unitId:e,subUnitId:t,payload:n,type:"add",...o})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:t,subUnitId:n}=e;try{if(this._univerInstanceService.getUnitType(t)!==m.UniverInstanceType.UNIVER_SHEET)return}catch{}const{matrix:o,locationMap:s}=this._ensure(t,n);switch(e.type){case"add":{this._addComment(e.unitId,e.subUnitId,e.payload);break}case"delete":{const{isRoot:c,comment:d}=e.payload,u=P.singleReferenceToGrid(d.ref);if(c){const{row:l,column:p}=u;l>=0&&p>=0&&o.realDeleteValue(l,p)}this._commentUpdate$.next({...e,...u});break}case"update":{const{commentId:c}=e.payload,d=this._threadCommentModel.getComment(t,n,c);if(!d)return;const u=P.singleReferenceToGrid(d.ref);this._commentUpdate$.next({...e,...u});break}case"updateRef":{const c=P.singleReferenceToGrid(e.payload.ref),{commentId:d}=e.payload,u=s.get(d);if(!u)return;const{row:l,column:p}=u;o.getValue(l,p)===d&&(o.realDeleteValue(l,p),s.delete(d)),c.row>=0&&c.column>=0&&(o.setValue(c.row,c.column,d),s.set(d,{row:c.row,column:c.column})),this._commentUpdate$.next({...e,...c});break}}}))}getByLocation(e,t,n,o){return this._ensureCommentMatrix(e,t).getValue(n,o)}getComment(e,t,n){return this._threadCommentModel.getComment(e,t,n)}getCommentWithChildren(e,t,n,o){const c=this._ensureCommentMatrix(e,t).getValue(n,o);if(c)return this._threadCommentModel.getCommentWithChildren(e,t,c)}showCommentMarker(e,t,n,o){const s=this.getByLocation(e,t,n,o);if(!s)return!1;const c=this.getComment(e,t,s);return!!(c&&!c.resolved)}},a.SheetsThreadCommentModel=he([X(0,h.Inject(S.ThreadCommentModel)),X(1,m.IUniverInstanceService)],a.SheetsThreadCommentModel);const J="univer.sheet.thread-comment-modal",B="comment-single",Z="univer.sheet.thread-comment";var le=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,ve=(i,r,e,t)=>{for(var n=t>1?void 0:t?pe(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&le(r,e,n),n},Q=(i,r)=>(e,t)=>r(e,t,i);a.SheetsThreadCommentPopupService=class extends m.Disposable{constructor(e,t){super();y(this,"_lastPopup",null);y(this,"_activePopup");y(this,"_activePopup$",new L.BehaviorSubject(null));y(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=e,this._zenZoneService=t,this._initZenVisible()}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this.hidePopup()}))}showPopup(e,t){var l;const{row:n,col:o,unitId:s,subUnitId:c}=e;if(this._activePopup&&n===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&c===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=e,this._activePopup$.next(e);const d=this._canvasPopupManagerService.attachPopupToCell(n,o,{componentKey:J,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!d)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const u=new m.DisposableCollection;u.add(d),u.add({dispose:()=>{t==null||t()}}),this._lastPopup=u}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=ve([Q(0,h.Inject(U.SheetCanvasPopManagerService)),Q(1,_.IZenZoneService)],a.SheetsThreadCommentPopupService);const Ce=()=>{const i=w.useDependency(m.IUniverInstanceService),r=w.useDependency(a.SheetsThreadCommentPopupService),e=_.useObservable(r.activePopup$),t=w.useDependency(a.SheetsThreadCommentModel);if(_.useObservable(t.commentUpdate$),!e)return null;const{row:n,col:o,unitId:s,subUnitId:c,trigger:d}=e,u=t.getByLocation(s,c,n,o),l=`${m.Tools.chatAtABC(o)}${n+1}`,p=()=>{r.hidePopup()},O=$=>{var j,E,N;return(N=(E=(j=i.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET))==null?void 0:j.getSheetBySheetId($))==null?void 0:E.getName())!=null?N:""};return M.createElement(T.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:u,unitId:s,subUnitId:c,type:m.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:p,getSubUnitName:O,autoFocus:d==="context-menu"})},V={type:m.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var E;const r=i.get(f.SelectionManagerService),e=i.get(m.IUniverInstanceService),t=i.get(a.SheetsThreadCommentPopupService),n=i.get(T.ThreadCommentPanelService),o=(E=r.getFirst())==null?void 0:E.primary,s=r.getCurrent(),c=i.get(a.SheetsThreadCommentModel);if(!s||!o)return!1;const{unitId:d,sheetId:u}=s,l=f.getSheetCommandTarget(e,{unitId:d,subUnitId:u});if(!l)return!1;const{workbook:p,worksheet:O}=l,$={workbook:p,worksheet:O,unitId:d,subUnitId:u,row:o.actualRow,col:o.startColumn};t.showPopup($);const j=c.getByLocation(d,u,o.actualRow,o.startColumn);return j&&n.setActiveComment({unitId:d,subUnitId:u,commentId:j,trigger:"context-menu"}),!0}},fe=()=>{const i=w.useDependency(U.IMarkSelectionService),r=w.useDependency(m.IUniverInstanceService),e=w.useDependency(S.ThreadCommentModel),t=w.useDependency(a.SheetsThreadCommentPopupService),n=r.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET);if(!n)return null;const o=n.getUnitId(),s=w.useDependency(m.ICommandService),c=M.useMemo(()=>n.activeSheet$.pipe(L.map(v=>v==null?void 0:v.getSheetId())),[n.activeSheet$]),d=w.useObservable(c,n.getActiveSheet().getSheetId()),u=M.useRef(),l=w.useDependency(T.ThreadCommentPanelService),p=w.useObservable(l.activeCommentId$),O=M.useCallback(v=>{const C=n.getSheets(),g={};return C.forEach((I,D)=>{g[I.getSheetId()]=D}),v.map(I=>{var re;const D=P.singleReferenceToGrid(I.ref),ze=[(re=g[I.subUnitId])!=null?re:0,D.row,D.column];return{...I,p:ze}}).sort((I,D)=>I.p[0]===D.p[0]?I.p[1]===D.p[1]?I.p[2]-D.p[2]:I.p[1]-D.p[1]:I.p[0]-D.p[0])},[n]),$=M.useCallback(v=>{if(v.unitId===o&&v.subUnitId===d&&!v.resolved){const{row:C,column:g}=P.singleReferenceToGrid(v.ref);if(!Number.isNaN(C)&&!Number.isNaN(g))return i.addShape({range:{startColumn:g,endColumn:g,startRow:C,endRow:C},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,d,o]),j=v=>{var C,g;return(g=(C=n.getSheetBySheetId(v))==null?void 0:C.getName())!=null?g:""},E=()=>{s.executeCommand(V.id)},N=()=>{t.hidePopup()},W=v=>{p&&p.unitId===v.unitId&&p.subUnitId===v.subUnitId&&p.commentId===v.id||(u.current&&(i.removeShape(u.current),u.current=null),u.current=$(v))},q=()=>{u.current&&(i.removeShape(u.current),u.current=null)};return M.useEffect(()=>{if(!p)return;const v=e.getComment(p.unitId,p.subUnitId,p.commentId);if(!v)return;const C=$(v);return()=>{C&&i.removeShape(C)}},[$,p,e,i]),M.createElement(T.ThreadCommentPanel,{unitId:o,subUnitId$:c,type:m.UniverInstanceType.UNIVER_SHEET,onAdd:E,getSubUnitName:j,onResolve:N,sortComments:O,onItemEnter:W,onItemLeave:q})},_e=i=>({id:V.id,type:_.MenuItemType.BUTTON,positions:[_.MenuPosition.CONTEXT_MENU],icon:B,title:"sheetThreadComment.menu.addComment",hidden$:_.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET),disabled$:U.getCurrentRangeDisable$(i,{workbookTypes:[f.WorkbookCommentPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]})}),Se=i=>({id:T.ToggleSheetCommentPanelOperation.id,type:_.MenuItemType.BUTTON,icon:B,tooltip:"sheetThreadComment.menu.commentManagement",positions:_.MenuPosition.TOOLBAR_START,group:_.MenuGroup.TOOLBAR_OTHERS,disabled$:U.getCurrentRangeDisable$(i,{workbookTypes:[f.WorkbookCommentPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET)}),Ie={id:V.id,binding:_.KeyCode.M|_.MetaKeys.CTRL_COMMAND|_.MetaKeys.ALT,preconditions:U.whenSheetEditorFocused};var ge=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Pe=(i,r,e,t)=>{for(var n=t>1?void 0:t?Te(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&ge(r,e,n),n},R=(i,r)=>(e,t)=>r(e,t,i);const Me={};a.SheetsThreadCommentController=class extends m.Disposable{constructor(r,e,t,n,o,s,c,d,u,l,p){super(),this._config=r,this._menuService=e,this._injector=t,this._componentManager=n,this._localeService=o,this._commandService=s,this._sheetsThreadCommentPopupService=c,this._sheetsThreadCommentModel=d,this._threadCommentPanelService=u,this._shortcutService=l,this._univerInstanceService=p,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener()}_initShortcut(){this._shortcutService.registerShortcut(Ie)}_initCommandListener(){this._commandService.onCommandExecuted(r=>{if(r.id===f.SetSelectionsOperation.id){const e=r.params,{unitId:t,subUnitId:n,selections:o,type:s}=e;if((s===f.SelectionMoveType.MOVE_END||s===void 0)&&o[0].primary){const c=o[0].primary.actualRow,d=o[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(t,n,c,d)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const u=this._sheetsThreadCommentModel.getByLocation(t,n,c,d);u&&this._commandService.executeCommand(T.SetActiveCommentOperation.id,{unitId:t,subUnitId:n,commentId:u})}}if(r.id===S.DeleteCommentMutation.id){const e=r.params,t=this._sheetsThreadCommentPopupService.activePopup;if(!t)return;const{unitId:n,subUnitId:o,commentId:s}=t;e.unitId===n&&e.subUnitId===o&&e.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:r={}}=this._config;[_e,Se].forEach(e=>{this._menuService.addMenuItem(e(this._injector),r)})}_initComponent(){[[J,Ce],[T.THREAD_COMMENT_PANEL,fe],[B,Y]].forEach(([r,e])=>{this._componentManager.register(r,e)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async r=>{if(r){const{unitId:e,subUnitId:t,commentId:n,trigger:o}=r,s=this._sheetsThreadCommentModel.getComment(e,t,n);if(!s||s.resolved)return;const c=this._univerInstanceService.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET);if(!c||c.getUnitId()!==e)return;c.getActiveSheet().getSheetId()!==t&&await this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t});const l=P.singleReferenceToGrid(s.ref);await this._commandService.executeCommand(U.ScrollToCellCommand.id,{range:{startColumn:l.column,endColumn:l.column,startRow:l.row,endRow:l.row}}),this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:t,row:l.row,col:l.column,commentId:s.id,trigger:o})}else this._sheetsThreadCommentPopupService.hidePopup()}))}},a.SheetsThreadCommentController=Pe([m.OnLifecycle(m.LifecycleStages.Starting,a.SheetsThreadCommentController),R(1,_.IMenuService),R(2,h.Inject(h.Injector)),R(3,h.Inject(_.ComponentManager)),R(4,h.Inject(m.LocaleService)),R(5,m.ICommandService),R(6,h.Inject(a.SheetsThreadCommentPopupService)),R(7,h.Inject(a.SheetsThreadCommentModel)),R(8,h.Inject(T.ThreadCommentPanelService)),R(9,_.IShortcutService),R(10,m.IUniverInstanceService)],a.SheetsThreadCommentController);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,we=(i,r,e,t)=>{for(var n=t>1?void 0:t?ye(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&be(r,e,n),n},z=(i,r)=>(e,t)=>r(e,t,i);a.SheetsThreadCommentRefRangeController=class extends m.Disposable{constructor(e,t,n){super();y(this,"_disposableMap",new Map);this._refRangeService=e,this._sheetsThreadCommentModel=t,this._threadCommentModel=n,this._initData(),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}-${t}-${n}`}_register(e,t,n){const o=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row},c=d=>{const u=f.handleDefaultRangeChangeWithEffectRefCommands(s,d);return u&&u.startColumn===s.startColumn&&u.startRow===s.startRow?{undos:[],redos:[]}:u?{redos:[{id:S.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:P.serializeRange(u),commentId:o}}}],undos:[{id:S.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:P.serializeRange(s),commentId:o}}}]}:{redos:[{id:S.DeleteCommentMutation.id,params:{unitId:e,subUnitId:t,commentId:o}}],undos:[{id:S.AddCommentMutation.id,params:{unitId:e,subUnitId:t,comment:n}}]}};this._disposableMap.set(this._getIdWithUnitId(e,t,o),this._refRangeService.registerRefRange(s,c,e,t))}_initData(){const e=this._threadCommentModel.getAll();for(const t in e){const n=e[t];for(const o in n){const s=n[o];for(const c in s){const d=s[c],u=d.ref,l=P.singleReferenceToGrid(u);this._register(t,o,{...d,...l})}}}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:t,subUnitId:n}=e;switch(e.type){case"add":{const o=e.payload;this._register(e.unitId,e.subUnitId,{...o,row:e.row,column:e.column});break}case"delete":{const o=this._disposableMap.get(this._getIdWithUnitId(t,n,e.payload.commentId));o==null||o.dispose();break}case"updateRef":{const o=this._sheetsThreadCommentModel.getComment(t,n,e.payload.commentId);if(!o)return;const s=this._disposableMap.get(this._getIdWithUnitId(t,n,o.id));s==null||s.dispose(),this._register(e.unitId,e.subUnitId,{...o,row:e.row,column:e.column});break}}})),this.disposeWithMe(m.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}},a.SheetsThreadCommentRefRangeController=we([m.OnLifecycle(m.LifecycleStages.Starting,a.SheetsThreadCommentRefRangeController),z(0,h.Inject(f.RefRangeService)),z(1,h.Inject(a.SheetsThreadCommentModel)),z(2,h.Inject(S.ThreadCommentModel))],a.SheetsThreadCommentRefRangeController);var Oe=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Re=(i,r,e,t)=>{for(var n=t>1?void 0:t?Ue(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&Oe(r,e,n),n},A=(i,r)=>(e,t)=>r(e,t,i);let H=class extends m.Disposable{constructor(i,r,e,t){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=r,this._univerInstanceService=e,this._renderManagerService=t,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(i,r,e)=>{const{row:t,col:n,unitId:o,subUnitId:s}=r;return this._sheetsThreadCommentModel.showCommentMarker(o,s,t,n)?e({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):e(i)},priority:100}))}_initSkeletonChange(){const i=()=>{const r=this._univerInstanceService.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET);if(!r)return;const e=r.getUnitId(),t=r.getActiveSheet().getSheetId(),n=this._renderManagerService.getRenderById(e),o=n==null?void 0:n.with(U.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:t});o==null||o.makeDirty(!0),o==null||o.calculate(),n&&n.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(()=>{i()}))}};H=Re([m.OnLifecycle(m.LifecycleStages.Ready,H),A(0,h.Inject(f.SheetInterceptorService)),A(1,h.Inject(a.SheetsThreadCommentModel)),A(2,m.IUniverInstanceService),A(3,oe.IRenderManagerService)],H);var je=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,De=(i,r,e,t)=>{for(var n=t>1?void 0:t?Ee(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&je(r,e,n),n},x=(i,r)=>(e,t)=>r(e,t,i);const $e=(i,r,e)=>{const t=P.singleReferenceToGrid(i),n=e.row-r.row,o=e.column-r.column,s={startColumn:t.column+o,startRow:t.row+n,endColumn:t.column+o,endRow:t.row+n};return P.serializeRange(s)};a.SheetsThreadCommentCopyPasteController=class extends m.Disposable{constructor(e,t){super();y(this,"_copyInfo");this._sheetClipboardService=e,this._sheetsThreadCommentModel=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Z,onBeforeCopy:(e,t,n)=>{this._copyInfo={unitId:e,subUnitId:t,range:n}},onPasteCells:(e,t,n,o)=>{const{unitId:s,subUnitId:c,range:d}=t,u={row:d.rows[0],column:d.cols[0]};if(o.copyType===U.COPY_TYPE.CUT&&this._copyInfo){const{range:l,unitId:p,subUnitId:O}=this._copyInfo,$={row:l.startRow,column:l.startColumn};if(!(s===p&&c===O)){const j=[];m.Range.foreach(l,(C,g)=>{const I=this._sheetsThreadCommentModel.getCommentWithChildren(p,O,C,g);I&&j.push(I)});const E=[],N=[],W=[],q=[],v=C=>{E.unshift({id:S.DeleteCommentMutation.id,params:{unitId:p,subUnitId:O,commentId:C.id}}),W.push({id:S.AddCommentMutation.id,params:{unitId:s,subUnitId:c,comment:{...C,ref:$e(C.ref,$,u),unitId:s,subUnitId:c}}}),N.push({id:S.AddCommentMutation.id,params:{unitId:p,subUnitId:O,comment:C}}),q.unshift({id:S.DeleteCommentMutation.id,params:{unitId:s,subUnitId:c,commentId:C.id}})};return j.forEach(C=>{v(C.root),C.children.forEach(g=>{v(g)})}),{redos:[...E,...W],undos:[...q,...N]}}}return{redos:[],undos:[]}}}))}},a.SheetsThreadCommentCopyPasteController=De([m.OnLifecycle(m.LifecycleStages.Rendered,a.SheetsThreadCommentCopyPasteController),x(0,h.Inject(U.ISheetClipboardService)),x(1,h.Inject(a.SheetsThreadCommentModel))],a.SheetsThreadCommentCopyPasteController);var Ne=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,Ve=(i,r,e,t)=>{for(var n=t>1?void 0:t?Le(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&Ne(r,e,n),n},G=(i,r)=>(e,t)=>r(e,t,i);a.SheetsThreadCommentHoverController=class extends m.Disposable{constructor(r,e,t){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=e,this._sheetsThreadCommentModel=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(L.debounceTime(100)).subscribe(r=>{const e=this._sheetsThreadCommentPopupService.activePopup;if(r&&(e&&e.temp||!e)){const{location:t}=r,{unitId:n,subUnitId:o,row:s,col:c}=t,d=this._sheetsThreadCommentModel.getByLocation(n,o,s,c);if(d){const u=this._sheetsThreadCommentModel.getComment(n,o,d);u&&!u.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:o,row:s,col:c,commentId:d,temp:!0})}else e&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},a.SheetsThreadCommentHoverController=Ve([m.OnLifecycle(m.LifecycleStages.Rendered,a.SheetsThreadCommentHoverController),G(0,h.Inject(U.HoverManagerService)),G(1,h.Inject(a.SheetsThreadCommentPopupService)),G(2,h.Inject(a.SheetsThreadCommentModel))],a.SheetsThreadCommentHoverController);var Ae=Object.defineProperty,He=Object.getOwnPropertyDescriptor,We=(i,r,e,t)=>{for(var n=t>1?void 0:t?He(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&Ae(r,e,n),n},F=(i,r)=>(e,t)=>r(e,t,i);a.ThreadCommentRemoveSheetsController=class extends m.Disposable{constructor(r,e,t){super(),this._sheetInterceptorService=r,this._univerInstanceService=e,this._threadCommentModel=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===f.RemoveSheetCommand.id){const e=r.params,t=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const n=t.getUnitId(),o=e.subUnitId||t.getActiveSheet().getSheetId(),{commentMap:s}=this._threadCommentModel.ensureMap(n,o),c=Array.from(Object.keys(s)),d=Array.from(Object.values(s)),u=c.map(p=>({id:S.DeleteCommentMutation.id,params:{unitId:n,subUnitId:o,commentId:p}})),l=d.map(p=>({id:S.AddCommentMutation.id,params:{unitId:n,subUnitId:o,comment:p}}));return{redos:u,undos:l}}return{redos:[],undos:[]}}}))}},a.ThreadCommentRemoveSheetsController=We([m.OnLifecycle(m.LifecycleStages.Ready,a.ThreadCommentRemoveSheetsController),F(0,h.Inject(f.SheetInterceptorService)),F(1,m.IUniverInstanceService),F(2,h.Inject(S.ThreadCommentModel))],a.ThreadCommentRemoveSheetsController);var ee=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Be=(i,r,e)=>r in i?ee(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e,Ze=(i,r,e,t)=>{for(var n=t>1?void 0:t?qe(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(t?s(r,e,n):s(n))||n);return t&&n&&ee(r,e,n),n},te=(i,r)=>(e,t)=>r(e,t,i),ne=(i,r,e)=>(Be(i,typeof r!="symbol"?r+"":r,e),e);a.UniverSheetsThreadCommentPlugin=class extends m.Plugin{constructor(e={},t,n){super();y(this,"_pluginConfig");this._injector=t,this._commandService=n,this._pluginConfig=m.Tools.deepMerge({},Me,e)}onStarting(e){[[a.SheetsThreadCommentModel],[a.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(a.SheetsThreadCommentController,this._pluginConfig)}],[a.SheetsThreadCommentRefRangeController],[H],[a.SheetsThreadCommentCopyPasteController],[a.SheetsThreadCommentHoverController],[a.ThreadCommentRemoveSheetsController],[a.SheetsThreadCommentPopupService]].forEach(t=>{e.add(t)}),[V].forEach(t=>{this._commandService.registerCommand(t)})}},ne(a.UniverSheetsThreadCommentPlugin,"pluginName",Z),ne(a.UniverSheetsThreadCommentPlugin,"type",m.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsThreadCommentPlugin=Ze([m.DependentOn(T.UniverThreadCommentUIPlugin),te(1,h.Inject(h.Injector)),te(2,h.Inject(m.ICommandService))],a.UniverSheetsThreadCommentPlugin),Object.defineProperty(a,"Inject",{enumerable:!0,get:()=>h.Inject}),Object.defineProperty(a,"Injector",{enumerable:!0,get:()=>h.Injector}),Object.defineProperty(a,"ICommandService",{enumerable:!0,get:()=>m.ICommandService}),Object.defineProperty(a,"Plugin",{enumerable:!0,get:()=>m.Plugin}),Object.defineProperty(a,"UniverInstanceType",{enumerable:!0,get:()=>m.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:()=>S.IThreadCommentDataSourceService}),a.SHEETS_THREAD_COMMENT=Z,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
1
+ (function(a,m){typeof exports=="object"&&typeof module<"u"?m(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"],m):(a=typeof globalThis<"u"?globalThis:a||self,m(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,m,c,P,f,v,V,j,T,D,R,g,B,oe){"use strict";var Le=Object.defineProperty;var ke=(a,m,c)=>m in a?Le(a,m,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[m]=c;var N=(a,m,c)=>ke(a,typeof m!="symbol"?m+"":m,c);var b=function(){return b=Object.assign||function(o){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(o[t]=r[t])}return o},b.apply(this,arguments)},ie=function(o,r){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&r.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(o);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(o,e[t])&&(n[e[t]]=o[e[t]]);return n},K=g.forwardRef(function(o,r){var n=o.icon,e=o.id,t=o.className,i=o.extend,s=ie(o,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),d=g.useRef("_".concat(ce()));return Y(n,"".concat(e),{defIds:n.defIds,idSuffix:d.current},b({ref:r,className:u},s),i)});function Y(o,r,n,e,t){return g.createElement(o.tag,b(b({key:r},se(o,n,t)),e),(ae(o,n).children||[]).map(function(i,s){return Y(i,"".concat(r,"-").concat(o.tag,"-").concat(s),n,void 0,t)}))}function se(o,r,n){var e=b({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],u=i[1];typeof u=="string"&&(e[s]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function ae(o,r){var n,e=r.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?b(b({},o),{children:o.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+r.idSuffix})}):t})}):o}function ce(){return Math.random().toString(36).substring(2,8)}K.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"}}]},X=g.forwardRef(function(o,r){return g.createElement(K,Object.assign({},o,{id:"comment-single",ref:r,icon:ue}))});X.displayName="CommentSingle";const J="univer.sheet.thread-comment-modal",Z="comment-single",z="SHEET_THREAD_COMMENT";var me=Object.defineProperty,de=Object.getOwnPropertyDescriptor,he=(o,r,n,e)=>{for(var t=e>1?void 0:e?de(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&me(r,n,t),t},Q=(o,r)=>(n,e)=>r(n,e,o);a.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new B.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible()}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var C;const{row:t,col:i,unitId:s,subUnitId:u}=n;if(this._activePopup&&t===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&u===((C=this.activePopup)==null?void 0:C.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const d=this._canvasPopupManagerService.attachPopupToCell(t,i,{componentKey:J,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!d)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const p=new c.DisposableCollection;p.add(d),p.add({dispose:()=>{e==null||e()}}),this._lastPopup=p}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=he([Q(0,m.Inject(T.SheetCanvasPopManagerService)),Q(1,f.IZenZoneService)],a.SheetsThreadCommentPopupService);const le=()=>{const o=R.useDependency(c.IUniverInstanceService),r=R.useDependency(a.SheetsThreadCommentPopupService),n=f.useObservable(r.activePopup$),e=R.useDependency(D.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:t,col:i,unitId:s,subUnitId:u,trigger:d}=n,p=e.getByLocation(s,u,t,i),C=`${c.Tools.chatAtABC(i)}${t+1}`,l=()=>{r.hidePopup()},S=y=>{var O,_,$;return($=(_=(O=o.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:O.getSheetBySheetId(y))==null?void 0:_.getName())!=null?$:""};return g.createElement(P.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:p,unitId:s,subUnitId:u,type:c.UniverInstanceType.UNIVER_SHEET,refStr:C,onClose:l,getSubUnitName:S,autoFocus:d==="context-menu"})},H={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var _;const r=o.get(v.SelectionManagerService),n=o.get(c.IUniverInstanceService),e=o.get(a.SheetsThreadCommentPopupService),t=o.get(P.ThreadCommentPanelService),i=(_=r.getFirst())==null?void 0:_.primary,s=r.getCurrent(),u=o.get(D.SheetsThreadCommentModel);if(!s||!i)return!1;const{unitId:d,sheetId:p}=s,C=v.getSheetCommandTarget(n,{unitId:d,subUnitId:p});if(!C)return!1;const{workbook:l,worksheet:S}=C,y={workbook:l,worksheet:S,unitId:d,subUnitId:p,row:i.startRow,col:i.startColumn};e.showPopup(y);const O=u.getByLocation(d,p,i.startRow,i.startColumn);return O&&t.setActiveComment({unitId:d,subUnitId:p,commentId:O,trigger:"context-menu"}),!0}},pe=()=>{var A;const o=R.useDependency(T.IMarkSelectionService),r=R.useDependency(c.IUniverInstanceService),n=R.useDependency(j.ThreadCommentModel),e=R.useDependency(a.SheetsThreadCommentPopupService),t=r.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const i=t.getUnitId(),s=R.useDependency(c.ICommandService),u=g.useMemo(()=>t.activeSheet$.pipe(B.map(h=>h==null?void 0:h.getSheetId())),[t.activeSheet$]),d=f.useObservable(u,(A=t.getActiveSheet())==null?void 0:A.getSheetId()),p=g.useRef(),C=R.useDependency(P.ThreadCommentPanelService),l=f.useObservable(C.activeCommentId$),S=g.useCallback(h=>{const I=t.getSheets(),M={};return I.forEach((U,E)=>{M[U.getSheetId()]=E}),h.map(U=>{var re;const E=V.singleReferenceToGrid(U.ref),He=[(re=M[U.subUnitId])!=null?re:0,E.row,E.column];return{...U,p:He}}).sort((U,E)=>U.p[0]===E.p[0]?U.p[1]===E.p[1]?U.p[2]-E.p[2]:U.p[1]-E.p[1]:U.p[0]-E.p[0])},[t]),y=g.useCallback(h=>{if(h.unitId===i&&h.subUnitId===d&&!h.resolved){const{row:I,column:M}=V.singleReferenceToGrid(h.ref);if(!Number.isNaN(I)&&!Number.isNaN(M))return o.addShape({range:{startColumn:M,endColumn:M,startRow:I,endRow:I},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,d,i]),O=h=>{var I,M;return(M=(I=t.getSheetBySheetId(h))==null?void 0:I.getName())!=null?M:""},_=()=>{s.executeCommand(H.id)},$=()=>{e.hidePopup()},F=h=>{l&&l.unitId===h.unitId&&l.subUnitId===h.subUnitId&&l.commentId===h.id||(p.current&&(o.removeShape(p.current),p.current=null),p.current=y(h))},q=()=>{p.current&&(o.removeShape(p.current),p.current=null)};return g.useEffect(()=>{if(!l)return;const h=n.getComment(l.unitId,l.subUnitId,l.commentId);if(!h)return;const I=y(h);return()=>{I&&o.removeShape(I)}},[y,l,n,o]),g.createElement(P.ThreadCommentPanel,{unitId:i,subUnitId$:u,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:_,getSubUnitName:O,onResolve:$,sortComments:S,onItemEnter:F,onItemLeave:q})},ve=o=>({id:H.id,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.CONTEXT_MENU],icon:Z,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),disabled$:T.getCurrentRangeDisable$(o,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),Ce=o=>({id:P.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:Z,tooltip:"sheetThreadComment.menu.commentManagement",positions:f.MenuPosition.TOOLBAR_START,group:f.MenuGroup.TOOLBAR_OTHERS,disabled$:T.getCurrentRangeDisable$(o,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET)}),Se={id:H.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:T.whenSheetEditorFocused};var fe=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ie=(o,r,n,e)=>{for(var t=e>1?void 0:e?_e(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&fe(r,n,t),t},w=(o,r)=>(n,e)=>r(n,e,o);const Pe={};a.SheetsThreadCommentController=class extends c.Disposable{constructor(r,n,e,t,i,s,u,d,p,C,l,S){super(),this._config=r,this._menuService=n,this._injector=e,this._componentManager=t,this._localeService=i,this._commandService=s,this._sheetsThreadCommentPopupService=u,this._sheetsThreadCommentModel=d,this._threadCommentPanelService=p,this._shortcutService=C,this._univerInstanceService=l,this._sheetPermissionInterceptorBaseController=S,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener()}_initShortcut(){this._shortcutService.registerShortcut(Se)}_initCommandListener(){this._commandService.onCommandExecuted(r=>{if(r.id===v.SetSelectionsOperation.id){const n=r.params,{unitId:e,subUnitId:t,selections:i,type:s}=n;if((s===v.SelectionMoveType.MOVE_END||s===void 0)&&i[0].primary){const u=i[0].primary.actualRow,d=i[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(e,t,u,d)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const p=this._sheetsThreadCommentModel.getByLocation(e,t,u,d);p&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:e,subUnitId:t,commentId:p})}}if(r.id===j.DeleteCommentMutation.id){const n=r.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:t,subUnitId:i,commentId:s}=e;n.unitId===t&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:r={}}=this._config;[ve,Ce].forEach(n=>{this._menuService.addMenuItem(n(this._injector),r)})}_initComponent(){[[J,le],[P.THREAD_COMMENT_PANEL,pe],[Z,X]].forEach(([r,n])=>{this._componentManager.register(r,n)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async r=>{var n;if(r){const{unitId:e,subUnitId:t,commentId:i,trigger:s}=r,u=this._sheetsThreadCommentModel.getComment(e,t,i);if(!u||u.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==e)return;((n=d.getActiveSheet())==null?void 0:n.getSheetId())!==t&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t});const l=V.singleReferenceToGrid(u.ref),{row:S,column:y}=l;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:S,startColumn:y,endRow:S,endColumn:y}]))return;const _=5;await this._commandService.executeCommand(T.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-_,0),endRow:l.row+_,startColumn:Math.max(l.column-_,0),endColumn:l.column+_}}),this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:t,row:l.row,col:l.column,commentId:u.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}},a.SheetsThreadCommentController=Ie([c.OnLifecycle(c.LifecycleStages.Starting,a.SheetsThreadCommentController),w(1,f.IMenuService),w(2,m.Inject(m.Injector)),w(3,m.Inject(f.ComponentManager)),w(4,m.Inject(c.LocaleService)),w(5,c.ICommandService),w(6,m.Inject(a.SheetsThreadCommentPopupService)),w(7,m.Inject(D.SheetsThreadCommentModel)),w(8,m.Inject(P.ThreadCommentPanelService)),w(9,f.IShortcutService),w(10,c.IUniverInstanceService),w(11,m.Inject(T.SheetPermissionInterceptorBaseController))],a.SheetsThreadCommentController);var Te=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,be=(o,r,n,e)=>{for(var t=e>1?void 0:e?ge(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Te(r,n,t),t},L=(o,r)=>(n,e)=>r(n,e,o);let k=class extends c.Disposable{constructor(o,r,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=r,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(o,r,n)=>{const{row:e,col:t,unitId:i,subUnitId:s}=r;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,t)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var s;const r=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!r)return;const n=r.getUnitId(),e=(s=r.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(T.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});i==null||i.makeDirty(!0),i==null||i.calculate(),t&&t.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(()=>{o()}))}};k=be([c.OnLifecycle(c.LifecycleStages.Ready,k),L(0,m.Inject(v.SheetInterceptorService)),L(1,m.Inject(D.SheetsThreadCommentModel)),L(2,c.IUniverInstanceService),L(3,oe.IRenderManagerService)],k);var ye=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,we=(o,r,n,e)=>{for(var t=e>1?void 0:e?Me(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&ye(r,n,t),t},x=(o,r)=>(n,e)=>r(n,e,o);const Oe=(o,r,n)=>{const e=V.singleReferenceToGrid(o),t=n.row-r.row,i=n.column-r.column,s={startColumn:e.column+i,startRow:e.row+t,endColumn:e.column+i,endRow:e.row+t};return V.serializeRange(s)};a.SheetsThreadCommentCopyPasteController=class extends c.Disposable{constructor(n,e){super();N(this,"_copyInfo");this._sheetClipboardService=n,this._sheetsThreadCommentModel=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:z,onBeforeCopy:(n,e,t)=>{this._copyInfo={unitId:n,subUnitId:e,range:t}},onPasteCells:(n,e,t,i)=>{const{unitId:s,subUnitId:u,range:d}=e,p={row:d.rows[0],column:d.cols[0]};if(i.copyType===T.COPY_TYPE.CUT&&this._copyInfo){const{range:C,unitId:l,subUnitId:S}=this._copyInfo,y={row:C.startRow,column:C.startColumn};if(!(s===l&&u===S)){const O=[];c.Range.foreach(C,(h,I)=>{const M=this._sheetsThreadCommentModel.getCommentWithChildren(l,S,h,I);M&&O.push(M)});const _=[],$=[],F=[],q=[],A=h=>{_.unshift({id:j.DeleteCommentMutation.id,params:{unitId:l,subUnitId:S,commentId:h.id}}),F.push({id:j.AddCommentMutation.id,params:{unitId:s,subUnitId:u,comment:{...h,ref:Oe(h.ref,y,p),unitId:s,subUnitId:u}}}),$.push({id:j.AddCommentMutation.id,params:{unitId:l,subUnitId:S,comment:h}}),q.unshift({id:j.DeleteCommentMutation.id,params:{unitId:s,subUnitId:u,commentId:h.id}})};return O.forEach(h=>{A(h.root),h.children.forEach(I=>{A(I)})}),{redos:[..._,...F],undos:[...q,...$]}}}return{redos:[],undos:[]}}}))}},a.SheetsThreadCommentCopyPasteController=we([c.OnLifecycle(c.LifecycleStages.Rendered,a.SheetsThreadCommentCopyPasteController),x(0,m.Inject(T.ISheetClipboardService)),x(1,m.Inject(D.SheetsThreadCommentModel))],a.SheetsThreadCommentCopyPasteController);var Ue=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ee=(o,r,n,e)=>{for(var t=e>1?void 0:e?je(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Ue(r,n,t),t},W=(o,r)=>(n,e)=>r(n,e,o);a.SheetsThreadCommentHoverController=class extends c.Disposable{constructor(r,n,e,t){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(B.debounceTime(100)).subscribe(r=>{const n=this._sheetsThreadCommentPopupService.activePopup;if(r&&(n&&n.temp||!n)){const{location:e}=r,{unitId:t,subUnitId:i,row:s,col:u}=e,d=this._sheetsThreadCommentModel.getByLocation(t,i,s,u);if(d){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:s,startColumn:u,endRow:s,endColumn:u}]))return;const C=this._sheetsThreadCommentModel.getComment(t,i,d);C&&!C.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:i,row:s,col:u,commentId:d,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},a.SheetsThreadCommentHoverController=Ee([c.OnLifecycle(c.LifecycleStages.Rendered,a.SheetsThreadCommentHoverController),W(0,m.Inject(T.HoverManagerService)),W(1,m.Inject(a.SheetsThreadCommentPopupService)),W(2,m.Inject(D.SheetsThreadCommentModel)),W(3,m.Inject(T.SheetPermissionInterceptorBaseController))],a.SheetsThreadCommentHoverController);var Re=Object.defineProperty,De=Object.getOwnPropertyDescriptor,$e=(o,r,n,e)=>{for(var t=e>1?void 0:e?De(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Re(r,n,t),t},G=(o,r)=>(n,e)=>r(n,e,o);a.ThreadCommentRemoveSheetsController=class extends c.Disposable{constructor(r,n,e){super(),this._sheetInterceptorService=r,this._univerInstanceService=n,this._threadCommentModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var n;if(r.id===v.RemoveSheetCommand.id){const e=r.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:u}=this._threadCommentModel.ensureMap(i,s),d=Array.from(Object.keys(u)),p=Array.from(Object.values(u)),C=d.map(S=>({id:j.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:S}})),l=p.map(S=>({id:j.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:S}}));return{redos:C,undos:l}}return{redos:[],undos:[]}}}))}},a.ThreadCommentRemoveSheetsController=$e([c.OnLifecycle(c.LifecycleStages.Ready,a.ThreadCommentRemoveSheetsController),G(0,m.Inject(v.SheetInterceptorService)),G(1,c.IUniverInstanceService),G(2,m.Inject(j.ThreadCommentModel))],a.ThreadCommentRemoveSheetsController);var ee=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Ve=(o,r,n)=>r in o?ee(o,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[r]=n,Ae=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ne(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&ee(r,n,t),t},te=(o,r)=>(n,e)=>r(n,e,o),ne=(o,r,n)=>Ve(o,typeof r!="symbol"?r+"":r,n);a.UniverSheetsThreadCommentPlugin=class extends c.Plugin{constructor(n={},e,t){super();N(this,"_pluginConfig");this._injector=e,this._commandService=t,this._pluginConfig=c.Tools.deepMerge({},Pe,n)}onStarting(n){[[a.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(a.SheetsThreadCommentController,this._pluginConfig)}],[k],[a.SheetsThreadCommentCopyPasteController],[a.SheetsThreadCommentHoverController],[a.ThreadCommentRemoveSheetsController],[a.SheetsThreadCommentPopupService]].forEach(e=>{n.add(e)}),[H].forEach(e=>{this._commandService.registerCommand(e)})}},ne(a.UniverSheetsThreadCommentPlugin,"pluginName",z),ne(a.UniverSheetsThreadCommentPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsThreadCommentPlugin=Ae([c.DependentOn(P.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentBasePlugin),te(1,m.Inject(m.Injector)),te(2,m.Inject(c.ICommandService))],a.UniverSheetsThreadCommentPlugin),Object.defineProperty(a,"Inject",{enumerable:!0,get:()=>m.Inject}),Object.defineProperty(a,"Injector",{enumerable:!0,get:()=>m.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:()=>P.IThreadCommentMentionDataService}),Object.defineProperty(a,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin}),Object.defineProperty(a,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>j.IThreadCommentDataSourceService}),Object.defineProperty(a,"SheetsThreadCommentModel",{enumerable:!0,get:()=>D.SheetsThreadCommentModel}),a.SHEETS_THREAD_COMMENT=z,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-thread-comment",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -45,38 +45,40 @@
45
45
  "lib"
46
46
  ],
47
47
  "peerDependencies": {
48
- "@wendellhu/redi": "0.15.2",
48
+ "@wendellhu/redi": "0.15.4",
49
49
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
50
50
  "rxjs": ">=7.0.0",
51
- "@univerjs/engine-formula": "0.1.14",
52
- "@univerjs/core": "0.1.14",
53
- "@univerjs/engine-render": "0.1.14",
54
- "@univerjs/sheets": "0.1.14",
55
- "@univerjs/sheets-ui": "0.1.14",
56
- "@univerjs/thread-comment-ui": "0.1.14",
57
- "@univerjs/thread-comment": "0.1.14",
58
- "@univerjs/ui": "0.1.14"
51
+ "@univerjs/core": "0.1.16",
52
+ "@univerjs/engine-formula": "0.1.16",
53
+ "@univerjs/engine-render": "0.1.16",
54
+ "@univerjs/sheets": "0.1.16",
55
+ "@univerjs/sheets-thread-comment-base": "0.1.16",
56
+ "@univerjs/thread-comment": "0.1.16",
57
+ "@univerjs/sheets-ui": "0.1.16",
58
+ "@univerjs/thread-comment-ui": "0.1.16",
59
+ "@univerjs/ui": "0.1.16"
59
60
  },
60
61
  "dependencies": {
61
- "@univerjs/icons": "^0.1.56",
62
- "@univerjs/thread-comment": "0.1.14",
63
- "@univerjs/thread-comment-ui": "0.1.14"
62
+ "@univerjs/icons": "^0.1.57",
63
+ "@univerjs/thread-comment": "0.1.16",
64
+ "@univerjs/sheets-thread-comment-base": "0.1.16",
65
+ "@univerjs/thread-comment-ui": "0.1.16"
64
66
  },
65
67
  "devDependencies": {
66
- "@wendellhu/redi": "0.15.2",
68
+ "@wendellhu/redi": "0.15.4",
67
69
  "clsx": "^2.1.1",
68
70
  "react": "18.3.1",
69
71
  "rxjs": "^7.8.1",
70
72
  "typescript": "^5.4.5",
71
- "vite": "^5.2.12",
73
+ "vite": "^5.3.1",
72
74
  "vitest": "^1.6.0",
73
- "@univerjs/core": "0.1.14",
74
- "@univerjs/design": "0.1.14",
75
- "@univerjs/engine-formula": "0.1.14",
76
- "@univerjs/shared": "0.1.14",
77
- "@univerjs/thread-comment-ui": "0.1.14",
78
- "@univerjs/ui": "0.1.14",
79
- "@univerjs/thread-comment": "0.1.14"
75
+ "@univerjs/core": "0.1.16",
76
+ "@univerjs/engine-formula": "0.1.16",
77
+ "@univerjs/shared": "0.1.16",
78
+ "@univerjs/design": "0.1.16",
79
+ "@univerjs/thread-comment": "0.1.16",
80
+ "@univerjs/thread-comment-ui": "0.1.16",
81
+ "@univerjs/ui": "0.1.16"
80
82
  },
81
83
  "univerSpace": {
82
84
  ".": {
@@ -97,6 +99,7 @@
97
99
  "test:watch": "vitest",
98
100
  "coverage": "vitest run --coverage",
99
101
  "lint:types": "tsc --noEmit",
100
- "build": "tsc && vite build"
102
+ "build": "tsc && vite build",
103
+ "sync:cnpm": "cnpm sync"
101
104
  }
102
105
  }
@@ -1,16 +0,0 @@
1
- import { Disposable } from '@univerjs/core';
2
- import { RefRangeService } from '@univerjs/sheets';
3
- import { ThreadCommentModel } from '@univerjs/thread-comment';
4
- import { SheetsThreadCommentModel } from '../models/sheets-thread-comment.model';
5
-
6
- export declare class SheetsThreadCommentRefRangeController extends Disposable {
7
- private readonly _refRangeService;
8
- private readonly _sheetsThreadCommentModel;
9
- private readonly _threadCommentModel;
10
- private _disposableMap;
11
- constructor(_refRangeService: RefRangeService, _sheetsThreadCommentModel: SheetsThreadCommentModel, _threadCommentModel: ThreadCommentModel);
12
- private _getIdWithUnitId;
13
- private _register;
14
- private _initData;
15
- private _initRefRange;
16
- }
@@ -1,31 +0,0 @@
1
- import { Disposable, IUniverInstanceService } from '@univerjs/core';
2
- import { CommentUpdate, IThreadComment, ThreadCommentModel } from '@univerjs/thread-comment';
3
-
4
- export type SheetCommentUpdate = CommentUpdate & {
5
- row: number;
6
- column: number;
7
- };
8
- export declare class SheetsThreadCommentModel extends Disposable {
9
- private readonly _threadCommentModel;
10
- private readonly _univerInstanceService;
11
- private _matrixMap;
12
- private _locationMap;
13
- private _commentUpdate$;
14
- commentUpdate$: import('rxjs').Observable<SheetCommentUpdate>;
15
- constructor(_threadCommentModel: ThreadCommentModel, _univerInstanceService: IUniverInstanceService);
16
- private _init;
17
- private _ensureCommentMatrix;
18
- private _ensureCommentLocationMap;
19
- private _ensure;
20
- private _initData;
21
- private _addComment;
22
- private _initUpdateTransform;
23
- getByLocation(unitId: string, subUnitId: string, row: number, column: number): string | undefined;
24
- getComment(unitId: string, subUnitId: string, commentId: string): IThreadComment | undefined;
25
- getCommentWithChildren(unitId: string, subUnitId: string, row: number, column: number): {
26
- root: IThreadComment;
27
- children: IThreadComment[];
28
- relativeUsers: Set<string>;
29
- } | undefined;
30
- showCommentMarker(unitId: string, subUnitId: string, row: number, column: number): boolean;
31
- }