@univerjs/sheets-thread-comment-ui 0.17.0 → 0.18.0

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.
Files changed (77) hide show
  1. package/lib/cjs/index.js +1 -1
  2. package/lib/cjs/locale/ca-ES.js +1 -1
  3. package/lib/cjs/locale/en-US.js +1 -1
  4. package/lib/cjs/locale/es-ES.js +1 -1
  5. package/lib/cjs/locale/fa-IR.js +1 -1
  6. package/lib/cjs/locale/fr-FR.js +1 -1
  7. package/lib/cjs/locale/ja-JP.js +1 -1
  8. package/lib/cjs/locale/ko-KR.js +1 -1
  9. package/lib/cjs/locale/ru-RU.js +1 -1
  10. package/lib/cjs/locale/sk-SK.js +1 -1
  11. package/lib/cjs/locale/vi-VN.js +1 -1
  12. package/lib/cjs/locale/zh-CN.js +1 -1
  13. package/lib/cjs/locale/zh-TW.js +1 -1
  14. package/lib/es/index.js +1 -828
  15. package/lib/es/locale/ca-ES.js +1 -11
  16. package/lib/es/locale/en-US.js +1 -11
  17. package/lib/es/locale/es-ES.js +1 -11
  18. package/lib/es/locale/fa-IR.js +1 -11
  19. package/lib/es/locale/fr-FR.js +1 -11
  20. package/lib/es/locale/ja-JP.js +1 -11
  21. package/lib/es/locale/ko-KR.js +1 -11
  22. package/lib/es/locale/ru-RU.js +1 -11
  23. package/lib/es/locale/sk-SK.js +1 -11
  24. package/lib/es/locale/vi-VN.js +1 -11
  25. package/lib/es/locale/zh-CN.js +1 -11
  26. package/lib/es/locale/zh-TW.js +1 -11
  27. package/lib/index.css +1 -0
  28. package/lib/index.js +1 -828
  29. package/lib/locale/ca-ES.js +1 -11
  30. package/lib/locale/en-US.js +1 -11
  31. package/lib/locale/es-ES.js +1 -11
  32. package/lib/locale/fa-IR.js +1 -11
  33. package/lib/locale/fr-FR.js +1 -11
  34. package/lib/locale/ja-JP.js +1 -11
  35. package/lib/locale/ko-KR.js +1 -11
  36. package/lib/locale/ru-RU.js +1 -11
  37. package/lib/locale/sk-SK.js +1 -11
  38. package/lib/locale/vi-VN.js +1 -11
  39. package/lib/locale/zh-CN.js +1 -11
  40. package/lib/locale/zh-TW.js +1 -11
  41. package/lib/types/commands/operations/comment.operation.d.ts +16 -1
  42. package/lib/types/config/config.d.ts +17 -2
  43. package/lib/types/controllers/render-controllers/render.controller.d.ts +15 -0
  44. package/lib/types/controllers/sheets-thread-comment-copy-paste.controller.d.ts +15 -0
  45. package/lib/types/controllers/sheets-thread-comment-hover.controller.d.ts +15 -0
  46. package/lib/types/controllers/sheets-thread-comment-popup.controller.d.ts +15 -0
  47. package/lib/types/controllers/sheets-thread-comment.controller.d.ts +15 -0
  48. package/lib/types/locale/ca-ES.d.ts +16 -1
  49. package/lib/types/locale/es-ES.d.ts +16 -1
  50. package/lib/types/locale/fa-IR.d.ts +16 -1
  51. package/lib/types/locale/fr-FR.d.ts +16 -1
  52. package/lib/types/locale/ja-JP.d.ts +16 -1
  53. package/lib/types/locale/ko-KR.d.ts +16 -1
  54. package/lib/types/locale/ru-RU.d.ts +16 -1
  55. package/lib/types/locale/sk-SK.d.ts +16 -1
  56. package/lib/types/locale/vi-VN.d.ts +16 -1
  57. package/lib/types/locale/zh-CN.d.ts +16 -1
  58. package/lib/types/locale/zh-TW.d.ts +16 -1
  59. package/lib/types/menu/menu.d.ts +22 -6
  60. package/lib/types/menu/schema.d.ts +16 -1
  61. package/lib/types/plugin.d.ts +16 -1
  62. package/lib/types/services/sheets-thread-comment-popup.service.d.ts +19 -3
  63. package/lib/types/types/interfaces/i-sheet-thread-comment.d.ts +16 -1
  64. package/lib/umd/index.js +1 -1
  65. package/lib/umd/locale/ca-ES.js +1 -1
  66. package/lib/umd/locale/en-US.js +1 -1
  67. package/lib/umd/locale/es-ES.js +1 -1
  68. package/lib/umd/locale/fa-IR.js +1 -1
  69. package/lib/umd/locale/fr-FR.js +1 -1
  70. package/lib/umd/locale/ja-JP.js +1 -1
  71. package/lib/umd/locale/ko-KR.js +1 -1
  72. package/lib/umd/locale/ru-RU.js +1 -1
  73. package/lib/umd/locale/sk-SK.js +1 -1
  74. package/lib/umd/locale/vi-VN.js +1 -1
  75. package/lib/umd/locale/zh-CN.js +1 -1
  76. package/lib/umd/locale/zh-TW.js +1 -1
  77. package/package.json +15 -14
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var me=Object.defineProperty;var he=(r,e,n)=>e in r?me(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var k=(r,e,n)=>he(r,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),$=require("@univerjs/sheets-thread-comment"),f=require("@univerjs/thread-comment-ui"),P=require("@univerjs/sheets-ui"),u=require("@univerjs/ui"),V=require("rxjs"),te=require("@univerjs/engine-render"),N=require("@univerjs/engine-formula"),w=require("@univerjs/thread-comment"),R=require("react"),ne=require("react/jsx-runtime"),re="univer.sheet.thread-comment-modal",Q="SHEET_THREAD_COMMENT";var de=Object.getOwnPropertyDescriptor,ue=(r,e,n,t)=>{for(var o=t>1?void 0:t?de(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},z=(r,e)=>(n,t)=>e(n,t,r);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,t,o){super();k(this,"_lastPopup",null);k(this,"_activePopup");k(this,"_activePopup$",new V.BehaviorSubject(null));k(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=t,this._cellPopupManagerService=o,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(n,t){var l;const{row:o,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&o===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._cellPopupManagerService.showPopup({row:o,col:i,unitId:s,subUnitId:c},{componentKey:re,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean),priority:2});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new a.DisposableCollection;h.add(m),h.add({dispose:()=>{t==null||t()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=ue([z(0,a.Inject(P.SheetCanvasPopManagerService)),z(1,u.IZenZoneService),z(2,a.Inject(P.CellPopupManagerService))],exports.SheetsThreadCommentPopupService);const j={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(r){var _;const e=r.get(C.SheetsSelectionsService),n=r.get(a.IUniverInstanceService),t=r.get(exports.SheetsThreadCommentPopupService),o=r.get(f.ThreadCommentPanelService),i=(_=e.getCurrentLastSelection())==null?void 0:_.primary,s=r.get($.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(n);if(!c)return!1;const{workbook:m,worksheet:h,unitId:l,subUnitId:d}=c,S={workbook:m,worksheet:h,unitId:l,subUnitId:d,row:i.startRow,col:i.startColumn};t.showPopup(S);const v=s.getByLocation(l,d,i.startRow,i.startColumn);return v&&o.setActiveComment({unitId:l,subUnitId:d,commentId:v,trigger:"context-menu"}),!0}},le="@univerjs/sheets-thread-comment-ui",pe="0.17.0",oe={name:le,version:pe},Ce="sheets-thread-comment.config",ee={};var ve=Object.getOwnPropertyDescriptor,Se=(r,e,n,t)=>{for(var o=t>1?void 0:t?ve(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},x=(r,e)=>(n,t)=>e(n,t,r);let B=class extends a.Disposable{constructor(r,e,n,t){super(),this._sheetInterceptorService=r,this._sheetsThreadCommentModel=e,this._univerInstanceService=n,this._renderManagerService=t,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(r,e,n)=>{const{row:t,col:o,unitId:i,subUnitId:s}=e;return this._sheetsThreadCommentModel.showCommentMarker(i,s,t,o)&&((!r||r===e.rawData)&&(r={...e.rawData}),r.markers={...r==null?void 0:r.markers,tr:{color:"#FFBD37",size:6}}),n(r)},priority:100}))}_initSkeletonChange(){const r=()=>{var o;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return;const n=e.getUnitId(),t=this._renderManagerService.getRenderById(n);(o=t==null?void 0:t.mainComponent)==null||o.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(V.debounceTime(16)).subscribe(()=>{r()}))}};B=Se([x(0,a.Inject(C.SheetInterceptorService)),x(1,a.Inject($.SheetsThreadCommentModel)),x(2,a.IUniverInstanceService),x(3,te.IRenderManagerService)],B);var _e=Object.getOwnPropertyDescriptor,ge=(r,e,n,t)=>{for(var o=t>1?void 0:t?_e(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},K=(r,e)=>(n,t)=>e(n,t,r);const Ie=(r,e,n)=>{const t=N.singleReferenceToGrid(r),o=n.row-e.row,i=n.column-e.column,s={startColumn:t.column+i,startRow:t.row+o,endColumn:t.column+i,endRow:t.row+o};return N.serializeRange(s)};let L=class extends a.Disposable{constructor(e,n,t){super();k(this,"_copyInfo");this._sheetClipboardService=e,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(e,n,t)=>{this._copyInfo={unitId:e,subUnitId:n,range:t}},onPasteCells:(e,n,t,o)=>{const{unitId:i,subUnitId:s,range:c}=n,m={row:c.rows[0],column:c.cols[0]};if(o.copyType===P.COPY_TYPE.CUT&&this._copyInfo){const{range:h,unitId:l,subUnitId:d}=this._copyInfo,S={row:h.startRow,column:h.startColumn};if(!(i===l&&s===d)){const v=[];a.Range.foreach(h,(b,p)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(l,d,b,p);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(g=>{v.push(g)}):M.forEach(({children:g,...U})=>{U.parentId||v.push(U)})});const _=[],T=[],D=[],A=[],G=b=>{_.unshift({id:w.DeleteCommentMutation.id,params:{unitId:l,subUnitId:d,commentId:b.id}}),D.push({id:w.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...b,ref:Ie(b.ref,S,m),unitId:i,subUnitId:s},sync:!0}}),T.push({id:w.AddCommentMutation.id,params:{unitId:l,subUnitId:d,comment:b,sync:!0}}),A.unshift({id:w.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:b.id}})};return v.forEach(b=>{G(b)}),{redos:[..._,...D],undos:[...A,...T]}}}return{redos:[],undos:[]}}}))}};L=ge([K(0,a.Inject(P.ISheetClipboardService)),K(1,a.Inject($.SheetsThreadCommentModel)),K(2,w.IThreadCommentDataSourceService)],L);var fe=Object.getOwnPropertyDescriptor,Pe=(r,e,n,t)=>{for(var o=t>1?void 0:t?fe(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},H=(r,e)=>(n,t)=>e(n,t,r);let W=class extends a.Disposable{constructor(r,e,n,t){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=e,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=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:n}=r,{unitId:t,subUnitId:o,row:i,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(t,o,i,s);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}],t,o))return;const h=this._sheetsThreadCommentModel.getComment(t,o,c);h&&!h.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:o,row:i,col:s,commentId:c,temp:!0})}else e&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};W=Pe([H(0,a.Inject(P.HoverManagerService)),H(1,a.Inject(exports.SheetsThreadCommentPopupService)),H(2,a.Inject($.SheetsThreadCommentModel)),H(3,a.Inject(C.SheetPermissionCheckController))],W);var Te=Object.getOwnPropertyDescriptor,be=(r,e,n,t)=>{for(var o=t>1?void 0:t?Te(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},E=(r,e)=>(n,t)=>e(n,t,r);let F=class extends a.Disposable{constructor(e,n,t,o,i,s,c,m,h,l){super();k(this,"_isSwitchToCommenting",!1);k(this,"_selectionShapeInfo",null);this._commandService=e,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=t,this._threadCommentPanelService=o,this._univerInstanceService=i,this._sheetPermissionCheckController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=h,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(e,n,t){var S,v,_;const o=(S=e[0])==null?void 0:S.range,i=this._renderManagerService.getRenderById(n),s=(v=i==null?void 0:i.with(P.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:v.skeleton;if(!s||!o)return;const c=s.getCellWithCoordByIndex(o.startRow,o.startColumn);if((((_=o.rangeType)!=null?_:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||o.endColumn-o.startColumn>0||o.endRow-o.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,o))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(f.SetActiveCommentOperation.id);return}const h=c.actualRow,l=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,t,h,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(f.SetActiveCommentOperation.id);return}const d=this._sheetsThreadCommentModel.getByLocation(n,t,h,l);d&&this._commandService.executeCommand(f.SetActiveCommentOperation.id,{unitId:n,subUnitId:t,commentId:d})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(e,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(e=>{if(e.id===w.DeleteCommentMutation.id){const n=e.params,t=this._sheetsThreadCommentPopupService.activePopup;if(!t)return;const{unitId:o,subUnitId:i,commentId:s}=t;n.unitId===o&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async e=>{var n;if(e){const{unitId:t,subUnitId:o,commentId:i,trigger:s}=e,c=this._sheetsThreadCommentModel.getComment(t,o,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==t)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==o&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:o}),this._isSwitchToCommenting=!1;const d=N.singleReferenceToGrid(c.ref),{row:S,column:v}=d;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:S,startColumn:v,endRow:S,endColumn:v}],t,o))return;const T=1;if(await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-T,0),endRow:d.row+T,startColumn:Math.max(d.column-T,0),endColumn:d.column+T}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:o,row:d.row,col:d.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(V.debounceTime(100)).subscribe(e=>{var S,v;if(!e){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:t,commentId:o}=e;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,t,o);if(!i)return;const s=N.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const h=(S=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getSheetBySheetId(t),l=(v=h==null?void 0:h.getMergedCell(c,m))!=null?v:{startColumn:m,endColumn:m,startRow:c,endRow:c},d=this._markSelectionService.addShape({range:l,style:{fill:"rgba(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);d&&(this._selectionShapeInfo={...e,shapeId:d})}))}};F=be([E(0,a.ICommandService),E(1,a.Inject(exports.SheetsThreadCommentPopupService)),E(2,a.Inject($.SheetsThreadCommentModel)),E(3,a.Inject(f.ThreadCommentPanelService)),E(4,a.IUniverInstanceService),E(5,a.Inject(C.SheetPermissionCheckController)),E(6,P.IMarkSelectionService),E(7,a.Inject(C.SheetsSelectionsService)),E(8,P.IEditorBridgeService),E(9,te.IRenderManagerService)],F);function ie({ref:r,...e}){const{icon:n,id:t,className:o,extend:i,...s}=e,c=`univerjs-icon univerjs-icon-${t} ${o||""}`.trim(),m=R.useRef(`_${ye()}`);return se(n,`${t}`,{defIds:n.defIds,idSuffix:m.current},{ref:r,className:c,...s},i)}function se(r,e,n,t,o){return R.createElement(r.tag,{key:e,...Me(r,n,o),...t},(we(r,n).children||[]).map((i,s)=>se(i,`${e}-${r.tag}-${s}`,n,void 0,o)))}function Me(r,e,n){const t={...r.attrs};n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1),r.tag==="mask"&&t.id&&(t.id=t.id+e.idSuffix),Object.entries(t).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(t[i]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(r.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(([i,s])=>{typeof s=="string"&&(t[i]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),t}function we(r,e){var t;const{defIds:n}=e;return!n||n.length===0?r:r.tag==="defs"&&((t=r.children)!=null&&t.length)?{...r,children:r.children.map(o=>typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:r}function ye(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";const Ue={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.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.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.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"}},{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"}}]},ae=R.forwardRef(function(e,n){return R.createElement(ie,Object.assign({},e,{id:"comment-icon",ref:n,icon:Ue}))});ae.displayName="CommentIcon";const Ee=r=>({id:j.id,type:u.MenuItemType.BUTTON,icon:"CommentIcon",title:"sheetThreadComment.menu.addComment",hidden$:u.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET),disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Re=r=>({id:f.ToggleSheetCommentPanelOperation.id,type:u.MenuItemType.BUTTON,icon:"CommentIcon",tooltip:"sheetThreadComment.menu.commentManagement",disabled$:P.getCurrentRangeDisable$(r,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:u.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET)}),Oe={id:j.id,binding:u.KeyCode.M|u.MetaKeys.CTRL_COMMAND|u.MetaKeys.ALT,preconditions:P.whenSheetEditorFocused},ke={[u.RibbonInsertGroup.MEDIA]:{[f.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:Re}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.OTHERS]:{[j.id]:{order:0,menuItemFactory:Ee}}}},De=()=>{const r=u.useDependency(a.IUniverInstanceService),e=u.useDependency(exports.SheetsThreadCommentPopupService),n=u.useObservable(e.activePopup$),t=u.useDependency($.SheetsThreadCommentModel);if(u.useObservable(t.commentUpdate$),!n)return null;const{row:o,col:i,unitId:s,subUnitId:c,trigger:m}=n,h=t.getByLocation(s,c,o,i),l=`${a.Tools.chatAtABC(i)}${o+1}`,d=()=>{e.hidePopup()},S=v=>{var _,T,D;return(D=(T=(_=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:_.getSheetBySheetId(v))==null?void 0:T.getName())!=null?D:""};return ne.jsx(f.ThreadCommentTree,{onClick:()=>{e.persistPopup()},prefix:"cell",id:h,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:d,getSubUnitName:S,autoFocus:m==="context-menu"})},$e=()=>{var b;const r=u.useDependency(P.IMarkSelectionService),e=u.useDependency(a.IUniverInstanceService),n=u.useDependency(exports.SheetsThreadCommentPopupService),t=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=t.getUnitId(),i=u.useDependency(a.ICommandService),s=R.useMemo(()=>t.activeSheet$.pipe(V.map(p=>p==null?void 0:p.getSheetId())),[t.activeSheet$]),c=u.useObservable(s,(b=t.getActiveSheet())==null?void 0:b.getSheetId()),m=R.useRef(null),h=u.useDependency(f.ThreadCommentPanelService),l=u.useObservable(h.activeCommentId$),d=u.useObservable(h.panelVisible$,h.panelVisible),S=R.useCallback(p=>{const M=t.getSheets(),g={};M.forEach((y,I)=>{g[y.getSheetId()]=I});const U=y=>y.map(I=>{var X;const O=N.singleReferenceToGrid(I.ref),ce=[(X=g[I.subUnitId])!=null?X:0,O.row,O.column];return{...I,p:ce}}).sort((I,O)=>I.p[0]===O.p[0]?I.p[1]===O.p[1]?I.p[2]-O.p[2]:I.p[1]-O.p[1]:I.p[0]-O.p[0]);return[...U(p.filter(y=>!y.resolved)),...U(p.filter(y=>y.resolved))]},[t]),v=R.useCallback(p=>{var M;if(p.unitId===o&&p.subUnitId===c&&!p.resolved){const{row:g,column:U}=N.singleReferenceToGrid(p.ref),y=t.getSheetBySheetId(p.subUnitId),I=(M=y==null?void 0:y.getMergedCell(g,U))!=null?M:{startColumn:U,endColumn:U,startRow:g,endRow:g};if(!Number.isNaN(g)&&!Number.isNaN(U))return r.addShape({range:I,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}return null},[r,c,o]),_=p=>{var M,g;return(g=(M=t.getSheetBySheetId(p))==null?void 0:M.getName())!=null?g:""},T=()=>{i.executeCommand(j.id)},D=p=>{l&&l.unitId===p.unitId&&l.subUnitId===p.subUnitId&&l.commentId===p.id||(m.current&&(r.removeShape(m.current),m.current=null),m.current=v(p))},A=()=>{m.current&&(r.removeShape(m.current),m.current=null)},G=(p,M)=>{M&&n.hidePopup()};return R.useEffect(()=>{!d&&m.current&&r.removeShape(m.current)},[r,d]),ne.jsx(f.ThreadCommentPanel,{unitId:o,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:T,getSubUnitName:_,onResolve:G,sortComments:S,onItemEnter:D,onItemLeave:A,onDeleteComment:()=>(A(),!0)})};var Ne=Object.getOwnPropertyDescriptor,je=(r,e,n,t)=>{for(var o=t>1?void 0:t?Ne(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},Y=(r,e)=>(n,t)=>e(n,t,r);let Z=class extends a.Disposable{constructor(r,e,n){super(),this._menuManagerService=r,this._componentManager=e,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Oe)}_initMenu(){this._menuManagerService.mergeMenu(ke)}_initComponent(){[[re,De],[f.THREAD_COMMENT_PANEL,$e],["CommentIcon",ae]].forEach(([r,e])=>{this.disposeWithMe(this._componentManager.register(r,e))})}};Z=je([Y(0,u.IMenuManagerService),Y(1,a.Inject(u.ComponentManager)),Y(2,u.IShortcutService)],Z);var Ae=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,xe=(r,e,n)=>e in r?Ae(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,He=(r,e,n,t)=>{for(var o=t>1?void 0:t?Ve(e,n):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=s(o)||o);return o},J=(r,e)=>(n,t)=>e(n,t,r),q=(r,e,n)=>xe(r,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ee,n,t,o){super(),this._config=e,this._injector=n,this._commandService=t,this._configService=o;const{menu:i,...s}=a.merge({},ee,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ce,s)}onStarting(){[[Z],[B],[L],[W],[F],[exports.SheetsThreadCommentPopupService]].forEach(e=>{this._injector.add(e)}),[j].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(Z)}onReady(){this._injector.get(B)}onRendered(){this._injector.get(L),this._injector.get(W),this._injector.get(F)}};q(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",Q);q(exports.UniverSheetsThreadCommentUIPlugin,"packageName",oe.name);q(exports.UniverSheetsThreadCommentUIPlugin,"version",oe.version);q(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=He([a.DependentOn(f.UniverThreadCommentUIPlugin,$.UniverSheetsThreadCommentPlugin),J(1,a.Inject(a.Injector)),J(2,a.Inject(a.ICommandService)),J(3,a.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>f.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>w.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>w.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>w.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>w.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>w.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>w.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=Q;exports.ShowAddSheetCommentModalOperation=j;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/sheets`),n=require(`@univerjs/sheets-thread-comment`),r=require(`@univerjs/thread-comment-ui`),i=require(`@univerjs/sheets-ui`),a=require(`@univerjs/ui`),o=require(`rxjs`),s=require(`@univerjs/engine-render`),c=require(`@univerjs/engine-formula`),l=require(`@univerjs/thread-comment`),u=require(`@univerjs/icons`),d=require(`react/jsx-runtime`),f=require(`react`);const p=`univer.sheet.thread-comment-modal`,m=`SHEET_THREAD_COMMENT`;function h(e){"@babel/helpers - typeof";return h=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},h(e)}function g(e,t){if(h(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(h(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _(e){var t=g(e,`string`);return h(t)==`symbol`?t:t+``}function v(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let x=class extends e.Disposable{get activePopup(){return this._activePopup}constructor(e,t,n){super(),this._canvasPopupManagerService=e,this._zenZoneService=t,this._cellPopupManagerService=n,v(this,`_lastPopup`,null),v(this,`_activePopup`,void 0),v(this,`_activePopup$`,new o.BehaviorSubject(null)),v(this,`activePopup$`,this._activePopup$.asObservable()),this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this.hidePopup()}))}dispose(){super.dispose(),this.hidePopup()}showPopup(t,n){var r;let{row:i,col:a,unitId:o,subUnitId:s}=t;if(this._activePopup&&i===this._activePopup.row&&a===this._activePopup.col&&o===this._activePopup.unitId&&s===((r=this.activePopup)==null?void 0:r.subUnitId)){this._activePopup=t,this._activePopup$.next(t);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=t,this._activePopup$.next(t);let c=this._cellPopupManagerService.showPopup({row:i,col:a,unitId:o,subUnitId:s},{componentKey:p,onClickOutside:()=>{this.hidePopup()},direction:`horizontal`,excludeOutside:[...Array.from(document.querySelectorAll(`.univer-thread-comment`)),document.getElementById(`thread-comment-add`)].filter(Boolean),priority:2});if(!c)throw Error(`[SheetsThreadCommentPopupService]: cannot show popup!`);let l=new e.DisposableCollection;l.add(c),l.add({dispose:()=>{n==null||n()}}),this._lastPopup=l}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};x=b([y(0,(0,e.Inject)(i.SheetCanvasPopManagerService)),y(1,a.IZenZoneService),y(2,(0,e.Inject)(i.CellPopupManagerService))],x);const S={type:e.CommandType.OPERATION,id:`sheets.operation.show-comment-modal`,handler(i){var a;let o=i.get(t.SheetsSelectionsService),s=i.get(e.IUniverInstanceService),c=i.get(x),l=i.get(r.ThreadCommentPanelService),u=(a=o.getCurrentLastSelection())==null?void 0:a.primary,d=i.get(n.SheetsThreadCommentModel);if(!u)return!1;let f=(0,t.getSheetCommandTarget)(s);if(!f)return!1;let{workbook:p,worksheet:m,unitId:h,subUnitId:g}=f,_={workbook:p,worksheet:m,unitId:h,subUnitId:g,row:u.startRow,col:u.startColumn};c.showPopup(_);let v=d.getByLocation(h,g,u.startRow,u.startColumn);return v&&l.setActiveComment({unitId:h,subUnitId:g,commentId:v,trigger:`context-menu`}),!0}};var C=`@univerjs/sheets-thread-comment-ui`,w=`0.18.0`;const T=`sheets-thread-comment.config`;Symbol(T);const E={};let D=class extends e.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._sheetsThreadCommentModel=t,this._univerInstanceService=n,this._renderManagerService=r,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(t.INTERCEPTOR_POINT.CELL_CONTENT,{effect:e.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t;return this._sheetsThreadCommentModel.showCommentMarker(a,o,r,i)?((!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,tr:{color:`#FFBD37`,size:6}},n(e)):n(e)},priority:100}))}_initSkeletonChange(){let t=()=>{var t;let n=this._univerInstanceService.getCurrentUnitForType(e.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=n.getUnitId(),i=this._renderManagerService.getRenderById(r);i==null||(t=i.mainComponent)==null||t.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe((0,o.debounceTime)(16)).subscribe(()=>{t()}))}};D=b([y(0,(0,e.Inject)(t.SheetInterceptorService)),y(1,(0,e.Inject)(n.SheetsThreadCommentModel)),y(2,e.IUniverInstanceService),y(3,s.IRenderManagerService)],D);const O=(e,t,n)=>{let r=(0,c.singleReferenceToGrid)(e),i=n.row-t.row,a=n.column-t.column;return(0,c.serializeRange)({startColumn:r.column+a,startRow:r.row+i,endColumn:r.column+a,endRow:r.row+i})};let k=class extends e.Disposable{constructor(e,t,n){super(),this._sheetClipboardService=e,this._sheetsThreadCommentModel=t,this._threadCommentDataSourceService=n,v(this,`_copyInfo`,void 0),this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:m,onBeforeCopy:(e,t,n)=>{this._copyInfo={unitId:e,subUnitId:t,range:n}},onPasteCells:(t,n,r,a)=>{let{unitId:o,subUnitId:s,range:c}=n,u={row:c.rows[0],column:c.cols[0]};if(a.copyType===i.COPY_TYPE.CUT&&this._copyInfo){let{range:t,unitId:n,subUnitId:r}=this._copyInfo,i={row:t.startRow,column:t.startColumn};if(!(o===n&&s===r)){let a=[];e.Range.foreach(t,(e,t)=>{let i=this._sheetsThreadCommentModel.getAllByLocation(n,r,e,t);this._threadCommentDataSourceService.syncUpdateMutationToColla?i.forEach(e=>{a.push(e)}):i.forEach(({children:e,...t})=>{t.parentId||a.push(t)})});let c=[],d=[],f=[],p=[],m=e=>{c.unshift({id:l.DeleteCommentMutation.id,params:{unitId:n,subUnitId:r,commentId:e.id}}),f.push({id:l.AddCommentMutation.id,params:{unitId:o,subUnitId:s,comment:{...e,ref:O(e.ref,i,u),unitId:o,subUnitId:s},sync:!0}}),d.push({id:l.AddCommentMutation.id,params:{unitId:n,subUnitId:r,comment:e,sync:!0}}),p.unshift({id:l.DeleteCommentMutation.id,params:{unitId:o,subUnitId:s,commentId:e.id}})};return a.forEach(e=>{m(e)}),{redos:[...c,...f],undos:[...p,...d]}}}return{redos:[],undos:[]}}}))}};k=b([y(0,(0,e.Inject)(i.ISheetClipboardService)),y(1,(0,e.Inject)(n.SheetsThreadCommentModel)),y(2,l.IThreadCommentDataSourceService)],k);let A=class extends e.Disposable{constructor(e,t,n,r){super(),this._hoverManagerService=e,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._sheetPermissionCheckController=r,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,o.debounceTime)(100)).subscribe(e=>{let n=this._sheetsThreadCommentPopupService.activePopup;if(e&&(n&&n.temp||!n)){let{location:r}=e,{unitId:i,subUnitId:a,row:o,col:s}=r,c=this._sheetsThreadCommentModel.getByLocation(i,a,o,s);if(c){if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[t.WorkbookCommentPermission],worksheetTypes:[t.WorksheetViewPermission],rangeTypes:[t.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}],i,a))return;let e=this._sheetsThreadCommentModel.getComment(i,a,c);e&&!e.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:i,subUnitId:a,row:o,col:s,commentId:c,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};A=b([y(0,(0,e.Inject)(i.HoverManagerService)),y(1,(0,e.Inject)(x)),y(2,(0,e.Inject)(n.SheetsThreadCommentModel)),y(3,(0,e.Inject)(t.SheetPermissionCheckController))],A);let j=class extends e.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._commandService=e,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=n,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionCheckController=a,this._markSelectionService=o,this._sheetSelectionService=s,this._editorBridgeService=c,this._renderManagerService=l,v(this,`_isSwitchToCommenting`,!1),v(this,`_selectionShapeInfo`,null),this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,n,a){var o,s,c;let l=(o=t[0])==null?void 0:o.range,u=this._renderManagerService.getRenderById(n),d=u==null||(s=u.with(i.SheetSkeletonManagerService).getSkeletonParam(a))==null?void 0:s.skeleton;if(!d||!l)return;let f=d.getCellWithCoordByIndex(l.startRow,l.startColumn);if((((c=l.rangeType)==null?e.RANGE_TYPE.NORMAL:c)!==e.RANGE_TYPE.NORMAL||l.endColumn-l.startColumn>0||l.endRow-l.startRow>0)&&!((f.isMerged||f.isMergedMainCell)&&e.Rectangle.equals(f.mergeInfo,l))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(r.SetActiveCommentOperation.id);return}let p=f.actualRow,m=f.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,a,p,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(r.SetActiveCommentOperation.id);return}let h=this._sheetsThreadCommentModel.getByLocation(n,a,p,m);h&&this._commandService.executeCommand(r.SetActiveCommentOperation.id,{unitId:n,subUnitId:a,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchToCommenting)return;let t=this._sheetSelectionService.currentSelectionParam;t&&this._handleSelectionChange(e,t.unitId,t.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(e=>{if(e.id===l.DeleteCommentMutation.id){let t=e.params,n=this._sheetsThreadCommentPopupService.activePopup;if(!n)return;let{unitId:r,subUnitId:i,commentId:a}=n;t.unitId===r&&t.subUnitId===i&&t.commentId===a&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async n=>{if(n){var r;let{unitId:a,subUnitId:o,commentId:s,trigger:l}=n,u=this._sheetsThreadCommentModel.getComment(a,o,s);if(!u||u.resolved)return;let d=this._univerInstanceService.getCurrentUnitForType(e.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==a)return;this._isSwitchToCommenting=!0,((r=d.getActiveSheet())==null?void 0:r.getSheetId())!==o&&await this._commandService.executeCommand(t.SetWorksheetActiveOperation.id,{unitId:a,subUnitId:o}),this._isSwitchToCommenting=!1;let f=(0,c.singleReferenceToGrid)(u.ref),{row:p,column:m}=f;if(!this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[t.WorkbookCommentPermission],worksheetTypes:[t.WorksheetViewPermission],rangeTypes:[t.RangeProtectionPermissionViewPoint]},[{startRow:p,startColumn:m,endRow:p,endColumn:m}],a,o)||(await this._commandService.executeCommand(i.ScrollToRangeOperation.id,{range:{startRow:Math.max(f.row-1,0),endRow:f.row+1,startColumn:Math.max(f.column-1,0),endColumn:f.column+1}}),this._editorBridgeService.isVisible().visible))return;this._sheetsThreadCommentPopupService.showPopup({unitId:a,subUnitId:o,row:f.row,col:f.column,commentId:u.id,trigger:l})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe((0,o.debounceTime)(100)).subscribe(t=>{var n,r;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}let{unitId:i,subUnitId:a,commentId:o}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);let s=this._sheetsThreadCommentModel.getComment(i,a,o);if(!s)return;let{row:l,column:u}=(0,c.singleReferenceToGrid)(s.ref);if(Number.isNaN(l)||Number.isNaN(u))return null;let d=(n=this._univerInstanceService.getCurrentUnitForType(e.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.getSheetBySheetId(a),f=(r=d==null?void 0:d.getMergedCell(l,u))==null?{startColumn:u,endColumn:u,startRow:l,endRow:l}:r,p=this._markSelectionService.addShape({range:f,style:{fill:`rgba(255, 189, 55, 0.35)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null},[],-1);p&&(this._selectionShapeInfo={...t,shapeId:p})}))}};j=b([y(0,e.ICommandService),y(1,(0,e.Inject)(x)),y(2,(0,e.Inject)(n.SheetsThreadCommentModel)),y(3,(0,e.Inject)(r.ThreadCommentPanelService)),y(4,e.IUniverInstanceService),y(5,(0,e.Inject)(t.SheetPermissionCheckController)),y(6,i.IMarkSelectionService),y(7,(0,e.Inject)(t.SheetsSelectionsService)),y(8,i.IEditorBridgeService),y(9,s.IRenderManagerService)],j);const M=n=>({id:S.id,type:a.MenuItemType.BUTTON,icon:`CommentIcon`,title:`sheetThreadComment.menu.addComment`,hidden$:(0,a.getMenuHiddenObservable)(n,e.UniverInstanceType.UNIVER_SHEET),disabled$:(0,i.getCurrentRangeDisable$)(n,{workbookTypes:[t.WorkbookCommentPermission],worksheetTypes:[t.WorksheetViewPermission],rangeTypes:[t.RangeProtectionPermissionViewPoint]})}),N=n=>({id:r.ToggleSheetCommentPanelOperation.id,type:a.MenuItemType.BUTTON,icon:`CommentIcon`,tooltip:`sheetThreadComment.menu.commentManagement`,disabled$:(0,i.getCurrentRangeDisable$)(n,{workbookTypes:[t.WorkbookCommentPermission],worksheetTypes:[t.WorksheetViewPermission],rangeTypes:[t.RangeProtectionPermissionViewPoint]}),hidden$:(0,a.getMenuHiddenObservable)(n,e.UniverInstanceType.UNIVER_SHEET)}),P={id:S.id,binding:a.KeyCode.M|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.ALT,preconditions:i.whenSheetEditorFocused},F={[a.RibbonInsertGroup.MEDIA]:{[r.ToggleSheetCommentPanelOperation.id]:{order:2,menuItemFactory:N}},[a.ContextMenuPosition.MAIN_AREA]:{[a.ContextMenuGroup.OTHERS]:{[S.id]:{order:0,menuItemFactory:M}}}},I=()=>{let t=(0,a.useDependency)(e.IUniverInstanceService),i=(0,a.useDependency)(x),o=(0,a.useObservable)(i.activePopup$),s=(0,a.useDependency)(n.SheetsThreadCommentModel);if((0,a.useObservable)(s.commentUpdate$),!o)return null;let{row:c,col:l,unitId:u,subUnitId:f,trigger:p}=o,m=s.getByLocation(u,f,c,l),h=`${e.Tools.chatAtABC(l)}${c+1}`;return(0,d.jsx)(r.ThreadCommentTree,{onClick:()=>{i.persistPopup()},prefix:`cell`,id:m,unitId:u,subUnitId:f,type:e.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:()=>{i.hidePopup()},getSubUnitName:n=>{var r,i;return(r=(i=t.getCurrentUnitForType(e.UniverInstanceType.UNIVER_SHEET))==null||(i=i.getSheetBySheetId(n))==null?void 0:i.getName())==null?``:r},autoFocus:p===`context-menu`})},L=()=>{var t;let n=(0,a.useDependency)(i.IMarkSelectionService),s=(0,a.useDependency)(e.IUniverInstanceService),l=(0,a.useDependency)(x),u=s.getCurrentUnitForType(e.UniverInstanceType.UNIVER_SHEET),p=u.getUnitId(),m=(0,a.useDependency)(e.ICommandService),h=(0,f.useMemo)(()=>u.activeSheet$.pipe((0,o.map)(e=>e==null?void 0:e.getSheetId())),[u.activeSheet$]),g=(0,a.useObservable)(h,(t=u.getActiveSheet())==null?void 0:t.getSheetId()),_=(0,f.useRef)(null),v=(0,a.useDependency)(r.ThreadCommentPanelService),y=(0,a.useObservable)(v.activeCommentId$),b=(0,a.useObservable)(v.panelVisible$,v.panelVisible),C=(0,f.useCallback)(e=>{let t=u.getSheets(),n={};t.forEach((e,t)=>{n[e.getSheetId()]=t});let r=e=>e.map(e=>{var t;let r=(0,c.singleReferenceToGrid)(e.ref),i=[(t=n[e.subUnitId])==null?0:t,r.row,r.column];return{...e,p:i}}).sort((e,t)=>e.p[0]===t.p[0]?e.p[1]===t.p[1]?e.p[2]-t.p[2]:e.p[1]-t.p[1]:e.p[0]-t.p[0]);return[...r(e.filter(e=>!e.resolved)),...r(e.filter(e=>e.resolved))]},[u]),w=(0,f.useCallback)(e=>{if(e.unitId===p&&e.subUnitId===g&&!e.resolved){var t;let{row:r,column:i}=(0,c.singleReferenceToGrid)(e.ref),a=u.getSheetBySheetId(e.subUnitId),o=(t=a==null?void 0:a.getMergedCell(r,i))==null?{startColumn:i,endColumn:i,startRow:r,endRow:r}:t;if(!Number.isNaN(r)&&!Number.isNaN(i))return n.addShape({range:o,style:{fill:`rgb(255, 189, 55, 0.35)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null})}return null},[n,g,p]),T=e=>{var t,n;return(t=(n=u.getSheetBySheetId(e))==null?void 0:n.getName())==null?``:t},E=()=>{m.executeCommand(S.id)},D=e=>{y&&y.unitId===e.unitId&&y.subUnitId===e.subUnitId&&y.commentId===e.id||(_.current&&(n.removeShape(_.current),_.current=null),_.current=w(e))},O=()=>{_.current&&(n.removeShape(_.current),_.current=null)};return(0,f.useEffect)(()=>{!b&&_.current&&n.removeShape(_.current)},[n,b]),(0,d.jsx)(r.ThreadCommentPanel,{unitId:p,subUnitId$:h,type:e.UniverInstanceType.UNIVER_SHEET,onAdd:E,getSubUnitName:T,onResolve:(e,t)=>{t&&l.hidePopup()},sortComments:C,onItemEnter:D,onItemLeave:O,onDeleteComment:()=>(O(),!0)})};let R=class extends e.Disposable{constructor(e,t,n){super(),this._menuManagerService=e,this._componentManager=t,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(P)}_initMenu(){this._menuManagerService.mergeMenu(F)}_initComponent(){[[p,I],[r.THREAD_COMMENT_PANEL,L],[`CommentIcon`,u.CommentIcon]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};R=b([y(0,a.IMenuManagerService),y(1,(0,e.Inject)(a.ComponentManager)),y(2,a.IShortcutService)],R);let z=class extends e.Plugin{constructor(t=E,n,r,i){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,e.merge)({},E,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(T,o)}onStarting(){[[R],[D],[k],[A],[j],[x]].forEach(e=>{this._injector.add(e)}),[S].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(R)}onReady(){this._injector.get(D)}onRendered(){this._injector.get(k),this._injector.get(A),this._injector.get(j)}};v(z,`pluginName`,m),v(z,`packageName`,C),v(z,`version`,w),v(z,`type`,e.UniverInstanceType.UNIVER_SHEET),z=b([(0,e.DependentOn)(r.UniverThreadCommentUIPlugin,n.UniverSheetsThreadCommentPlugin),y(1,(0,e.Inject)(e.Injector)),y(2,(0,e.Inject)(e.ICommandService)),y(3,e.IConfigService)],z),Object.defineProperty(exports,`AddCommentCommand`,{enumerable:!0,get:function(){return l.AddCommentCommand}}),Object.defineProperty(exports,`DeleteCommentCommand`,{enumerable:!0,get:function(){return l.DeleteCommentCommand}}),Object.defineProperty(exports,`DeleteCommentTreeCommand`,{enumerable:!0,get:function(){return l.DeleteCommentTreeCommand}}),Object.defineProperty(exports,`IThreadCommentDataSourceService`,{enumerable:!0,get:function(){return l.IThreadCommentDataSourceService}}),Object.defineProperty(exports,`ResolveCommentCommand`,{enumerable:!0,get:function(){return l.ResolveCommentCommand}}),exports.SHEETS_THREAD_COMMENT=m,Object.defineProperty(exports,`SheetsThreadCommentPopupService`,{enumerable:!0,get:function(){return x}}),exports.ShowAddSheetCommentModalOperation=S,Object.defineProperty(exports,`UniverSheetsThreadCommentUIPlugin`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`UniverThreadCommentUIPlugin`,{enumerable:!0,get:function(){return r.UniverThreadCommentUIPlugin}}),Object.defineProperty(exports,`UpdateCommentCommand`,{enumerable:!0,get:function(){return l.UpdateCommentCommand}});
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"Afegeix un comentari",commentManagement:"Gestió de comentaris"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`Afegeix un comentari`,commentManagement:`Gestió de comentaris`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"Add Comment",commentManagement:"Comment Management"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`Add Comment`,commentManagement:`Comment Management`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"Añadir comentario",commentManagement:"Gestión de comentarios"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`Añadir comentario`,commentManagement:`Gestión de comentarios`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"افزودن نظر",commentManagement:"مدیریت نظر"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`افزودن نظر`,commentManagement:`مدیریت نظر`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"Ajouter un commentaire",commentManagement:"Gestion des commentaires"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`Ajouter un commentaire`,commentManagement:`Gestion des commentaires`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"コメントを追加",commentManagement:"コメント管理"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`コメントを追加`,commentManagement:`コメント管理`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"댓글 추가",commentManagement:"댓글 관리"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`댓글 추가`,commentManagement:`댓글 관리`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"Добавить комментарий",commentManagement:"Управление комментариями"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`Добавить комментарий`,commentManagement:`Управление комментариями`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"Pridať komentár",commentManagement:"Správa komentárov"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`Pridať komentár`,commentManagement:`Správa komentárov`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"Thêm bình luận",commentManagement:"Quản lý bình luận"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`Thêm bình luận`,commentManagement:`Quản lý bình luận`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"添加评论",commentManagement:"评论管理"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`添加评论`,commentManagement:`评论管理`}}};module.exports=e;
@@ -1 +1 @@
1
- "use strict";const e={sheetThreadComment:{menu:{addComment:"新增評論",commentManagement:"評論管理"}}};module.exports=e;
1
+ const e={sheetThreadComment:{menu:{addComment:`新增評論`,commentManagement:`評論管理`}}};module.exports=e;