@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.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +280 -277
- package/lib/locale/en-US.json +8 -0
- package/lib/locale/ru-RU.json +8 -0
- package/lib/locale/zh-CN.json +8 -0
- package/lib/types/controllers/menu.d.ts +3 -1
- package/lib/types/controllers/sheets-thread-comment.controller.d.ts +0 -1
- package/lib/umd/index.js +1 -1
- package/package.json +22 -21
- package/lib/types/locale/index.d.ts +0 -18
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var re=Object.defineProperty;var oe=(i,r,e)=>r in i?re(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var S=(i,r,e)=>(oe(i,typeof r!="symbol"?r+"":r,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@wendellhu/redi"),c=require("@univerjs/core"),P=require("@univerjs/thread-comment-ui"),_=require("@univerjs/ui"),U=require("@univerjs/sheets"),M=require("@univerjs/engine-formula"),D=require("@univerjs/sheets-ui"),v=require("@univerjs/thread-comment"),y=require("@wendellhu/redi/react-bindings"),g=require("react"),q=require("rxjs"),ie=require("@univerjs/engine-render");var T=function(){return T=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},T.apply(this,arguments)},se=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},J=g.forwardRef(function(i,r){var e=i.icon,t=i.id,n=i.className,o=i.extend,s=se(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(n||"").trim(),m=g.useRef("_".concat(me()));return Q(e,"".concat(t),{defIds:e.defIds,idSuffix:m.current},T({ref:r,className:a},s),o)});function Q(i,r,e,t,n){return g.createElement(i.tag,T(T({key:r},ae(i,e,n)),t),(ce(i,e).children||[]).map(function(o,s){return Q(o,"".concat(r,"-").concat(i.tag,"-").concat(s),e,void 0,n)}))}function ae(i,r,e){var t=T({},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],a=o[1];typeof a=="string"&&(t[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),t}function ce(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)?T(T({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&t&&t.indexOf(n.attrs.id)>-1?T(T({},n),{attrs:T(T({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function me(){return Math.random().toString(36).substring(2,8)}J.displayName="UniverIcon";var de={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ee=g.forwardRef(function(i,r){return g.createElement(J,Object.assign({},i,{id:"comment-single",ref:r,icon:de}))});ee.displayName="CommentSingle";var he=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,le=(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&&he(r,e,n),n},K=(i,r)=>(e,t)=>r(e,t,i);exports.SheetsThreadCommentModel=class extends c.Disposable{constructor(e,t){super();S(this,"_matrixMap",new Map);S(this,"_locationMap",new Map);S(this,"_commentUpdate$",new q.Subject);S(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 c.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 a in s){const m=s[a];this._addComment(t,o,m)}}}}_addComment(e,t,n){const o=M.singleReferenceToGrid(n.ref),s=n.parentId,{row:a,column:m}=o,d=n.id,{matrix:h,locationMap:u}=this._ensure(e,t);!s&&a>=0&&m>=0&&(h.setValue(a,m,d),u.set(d,{row:a,column:m})),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)!==c.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:a,comment:m}=e.payload,d=M.singleReferenceToGrid(m.ref);if(a){const{row:h,column:u}=d;h>=0&&u>=0&&o.realDeleteValue(h,u)}this._commentUpdate$.next({...e,...d});break}case"update":{const{commentId:a}=e.payload,m=this._threadCommentModel.getComment(t,n,a);if(!m)return;const d=M.singleReferenceToGrid(m.ref);this._commentUpdate$.next({...e,...d});break}case"updateRef":{const a=M.singleReferenceToGrid(e.payload.ref),{commentId:m}=e.payload,d=s.get(m);if(!d)return;const{row:h,column:u}=d;o.getValue(h,u)===m&&(o.realDeleteValue(h,u),s.delete(m)),a.row>=0&&a.column>=0&&(o.setValue(a.row,a.column,m),s.set(m,{row:a.row,column:a.column})),this._commentUpdate$.next({...e,...a});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 a=this._ensureCommentMatrix(e,t).getValue(n,o);if(a)return this._threadCommentModel.getCommentWithChildren(e,t,a)}showCommentMarker(e,t,n,o){const s=this.getByLocation(e,t,n,o);if(!s)return!1;const a=this.getComment(e,t,s);return!!(a&&!a.resolved)}};exports.SheetsThreadCommentModel=le([K(0,l.Inject(v.ThreadCommentModel)),K(1,c.IUniverInstanceService)],exports.SheetsThreadCommentModel);const te="univer.sheet.thread-comment-modal",z="comment-single",Z="univer.sheet.thread-comment";var pe=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,ve=(i,r,e,t)=>{for(var n=t>1?void 0:t?Ce(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&&pe(r,e,n),n},k=(i,r)=>(e,t)=>r(e,t,i);exports.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(e,t){super();S(this,"_lastPopup",null);S(this,"_activePopup");S(this,"_activePopup$",new q.BehaviorSubject(null));S(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 h;const{row:n,col:o,unitId:s,subUnitId:a}=e;if(this._activePopup&&n===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&a===((h=this.activePopup)==null?void 0:h.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 m=this._canvasPopupManagerService.attachPopupToCell(n,o,{componentKey:te,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new c.DisposableCollection;d.add(m),d.add({dispose:()=>{t==null||t()}}),this._lastPopup=d}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=ve([k(0,l.Inject(D.SheetCanvasPopManagerService)),k(1,_.IZenZoneService)],exports.SheetsThreadCommentPopupService);const _e=()=>{const i=y.useDependency(c.IUniverInstanceService),r=y.useDependency(exports.SheetsThreadCommentPopupService),e=_.useObservable(r.activePopup$),t=y.useDependency(exports.SheetsThreadCommentModel);if(_.useObservable(t.commentUpdate$),!e)return null;const{row:n,col:o,unitId:s,subUnitId:a,trigger:m}=e,d=t.getByLocation(s,a,n,o),h=`${c.Tools.chatAtABC(o)}${n+1}`,u=()=>{r.hidePopup()},b=j=>{var R,w,$;return($=(w=(R=i.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:R.getSheetBySheetId(j))==null?void 0:w.getName())!=null?$:""};return g.createElement(P.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:a,type:c.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:u,getSubUnitName:b,autoFocus:m==="context-menu"})},H={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var w;const r=i.get(U.SelectionManagerService),e=i.get(c.IUniverInstanceService),t=i.get(exports.SheetsThreadCommentPopupService),n=i.get(P.ThreadCommentPanelService),o=(w=r.getFirst())==null?void 0:w.primary,s=r.getCurrent(),a=i.get(exports.SheetsThreadCommentModel);if(!s||!o)return!1;const{unitId:m,sheetId:d}=s,h=U.getSheetCommandTarget(e,{unitId:m,subUnitId:d});if(!h)return!1;const{workbook:u,worksheet:b}=h,j={workbook:u,worksheet:b,unitId:m,subUnitId:d,row:o.actualRow,col:o.startColumn};t.showPopup(j);const R=a.getByLocation(m,d,o.actualRow,o.startColumn);return R&&n.setActiveComment({unitId:m,subUnitId:d,commentId:R,trigger:"context-menu"}),!0}},fe=()=>{const i=y.useDependency(D.IMarkSelectionService),r=y.useDependency(c.IUniverInstanceService),e=y.useDependency(v.ThreadCommentModel),t=y.useDependency(exports.SheetsThreadCommentPopupService),n=r.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!n)return null;const o=n.getUnitId(),s=y.useDependency(c.ICommandService),a=g.useMemo(()=>n.activeSheet$.pipe(q.map(p=>p==null?void 0:p.getSheetId())),[n.activeSheet$]),m=y.useObservable(a,n.getActiveSheet().getSheetId()),d=g.useRef(),h=y.useDependency(P.ThreadCommentPanelService),u=y.useObservable(h.activeCommentId$),b=g.useCallback(p=>{const C=n.getSheets(),I={};return C.forEach((f,O)=>{I[f.getSheetId()]=O}),p.map(f=>{var G;const O=M.singleReferenceToGrid(f.ref),ne=[(G=I[f.subUnitId])!=null?G:0,O.row,O.column];return{...f,p:ne}}).sort((f,O)=>f.p[0]===O.p[0]?f.p[1]===O.p[1]?f.p[2]-O.p[2]:f.p[1]-O.p[1]:f.p[0]-O.p[0])},[n]),j=g.useCallback(p=>{if(p.unitId===o&&p.subUnitId===m&&!p.resolved){const{row:C,column:I}=M.singleReferenceToGrid(p.ref);if(!Number.isNaN(C)&&!Number.isNaN(I))return i.addShape({range:{startColumn:I,endColumn:I,startRow:C,endRow:C},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,m,o]),R=p=>{var C,I;return(I=(C=n.getSheetBySheetId(p))==null?void 0:C.getName())!=null?I:""},w=()=>{s.executeCommand(H.id)},$=()=>{t.hidePopup()},N=p=>{u&&u.unitId===p.unitId&&u.subUnitId===p.subUnitId&&u.commentId===p.id||(d.current&&(i.removeShape(d.current),d.current=null),d.current=j(p))},L=()=>{d.current&&(i.removeShape(d.current),d.current=null)};return g.useEffect(()=>{if(!u)return;const p=e.getComment(u.unitId,u.subUnitId,u.commentId);if(!p)return;const C=j(p);return()=>{C&&i.removeShape(C)}},[j,u,e,i]),g.createElement(P.ThreadCommentPanel,{unitId:o,subUnitId$:a,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:w,getSubUnitName:R,onResolve:$,sortComments:b,onItemEnter:N,onItemLeave:L})},Se={sheetThreadComment:{menu:{addComment:"添加评论",commentManagement:"评论管理"}}},Ie=i=>({id:H.id,type:_.MenuItemType.BUTTON,positions:[_.MenuPosition.CONTEXT_MENU],icon:z,title:"sheetThreadComment.menu.addComment",hidden$:_.getMenuHiddenObservable(i,c.UniverInstanceType.UNIVER_SHEET)}),ge=i=>({id:P.ToggleSheetCommentPanelOperation.id,type:_.MenuItemType.BUTTON,icon:z,tooltip:"sheetThreadComment.menu.commentManagement",positions:_.MenuPosition.TOOLBAR_START,hidden$:_.getMenuHiddenObservable(i,c.UniverInstanceType.UNIVER_SHEET)}),Te={id:H.id,binding:_.KeyCode.M|_.MetaKeys.CTRL_COMMAND|_.MetaKeys.ALT,preconditions:D.whenSheetEditorFocused};var Me=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,be=(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&&Me(r,e,n),n},E=(i,r)=>(e,t)=>r(e,t,i);const ye={};exports.SheetsThreadCommentController=class extends c.Disposable{constructor(r,e,t,n,o,s,a,m,d,h,u){super(),this._config=r,this._menuService=e,this._injector=t,this._componentManager=n,this._localeService=o,this._commandService=s,this._sheetsThreadCommentPopupService=a,this._sheetsThreadCommentModel=m,this._threadCommentPanelService=d,this._shortcutService=h,this._univerInstanceService=u,this._initMenu(),this._initShortcut(),this._initComponent(),this._initLocale(),this._initCommandListener(),this._initPanelListener()}_initShortcut(){this._shortcutService.registerShortcut(Te)}_initCommandListener(){this._commandService.onCommandExecuted(r=>{if(r.id===U.SetSelectionsOperation.id){const e=r.params,{unitId:t,subUnitId:n,selections:o,type:s}=e;if((s===U.SelectionMoveType.MOVE_END||s===void 0)&&o[0].primary){const a=o[0].primary.actualRow,m=o[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(t,n,a,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const d=this._sheetsThreadCommentModel.getByLocation(t,n,a,m);d&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:t,subUnitId:n,commentId:d})}}if(r.id===v.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;[Ie,ge].forEach(e=>{this._menuService.addMenuItem(e(this._injector),r)})}_initComponent(){[[te,_e],[P.THREAD_COMMENT_PANEL,fe],[z,ee]].forEach(([r,e])=>{this._componentManager.register(r,e)})}_initLocale(){this._localeService.load({zhCN:Se})}_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 a=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!a||a.getUnitId()!==e)return;a.getActiveSheet().getSheetId()!==t&&await this._commandService.executeCommand(U.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t});const h=M.singleReferenceToGrid(s.ref);await this._commandService.executeCommand(D.ScrollToCellCommand.id,{range:{startColumn:h.column,endColumn:h.column,startRow:h.row,endRow:h.row}}),this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:t,row:h.row,col:h.column,commentId:s.id,trigger:o})}else this._sheetsThreadCommentPopupService.hidePopup()}))}};exports.SheetsThreadCommentController=be([c.OnLifecycle(c.LifecycleStages.Starting,exports.SheetsThreadCommentController),E(1,_.IMenuService),E(2,l.Inject(l.Injector)),E(3,l.Inject(_.ComponentManager)),E(4,l.Inject(c.LocaleService)),E(5,c.ICommandService),E(6,l.Inject(exports.SheetsThreadCommentPopupService)),E(7,l.Inject(exports.SheetsThreadCommentModel)),E(8,l.Inject(P.ThreadCommentPanelService)),E(9,_.IShortcutService),E(10,c.IUniverInstanceService)],exports.SheetsThreadCommentController);var Ue=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,we=(i,r,e,t)=>{for(var n=t>1?void 0:t?Re(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},B=(i,r)=>(e,t)=>r(e,t,i);exports.SheetsThreadCommentRefRangeController=class extends c.Disposable{constructor(e,t,n){super();S(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},a=m=>{const d=U.handleDefaultRangeChangeWithEffectRefCommands(s,m);return d&&d.startColumn===s.startColumn&&d.startRow===s.startRow?{undos:[],redos:[]}:d?{redos:[{id:v.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:M.serializeRange(d),commentId:o}}}],undos:[{id:v.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:M.serializeRange(s),commentId:o}}}]}:{redos:[{id:v.DeleteCommentMutation.id,params:{unitId:e,subUnitId:t,commentId:o}}],undos:[{id:v.AddCommentMutation.id,params:{unitId:e,subUnitId:t,comment:n}}]}};this._disposableMap.set(this._getIdWithUnitId(e,t,o),this._refRangeService.registerRefRange(s,a,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 a in s){const m=s[a],d=m.ref,h=M.singleReferenceToGrid(d);this._register(t,o,{...m,...h})}}}}_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(c.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};exports.SheetsThreadCommentRefRangeController=we([c.OnLifecycle(c.LifecycleStages.Starting,exports.SheetsThreadCommentRefRangeController),B(0,l.Inject(U.RefRangeService)),B(1,l.Inject(exports.SheetsThreadCommentModel)),B(2,l.Inject(v.ThreadCommentModel))],exports.SheetsThreadCommentRefRangeController);var Oe=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,je=(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&&Oe(r,e,n),n},x=(i,r)=>(e,t)=>r(e,t,i);let A=class extends c.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(U.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(c.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=je([c.OnLifecycle(c.LifecycleStages.Ready,A),x(0,l.Inject(U.SheetInterceptorService)),x(1,l.Inject(exports.SheetsThreadCommentModel)),x(2,c.IUniverInstanceService),x(3,l.Inject(D.SheetSkeletonManagerService)),x(4,ie.IRenderManagerService)],A);var De=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,xe=(i,r,e,t)=>{for(var n=t>1?void 0:t?$e(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},Y=(i,r)=>(e,t)=>r(e,t,i);const Ne=(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)};exports.SheetsThreadCommentCopyPasteController=class extends c.Disposable{constructor(e,t){super();S(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:a,range:m}=t,d={row:m.rows[0],column:m.cols[0]};if(o.copyType===D.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:u,subUnitId:b}=this._copyInfo,j={row:h.startRow,column:h.startColumn};if(!(s===u&&a===b)){const R=[];c.Range.foreach(h,(C,I)=>{const f=this._sheetsThreadCommentModel.getCommentWithChildren(u,b,C,I);f&&R.push(f)});const w=[],$=[],N=[],L=[],p=C=>{w.unshift({id:v.DeleteCommentMutation.id,params:{unitId:u,subUnitId:b,commentId:C.id}}),N.push({id:v.AddCommentMutation.id,params:{unitId:s,subUnitId:a,comment:{...C,ref:Ne(C.ref,j,d),unitId:s,subUnitId:a}}}),$.push({id:v.AddCommentMutation.id,params:{unitId:u,subUnitId:b,comment:C}}),L.unshift({id:v.DeleteCommentMutation.id,params:{unitId:s,subUnitId:a,commentId:C.id}})};return R.forEach(C=>{p(C.root),C.children.forEach(I=>{p(I)})}),{redos:[...w,...N],undos:[...L,...$]}}}return{redos:[],undos:[]}}}))}};exports.SheetsThreadCommentCopyPasteController=xe([c.OnLifecycle(c.LifecycleStages.Rendered,exports.SheetsThreadCommentCopyPasteController),Y(0,l.Inject(D.ISheetClipboardService)),Y(1,l.Inject(exports.SheetsThreadCommentModel))],exports.SheetsThreadCommentCopyPasteController);var Le=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,Ae=(i,r,e,t)=>{for(var n=t>1?void 0:t?Ve(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},F=(i,r)=>(e,t)=>r(e,t,i);exports.SheetsThreadCommentHoverController=class extends c.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:a}=t,m=this._sheetsThreadCommentModel.getByLocation(n,o,s,a);if(m){const d=this._sheetsThreadCommentModel.getComment(n,o,m);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:o,row:s,col:a,commentId:m,temp:!0})}else e&&this._sheetsThreadCommentPopupService.hidePopup()}})}};exports.SheetsThreadCommentHoverController=Ae([c.OnLifecycle(c.LifecycleStages.Rendered,exports.SheetsThreadCommentHoverController),F(0,l.Inject(D.HoverManagerService)),F(1,l.Inject(exports.SheetsThreadCommentPopupService)),F(2,l.Inject(exports.SheetsThreadCommentModel))],exports.SheetsThreadCommentHoverController);var He=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Fe=(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&&He(r,e,n),n},W=(i,r)=>(e,t)=>r(e,t,i);exports.ThreadCommentRemoveSheetsController=class extends c.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===U.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 n=t.getUnitId(),o=e.subUnitId||t.getActiveSheet().getSheetId(),{commentMap:s}=this._threadCommentModel.ensureMap(n,o),a=Array.from(Object.keys(s)),m=Array.from(Object.values(s)),d=a.map(u=>({id:v.DeleteCommentMutation.id,params:{unitId:n,subUnitId:o,commentId:u}})),h=m.map(u=>({id:v.AddCommentMutation.id,params:{unitId:n,subUnitId:o,comment:u}}));return{redos:d,undos:h}}return{redos:[],undos:[]}}}))}};exports.ThreadCommentRemoveSheetsController=Fe([c.OnLifecycle(c.LifecycleStages.Ready,exports.ThreadCommentRemoveSheetsController),W(0,l.Inject(U.SheetInterceptorService)),W(1,c.IUniverInstanceService),W(2,l.Inject(v.ThreadCommentModel))],exports.ThreadCommentRemoveSheetsController);var We=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,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&&We(r,e,n),n},X=(i,r)=>(e,t)=>r(e,t,i),V;exports.UniverSheetsThreadCommentPlugin=(V=class extends P.UniverThreadCommentUIPlugin{constructor(e={},t,n){super(e,t,n);S(this,"_pluginConfig");this._injector=t,this._commandService=n,this._pluginConfig=c.Tools.deepMerge({},ye,e)}onStarting(e){super.onStarting(e),[[exports.SheetsThreadCommentModel],[exports.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(exports.SheetsThreadCommentController,this._pluginConfig)}],[exports.SheetsThreadCommentRefRangeController],[A],[exports.SheetsThreadCommentCopyPasteController],[exports.SheetsThreadCommentHoverController],[exports.ThreadCommentRemoveSheetsController],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[H].forEach(t=>{this._commandService.registerCommand(t)})}},S(V,"pluginName",Z),S(V,"type",c.UniverInstanceType.UNIVER_SHEET),V);exports.UniverSheetsThreadCommentPlugin=ze([X(1,l.Inject(l.Injector)),X(2,l.Inject(c.ICommandService))],exports.UniverSheetsThreadCommentPlugin);Object.defineProperty(exports,"Inject",{enumerable:!0,get:()=>l.Inject});Object.defineProperty(exports,"Injector",{enumerable:!0,get:()=>l.Injector});Object.defineProperty(exports,"ICommandService",{enumerable:!0,get:()=>c.ICommandService});Object.defineProperty(exports,"Plugin",{enumerable:!0,get:()=>c.Plugin});Object.defineProperty(exports,"UniverInstanceType",{enumerable:!0,get:()=>c.UniverInstanceType});Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>P.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>v.IThreadCommentDataSourceService});exports.SHEETS_THREAD_COMMENT=Z;
|
|
1
|
+
"use strict";var re=Object.defineProperty;var oe=(i,r,e)=>r in i?re(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var g=(i,r,e)=>(oe(i,typeof r!="symbol"?r+"":r,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@wendellhu/redi"),c=require("@univerjs/core"),b=require("@univerjs/thread-comment-ui"),_=require("@univerjs/ui"),v=require("@univerjs/sheets"),M=require("@univerjs/engine-formula"),j=require("@univerjs/sheets-ui"),f=require("@univerjs/thread-comment"),U=require("@wendellhu/redi/react-bindings"),T=require("react"),H=require("rxjs"),ie=require("@univerjs/engine-render");var P=function(){return P=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},P.apply(this,arguments)},se=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},J=T.forwardRef(function(i,r){var e=i.icon,t=i.id,n=i.className,o=i.extend,s=se(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(n||"").trim(),m=T.useRef("_".concat(me()));return Q(e,"".concat(t),{defIds:e.defIds,idSuffix:m.current},P({ref:r,className:a},s),o)});function Q(i,r,e,t,n){return T.createElement(i.tag,P(P({key:r},ae(i,e,n)),t),(ce(i,e).children||[]).map(function(o,s){return Q(o,"".concat(r,"-").concat(i.tag,"-").concat(s),e,void 0,n)}))}function ae(i,r,e){var t=P({},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],a=o[1];typeof a=="string"&&(t[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),t}function ce(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)?P(P({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&t&&t.indexOf(n.attrs.id)>-1?P(P({},n),{attrs:P(P({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function me(){return Math.random().toString(36).substring(2,8)}J.displayName="UniverIcon";var de={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ee=T.forwardRef(function(i,r){return T.createElement(J,Object.assign({},i,{id:"comment-single",ref:r,icon:de}))});ee.displayName="CommentSingle";var he=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,le=(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&&he(r,e,n),n},G=(i,r)=>(e,t)=>r(e,t,i);exports.SheetsThreadCommentModel=class extends c.Disposable{constructor(e,t){super();g(this,"_matrixMap",new Map);g(this,"_locationMap",new Map);g(this,"_commentUpdate$",new H.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 c.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 a in s){const m=s[a];this._addComment(t,o,m)}}}}_addComment(e,t,n){const o=M.singleReferenceToGrid(n.ref),s=n.parentId,{row:a,column:m}=o,d=n.id,{matrix:h,locationMap:u}=this._ensure(e,t);!s&&a>=0&&m>=0&&(h.setValue(a,m,d),u.set(d,{row:a,column:m})),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)!==c.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:a,comment:m}=e.payload,d=M.singleReferenceToGrid(m.ref);if(a){const{row:h,column:u}=d;h>=0&&u>=0&&o.realDeleteValue(h,u)}this._commentUpdate$.next({...e,...d});break}case"update":{const{commentId:a}=e.payload,m=this._threadCommentModel.getComment(t,n,a);if(!m)return;const d=M.singleReferenceToGrid(m.ref);this._commentUpdate$.next({...e,...d});break}case"updateRef":{const a=M.singleReferenceToGrid(e.payload.ref),{commentId:m}=e.payload,d=s.get(m);if(!d)return;const{row:h,column:u}=d;o.getValue(h,u)===m&&(o.realDeleteValue(h,u),s.delete(m)),a.row>=0&&a.column>=0&&(o.setValue(a.row,a.column,m),s.set(m,{row:a.row,column:a.column})),this._commentUpdate$.next({...e,...a});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 a=this._ensureCommentMatrix(e,t).getValue(n,o);if(a)return this._threadCommentModel.getCommentWithChildren(e,t,a)}showCommentMarker(e,t,n,o){const s=this.getByLocation(e,t,n,o);if(!s)return!1;const a=this.getComment(e,t,s);return!!(a&&!a.resolved)}};exports.SheetsThreadCommentModel=le([G(0,l.Inject(f.ThreadCommentModel)),G(1,c.IUniverInstanceService)],exports.SheetsThreadCommentModel);const te="univer.sheet.thread-comment-modal",q="comment-single",Z="univer.sheet.thread-comment";var pe=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,ve=(i,r,e,t)=>{for(var n=t>1?void 0:t?Ce(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&&pe(r,e,n),n},K=(i,r)=>(e,t)=>r(e,t,i);exports.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(e,t){super();g(this,"_lastPopup",null);g(this,"_activePopup");g(this,"_activePopup$",new H.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 h;const{row:n,col:o,unitId:s,subUnitId:a}=e;if(this._activePopup&&n===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&a===((h=this.activePopup)==null?void 0:h.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 m=this._canvasPopupManagerService.attachPopupToCell(n,o,{componentKey:te,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new c.DisposableCollection;d.add(m),d.add({dispose:()=>{t==null||t()}}),this._lastPopup=d}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=ve([K(0,l.Inject(j.SheetCanvasPopManagerService)),K(1,_.IZenZoneService)],exports.SheetsThreadCommentPopupService);const _e=()=>{const i=U.useDependency(c.IUniverInstanceService),r=U.useDependency(exports.SheetsThreadCommentPopupService),e=_.useObservable(r.activePopup$),t=U.useDependency(exports.SheetsThreadCommentModel);if(_.useObservable(t.commentUpdate$),!e)return null;const{row:n,col:o,unitId:s,subUnitId:a,trigger:m}=e,d=t.getByLocation(s,a,n,o),h=`${c.Tools.chatAtABC(o)}${n+1}`,u=()=>{r.hidePopup()},y=D=>{var R,w,$;return($=(w=(R=i.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:R.getSheetBySheetId(D))==null?void 0:w.getName())!=null?$:""};return T.createElement(b.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:a,type:c.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:u,getSubUnitName:y,autoFocus:m==="context-menu"})},W={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var w;const r=i.get(v.SelectionManagerService),e=i.get(c.IUniverInstanceService),t=i.get(exports.SheetsThreadCommentPopupService),n=i.get(b.ThreadCommentPanelService),o=(w=r.getFirst())==null?void 0:w.primary,s=r.getCurrent(),a=i.get(exports.SheetsThreadCommentModel);if(!s||!o)return!1;const{unitId:m,sheetId:d}=s,h=v.getSheetCommandTarget(e,{unitId:m,subUnitId:d});if(!h)return!1;const{workbook:u,worksheet:y}=h,D={workbook:u,worksheet:y,unitId:m,subUnitId:d,row:o.actualRow,col:o.startColumn};t.showPopup(D);const R=a.getByLocation(m,d,o.actualRow,o.startColumn);return R&&n.setActiveComment({unitId:m,subUnitId:d,commentId:R,trigger:"context-menu"}),!0}},fe=()=>{const i=U.useDependency(j.IMarkSelectionService),r=U.useDependency(c.IUniverInstanceService),e=U.useDependency(f.ThreadCommentModel),t=U.useDependency(exports.SheetsThreadCommentPopupService),n=r.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!n)return null;const o=n.getUnitId(),s=U.useDependency(c.ICommandService),a=T.useMemo(()=>n.activeSheet$.pipe(H.map(p=>p==null?void 0:p.getSheetId())),[n.activeSheet$]),m=U.useObservable(a,n.getActiveSheet().getSheetId()),d=T.useRef(),h=U.useDependency(b.ThreadCommentPanelService),u=U.useObservable(h.activeCommentId$),y=T.useCallback(p=>{const C=n.getSheets(),I={};return C.forEach((S,O)=>{I[S.getSheetId()]=O}),p.map(S=>{var z;const O=M.singleReferenceToGrid(S.ref),ne=[(z=I[S.subUnitId])!=null?z:0,O.row,O.column];return{...S,p:ne}}).sort((S,O)=>S.p[0]===O.p[0]?S.p[1]===O.p[1]?S.p[2]-O.p[2]:S.p[1]-O.p[1]:S.p[0]-O.p[0])},[n]),D=T.useCallback(p=>{if(p.unitId===o&&p.subUnitId===m&&!p.resolved){const{row:C,column:I}=M.singleReferenceToGrid(p.ref);if(!Number.isNaN(C)&&!Number.isNaN(I))return i.addShape({range:{startColumn:I,endColumn:I,startRow:C,endRow:C},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,m,o]),R=p=>{var C,I;return(I=(C=n.getSheetBySheetId(p))==null?void 0:C.getName())!=null?I:""},w=()=>{s.executeCommand(W.id)},$=()=>{t.hidePopup()},N=p=>{u&&u.unitId===p.unitId&&u.subUnitId===p.subUnitId&&u.commentId===p.id||(d.current&&(i.removeShape(d.current),d.current=null),d.current=D(p))},L=()=>{d.current&&(i.removeShape(d.current),d.current=null)};return T.useEffect(()=>{if(!u)return;const p=e.getComment(u.unitId,u.subUnitId,u.commentId);if(!p)return;const C=D(p);return()=>{C&&i.removeShape(C)}},[D,u,e,i]),T.createElement(b.ThreadCommentPanel,{unitId:o,subUnitId$:a,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:w,getSubUnitName:R,onResolve:$,sortComments:y,onItemEnter:N,onItemLeave:L})},Se=i=>({id:W.id,type:_.MenuItemType.BUTTON,positions:[_.MenuPosition.CONTEXT_MENU],icon:q,title:"sheetThreadComment.menu.addComment",hidden$:_.getMenuHiddenObservable(i,c.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCommentDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionEditPoint]})}),ge=i=>({id:b.ToggleSheetCommentPanelOperation.id,type:_.MenuItemType.BUTTON,icon:q,tooltip:"sheetThreadComment.menu.commentManagement",positions:_.MenuPosition.TOOLBAR_START,group:_.MenuGroup.TOOLBAR_OTHERS,disabled$:j.getCommentDisable$(i,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(i,c.UniverInstanceType.UNIVER_SHEET)}),Ie={id:W.id,binding:_.KeyCode.M|_.MetaKeys.CTRL_COMMAND|_.MetaKeys.ALT,preconditions:j.whenSheetEditorFocused};var Te=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Me=(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&&Te(r,e,n),n},E=(i,r)=>(e,t)=>r(e,t,i);const be={};exports.SheetsThreadCommentController=class extends c.Disposable{constructor(r,e,t,n,o,s,a,m,d,h,u){super(),this._config=r,this._menuService=e,this._injector=t,this._componentManager=n,this._localeService=o,this._commandService=s,this._sheetsThreadCommentPopupService=a,this._sheetsThreadCommentModel=m,this._threadCommentPanelService=d,this._shortcutService=h,this._univerInstanceService=u,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener()}_initShortcut(){this._shortcutService.registerShortcut(Ie)}_initCommandListener(){this._commandService.onCommandExecuted(r=>{if(r.id===v.SetSelectionsOperation.id){const e=r.params,{unitId:t,subUnitId:n,selections:o,type:s}=e;if((s===v.SelectionMoveType.MOVE_END||s===void 0)&&o[0].primary){const a=o[0].primary.actualRow,m=o[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(t,n,a,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(b.SetActiveCommentOperation.id);return}const d=this._sheetsThreadCommentModel.getByLocation(t,n,a,m);d&&this._commandService.executeCommand(b.SetActiveCommentOperation.id,{unitId:t,subUnitId:n,commentId:d})}}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;[Se,ge].forEach(e=>{this._menuService.addMenuItem(e(this._injector),r)})}_initComponent(){[[te,_e],[b.THREAD_COMMENT_PANEL,fe],[q,ee]].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 a=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!a||a.getUnitId()!==e)return;a.getActiveSheet().getSheetId()!==t&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t});const h=M.singleReferenceToGrid(s.ref);await this._commandService.executeCommand(j.ScrollToCellCommand.id,{range:{startColumn:h.column,endColumn:h.column,startRow:h.row,endRow:h.row}}),this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:t,row:h.row,col:h.column,commentId:s.id,trigger:o})}else this._sheetsThreadCommentPopupService.hidePopup()}))}};exports.SheetsThreadCommentController=Me([c.OnLifecycle(c.LifecycleStages.Starting,exports.SheetsThreadCommentController),E(1,_.IMenuService),E(2,l.Inject(l.Injector)),E(3,l.Inject(_.ComponentManager)),E(4,l.Inject(c.LocaleService)),E(5,c.ICommandService),E(6,l.Inject(exports.SheetsThreadCommentPopupService)),E(7,l.Inject(exports.SheetsThreadCommentModel)),E(8,l.Inject(b.ThreadCommentPanelService)),E(9,_.IShortcutService),E(10,c.IUniverInstanceService)],exports.SheetsThreadCommentController);var ye=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&&ye(r,e,n),n},B=(i,r)=>(e,t)=>r(e,t,i);exports.SheetsThreadCommentRefRangeController=class extends c.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},a=m=>{const d=v.handleDefaultRangeChangeWithEffectRefCommands(s,m);return d&&d.startColumn===s.startColumn&&d.startRow===s.startRow?{undos:[],redos:[]}:d?{redos:[{id:f.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:M.serializeRange(d),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,a,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 a in s){const m=s[a],d=m.ref,h=M.singleReferenceToGrid(d);this._register(t,o,{...m,...h})}}}}_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(c.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};exports.SheetsThreadCommentRefRangeController=Re([c.OnLifecycle(c.LifecycleStages.Starting,exports.SheetsThreadCommentRefRangeController),B(0,l.Inject(v.RefRangeService)),B(1,l.Inject(exports.SheetsThreadCommentModel)),B(2,l.Inject(f.ThreadCommentModel))],exports.SheetsThreadCommentRefRangeController);var we=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Ee=(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},x=(i,r)=>(e,t)=>r(e,t,i);let A=class extends c.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(v.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(c.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=Ee([c.OnLifecycle(c.LifecycleStages.Ready,A),x(0,l.Inject(v.SheetInterceptorService)),x(1,l.Inject(exports.SheetsThreadCommentModel)),x(2,c.IUniverInstanceService),x(3,l.Inject(j.SheetSkeletonManagerService)),x(4,ie.IRenderManagerService)],A);var je=Object.defineProperty,De=Object.getOwnPropertyDescriptor,$e=(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&&je(r,e,n),n},Y=(i,r)=>(e,t)=>r(e,t,i);const xe=(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)};exports.SheetsThreadCommentCopyPasteController=class extends c.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:a,range:m}=t,d={row:m.rows[0],column:m.cols[0]};if(o.copyType===j.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:u,subUnitId:y}=this._copyInfo,D={row:h.startRow,column:h.startColumn};if(!(s===u&&a===y)){const R=[];c.Range.foreach(h,(C,I)=>{const S=this._sheetsThreadCommentModel.getCommentWithChildren(u,y,C,I);S&&R.push(S)});const w=[],$=[],N=[],L=[],p=C=>{w.unshift({id:f.DeleteCommentMutation.id,params:{unitId:u,subUnitId:y,commentId:C.id}}),N.push({id:f.AddCommentMutation.id,params:{unitId:s,subUnitId:a,comment:{...C,ref:xe(C.ref,D,d),unitId:s,subUnitId:a}}}),$.push({id:f.AddCommentMutation.id,params:{unitId:u,subUnitId:y,comment:C}}),L.unshift({id:f.DeleteCommentMutation.id,params:{unitId:s,subUnitId:a,commentId:C.id}})};return R.forEach(C=>{p(C.root),C.children.forEach(I=>{p(I)})}),{redos:[...w,...N],undos:[...L,...$]}}}return{redos:[],undos:[]}}}))}};exports.SheetsThreadCommentCopyPasteController=$e([c.OnLifecycle(c.LifecycleStages.Rendered,exports.SheetsThreadCommentCopyPasteController),Y(0,l.Inject(j.ISheetClipboardService)),Y(1,l.Inject(exports.SheetsThreadCommentModel))],exports.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);exports.SheetsThreadCommentHoverController=class extends c.Disposable{constructor(r,e,t){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=e,this._sheetsThreadCommentModel=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(H.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:a}=t,m=this._sheetsThreadCommentModel.getByLocation(n,o,s,a);if(m){const d=this._sheetsThreadCommentModel.getComment(n,o,m);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:n,subUnitId:o,row:s,col:a,commentId:m,temp:!0})}else e&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};exports.SheetsThreadCommentHoverController=Ve([c.OnLifecycle(c.LifecycleStages.Rendered,exports.SheetsThreadCommentHoverController),F(0,l.Inject(j.HoverManagerService)),F(1,l.Inject(exports.SheetsThreadCommentPopupService)),F(2,l.Inject(exports.SheetsThreadCommentModel))],exports.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);exports.ThreadCommentRemoveSheetsController=class extends c.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===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 n=t.getUnitId(),o=e.subUnitId||t.getActiveSheet().getSheetId(),{commentMap:s}=this._threadCommentModel.ensureMap(n,o),a=Array.from(Object.keys(s)),m=Array.from(Object.values(s)),d=a.map(u=>({id:f.DeleteCommentMutation.id,params:{unitId:n,subUnitId:o,commentId:u}})),h=m.map(u=>({id:f.AddCommentMutation.id,params:{unitId:n,subUnitId:o,comment:u}}));return{redos:d,undos:h}}return{redos:[],undos:[]}}}))}};exports.ThreadCommentRemoveSheetsController=We([c.OnLifecycle(c.LifecycleStages.Ready,exports.ThreadCommentRemoveSheetsController),k(0,l.Inject(v.SheetInterceptorService)),k(1,c.IUniverInstanceService),k(2,l.Inject(f.ThreadCommentModel))],exports.ThreadCommentRemoveSheetsController);var Be=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,ke=(i,r,e,t)=>{for(var n=t>1?void 0:t?Fe(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},X=(i,r)=>(e,t)=>r(e,t,i),V;exports.UniverSheetsThreadCommentPlugin=(V=class extends b.UniverThreadCommentUIPlugin{constructor(e={},t,n){super(e,t,n);g(this,"_pluginConfig");this._injector=t,this._commandService=n,this._pluginConfig=c.Tools.deepMerge({},be,e)}onStarting(e){super.onStarting(e),[[exports.SheetsThreadCommentModel],[exports.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(exports.SheetsThreadCommentController,this._pluginConfig)}],[exports.SheetsThreadCommentRefRangeController],[A],[exports.SheetsThreadCommentCopyPasteController],[exports.SheetsThreadCommentHoverController],[exports.ThreadCommentRemoveSheetsController],[exports.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[W].forEach(t=>{this._commandService.registerCommand(t)})}},g(V,"pluginName",Z),g(V,"type",c.UniverInstanceType.UNIVER_SHEET),V);exports.UniverSheetsThreadCommentPlugin=ke([X(1,l.Inject(l.Injector)),X(2,l.Inject(c.ICommandService))],exports.UniverSheetsThreadCommentPlugin);Object.defineProperty(exports,"Inject",{enumerable:!0,get:()=>l.Inject});Object.defineProperty(exports,"Injector",{enumerable:!0,get:()=>l.Injector});Object.defineProperty(exports,"ICommandService",{enumerable:!0,get:()=>c.ICommandService});Object.defineProperty(exports,"Plugin",{enumerable:!0,get:()=>c.Plugin});Object.defineProperty(exports,"UniverInstanceType",{enumerable:!0,get:()=>c.UniverInstanceType});Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>b.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>b.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>f.IThreadCommentDataSourceService});exports.SHEETS_THREAD_COMMENT=Z;
|