@univerjs/sheets-thread-comment 0.1.12 → 0.1.13

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.
@@ -0,0 +1,8 @@
1
+ {
2
+ "sheetThreadComment": {
3
+ "menu": {
4
+ "addComment": "Add Comment",
5
+ "commentManagement": "Comment Management"
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "sheetThreadComment": {
3
+ "menu": {
4
+ "addComment": "Add Comment",
5
+ "commentManagement": "Comment Management"
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "sheetThreadComment": {
3
+ "menu": {
4
+ "addComment": "添加评论",
5
+ "commentManagement": "评论管理"
6
+ }
7
+ }
8
+ }
@@ -1,4 +1,4 @@
1
- import { IMenuItem, IShortcutItem, MenuItemType, MenuPosition } from '@univerjs/ui';
1
+ import { IMenuItem, IShortcutItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
2
2
  import { IAccessor } from '@wendellhu/redi';
3
3
 
4
4
  export declare const threadCommentMenuFactory: (accessor: IAccessor) => IMenuItem;
@@ -8,6 +8,8 @@ export declare const threadPanelMenuFactory: (accessor: IAccessor) => {
8
8
  icon: string;
9
9
  tooltip: string;
10
10
  positions: MenuPosition;
11
+ group: MenuGroup;
12
+ disabled$: import('rxjs').Observable<boolean>;
11
13
  hidden$: import('rxjs').Observable<boolean>;
12
14
  };
13
15
  export declare const AddCommentShortcut: IShortcutItem;
@@ -27,6 +27,5 @@ export declare class SheetsThreadCommentController extends Disposable {
27
27
  private _initCommandListener;
28
28
  private _initMenu;
29
29
  private _initComponent;
30
- private _initLocale;
31
30
  private _initPanelListener;
32
31
  }
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,_,y,M,$,f,w,P,z,re){"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 I=(a,h,m)=>(Fe(a,typeof h!="symbol"?h+"":h,m),m);var H;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)},oe=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=P.forwardRef(function(i,r){var e=i.icon,t=i.id,n=i.className,o=i.extend,s=oe(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(n||"").trim(),d=P.useRef("_".concat(ae()));return Y(e,"".concat(t),{defIds:e.defIds,idSuffix:d.current},b({ref:r,className:c},s),o)});function Y(i,r,e,t,n){return P.createElement(i.tag,b(b({key:r},ie(i,e,n)),t),(se(i,e).children||[]).map(function(o,s){return Y(o,"".concat(r,"-").concat(i.tag,"-").concat(s),e,void 0,n)}))}function ie(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 se(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 ae(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var ce={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=P.forwardRef(function(i,r){return P.createElement(k,Object.assign({},i,{id:"comment-single",ref:r,icon:ce}))});X.displayName="CommentSingle";var me=Object.defineProperty,de=Object.getOwnPropertyDescriptor,ue=(i,r,e,t)=>{for(var n=t>1?void 0:t?de(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&&me(r,e,n),n},x=(i,r)=>(e,t)=>r(e,t,i);a.SheetsThreadCommentModel=class extends m.Disposable{constructor(e,t){super();I(this,"_matrixMap",new Map);I(this,"_locationMap",new Map);I(this,"_commentUpdate$",new z.Subject);I(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=M.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=M.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=M.singleReferenceToGrid(d.ref);this._commentUpdate$.next({...e,...u});break}case"updateRef":{const c=M.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=ue([x(0,h.Inject(f.ThreadCommentModel)),x(1,m.IUniverInstanceService)],a.SheetsThreadCommentModel);const J="univer.sheet.thread-comment-modal",Z="comment-single",B="univer.sheet.thread-comment";var he=Object.defineProperty,le=Object.getOwnPropertyDescriptor,pe=(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&&he(r,e,n),n},Q=(i,r)=>(e,t)=>r(e,t,i);a.SheetsThreadCommentPopupService=class extends m.Disposable{constructor(e,t){super();I(this,"_lastPopup",null);I(this,"_activePopup");I(this,"_activePopup$",new z.BehaviorSubject(null));I(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=pe([Q(0,h.Inject($.SheetCanvasPopManagerService)),Q(1,_.IZenZoneService)],a.SheetsThreadCommentPopupService);const ve=()=>{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()},U=D=>{var R,j,N;return(N=(j=(R=i.getCurrentUnitForType(m.UniverInstanceType.UNIVER_SHEET))==null?void 0:R.getSheetBySheetId(D))==null?void 0:j.getName())!=null?N:""};return P.createElement(T.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:u,unitId:s,subUnitId:c,type:m.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:p,getSubUnitName:U,autoFocus:d==="context-menu"})},V={type:m.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var j;const r=i.get(y.SelectionManagerService),e=i.get(m.IUniverInstanceService),t=i.get(a.SheetsThreadCommentPopupService),n=i.get(T.ThreadCommentPanelService),o=(j=r.getFirst())==null?void 0:j.primary,s=r.getCurrent(),c=i.get(a.SheetsThreadCommentModel);if(!s||!o)return!1;const{unitId:d,sheetId:u}=s,l=y.getSheetCommandTarget(e,{unitId:d,subUnitId:u});if(!l)return!1;const{workbook:p,worksheet:U}=l,D={workbook:p,worksheet:U,unitId:d,subUnitId:u,row:o.actualRow,col:o.startColumn};t.showPopup(D);const R=c.getByLocation(d,u,o.actualRow,o.startColumn);return R&&n.setActiveComment({unitId:d,subUnitId:u,commentId:R,trigger:"context-menu"}),!0}},Ce=()=>{const i=w.useDependency($.IMarkSelectionService),r=w.useDependency(m.IUniverInstanceService),e=w.useDependency(f.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=P.useMemo(()=>n.activeSheet$.pipe(z.map(v=>v==null?void 0:v.getSheetId())),[n.activeSheet$]),d=w.useObservable(c,n.getActiveSheet().getSheetId()),u=P.useRef(),l=w.useDependency(T.ThreadCommentPanelService),p=w.useObservable(l.activeCommentId$),U=P.useCallback(v=>{const C=n.getSheets(),g={};return C.forEach((S,E)=>{g[S.getSheetId()]=E}),v.map(S=>{var ne;const E=M.singleReferenceToGrid(S.ref),Be=[(ne=g[S.subUnitId])!=null?ne:0,E.row,E.column];return{...S,p:Be}}).sort((S,E)=>S.p[0]===E.p[0]?S.p[1]===E.p[1]?S.p[2]-E.p[2]:S.p[1]-E.p[1]:S.p[0]-E.p[0])},[n]),D=P.useCallback(v=>{if(v.unitId===o&&v.subUnitId===d&&!v.resolved){const{row:C,column:g}=M.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]),R=v=>{var C,g;return(g=(C=n.getSheetBySheetId(v))==null?void 0:C.getName())!=null?g:""},j=()=>{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=D(v))},q=()=>{u.current&&(i.removeShape(u.current),u.current=null)};return P.useEffect(()=>{if(!p)return;const v=e.getComment(p.unitId,p.subUnitId,p.commentId);if(!v)return;const C=D(v);return()=>{C&&i.removeShape(C)}},[D,p,e,i]),P.createElement(T.ThreadCommentPanel,{unitId:o,subUnitId$:c,type:m.UniverInstanceType.UNIVER_SHEET,onAdd:j,getSubUnitName:R,onResolve:N,sortComments:U,onItemEnter:W,onItemLeave:q})},fe={sheetThreadComment:{menu:{addComment:"添加评论",commentManagement:"评论管理"}}},_e=i=>({id:V.id,type:_.MenuItemType.BUTTON,positions:[_.MenuPosition.CONTEXT_MENU],icon:Z,title:"sheetThreadComment.menu.addComment",hidden$:_.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET)}),Se=i=>({id:T.ToggleSheetCommentPanelOperation.id,type:_.MenuItemType.BUTTON,icon:Z,tooltip:"sheetThreadComment.menu.commentManagement",positions:_.MenuPosition.TOOLBAR_START,hidden$:_.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET)}),Ie={id:V.id,binding:_.KeyCode.M|_.MetaKeys.CTRL_COMMAND|_.MetaKeys.ALT,preconditions:$.whenSheetEditorFocused};var ge=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Me=(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},O=(i,r)=>(e,t)=>r(e,t,i);const Pe={};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._initLocale(),this._initCommandListener(),this._initPanelListener()}_initShortcut(){this._shortcutService.registerShortcut(Ie)}_initCommandListener(){this._commandService.onCommandExecuted(r=>{if(r.id===y.SetSelectionsOperation.id){const e=r.params,{unitId:t,subUnitId:n,selections:o,type:s}=e;if((s===y.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===f.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,ve],[T.THREAD_COMMENT_PANEL,Ce],[Z,X]].forEach(([r,e])=>{this._componentManager.register(r,e)})}_initLocale(){this._localeService.load({zhCN:fe})}_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(y.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t});const l=M.singleReferenceToGrid(s.ref);await this._commandService.executeCommand($.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=Me([m.OnLifecycle(m.LifecycleStages.Starting,a.SheetsThreadCommentController),O(1,_.IMenuService),O(2,h.Inject(h.Injector)),O(3,h.Inject(_.ComponentManager)),O(4,h.Inject(m.LocaleService)),O(5,m.ICommandService),O(6,h.Inject(a.SheetsThreadCommentPopupService)),O(7,h.Inject(a.SheetsThreadCommentModel)),O(8,h.Inject(T.ThreadCommentPanelService)),O(9,_.IShortcutService),O(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},G=(i,r)=>(e,t)=>r(e,t,i);a.SheetsThreadCommentRefRangeController=class extends m.Disposable{constructor(e,t,n){super();I(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=y.handleDefaultRangeChangeWithEffectRefCommands(s,d);return u&&u.startColumn===s.startColumn&&u.startRow===s.startRow?{undos:[],redos:[]}:u?{redos:[{id:f.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:M.serializeRange(u),commentId:o}}}],undos:[{id:f.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:M.serializeRange(s),commentId:o}}}]}:{redos:[{id:f.DeleteCommentMutation.id,params:{unitId:e,subUnitId:t,commentId:o}}],undos:[{id:f.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=M.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),G(0,h.Inject(y.RefRangeService)),G(1,h.Inject(a.SheetsThreadCommentModel)),G(2,h.Inject(f.ThreadCommentModel))],a.SheetsThreadCommentRefRangeController);var Ue=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Re=(i,r,e,t)=>{for(var n=t>1?void 0:t?Oe(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&&Ue(r,e,n),n},L=(i,r)=>(e,t)=>r(e,t,i);let A=class extends m.Disposable{constructor(i,r,e,t,n){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=r,this._univerInstanceService=e,this._sheetSkeletonManagerService=t,this._renderManagerService=n,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(y.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._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:e,sheetId:t}),o=this._renderManagerService.getRenderById(e);n==null||n.makeDirty(!0),n==null||n.calculate(),o&&o.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(()=>{i()}))}};A=Re([m.OnLifecycle(m.LifecycleStages.Ready,A),L(0,h.Inject(y.SheetInterceptorService)),L(1,h.Inject(a.SheetsThreadCommentModel)),L(2,m.IUniverInstanceService),L(3,h.Inject($.SheetSkeletonManagerService)),L(4,re.IRenderManagerService)],A);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},ee=(i,r)=>(e,t)=>r(e,t,i);const $e=(i,r,e)=>{const t=M.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 M.serializeRange(s)};a.SheetsThreadCommentCopyPasteController=class extends m.Disposable{constructor(e,t){super();I(this,"_copyInfo");this._sheetClipboardService=e,this._sheetsThreadCommentModel=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:B,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===$.COPY_TYPE.CUT&&this._copyInfo){const{range:l,unitId:p,subUnitId:U}=this._copyInfo,D={row:l.startRow,column:l.startColumn};if(!(s===p&&c===U)){const R=[];m.Range.foreach(l,(C,g)=>{const S=this._sheetsThreadCommentModel.getCommentWithChildren(p,U,C,g);S&&R.push(S)});const j=[],N=[],W=[],q=[],v=C=>{j.unshift({id:f.DeleteCommentMutation.id,params:{unitId:p,subUnitId:U,commentId:C.id}}),W.push({id:f.AddCommentMutation.id,params:{unitId:s,subUnitId:c,comment:{...C,ref:$e(C.ref,D,u),unitId:s,subUnitId:c}}}),N.push({id:f.AddCommentMutation.id,params:{unitId:p,subUnitId:U,comment:C}}),q.unshift({id:f.DeleteCommentMutation.id,params:{unitId:s,subUnitId:c,commentId:C.id}})};return R.forEach(C=>{v(C.root),C.children.forEach(g=>{v(g)})}),{redos:[...j,...W],undos:[...q,...N]}}}return{redos:[],undos:[]}}}))}},a.SheetsThreadCommentCopyPasteController=De([m.OnLifecycle(m.LifecycleStages.Rendered,a.SheetsThreadCommentCopyPasteController),ee(0,h.Inject($.ISheetClipboardService)),ee(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},F=(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._hoverManagerService.currentCell$.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),F(0,h.Inject($.HoverManagerService)),F(1,h.Inject(a.SheetsThreadCommentPopupService)),F(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},K=(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===y.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:f.DeleteCommentMutation.id,params:{unitId:n,subUnitId:o,commentId:p}})),l=d.map(p=>({id:f.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),K(0,h.Inject(y.SheetInterceptorService)),K(1,m.IUniverInstanceService),K(2,h.Inject(f.ThreadCommentModel))],a.ThreadCommentRemoveSheetsController);var qe=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Ze=(i,r,e,t)=>{for(var n=t>1?void 0:t?ze(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&&qe(r,e,n),n},te=(i,r)=>(e,t)=>r(e,t,i);a.UniverSheetsThreadCommentPlugin=(H=class extends T.UniverThreadCommentUIPlugin{constructor(e={},t,n){super(e,t,n);I(this,"_pluginConfig");this._injector=t,this._commandService=n,this._pluginConfig=m.Tools.deepMerge({},Pe,e)}onStarting(e){super.onStarting(e),[[a.SheetsThreadCommentModel],[a.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(a.SheetsThreadCommentController,this._pluginConfig)}],[a.SheetsThreadCommentRefRangeController],[A],[a.SheetsThreadCommentCopyPasteController],[a.SheetsThreadCommentHoverController],[a.ThreadCommentRemoveSheetsController],[a.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[V].forEach(t=>{this._commandService.registerCommand(t)})}},I(H,"pluginName",B),I(H,"type",m.UniverInstanceType.UNIVER_SHEET),H),a.UniverSheetsThreadCommentPlugin=Ze([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:()=>f.IThreadCommentDataSourceService}),a.SHEETS_THREAD_COMMENT=B,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
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,P,_,f,M,U,S,w,b,V,re){"use strict";var Ze=Object.defineProperty;var ze=(a,h,m)=>h in a?Ze(a,h,{enumerable:!0,configurable:!0,writable:!0,value:m}):a[h]=m;var g=(a,h,m)=>(ze(a,typeof h!="symbol"?h+"":h,m),m);var W;var y=function(){return y=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},y.apply(this,arguments)},oe=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=b.forwardRef(function(i,r){var e=i.icon,t=i.id,n=i.className,o=i.extend,s=oe(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(n||"").trim(),d=b.useRef("_".concat(ae()));return Y(e,"".concat(t),{defIds:e.defIds,idSuffix:d.current},y({ref:r,className:c},s),o)});function Y(i,r,e,t,n){return b.createElement(i.tag,y(y({key:r},ie(i,e,n)),t),(se(i,e).children||[]).map(function(o,s){return Y(o,"".concat(r,"-").concat(i.tag,"-").concat(s),e,void 0,n)}))}function ie(i,r,e){var t=y({},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 se(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)?y(y({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&t&&t.indexOf(n.attrs.id)>-1?y(y({},n),{attrs:y(y({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function ae(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var ce={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=b.forwardRef(function(i,r){return b.createElement(K,Object.assign({},i,{id:"comment-single",ref:r,icon:ce}))});X.displayName="CommentSingle";var me=Object.defineProperty,de=Object.getOwnPropertyDescriptor,ue=(i,r,e,t)=>{for(var n=t>1?void 0:t?de(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&&me(r,e,n),n},J=(i,r)=>(e,t)=>r(e,t,i);a.SheetsThreadCommentModel=class extends m.Disposable{constructor(e,t){super();g(this,"_matrixMap",new Map);g(this,"_locationMap",new Map);g(this,"_commentUpdate$",new V.Subject);g(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=M.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=M.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=M.singleReferenceToGrid(d.ref);this._commentUpdate$.next({...e,...u});break}case"updateRef":{const c=M.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=ue([J(0,h.Inject(S.ThreadCommentModel)),J(1,m.IUniverInstanceService)],a.SheetsThreadCommentModel);const Q="univer.sheet.thread-comment-modal",B="comment-single",Z="univer.sheet.thread-comment";var he=Object.defineProperty,le=Object.getOwnPropertyDescriptor,pe=(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&&he(r,e,n),n},x=(i,r)=>(e,t)=>r(e,t,i);a.SheetsThreadCommentPopupService=class extends m.Disposable{constructor(e,t){super();g(this,"_lastPopup",null);g(this,"_activePopup");g(this,"_activePopup$",new V.BehaviorSubject(null));g(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:Q,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=pe([x(0,h.Inject(U.SheetCanvasPopManagerService)),x(1,_.IZenZoneService)],a.SheetsThreadCommentPopupService);const ve=()=>{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 b.createElement(P.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"})},A={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(P.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}},Ce=()=>{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=b.useMemo(()=>n.activeSheet$.pipe(V.map(v=>v==null?void 0:v.getSheetId())),[n.activeSheet$]),d=w.useObservable(c,n.getActiveSheet().getSheetId()),u=b.useRef(),l=w.useDependency(P.ThreadCommentPanelService),p=w.useObservable(l.activeCommentId$),O=b.useCallback(v=>{const C=n.getSheets(),T={};return C.forEach((I,D)=>{T[I.getSheetId()]=D}),v.map(I=>{var ne;const D=M.singleReferenceToGrid(I.ref),Be=[(ne=T[I.subUnitId])!=null?ne:0,D.row,D.column];return{...I,p:Be}}).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]),$=b.useCallback(v=>{if(v.unitId===o&&v.subUnitId===d&&!v.resolved){const{row:C,column:T}=M.singleReferenceToGrid(v.ref);if(!Number.isNaN(C)&&!Number.isNaN(T))return i.addShape({range:{startColumn:T,endColumn:T,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,T;return(T=(C=n.getSheetBySheetId(v))==null?void 0:C.getName())!=null?T:""},E=()=>{s.executeCommand(A.id)},N=()=>{t.hidePopup()},k=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 b.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]),b.createElement(P.ThreadCommentPanel,{unitId:o,subUnitId$:c,type:m.UniverInstanceType.UNIVER_SHEET,onAdd:E,getSubUnitName:j,onResolve:N,sortComments:O,onItemEnter:k,onItemLeave:q})},fe=i=>({id:A.id,type:_.MenuItemType.BUTTON,positions:[_.MenuPosition.CONTEXT_MENU],icon:B,title:"sheetThreadComment.menu.addComment",hidden$:_.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET),disabled$:U.getCommentDisable$(i,{workbookTypes:[f.WorkbookCommentPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]})}),_e=i=>({id:P.ToggleSheetCommentPanelOperation.id,type:_.MenuItemType.BUTTON,icon:B,tooltip:"sheetThreadComment.menu.commentManagement",positions:_.MenuPosition.TOOLBAR_START,group:_.MenuGroup.TOOLBAR_OTHERS,disabled$:U.getCommentDisable$(i,{workbookTypes:[f.WorkbookCommentPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET)}),Se={id:A.id,binding:_.KeyCode.M|_.MetaKeys.CTRL_COMMAND|_.MetaKeys.ALT,preconditions:U.whenSheetEditorFocused};var Ie=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Te=(i,r,e,t)=>{for(var n=t>1?void 0:t?ge(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&&Ie(r,e,n),n},R=(i,r)=>(e,t)=>r(e,t,i);const Pe={};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(Se)}_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(P.SetActiveCommentOperation.id);return}const u=this._sheetsThreadCommentModel.getByLocation(t,n,c,d);u&&this._commandService.executeCommand(P.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;[fe,_e].forEach(e=>{this._menuService.addMenuItem(e(this._injector),r)})}_initComponent(){[[Q,ve],[P.THREAD_COMMENT_PANEL,Ce],[B,X]].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=M.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=Te([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(P.ThreadCommentPanelService)),R(9,_.IShortcutService),R(10,m.IUniverInstanceService)],a.SheetsThreadCommentController);var Me=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=(i,r,e,t)=>{for(var n=t>1?void 0:t?be(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&&Me(r,e,n),n},z=(i,r)=>(e,t)=>r(e,t,i);a.SheetsThreadCommentRefRangeController=class extends m.Disposable{constructor(e,t,n){super();g(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:M.serializeRange(u),commentId:o}}}],undos:[{id:S.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:M.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=M.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=ye([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 we=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Ue=(i,r,e,t)=>{for(var n=t>1?void 0:t?Oe(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&&we(r,e,n),n},L=(i,r)=>(e,t)=>r(e,t,i);let H=class extends m.Disposable{constructor(i,r,e,t,n){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=r,this._univerInstanceService=e,this._sheetSkeletonManagerService=t,this._renderManagerService=n,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._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:e,sheetId:t}),o=this._renderManagerService.getRenderById(e);n==null||n.makeDirty(!0),n==null||n.calculate(),o&&o.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(()=>{i()}))}};H=Ue([m.OnLifecycle(m.LifecycleStages.Ready,H),L(0,h.Inject(f.SheetInterceptorService)),L(1,h.Inject(a.SheetsThreadCommentModel)),L(2,m.IUniverInstanceService),L(3,h.Inject(U.SheetSkeletonManagerService)),L(4,re.IRenderManagerService)],H);var Re=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ee=(i,r,e,t)=>{for(var n=t>1?void 0:t?je(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&&Re(r,e,n),n},ee=(i,r)=>(e,t)=>r(e,t,i);const De=(i,r,e)=>{const t=M.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 M.serializeRange(s)};a.SheetsThreadCommentCopyPasteController=class extends m.Disposable{constructor(e,t){super();g(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,T)=>{const I=this._sheetsThreadCommentModel.getCommentWithChildren(p,O,C,T);I&&j.push(I)});const E=[],N=[],k=[],q=[],v=C=>{E.unshift({id:S.DeleteCommentMutation.id,params:{unitId:p,subUnitId:O,commentId:C.id}}),k.push({id:S.AddCommentMutation.id,params:{unitId:s,subUnitId:c,comment:{...C,ref:De(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(T=>{v(T)})}),{redos:[...E,...k],undos:[...q,...N]}}}return{redos:[],undos:[]}}}))}},a.SheetsThreadCommentCopyPasteController=Ee([m.OnLifecycle(m.LifecycleStages.Rendered,a.SheetsThreadCommentCopyPasteController),ee(0,h.Inject(U.ISheetClipboardService)),ee(1,h.Inject(a.SheetsThreadCommentModel))],a.SheetsThreadCommentCopyPasteController);var $e=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Le=(i,r,e,t)=>{for(var n=t>1?void 0:t?Ne(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&&$e(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(V.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=Le([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 Ve=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,He=(i,r,e,t)=>{for(var n=t>1?void 0:t?Ae(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&&Ve(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=He([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 We=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,qe=(i,r,e,t)=>{for(var n=t>1?void 0:t?ke(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&&We(r,e,n),n},te=(i,r)=>(e,t)=>r(e,t,i);a.UniverSheetsThreadCommentPlugin=(W=class extends P.UniverThreadCommentUIPlugin{constructor(e={},t,n){super(e,t,n);g(this,"_pluginConfig");this._injector=t,this._commandService=n,this._pluginConfig=m.Tools.deepMerge({},Pe,e)}onStarting(e){super.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=>{this._injector.add(t)}),[A].forEach(t=>{this._commandService.registerCommand(t)})}},g(W,"pluginName",Z),g(W,"type",m.UniverInstanceType.UNIVER_SHEET),W),a.UniverSheetsThreadCommentPlugin=qe([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:()=>P.IThreadCommentMentionDataService}),Object.defineProperty(a,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin}),Object.defineProperty(a,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>S.IThreadCommentDataSourceService}),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.12",
3
+ "version": "0.1.13",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -29,6 +29,7 @@
29
29
  "require": "./lib/cjs/*",
30
30
  "types": "./lib/types/index.d.ts"
31
31
  },
32
+ "./locale/*": "./lib/locale/*.json",
32
33
  "./lib/*": "./lib/*"
33
34
  },
34
35
  "main": "./lib/cjs/index.js",
@@ -47,35 +48,35 @@
47
48
  "@wendellhu/redi": "0.15.2",
48
49
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
49
50
  "rxjs": ">=7.0.0",
50
- "@univerjs/engine-formula": "0.1.12",
51
- "@univerjs/core": "0.1.12",
52
- "@univerjs/engine-render": "0.1.12",
53
- "@univerjs/sheets": "0.1.12",
54
- "@univerjs/thread-comment": "0.1.12",
55
- "@univerjs/sheets-ui": "0.1.12",
56
- "@univerjs/thread-comment-ui": "0.1.12",
57
- "@univerjs/ui": "0.1.12"
51
+ "@univerjs/core": "0.1.13",
52
+ "@univerjs/engine-formula": "0.1.13",
53
+ "@univerjs/sheets": "0.1.13",
54
+ "@univerjs/engine-render": "0.1.13",
55
+ "@univerjs/sheets-ui": "0.1.13",
56
+ "@univerjs/thread-comment": "0.1.13",
57
+ "@univerjs/thread-comment-ui": "0.1.13",
58
+ "@univerjs/ui": "0.1.13"
58
59
  },
59
60
  "dependencies": {
60
- "@univerjs/icons": "^0.1.52",
61
- "@univerjs/thread-comment": "0.1.12",
62
- "@univerjs/thread-comment-ui": "0.1.12"
61
+ "@univerjs/icons": "^0.1.55",
62
+ "@univerjs/thread-comment": "0.1.13",
63
+ "@univerjs/thread-comment-ui": "0.1.13"
63
64
  },
64
65
  "devDependencies": {
65
66
  "@wendellhu/redi": "0.15.2",
66
67
  "clsx": "^2.1.1",
67
- "react": "^18.2.0",
68
+ "react": "18.2.0",
68
69
  "rxjs": "^7.8.1",
69
70
  "typescript": "^5.4.5",
70
- "vite": "^5.2.11",
71
+ "vite": "^5.2.12",
71
72
  "vitest": "^1.6.0",
72
- "@univerjs/core": "0.1.12",
73
- "@univerjs/design": "0.1.12",
74
- "@univerjs/shared": "0.1.12",
75
- "@univerjs/thread-comment": "0.1.12",
76
- "@univerjs/thread-comment-ui": "0.1.12",
77
- "@univerjs/engine-formula": "0.1.12",
78
- "@univerjs/ui": "0.1.12"
73
+ "@univerjs/core": "0.1.13",
74
+ "@univerjs/design": "0.1.13",
75
+ "@univerjs/engine-formula": "0.1.13",
76
+ "@univerjs/shared": "0.1.13",
77
+ "@univerjs/thread-comment-ui": "0.1.13",
78
+ "@univerjs/thread-comment": "0.1.13",
79
+ "@univerjs/ui": "0.1.13"
79
80
  },
80
81
  "scripts": {
81
82
  "test": "vitest run",
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright 2023-present DreamNum Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export { default as enUS } from './en-US';
17
- export { default as zhCN } from './zh-CN';
18
- export { default as ruRU } from './ru-RU';