@univerjs/sheets-thread-comment-ui 0.5.0-nightly.202411181606 → 0.5.0-nightly.202411201606

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/README.md CHANGED
@@ -57,9 +57,7 @@ class CustomMentionDataService implements IThreadCommentMentionDataService {
57
57
  }
58
58
  }
59
59
 
60
- univer.registerPlugin(UniverSheetsThreadCommentPlugin, {
61
- overrides: [[IThreadCommentMentionDataService, { useClass: CustomMentionDataService }]],
62
- });
60
+ univer.registerPlugin(UniverSheetsThreadCommentPlugin);
63
61
  ```
64
62
 
65
63
  ### API
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ve=Object.defineProperty;var Ce=(o,e,n)=>e in o?ve(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n;var D=(o,e,n)=>Ce(o,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),N=require("@univerjs/sheets-thread-comment"),I=require("@univerjs/thread-comment-ui"),g=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),B=require("rxjs"),oe=require("@univerjs/engine-render"),O=require("react"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),ie="univer.sheet.thread-comment-modal",ee="comment-single",te="SHEET_THREAD_COMMENT";var Se=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,fe=(o,e,n,t)=>{for(var r=t>1?void 0:t?_e(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Se(e,n,r),r},re=(o,e)=>(n,t)=>e(n,t,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,t){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new B.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=t,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,t){var h;const{row:r,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:ie,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 a.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=fe([re(0,a.Inject(g.SheetCanvasPopManagerService)),re(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const e=o.get(C.SheetsSelectionsService),n=o.get(a.IUniverInstanceService),t=o.get(exports.SheetsThreadCommentPopupService),r=o.get(I.ThreadCommentPanelService),i=(f=e.getCurrentLastSelection())==null?void 0:f.primary,s=o.get(N.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(n);if(!c)return!1;const{workbook:m,worksheet:d,unitId:h,subUnitId:u}=c,l={workbook:m,worksheet:d,unitId:h,subUnitId:u,row:i.startRow,col:i.startColumn};t.showPopup(l);const v=s.getByLocation(h,u,i.startRow,i.startColumn);return v&&r.setActiveComment({unitId:h,subUnitId:u,commentId:v,trigger:"context-menu"}),!0}},Ie="sheets-thread-comment.config",ge={};var Pe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(o,e,n,t)=>{for(var r=t>1?void 0:t?Te(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Pe(e,n,r),r},k=(o,e)=>(n,t)=>e(n,t,o);let W=class extends a.Disposable{constructor(o,e,n,t){super(),this._sheetInterceptorService=o,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:(o,e,n)=>{const{row:t,col:r,unitId:i,subUnitId:s}=e;return this._sheetsThreadCommentModel.showCommentMarker(i,s,t,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return;const n=e.getUnitId(),t=this._renderManagerService.getRenderById(n);(r=t==null?void 0:t.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(B.debounceTime(16)).subscribe(()=>{o()}))}};W=be([k(0,a.Inject(C.SheetInterceptorService)),k(1,a.Inject(N.SheetsThreadCommentModel)),k(2,a.IUniverInstanceService),k(3,oe.IRenderManagerService)],W);var w=function(){return w=Object.assign||function(o){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(o[r]=e[r])}return o},w.apply(this,arguments)},ye=function(o,e){var n={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(n[t]=o[t]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(o);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(o,t[r])&&(n[t[r]]=o[t[r]]);return n},se=O.forwardRef(function(o,e){var n=o.icon,t=o.id,r=o.className,i=o.extend,s=ye(o,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),m=O.useRef("_".concat(Ue()));return ae(n,"".concat(t),{defIds:n.defIds,idSuffix:m.current},w({ref:e,className:c},s),i)});function ae(o,e,n,t,r){return O.createElement(o.tag,w(w({key:e},Me(o,n,r)),t),(we(o,n).children||[]).map(function(i,s){return ae(i,"".concat(e,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function Me(o,e,n){var t=w({},o.attrs);n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(o.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(i){var s=i[0],c=i[1];typeof c=="string"&&(t[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function we(o,e){var n,t=e.defIds;return!t||t.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?w(w({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?w(w({},r),{attrs:w(w({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):o}function Ue(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var Oe={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"}}]},ce=O.forwardRef(function(o,e){return O.createElement(se,Object.assign({},o,{id:"comment-single",ref:e,icon:Oe}))});ce.displayName="CommentSingle";var me={exports:{}},Y={};/**
1
+ "use strict";var ve=Object.defineProperty;var Ce=(o,e,n)=>e in o?ve(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n;var D=(o,e,n)=>Ce(o,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),N=require("@univerjs/sheets-thread-comment"),T=require("@univerjs/thread-comment-ui"),I=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),B=require("rxjs"),oe=require("@univerjs/engine-render"),O=require("react"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),ie="univer.sheet.thread-comment-modal",ee="comment-single",te="SHEET_THREAD_COMMENT";var Se=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,fe=(o,e,n,t)=>{for(var r=t>1?void 0:t?_e(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Se(e,n,r),r},re=(o,e)=>(n,t)=>e(n,t,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,t){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new B.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=t,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,t){var h;const{row:r,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:ie,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 a.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=fe([re(0,a.Inject(I.SheetCanvasPopManagerService)),re(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const e=o.get(C.SheetsSelectionsService),n=o.get(a.IUniverInstanceService),t=o.get(exports.SheetsThreadCommentPopupService),r=o.get(T.ThreadCommentPanelService),i=(f=e.getCurrentLastSelection())==null?void 0:f.primary,s=o.get(N.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(n);if(!c)return!1;const{workbook:m,worksheet:d,unitId:h,subUnitId:u}=c,l={workbook:m,worksheet:d,unitId:h,subUnitId:u,row:i.startRow,col:i.startColumn};t.showPopup(l);const v=s.getByLocation(h,u,i.startRow,i.startColumn);return v&&r.setActiveComment({unitId:h,subUnitId:u,commentId:v,trigger:"context-menu"}),!0}},Ie="sheets-thread-comment.config",ge={};var Pe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(o,e,n,t)=>{for(var r=t>1?void 0:t?Te(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Pe(e,n,r),r},k=(o,e)=>(n,t)=>e(n,t,o);let W=class extends a.Disposable{constructor(o,e,n,t){super(),this._sheetInterceptorService=o,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:(o,e,n)=>{const{row:t,col:r,unitId:i,subUnitId:s}=e;return this._sheetsThreadCommentModel.showCommentMarker(i,s,t,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return;const n=e.getUnitId(),t=this._renderManagerService.getRenderById(n);(r=t==null?void 0:t.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(B.debounceTime(16)).subscribe(()=>{o()}))}};W=be([k(0,a.Inject(C.SheetInterceptorService)),k(1,a.Inject(N.SheetsThreadCommentModel)),k(2,a.IUniverInstanceService),k(3,oe.IRenderManagerService)],W);var w=function(){return w=Object.assign||function(o){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(o[r]=e[r])}return o},w.apply(this,arguments)},ye=function(o,e){var n={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(n[t]=o[t]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(o);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(o,t[r])&&(n[t[r]]=o[t[r]]);return n},se=O.forwardRef(function(o,e){var n=o.icon,t=o.id,r=o.className,i=o.extend,s=ye(o,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),m=O.useRef("_".concat(Ue()));return ae(n,"".concat(t),{defIds:n.defIds,idSuffix:m.current},w({ref:e,className:c},s),i)});function ae(o,e,n,t,r){return O.createElement(o.tag,w(w({key:e},Me(o,n,r)),t),(we(o,n).children||[]).map(function(i,s){return ae(i,"".concat(e,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function Me(o,e,n){var t=w({},o.attrs);n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(o.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(i){var s=i[0],c=i[1];typeof c=="string"&&(t[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function we(o,e){var n,t=e.defIds;return!t||t.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?w(w({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?w(w({},r),{attrs:w(w({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):o}function Ue(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var Oe={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"}}]},ce=O.forwardRef(function(o,e){return O.createElement(se,Object.assign({},o,{id:"comment-single",ref:e,icon:Oe}))});ce.displayName="CommentSingle";var me={exports:{}},Y={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Ee=O,Re=Symbol.for("react.element"),je=Symbol.for("react.fragment"),De=Object.prototype.hasOwnProperty,$e=Ee.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ne={key:!0,ref:!0,__self:!0,__source:!0};function de(o,e,n){var t,r={},i=null,s=null;n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(s=e.ref);for(t in e)De.call(e,t)&&!Ne.hasOwnProperty(t)&&(r[t]=e[t]);if(o&&o.defaultProps)for(t in e=o.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:Re,type:o,key:i,ref:s,props:r,_owner:$e.current}}Y.Fragment=je;Y.jsx=de;Y.jsxs=de;me.exports=Y;var ue=me.exports;const xe=()=>{const o=a.useDependency(a.IUniverInstanceService),e=a.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(e.activePopup$),t=a.useDependency(N.SheetsThreadCommentModel);if(S.useObservable(t.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:c,trigger:m}=n,d=t.getByLocation(s,c,r,i),h=`${a.Tools.chatAtABC(i)}${r+1}`,u=()=>{e.hidePopup()},l=v=>{var f,b,$;return($=(b=(f=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(v))==null?void 0:b.getName())!=null?$:""};return ue.jsx(I.ThreadCommentTree,{onClick:()=>{e.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:u,getSubUnitName:l,autoFocus:m==="context-menu"})},Ae=()=>{var y;const o=a.useDependency(g.IMarkSelectionService),e=a.useDependency(a.IUniverInstanceService),n=a.useDependency(exports.SheetsThreadCommentPopupService),t=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=t.getUnitId(),i=a.useDependency(a.ICommandService),s=O.useMemo(()=>t.activeSheet$.pipe(B.map(p=>p==null?void 0:p.getSheetId())),[t.activeSheet$]),c=S.useObservable(s,(y=t.getActiveSheet())==null?void 0:y.getSheetId()),m=O.useRef(),d=a.useDependency(I.ThreadCommentPanelService),h=S.useObservable(d.activeCommentId$),u=S.useObservable(d.panelVisible$,d.panelVisible),l=O.useCallback(p=>{const M=t.getSheets(),P={};M.forEach((U,T)=>{P[U.getSheetId()]=T});const E=U=>U.map(T=>{var ne;const j=x.singleReferenceToGrid(T.ref),pe=[(ne=P[T.subUnitId])!=null?ne:0,j.row,j.column];return{...T,p:pe}}).sort((T,j)=>T.p[0]===j.p[0]?T.p[1]===j.p[1]?T.p[2]-j.p[2]:T.p[1]-j.p[1]:T.p[0]-j.p[0]);return[...E(p.filter(U=>!U.resolved)),...E(p.filter(U=>U.resolved))]},[t]),v=O.useCallback(p=>{var M;if(p.unitId===r&&p.subUnitId===c&&!p.resolved){const{row:P,column:E}=x.singleReferenceToGrid(p.ref),U=t.getSheetBySheetId(p.subUnitId),T=(M=U==null?void 0:U.getMergedCell(P,E))!=null?M:{startColumn:E,endColumn:E,startRow:P,endRow:P};if(!Number.isNaN(P)&&!Number.isNaN(E))return o.addShape({range:T,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,c,r]),f=p=>{var M,P;return(P=(M=t.getSheetBySheetId(p))==null?void 0:M.getName())!=null?P:""},b=()=>{i.executeCommand(A.id)},$=p=>{h&&h.unitId===p.unitId&&h.subUnitId===p.subUnitId&&h.commentId===p.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=v(p))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},K=(p,M)=>{M&&n.hidePopup()};return O.useEffect(()=>{!u&&m.current&&o.removeShape(m.current)},[o,u]),ue.jsx(I.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:f,onResolve:K,sortComments:l,onItemEnter:$,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},Ve=o=>({id:A.id,type:S.MenuItemType.BUTTON,icon:ee,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:g.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Be=o=>({id:I.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:ee,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:g.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),ke={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:g.whenSheetEditorFocused},He={[S.RibbonStartGroup.OTHERS]:{[I.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Be}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:Ve}}}};var Le=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Fe=(o,e,n,t)=>{for(var r=t>1?void 0:t?We(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Le(e,n,r),r},J=(o,e)=>(n,t)=>e(n,t,o);let F=class extends a.Disposable{constructor(o,e,n){super(),this._menuManagerService=o,this._componentManager=e,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(ke)}_initMenu(){this._menuManagerService.mergeMenu(He)}_initComponent(){[[ie,xe],[I.THREAD_COMMENT_PANEL,Ae],[ee,ce]].forEach(([o,e])=>{this._componentManager.register(o,e)})}};F=Fe([J(0,S.IMenuManagerService),J(1,a.Inject(S.ComponentManager)),J(2,S.IShortcutService)],F);var qe=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Ze=(o,e,n,t)=>{for(var r=t>1?void 0:t?Ge(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&qe(e,n,r),r},Q=(o,e)=>(n,t)=>e(n,t,o);const ze=(o,e,n)=>{const t=x.singleReferenceToGrid(o),r=n.row-e.row,i=n.column-e.column,s={startColumn:t.column+i,startRow:t.row+r,endColumn:t.column+i,endRow:t.row+r};return x.serializeRange(s)};let q=class extends a.Disposable{constructor(e,n,t){super();D(this,"_copyInfo");this._sheetClipboardService=e,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:te,onBeforeCopy:(e,n,t)=>{this._copyInfo={unitId:e,subUnitId:n,range:t}},onPasteCells:(e,n,t,r)=>{const{unitId:i,subUnitId:s,range:c}=n,m={row:c.rows[0],column:c.cols[0]};if(r.copyType===g.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:h,subUnitId:u}=this._copyInfo,l={row:d.startRow,column:d.startColumn};if(!(i===h&&s===u)){const v=[];a.Range.foreach(d,(y,p)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(h,u,y,p);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(P=>{v.push(P)}):M.forEach(({children:P,...E})=>{E.parentId||v.push(E)})});const f=[],b=[],$=[],V=[],K=y=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:h,subUnitId:u,commentId:y.id}}),$.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:ze(y.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:h,subUnitId:u,comment:y,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return v.forEach(y=>{K(y)}),{redos:[...f,...$],undos:[...V,...b]}}}return{redos:[],undos:[]}}}))}};q=Ze([Q(0,a.Inject(g.ISheetClipboardService)),Q(1,a.Inject(N.SheetsThreadCommentModel)),Q(2,_.IThreadCommentDataSourceService)],q);var Ye=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Je=(o,e,n,t)=>{for(var r=t>1?void 0:t?Ke(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Ye(e,n,r),r},H=(o,e)=>(n,t)=>e(n,t,o);let G=class extends a.Disposable{constructor(o,e,n,t){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=e,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(B.debounceTime(100)).subscribe(o=>{const e=this._sheetsThreadCommentPopupService.activePopup;if(o&&(e&&e.temp||!e)){const{location:n}=o,{unitId:t,subUnitId:r,row:i,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(t,r,i,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(t,r,c);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:r,row:i,col:s,commentId:c,temp:!0})}else e&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=Je([H(0,a.Inject(g.HoverManagerService)),H(1,a.Inject(exports.SheetsThreadCommentPopupService)),H(2,a.Inject(N.SheetsThreadCommentModel)),H(3,a.Inject(g.SheetPermissionInterceptorBaseController))],G);var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(o,e,n,t)=>{for(var r=t>1?void 0:t?Xe(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Qe(e,n,r),r},R=(o,e)=>(n,t)=>e(n,t,o);let Z=class extends a.Disposable{constructor(e,n,t,r,i,s,c,m,d,h){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=e,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=t,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=h,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(e,n,t){var l,v,f;const r=(l=e[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(v=i==null?void 0:i.with(g.SheetSkeletonManagerService).getWorksheetSkeleton(t))==null?void 0:v.skeleton;if(!s||!r)return;const c=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const d=c.actualRow,h=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,t,d,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const u=this._sheetsThreadCommentModel.getByLocation(n,t,d,h);u&&this._commandService.executeCommand(I.SetActiveCommentOperation.id,{unitId:n,subUnitId:t,commentId:u})}_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===_.DeleteCommentMutation.id){const n=e.params,t=this._sheetsThreadCommentPopupService.activePopup;if(!t)return;const{unitId:r,subUnitId:i,commentId:s}=t;n.unitId===r&&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:r,commentId:i,trigger:s}=e,c=this._sheetsThreadCommentModel.getComment(t,r,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())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:r}),this._isSwitchToCommenting=!1;const u=x.singleReferenceToGrid(c.ref),{row:l,column:v}=u;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:v,endRow:l,endColumn:v}]))return;const b=1;if(await this._commandService.executeCommand(g.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-b,0),endRow:u.row+b,startColumn:Math.max(u.column-b,0),endColumn:u.column+b}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:r,row:u.row,col:u.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(B.debounceTime(100)).subscribe(e=>{var l,v;if(!e){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:t,commentId:r}=e;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,t,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const d=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(t),h=(v=d==null?void 0:d.getMergedCell(c,m))!=null?v:{startColumn:m,endColumn:m,startRow:c,endRow:c},u=this._markSelectionService.addShape({range:h,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);u&&(this._selectionShapeInfo={...e,shapeId:u})}))}};Z=et([R(0,a.ICommandService),R(1,a.Inject(exports.SheetsThreadCommentPopupService)),R(2,a.Inject(N.SheetsThreadCommentModel)),R(3,a.Inject(I.ThreadCommentPanelService)),R(4,a.IUniverInstanceService),R(5,a.Inject(g.SheetPermissionInterceptorBaseController)),R(6,g.IMarkSelectionService),R(7,a.Inject(C.SheetsSelectionsService)),R(8,g.IEditorBridgeService),R(9,oe.IRenderManagerService)],Z);var tt=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,rt=(o,e,n,t)=>{for(var r=t>1?void 0:t?nt(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&tt(e,n,r),r},L=(o,e)=>(n,t)=>e(n,t,o);let z=class extends a.Disposable{constructor(o,e,n,t){super(),this._sheetInterceptorService=o,this._univerInstanceService=e,this._threadCommentModel=n,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var e;if(o.id===C.RemoveSheetCommand.id){const n=o.params,t=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const r=t.getUnitId(),i=n.subUnitId||((e=t.getActiveSheet())==null?void 0:e.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),c=Array.from(s.values()).filter(l=>!l.parentId),m=c.map(l=>l.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,h=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),u=c.map(({children:l,...v})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...v,children:d?l:void 0},sync:!d}}));return{redos:h,undos:u}}return{redos:[],undos:[]}}}))}};z=rt([L(0,a.Inject(C.SheetInterceptorService)),L(1,a.IUniverInstanceService),L(2,a.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],z);var he=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,it=(o,e,n)=>e in o?he(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,st=(o,e,n,t)=>{for(var r=t>1?void 0:t?ot(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&he(e,n,r),r},X=(o,e)=>(n,t)=>e(n,t,o),le=(o,e,n)=>it(o,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ge,n,t,r){super(),this._config=e,this._injector=n,this._commandService=t,this._configService=r;const{menu:i,...s}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ie,s)}onStarting(){[[F],[W],[q],[G],[z],[Z],[exports.SheetsThreadCommentPopupService]].forEach(e=>{this._injector.add(e)}),[A].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(F)}onReady(){this._injector.get(W),this._injector.get(z)}onRendered(){this._injector.get(q),this._injector.get(G),this._injector.get(Z)}};le(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",te);le(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=st([a.DependentOn(I.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),X(1,a.Inject(a.Injector)),X(2,a.Inject(a.ICommandService)),X(3,a.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>I.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>I.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=te;exports.ShowAddSheetCommentModalOperation=A;
9
+ */var Ee=O,Re=Symbol.for("react.element"),je=Symbol.for("react.fragment"),De=Object.prototype.hasOwnProperty,$e=Ee.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ne={key:!0,ref:!0,__self:!0,__source:!0};function de(o,e,n){var t,r={},i=null,s=null;n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(s=e.ref);for(t in e)De.call(e,t)&&!Ne.hasOwnProperty(t)&&(r[t]=e[t]);if(o&&o.defaultProps)for(t in e=o.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:Re,type:o,key:i,ref:s,props:r,_owner:$e.current}}Y.Fragment=je;Y.jsx=de;Y.jsxs=de;me.exports=Y;var ue=me.exports;const xe=()=>{const o=a.useDependency(a.IUniverInstanceService),e=a.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(e.activePopup$),t=a.useDependency(N.SheetsThreadCommentModel);if(S.useObservable(t.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:c,trigger:m}=n,d=t.getByLocation(s,c,r,i),h=`${a.Tools.chatAtABC(i)}${r+1}`,u=()=>{e.hidePopup()},l=v=>{var f,b,$;return($=(b=(f=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(v))==null?void 0:b.getName())!=null?$:""};return ue.jsx(T.ThreadCommentTree,{onClick:()=>{e.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:u,getSubUnitName:l,autoFocus:m==="context-menu"})},Ae=()=>{var y;const o=a.useDependency(I.IMarkSelectionService),e=a.useDependency(a.IUniverInstanceService),n=a.useDependency(exports.SheetsThreadCommentPopupService),t=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=t.getUnitId(),i=a.useDependency(a.ICommandService),s=O.useMemo(()=>t.activeSheet$.pipe(B.map(p=>p==null?void 0:p.getSheetId())),[t.activeSheet$]),c=S.useObservable(s,(y=t.getActiveSheet())==null?void 0:y.getSheetId()),m=O.useRef(),d=a.useDependency(T.ThreadCommentPanelService),h=S.useObservable(d.activeCommentId$),u=S.useObservable(d.panelVisible$,d.panelVisible),l=O.useCallback(p=>{const M=t.getSheets(),g={};M.forEach((U,P)=>{g[U.getSheetId()]=P});const E=U=>U.map(P=>{var ne;const j=x.singleReferenceToGrid(P.ref),pe=[(ne=g[P.subUnitId])!=null?ne:0,j.row,j.column];return{...P,p:pe}}).sort((P,j)=>P.p[0]===j.p[0]?P.p[1]===j.p[1]?P.p[2]-j.p[2]:P.p[1]-j.p[1]:P.p[0]-j.p[0]);return[...E(p.filter(U=>!U.resolved)),...E(p.filter(U=>U.resolved))]},[t]),v=O.useCallback(p=>{var M;if(p.unitId===r&&p.subUnitId===c&&!p.resolved){const{row:g,column:E}=x.singleReferenceToGrid(p.ref),U=t.getSheetBySheetId(p.subUnitId),P=(M=U==null?void 0:U.getMergedCell(g,E))!=null?M:{startColumn:E,endColumn:E,startRow:g,endRow:g};if(!Number.isNaN(g)&&!Number.isNaN(E))return o.addShape({range:P,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,c,r]),f=p=>{var M,g;return(g=(M=t.getSheetBySheetId(p))==null?void 0:M.getName())!=null?g:""},b=()=>{i.executeCommand(A.id)},$=p=>{h&&h.unitId===p.unitId&&h.subUnitId===p.subUnitId&&h.commentId===p.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=v(p))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},K=(p,M)=>{M&&n.hidePopup()};return O.useEffect(()=>{!u&&m.current&&o.removeShape(m.current)},[o,u]),ue.jsx(T.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:f,onResolve:K,sortComments:l,onItemEnter:$,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},Ve=o=>({id:A.id,type:S.MenuItemType.BUTTON,icon:ee,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:I.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Be=o=>({id:T.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:ee,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:I.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),ke={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:I.whenSheetEditorFocused},He={[S.RibbonStartGroup.OTHERS]:{[T.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Be}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:Ve}}}};var Le=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Fe=(o,e,n,t)=>{for(var r=t>1?void 0:t?We(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Le(e,n,r),r},J=(o,e)=>(n,t)=>e(n,t,o);let F=class extends a.Disposable{constructor(o,e,n){super(),this._menuManagerService=o,this._componentManager=e,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(ke)}_initMenu(){this._menuManagerService.mergeMenu(He)}_initComponent(){[[ie,xe],[T.THREAD_COMMENT_PANEL,Ae],[ee,ce]].forEach(([o,e])=>{this._componentManager.register(o,e)})}};F=Fe([J(0,S.IMenuManagerService),J(1,a.Inject(S.ComponentManager)),J(2,S.IShortcutService)],F);var qe=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Ze=(o,e,n,t)=>{for(var r=t>1?void 0:t?Ge(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&qe(e,n,r),r},Q=(o,e)=>(n,t)=>e(n,t,o);const ze=(o,e,n)=>{const t=x.singleReferenceToGrid(o),r=n.row-e.row,i=n.column-e.column,s={startColumn:t.column+i,startRow:t.row+r,endColumn:t.column+i,endRow:t.row+r};return x.serializeRange(s)};let q=class extends a.Disposable{constructor(e,n,t){super();D(this,"_copyInfo");this._sheetClipboardService=e,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:te,onBeforeCopy:(e,n,t)=>{this._copyInfo={unitId:e,subUnitId:n,range:t}},onPasteCells:(e,n,t,r)=>{const{unitId:i,subUnitId:s,range:c}=n,m={row:c.rows[0],column:c.cols[0]};if(r.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:h,subUnitId:u}=this._copyInfo,l={row:d.startRow,column:d.startColumn};if(!(i===h&&s===u)){const v=[];a.Range.foreach(d,(y,p)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(h,u,y,p);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(g=>{v.push(g)}):M.forEach(({children:g,...E})=>{E.parentId||v.push(E)})});const f=[],b=[],$=[],V=[],K=y=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:h,subUnitId:u,commentId:y.id}}),$.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:ze(y.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:h,subUnitId:u,comment:y,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return v.forEach(y=>{K(y)}),{redos:[...f,...$],undos:[...V,...b]}}}return{redos:[],undos:[]}}}))}};q=Ze([Q(0,a.Inject(I.ISheetClipboardService)),Q(1,a.Inject(N.SheetsThreadCommentModel)),Q(2,_.IThreadCommentDataSourceService)],q);var Ye=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Je=(o,e,n,t)=>{for(var r=t>1?void 0:t?Ke(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Ye(e,n,r),r},H=(o,e)=>(n,t)=>e(n,t,o);let G=class extends a.Disposable{constructor(o,e,n,t){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=e,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(B.debounceTime(100)).subscribe(o=>{const e=this._sheetsThreadCommentPopupService.activePopup;if(o&&(e&&e.temp||!e)){const{location:n}=o,{unitId:t,subUnitId:r,row:i,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(t,r,i,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(t,r,c);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:r,row:i,col:s,commentId:c,temp:!0})}else e&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=Je([H(0,a.Inject(I.HoverManagerService)),H(1,a.Inject(exports.SheetsThreadCommentPopupService)),H(2,a.Inject(N.SheetsThreadCommentModel)),H(3,a.Inject(I.SheetPermissionInterceptorBaseController))],G);var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(o,e,n,t)=>{for(var r=t>1?void 0:t?Xe(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Qe(e,n,r),r},R=(o,e)=>(n,t)=>e(n,t,o);let Z=class extends a.Disposable{constructor(e,n,t,r,i,s,c,m,d,h){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=e,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=t,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=h,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(e,n,t){var l,v,f;const r=(l=e[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(v=i==null?void 0:i.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(t))==null?void 0:v.skeleton;if(!s||!r)return;const c=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const d=c.actualRow,h=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,t,d,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const u=this._sheetsThreadCommentModel.getByLocation(n,t,d,h);u&&this._commandService.executeCommand(T.SetActiveCommentOperation.id,{unitId:n,subUnitId:t,commentId:u})}_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===_.DeleteCommentMutation.id){const n=e.params,t=this._sheetsThreadCommentPopupService.activePopup;if(!t)return;const{unitId:r,subUnitId:i,commentId:s}=t;n.unitId===r&&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:r,commentId:i,trigger:s}=e,c=this._sheetsThreadCommentModel.getComment(t,r,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())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:r}),this._isSwitchToCommenting=!1;const u=x.singleReferenceToGrid(c.ref),{row:l,column:v}=u;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:v,endRow:l,endColumn:v}]))return;const b=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-b,0),endRow:u.row+b,startColumn:Math.max(u.column-b,0),endColumn:u.column+b}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:r,row:u.row,col:u.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(B.debounceTime(100)).subscribe(e=>{var l,v;if(!e){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:t,commentId:r}=e;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,t,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const d=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(t),h=(v=d==null?void 0:d.getMergedCell(c,m))!=null?v:{startColumn:m,endColumn:m,startRow:c,endRow:c},u=this._markSelectionService.addShape({range:h,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);u&&(this._selectionShapeInfo={...e,shapeId:u})}))}};Z=et([R(0,a.ICommandService),R(1,a.Inject(exports.SheetsThreadCommentPopupService)),R(2,a.Inject(N.SheetsThreadCommentModel)),R(3,a.Inject(T.ThreadCommentPanelService)),R(4,a.IUniverInstanceService),R(5,a.Inject(I.SheetPermissionInterceptorBaseController)),R(6,I.IMarkSelectionService),R(7,a.Inject(C.SheetsSelectionsService)),R(8,I.IEditorBridgeService),R(9,oe.IRenderManagerService)],Z);var tt=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,rt=(o,e,n,t)=>{for(var r=t>1?void 0:t?nt(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&tt(e,n,r),r},L=(o,e)=>(n,t)=>e(n,t,o);let z=class extends a.Disposable{constructor(o,e,n,t){super(),this._sheetInterceptorService=o,this._univerInstanceService=e,this._threadCommentModel=n,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var e;if(o.id===C.RemoveSheetCommand.id){const n=o.params,t=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const r=t.getUnitId(),i=n.subUnitId||((e=t.getActiveSheet())==null?void 0:e.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),c=Array.from(s.values()).filter(l=>!l.parentId),m=c.map(l=>l.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,h=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),u=c.map(({children:l,...v})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...v,children:d?l:void 0},sync:!d}}));return{redos:h,undos:u}}return{redos:[],undos:[]}}}))}};z=rt([L(0,a.Inject(C.SheetInterceptorService)),L(1,a.IUniverInstanceService),L(2,a.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],z);var he=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,it=(o,e,n)=>e in o?he(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,st=(o,e,n,t)=>{for(var r=t>1?void 0:t?ot(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&he(e,n,r),r},X=(o,e)=>(n,t)=>e(n,t,o),le=(o,e,n)=>it(o,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ge,n,t,r){super(),this._config=e,this._injector=n,this._commandService=t,this._configService=r;const{menu:i,...s}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ie,s)}onStarting(){[[F],[W],[q],[G],[z],[Z],[exports.SheetsThreadCommentPopupService]].forEach(e=>{this._injector.add(e)}),[A].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(F)}onReady(){this._injector.get(W),this._injector.get(z)}onRendered(){this._injector.get(q),this._injector.get(G),this._injector.get(Z)}};le(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",te);le(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=st([a.DependentOn(T.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),X(1,a.Inject(a.Injector)),X(2,a.Inject(a.ICommandService)),X(3,a.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>T.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=te;exports.ShowAddSheetCommentModalOperation=A;
package/lib/es/index.js CHANGED
@@ -5,16 +5,16 @@ import { Inject as v, Disposable as $, DisposableCollection as He, CommandType a
5
5
  import { SheetsSelectionsService as ve, getSheetCommandTarget as Je, SheetInterceptorService as _e, INTERCEPTOR_POINT as Qe, WorkbookCommentPermission as K, WorksheetViewPermission as J, RangeProtectionPermissionViewPoint as Q, SetWorksheetActiveOperation as Xe, RemoveSheetCommand as et } from "@univerjs/sheets";
6
6
  import { SheetsThreadCommentModel as x, UniverSheetsThreadCommentPlugin as tt } from "@univerjs/sheets-thread-comment";
7
7
  import { ThreadCommentPanelService as ae, ThreadCommentTree as nt, ThreadCommentPanel as rt, ToggleSheetCommentPanelOperation as fe, THREAD_COMMENT_PANEL as ot, SetActiveCommentOperation as te, UniverThreadCommentUIPlugin as it } from "@univerjs/thread-comment-ui";
8
- import { IThreadCommentMentionDataService as xn, UniverThreadCommentUIPlugin as Dn } from "@univerjs/thread-comment-ui";
9
- import { SheetCanvasPopManagerService as st, IMarkSelectionService as Ce, whenSheetEditorFocused as at, getCurrentRangeDisable$ as Se, ISheetClipboardService as ct, COPY_TYPE as mt, HoverManagerService as dt, SheetPermissionInterceptorBaseController as ge, IEditorBridgeService as ht, SheetSkeletonManagerService as ut, ScrollToRangeOperation as lt } from "@univerjs/sheets-ui";
8
+ import { UniverThreadCommentUIPlugin as xn } from "@univerjs/thread-comment-ui";
9
+ import { SheetCanvasPopManagerService as st, IMarkSelectionService as Ce, whenSheetEditorFocused as at, getCurrentRangeDisable$ as Se, ISheetClipboardService as ct, COPY_TYPE as dt, HoverManagerService as mt, SheetPermissionInterceptorBaseController as ge, IEditorBridgeService as ht, SheetSkeletonManagerService as ut, ScrollToRangeOperation as lt } from "@univerjs/sheets-ui";
10
10
  import { IZenZoneService as pt, useObservable as j, KeyCode as vt, MetaKeys as ue, MenuItemType as Ie, getMenuHiddenObservable as Pe, RibbonStartGroup as _t, ContextMenuPosition as ft, ContextMenuGroup as Ct, ComponentManager as St, IMenuManagerService as gt, IShortcutService as It } from "@univerjs/ui";
11
11
  import { BehaviorSubject as Pt, debounceTime as ce, map as Tt } from "rxjs";
12
12
  import { IRenderManagerService as Te } from "@univerjs/engine-render";
13
- import bt, { forwardRef as be, useRef as Me, createElement as we, useMemo as Mt, useCallback as le, useEffect as wt } from "react";
13
+ import bt, { forwardRef as be, useRef as we, createElement as Me, useMemo as wt, useCallback as le, useEffect as Mt } from "react";
14
14
  import { singleReferenceToGrid as A, serializeRange as yt } from "@univerjs/engine-formula";
15
15
  import { IThreadCommentDataSourceService as ye, DeleteCommentMutation as k, AddCommentMutation as ie, ThreadCommentModel as Et } from "@univerjs/thread-comment";
16
- import { AddCommentCommand as An, DeleteCommentCommand as Vn, DeleteCommentTreeCommand as Bn, IThreadCommentDataSourceService as Ln, ResolveCommentCommand as Hn, UpdateCommentCommand as kn } from "@univerjs/thread-comment";
17
- const Ee = "univer.sheet.thread-comment-modal", me = "comment-single", Oe = "SHEET_THREAD_COMMENT";
16
+ import { AddCommentCommand as jn, DeleteCommentCommand as An, DeleteCommentTreeCommand as Vn, IThreadCommentDataSourceService as Bn, ResolveCommentCommand as Ln, UpdateCommentCommand as Hn } from "@univerjs/thread-comment";
17
+ const Ee = "univer.sheet.thread-comment-modal", de = "comment-single", Oe = "SHEET_THREAD_COMMENT";
18
18
  var Ot = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, Ut = (o, e, r, t) => {
19
19
  for (var n = t > 1 ? void 0 : t ? Rt(e, r) : e, i = o.length - 1, s; i >= 0; i--)
20
20
  (s = o[i]) && (n = (t ? s(e, r, n) : s(n)) || n);
@@ -40,9 +40,9 @@ let R = class extends $ {
40
40
  }));
41
41
  }
42
42
  showPopup(e, r) {
43
- var m;
43
+ var d;
44
44
  const { row: t, col: n, unitId: i, subUnitId: s } = e;
45
- if (this._activePopup && t === this._activePopup.row && n === this._activePopup.col && i === this._activePopup.unitId && s === ((m = this.activePopup) == null ? void 0 : m.subUnitId)) {
45
+ if (this._activePopup && t === this._activePopup.row && n === this._activePopup.col && i === this._activePopup.unitId && s === ((d = this.activePopup) == null ? void 0 : d.subUnitId)) {
46
46
  this._activePopup = e, this._activePopup$.next(e);
47
47
  return;
48
48
  }
@@ -98,19 +98,19 @@ const V = {
98
98
  const a = Je(r);
99
99
  if (!a)
100
100
  return !1;
101
- const { workbook: c, worksheet: m, unitId: h, subUnitId: d } = a, u = {
101
+ const { workbook: c, worksheet: d, unitId: h, subUnitId: m } = a, u = {
102
102
  workbook: c,
103
- worksheet: m,
103
+ worksheet: d,
104
104
  unitId: h,
105
- subUnitId: d,
105
+ subUnitId: m,
106
106
  row: i.startRow,
107
107
  col: i.startColumn
108
108
  };
109
109
  t.showPopup(u);
110
- const p = s.getByLocation(h, d, i.startRow, i.startColumn);
110
+ const p = s.getByLocation(h, m, i.startRow, i.startColumn);
111
111
  return p && n.setActiveComment({
112
112
  unitId: h,
113
- subUnitId: d,
113
+ subUnitId: m,
114
114
  commentId: p,
115
115
  trigger: "context-menu"
116
116
  }), !0;
@@ -184,11 +184,11 @@ var P = function() {
184
184
  e.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[n]) && (r[t[n]] = o[t[n]]);
185
185
  return r;
186
186
  }, Re = be(function(o, e) {
187
- var r = o.icon, t = o.id, n = o.className, i = o.extend, s = At(o, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(n || "").trim(), c = Me("_".concat(Lt()));
187
+ var r = o.icon, t = o.id, n = o.className, i = o.extend, s = At(o, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(n || "").trim(), c = we("_".concat(Lt()));
188
188
  return Ue(r, "".concat(t), { defIds: r.defIds, idSuffix: c.current }, P({ ref: e, className: a }, s), i);
189
189
  });
190
190
  function Ue(o, e, r, t, n) {
191
- return we(o.tag, P(P({ key: e }, Vt(o, r, n)), t), (Bt(o, r).children || []).map(function(i, s) {
191
+ return Me(o.tag, P(P({ key: e }, Vt(o, r, n)), t), (Bt(o, r).children || []).map(function(i, s) {
192
192
  return Ue(i, "".concat(e, "-").concat(o.tag, "-").concat(s), r, void 0, n);
193
193
  }));
194
194
  }
@@ -212,7 +212,7 @@ function Lt() {
212
212
  }
213
213
  Re.displayName = "UniverIcon";
214
214
  var Ht = { 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" } }] }, $e = be(function(o, e) {
215
- return we(Re, Object.assign({}, o, {
215
+ return Me(Re, Object.assign({}, o, {
216
216
  id: "comment-single",
217
217
  ref: e,
218
218
  icon: Ht
@@ -246,7 +246,7 @@ const Yt = () => {
246
246
  const o = O(N), e = O(R), r = j(e.activePopup$), t = O(x);
247
247
  if (j(t.commentUpdate$), !r)
248
248
  return null;
249
- const { row: n, col: i, unitId: s, subUnitId: a, trigger: c } = r, m = t.getByLocation(s, a, n, i), h = `${We.chatAtABC(i)}${n + 1}`, d = () => {
249
+ const { row: n, col: i, unitId: s, subUnitId: a, trigger: c } = r, d = t.getByLocation(s, a, n, i), h = `${We.chatAtABC(i)}${n + 1}`, m = () => {
250
250
  e.hidePopup();
251
251
  }, u = (p) => {
252
252
  var _, S, U;
@@ -259,42 +259,42 @@ const Yt = () => {
259
259
  e.persistPopup();
260
260
  },
261
261
  prefix: "cell",
262
- id: m,
262
+ id: d,
263
263
  unitId: s,
264
264
  subUnitId: a,
265
265
  type: b.UNIVER_SHEET,
266
266
  refStr: h,
267
- onClose: d,
267
+ onClose: m,
268
268
  getSubUnitName: u,
269
269
  autoFocus: c === "context-menu"
270
270
  }
271
271
  );
272
272
  }, qt = () => {
273
273
  var g;
274
- const o = O(Ce), e = O(N), r = O(R), t = e.getCurrentUnitForType(b.UNIVER_SHEET), n = t.getUnitId(), i = O(se), s = Mt(() => t.activeSheet$.pipe(Tt((l) => l == null ? void 0 : l.getSheetId())), [t.activeSheet$]), a = j(s, (g = t.getActiveSheet()) == null ? void 0 : g.getSheetId()), c = Me(), m = O(ae), h = j(m.activeCommentId$), d = j(m.panelVisible$, m.panelVisible), u = le((l) => {
274
+ const o = O(Ce), e = O(N), r = O(R), t = e.getCurrentUnitForType(b.UNIVER_SHEET), n = t.getUnitId(), i = O(se), s = wt(() => t.activeSheet$.pipe(Tt((l) => l == null ? void 0 : l.getSheetId())), [t.activeSheet$]), a = j(s, (g = t.getActiveSheet()) == null ? void 0 : g.getSheetId()), c = we(), d = O(ae), h = j(d.activeCommentId$), m = j(d.panelVisible$, d.panelVisible), u = le((l) => {
275
275
  const I = t.getSheets(), f = {};
276
276
  I.forEach((T, C) => {
277
277
  f[T.getSheetId()] = C;
278
278
  });
279
- const M = (T) => T.map((C) => {
280
- var de;
281
- const y = A(C.ref), Ve = [(de = f[C.subUnitId]) != null ? de : 0, y.row, y.column];
279
+ const w = (T) => T.map((C) => {
280
+ var me;
281
+ const y = A(C.ref), Ve = [(me = f[C.subUnitId]) != null ? me : 0, y.row, y.column];
282
282
  return { ...C, p: Ve };
283
283
  }).sort((C, y) => C.p[0] === y.p[0] ? C.p[1] === y.p[1] ? C.p[2] - y.p[2] : C.p[1] - y.p[1] : C.p[0] - y.p[0]);
284
284
  return [
285
- ...M(l.filter((T) => !T.resolved)),
286
- ...M(l.filter((T) => T.resolved))
285
+ ...w(l.filter((T) => !T.resolved)),
286
+ ...w(l.filter((T) => T.resolved))
287
287
  ];
288
288
  }, [t]), p = le((l) => {
289
289
  var I;
290
290
  if (l.unitId === n && l.subUnitId === a && !l.resolved) {
291
- const { row: f, column: M } = A(l.ref), T = t.getSheetBySheetId(l.subUnitId), C = (I = T == null ? void 0 : T.getMergedCell(f, M)) != null ? I : {
292
- startColumn: M,
293
- endColumn: M,
291
+ const { row: f, column: w } = A(l.ref), T = t.getSheetBySheetId(l.subUnitId), C = (I = T == null ? void 0 : T.getMergedCell(f, w)) != null ? I : {
292
+ startColumn: w,
293
+ endColumn: w,
294
294
  startRow: f,
295
295
  endRow: f
296
296
  };
297
- if (!Number.isNaN(f) && !Number.isNaN(M))
297
+ if (!Number.isNaN(f) && !Number.isNaN(w))
298
298
  return o.addShape({
299
299
  range: C,
300
300
  style: {
@@ -319,9 +319,9 @@ const Yt = () => {
319
319
  }, ee = (l, I) => {
320
320
  I && r.hidePopup();
321
321
  };
322
- return wt(() => {
323
- !d && c.current && o.removeShape(c.current);
324
- }, [o, d]), /* @__PURE__ */ De.jsx(
322
+ return Mt(() => {
323
+ !m && c.current && o.removeShape(c.current);
324
+ }, [o, m]), /* @__PURE__ */ De.jsx(
325
325
  rt,
326
326
  {
327
327
  unitId: n,
@@ -339,7 +339,7 @@ const Yt = () => {
339
339
  }, Kt = (o) => ({
340
340
  id: V.id,
341
341
  type: Ie.BUTTON,
342
- icon: me,
342
+ icon: de,
343
343
  title: "sheetThreadComment.menu.addComment",
344
344
  hidden$: Pe(o, b.UNIVER_SHEET),
345
345
  disabled$: Se(o, {
@@ -350,7 +350,7 @@ const Yt = () => {
350
350
  }), Jt = (o) => ({
351
351
  id: fe.id,
352
352
  type: Ie.BUTTON,
353
- icon: me,
353
+ icon: de,
354
354
  tooltip: "sheetThreadComment.menu.commentManagement",
355
355
  disabled$: Se(o, {
356
356
  workbookTypes: [K],
@@ -397,7 +397,7 @@ let W = class extends $ {
397
397
  [
398
398
  [Ee, Yt],
399
399
  [ot, qt],
400
- [me, $e]
400
+ [de, $e]
401
401
  ].forEach(([o, e]) => {
402
402
  this._componentManager.register(o, e);
403
403
  });
@@ -446,19 +446,19 @@ let Z = class extends $ {
446
446
  row: a.rows[0],
447
447
  column: a.cols[0]
448
448
  };
449
- if (n.copyType === mt.CUT && this._copyInfo) {
450
- const { range: m, unitId: h, subUnitId: d } = this._copyInfo, u = {
451
- row: m.startRow,
452
- column: m.startColumn
449
+ if (n.copyType === dt.CUT && this._copyInfo) {
450
+ const { range: d, unitId: h, subUnitId: m } = this._copyInfo, u = {
451
+ row: d.startRow,
452
+ column: d.startColumn
453
453
  };
454
- if (!(i === h && s === d)) {
454
+ if (!(i === h && s === m)) {
455
455
  const p = [];
456
- Ze.foreach(m, (g, l) => {
457
- const I = this._sheetsThreadCommentModel.getAllByLocation(h, d, g, l);
456
+ Ze.foreach(d, (g, l) => {
457
+ const I = this._sheetsThreadCommentModel.getAllByLocation(h, m, g, l);
458
458
  this._threadCommentDataSourceService.syncUpdateMutationToColla ? I.forEach((f) => {
459
459
  p.push(f);
460
- }) : I.forEach(({ children: f, ...M }) => {
461
- M.parentId || p.push(M);
460
+ }) : I.forEach(({ children: f, ...w }) => {
461
+ w.parentId || p.push(w);
462
462
  });
463
463
  });
464
464
  const _ = [], S = [], U = [], D = [], ee = (g) => {
@@ -466,7 +466,7 @@ let Z = class extends $ {
466
466
  id: k.id,
467
467
  params: {
468
468
  unitId: h,
469
- subUnitId: d,
469
+ subUnitId: m,
470
470
  commentId: g.id
471
471
  }
472
472
  }), U.push({
@@ -486,7 +486,7 @@ let Z = class extends $ {
486
486
  id: ie.id,
487
487
  params: {
488
488
  unitId: h,
489
- subUnitId: d,
489
+ subUnitId: m,
490
490
  comment: g,
491
491
  sync: !0
492
492
  }
@@ -521,8 +521,8 @@ Z = sn([
521
521
  re(1, v(x)),
522
522
  re(2, ye)
523
523
  ], Z);
524
- var cn = Object.defineProperty, mn = Object.getOwnPropertyDescriptor, dn = (o, e, r, t) => {
525
- for (var n = t > 1 ? void 0 : t ? mn(e, r) : e, i = o.length - 1, s; i >= 0; i--)
524
+ var cn = Object.defineProperty, dn = Object.getOwnPropertyDescriptor, mn = (o, e, r, t) => {
525
+ for (var n = t > 1 ? void 0 : t ? dn(e, r) : e, i = o.length - 1, s; i >= 0; i--)
526
526
  (s = o[i]) && (n = (t ? s(e, r, n) : s(n)) || n);
527
527
  return t && n && cn(e, r, n), n;
528
528
  }, L = (o, e) => (r, t) => e(r, t, o);
@@ -543,8 +543,8 @@ let z = class extends $ {
543
543
  rangeTypes: [Q]
544
544
  }, [{ startRow: i, startColumn: s, endRow: i, endColumn: s }]))
545
545
  return;
546
- const m = this._sheetsThreadCommentModel.getComment(t, n, a);
547
- m && !m.resolved && this._sheetsThreadCommentPopupService.showPopup({
546
+ const d = this._sheetsThreadCommentModel.getComment(t, n, a);
547
+ d && !d.resolved && this._sheetsThreadCommentPopupService.showPopup({
548
548
  unitId: t,
549
549
  subUnitId: n,
550
550
  row: i,
@@ -559,8 +559,8 @@ let z = class extends $ {
559
559
  );
560
560
  }
561
561
  };
562
- z = dn([
563
- L(0, v(dt)),
562
+ z = mn([
563
+ L(0, v(mt)),
564
564
  L(1, v(R)),
565
565
  L(2, v(x)),
566
566
  L(3, v(ge))
@@ -569,13 +569,13 @@ var hn = Object.defineProperty, un = Object.getOwnPropertyDescriptor, ln = (o, e
569
569
  for (var n = t > 1 ? void 0 : t ? un(e, r) : e, i = o.length - 1, s; i >= 0; i--)
570
570
  (s = o[i]) && (n = (t ? s(e, r, n) : s(n)) || n);
571
571
  return t && n && hn(e, r, n), n;
572
- }, w = (o, e) => (r, t) => e(r, t, o);
572
+ }, M = (o, e) => (r, t) => e(r, t, o);
573
573
  let G = class extends $ {
574
- constructor(e, r, t, n, i, s, a, c, m, h) {
574
+ constructor(e, r, t, n, i, s, a, c, d, h) {
575
575
  super();
576
576
  E(this, "_isSwitchToCommenting", !1);
577
577
  E(this, "_selectionShapeInfo", null);
578
- this._commandService = e, this._sheetsThreadCommentPopupService = r, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = n, this._univerInstanceService = i, this._sheetPermissionInterceptorBaseController = s, this._markSelectionService = a, this._sheetSelectionService = c, this._editorBridgeService = m, this._renderManagerService = h, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
578
+ this._commandService = e, this._sheetsThreadCommentPopupService = r, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = n, this._univerInstanceService = i, this._sheetPermissionInterceptorBaseController = s, this._markSelectionService = a, this._sheetSelectionService = c, this._editorBridgeService = d, this._renderManagerService = h, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
579
579
  }
580
580
  _handleSelectionChange(e, r, t) {
581
581
  var u, p, _;
@@ -587,16 +587,16 @@ let G = class extends $ {
587
587
  this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(te.id);
588
588
  return;
589
589
  }
590
- const m = a.actualRow, h = a.actualColumn;
591
- if (!this._sheetsThreadCommentModel.showCommentMarker(r, t, m, h)) {
590
+ const d = a.actualRow, h = a.actualColumn;
591
+ if (!this._sheetsThreadCommentModel.showCommentMarker(r, t, d, h)) {
592
592
  this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(te.id);
593
593
  return;
594
594
  }
595
- const d = this._sheetsThreadCommentModel.getByLocation(r, t, m, h);
596
- d && this._commandService.executeCommand(te.id, {
595
+ const m = this._sheetsThreadCommentModel.getByLocation(r, t, d, h);
596
+ m && this._commandService.executeCommand(te.id, {
597
597
  unitId: r,
598
598
  subUnitId: t,
599
- commentId: d
599
+ commentId: m
600
600
  });
601
601
  }
602
602
  _initSelectionUpdateListener() {
@@ -641,7 +641,7 @@ let G = class extends $ {
641
641
  unitId: t,
642
642
  subUnitId: n
643
643
  }), this._isSwitchToCommenting = !1;
644
- const d = A(a.ref), { row: u, column: p } = d;
644
+ const m = A(a.ref), { row: u, column: p } = m;
645
645
  if (!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
646
646
  workbookTypes: [K],
647
647
  worksheetTypes: [J],
@@ -651,18 +651,18 @@ let G = class extends $ {
651
651
  const S = 1;
652
652
  if (await this._commandService.executeCommand(lt.id, {
653
653
  range: {
654
- startRow: Math.max(d.row - S, 0),
655
- endRow: d.row + S,
656
- startColumn: Math.max(d.column - S, 0),
657
- endColumn: d.column + S
654
+ startRow: Math.max(m.row - S, 0),
655
+ endRow: m.row + S,
656
+ startColumn: Math.max(m.column - S, 0),
657
+ endColumn: m.column + S
658
658
  }
659
659
  }), this._editorBridgeService.isVisible().visible)
660
660
  return;
661
661
  this._sheetsThreadCommentPopupService.showPopup({
662
662
  unitId: t,
663
663
  subUnitId: n,
664
- row: d.row,
665
- col: d.column,
664
+ row: m.row,
665
+ col: m.column,
666
666
  commentId: a.id,
667
667
  trigger: s
668
668
  });
@@ -685,12 +685,12 @@ let G = class extends $ {
685
685
  const s = A(i.ref), { row: a, column: c } = s;
686
686
  if (Number.isNaN(a) || Number.isNaN(c))
687
687
  return null;
688
- const m = (u = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : u.getSheetBySheetId(t), h = (p = m == null ? void 0 : m.getMergedCell(a, c)) != null ? p : {
688
+ const d = (u = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : u.getSheetBySheetId(t), h = (p = d == null ? void 0 : d.getMergedCell(a, c)) != null ? p : {
689
689
  startColumn: c,
690
690
  endColumn: c,
691
691
  startRow: a,
692
692
  endRow: a
693
- }, d = this._markSelectionService.addShape(
693
+ }, m = this._markSelectionService.addShape(
694
694
  {
695
695
  range: h,
696
696
  style: {
@@ -705,24 +705,24 @@ let G = class extends $ {
705
705
  [],
706
706
  -1
707
707
  );
708
- d && (this._selectionShapeInfo = {
708
+ m && (this._selectionShapeInfo = {
709
709
  ...e,
710
- shapeId: d
710
+ shapeId: m
711
711
  });
712
712
  }));
713
713
  }
714
714
  };
715
715
  G = ln([
716
- w(0, se),
717
- w(1, v(R)),
718
- w(2, v(x)),
719
- w(3, v(ae)),
720
- w(4, N),
721
- w(5, v(ge)),
722
- w(6, Ce),
723
- w(7, v(ve)),
724
- w(8, ht),
725
- w(9, Te)
716
+ M(0, se),
717
+ M(1, v(R)),
718
+ M(2, v(x)),
719
+ M(3, v(ae)),
720
+ M(4, N),
721
+ M(5, v(ge)),
722
+ M(6, Ce),
723
+ M(7, v(ve)),
724
+ M(8, ht),
725
+ M(9, Te)
726
726
  ], G);
727
727
  var pn = Object.defineProperty, vn = Object.getOwnPropertyDescriptor, _n = (o, e, r, t) => {
728
728
  for (var n = t > 1 ? void 0 : t ? vn(e, r) : e, i = o.length - 1, s; i >= 0; i--)
@@ -745,26 +745,26 @@ let Y = class extends $ {
745
745
  const n = t.getUnitId(), i = r.subUnitId || ((e = t.getActiveSheet()) == null ? void 0 : e.getSheetId());
746
746
  if (!i)
747
747
  return { redos: [], undos: [] };
748
- const s = this._threadCommentModel.ensureMap(n, i), a = Array.from(s.values()).filter((u) => !u.parentId), c = a.map((u) => u.id), m = this._threadCommentDataSourceService.syncUpdateMutationToColla, h = c.map((u) => ({
748
+ const s = this._threadCommentModel.ensureMap(n, i), a = Array.from(s.values()).filter((u) => !u.parentId), c = a.map((u) => u.id), d = this._threadCommentDataSourceService.syncUpdateMutationToColla, h = c.map((u) => ({
749
749
  id: k.id,
750
750
  params: {
751
751
  unitId: n,
752
752
  subUnitId: i,
753
753
  commentId: u
754
754
  }
755
- })), d = a.map(({ children: u, ...p }) => ({
755
+ })), m = a.map(({ children: u, ...p }) => ({
756
756
  id: ie.id,
757
757
  params: {
758
758
  unitId: n,
759
759
  subUnitId: i,
760
760
  comment: {
761
761
  ...p,
762
- children: m ? u : void 0
762
+ children: d ? u : void 0
763
763
  },
764
- sync: !m
764
+ sync: !d
765
765
  }
766
766
  }));
767
- return { redos: h, undos: d };
767
+ return { redos: h, undos: m };
768
768
  }
769
769
  return { redos: [], undos: [] };
770
770
  }
@@ -820,16 +820,15 @@ q = Sn([
820
820
  oe(3, Ke)
821
821
  ], q);
822
822
  export {
823
- An as AddCommentCommand,
824
- Vn as DeleteCommentCommand,
825
- Bn as DeleteCommentTreeCommand,
826
- Ln as IThreadCommentDataSourceService,
827
- xn as IThreadCommentMentionDataService,
828
- Hn as ResolveCommentCommand,
823
+ jn as AddCommentCommand,
824
+ An as DeleteCommentCommand,
825
+ Vn as DeleteCommentTreeCommand,
826
+ Bn as IThreadCommentDataSourceService,
827
+ Ln as ResolveCommentCommand,
829
828
  Oe as SHEETS_THREAD_COMMENT,
830
829
  R as SheetsThreadCommentPopupService,
831
830
  V as ShowAddSheetCommentModalOperation,
832
831
  q as UniverSheetsThreadCommentUIPlugin,
833
- Dn as UniverThreadCommentUIPlugin,
834
- kn as UpdateCommentCommand
832
+ xn as UniverThreadCommentUIPlugin,
833
+ Hn as UpdateCommentCommand
835
834
  };
@@ -19,6 +19,5 @@ export { SheetsThreadCommentPopupService } from './services/sheets-thread-commen
19
19
  export { SHEETS_THREAD_COMMENT } from './types/const';
20
20
  export { IThreadCommentDataSourceService } from '@univerjs/thread-comment';
21
21
  export { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';
22
- export { IThreadCommentMentionDataService } from '@univerjs/thread-comment-ui';
23
22
  export { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, ResolveCommentCommand, UpdateCommentCommand, } from '@univerjs/thread-comment';
24
23
  export type { IAddCommentCommandParams, IDeleteCommentCommandParams, IDeleteCommentTreeCommandParams, IResolveCommentCommandParams, IUpdateCommentCommandParams, } from '@univerjs/thread-comment';
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/engine-formula","@univerjs/thread-comment"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverSheetsThreadCommentUi={},c.UniverCore,c.UniverSheets,c.UniverSheetsThreadComment,c.UniverThreadCommentUi,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverEngineRender,c.React,c.UniverEngineFormula,c.UniverThreadComment))})(this,function(c,a,p,A,I,g,f,k,re,E,$,C){"use strict";var st=Object.defineProperty;var at=(c,a,p)=>a in c?st(c,a,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[a]=p;var N=(c,a,p)=>at(c,typeof a!="symbol"?a+"":a,p);const ie="univer.sheet.thread-comment-modal",J="comment-single",Q="SHEET_THREAD_COMMENT";var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,_e=(i,t,r,e)=>{for(var n=e>1?void 0:e?Se(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&ve(t,r,n),n},oe=(i,t)=>(r,e)=>t(r,e,i);c.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(r,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new k.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}showPopup(r,e){var l;const{row:n,col:o,unitId:s,subUnitId:d}=r;if(this._activePopup&&n===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&d===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const u=this._canvasPopupManagerService.attachPopupToCell(n,o,{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const m=new a.DisposableCollection;m.add(u),m.add({dispose:()=>{e==null||e()}}),this._lastPopup=m}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))}},c.SheetsThreadCommentPopupService=_e([oe(0,a.Inject(g.SheetCanvasPopManagerService)),oe(1,f.IZenZoneService)],c.SheetsThreadCommentPopupService);const B={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var P;const t=i.get(p.SheetsSelectionsService),r=i.get(a.IUniverInstanceService),e=i.get(c.SheetsThreadCommentPopupService),n=i.get(I.ThreadCommentPanelService),o=(P=t.getCurrentLastSelection())==null?void 0:P.primary,s=i.get(A.SheetsThreadCommentModel);if(!o)return!1;const d=p.getSheetCommandTarget(r);if(!d)return!1;const{workbook:u,worksheet:m,unitId:l,subUnitId:h}=d,v={workbook:u,worksheet:m,unitId:l,subUnitId:h,row:o.startRow,col:o.startColumn};e.showPopup(v);const _=s.getByLocation(l,h,o.startRow,o.startColumn);return _&&n.setActiveComment({unitId:l,subUnitId:h,commentId:_,trigger:"context-menu"}),!0}},fe="sheets-thread-comment.config",Ce={};var Ie=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Pe=(i,t,r,e)=>{for(var n=e>1?void 0:e?ge(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&Ie(t,r,n),n},L=(i,t)=>(r,e)=>t(r,e,i);let x=class extends a.Disposable{constructor(i,t,r,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(i,t,r)=>{const{row:e,col:n,unitId:o,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,s,e,n)?r({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):r(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var n;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(n=e==null?void 0:e.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{i()}))}};x=Pe([L(0,a.Inject(p.SheetInterceptorService)),L(1,a.Inject(A.SheetsThreadCommentModel)),L(2,a.IUniverInstanceService),L(3,re.IRenderManagerService)],x);var y=function(){return y=Object.assign||function(i){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},y.apply(this,arguments)},Te=function(i,t){var r={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(r[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)t.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(r[e[n]]=i[e[n]]);return r},se=E.forwardRef(function(i,t){var r=i.icon,e=i.id,n=i.className,o=i.extend,s=Te(i,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),u=E.useRef("_".concat(Me()));return ae(r,"".concat(e),{defIds:r.defIds,idSuffix:u.current},y({ref:t,className:d},s),o)});function ae(i,t,r,e,n){return E.createElement(i.tag,y(y({key:t},be(i,r,n)),e),(ye(i,r).children||[]).map(function(o,s){return ae(o,"".concat(t,"-").concat(i.tag,"-").concat(s),r,void 0,n)}))}function be(i,t,r){var e=y({},i.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1);var n=t.defIds;return!n||n.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],d=o[1];typeof d=="string"&&(e[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ye(i,t){var r,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((r=i.children)===null||r===void 0)&&r.length)?y(y({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?y(y({},n),{attrs:y(y({},n.attrs),{id:n.attrs.id+t.idSuffix})}):n})}):i}function Me(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var we={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"}}]},ce=E.forwardRef(function(i,t){return E.createElement(se,Object.assign({},i,{id:"comment-single",ref:t,icon:we}))});ce.displayName="CommentSingle";var de={exports:{}},W={};/**
1
+ (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/engine-formula","@univerjs/thread-comment"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverSheetsThreadCommentUi={},c.UniverCore,c.UniverSheets,c.UniverSheetsThreadComment,c.UniverThreadCommentUi,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverEngineRender,c.React,c.UniverEngineFormula,c.UniverThreadComment))})(this,function(c,a,p,A,P,I,f,k,re,E,$,C){"use strict";var st=Object.defineProperty;var at=(c,a,p)=>a in c?st(c,a,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[a]=p;var N=(c,a,p)=>at(c,typeof a!="symbol"?a+"":a,p);const ie="univer.sheet.thread-comment-modal",J="comment-single",Q="SHEET_THREAD_COMMENT";var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,_e=(i,t,r,e)=>{for(var n=e>1?void 0:e?Se(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&ve(t,r,n),n},oe=(i,t)=>(r,e)=>t(r,e,i);c.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(r,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new k.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}showPopup(r,e){var l;const{row:n,col:o,unitId:s,subUnitId:d}=r;if(this._activePopup&&n===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&d===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const u=this._canvasPopupManagerService.attachPopupToCell(n,o,{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const m=new a.DisposableCollection;m.add(u),m.add({dispose:()=>{e==null||e()}}),this._lastPopup=m}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))}},c.SheetsThreadCommentPopupService=_e([oe(0,a.Inject(I.SheetCanvasPopManagerService)),oe(1,f.IZenZoneService)],c.SheetsThreadCommentPopupService);const B={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var g;const t=i.get(p.SheetsSelectionsService),r=i.get(a.IUniverInstanceService),e=i.get(c.SheetsThreadCommentPopupService),n=i.get(P.ThreadCommentPanelService),o=(g=t.getCurrentLastSelection())==null?void 0:g.primary,s=i.get(A.SheetsThreadCommentModel);if(!o)return!1;const d=p.getSheetCommandTarget(r);if(!d)return!1;const{workbook:u,worksheet:m,unitId:l,subUnitId:h}=d,v={workbook:u,worksheet:m,unitId:l,subUnitId:h,row:o.startRow,col:o.startColumn};e.showPopup(v);const _=s.getByLocation(l,h,o.startRow,o.startColumn);return _&&n.setActiveComment({unitId:l,subUnitId:h,commentId:_,trigger:"context-menu"}),!0}},fe="sheets-thread-comment.config",Ce={};var Ie=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Pe=(i,t,r,e)=>{for(var n=e>1?void 0:e?ge(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&Ie(t,r,n),n},L=(i,t)=>(r,e)=>t(r,e,i);let x=class extends a.Disposable{constructor(i,t,r,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(i,t,r)=>{const{row:e,col:n,unitId:o,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,s,e,n)?r({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):r(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var n;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(n=e==null?void 0:e.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{i()}))}};x=Pe([L(0,a.Inject(p.SheetInterceptorService)),L(1,a.Inject(A.SheetsThreadCommentModel)),L(2,a.IUniverInstanceService),L(3,re.IRenderManagerService)],x);var y=function(){return y=Object.assign||function(i){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},y.apply(this,arguments)},Te=function(i,t){var r={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(r[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)t.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(r[e[n]]=i[e[n]]);return r},se=E.forwardRef(function(i,t){var r=i.icon,e=i.id,n=i.className,o=i.extend,s=Te(i,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),u=E.useRef("_".concat(Me()));return ae(r,"".concat(e),{defIds:r.defIds,idSuffix:u.current},y({ref:t,className:d},s),o)});function ae(i,t,r,e,n){return E.createElement(i.tag,y(y({key:t},be(i,r,n)),e),(ye(i,r).children||[]).map(function(o,s){return ae(o,"".concat(t,"-").concat(i.tag,"-").concat(s),r,void 0,n)}))}function be(i,t,r){var e=y({},i.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1);var n=t.defIds;return!n||n.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],d=o[1];typeof d=="string"&&(e[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ye(i,t){var r,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((r=i.children)===null||r===void 0)&&r.length)?y(y({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?y(y({},n),{attrs:y(y({},n.attrs),{id:n.attrs.id+t.idSuffix})}):n})}):i}function Me(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var we={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"}}]},ce=E.forwardRef(function(i,t){return E.createElement(se,Object.assign({},i,{id:"comment-single",ref:t,icon:we}))});ce.displayName="CommentSingle";var de={exports:{}},W={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Oe=E,Ee=Symbol.for("react.element"),Re=Symbol.for("react.fragment"),Ue=Object.prototype.hasOwnProperty,je=Oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,De={key:!0,ref:!0,__self:!0,__source:!0};function ue(i,t,r){var e,n={},o=null,s=null;r!==void 0&&(o=""+r),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(s=t.ref);for(e in t)Ue.call(t,e)&&!De.hasOwnProperty(e)&&(n[e]=t[e]);if(i&&i.defaultProps)for(e in t=i.defaultProps,t)n[e]===void 0&&(n[e]=t[e]);return{$$typeof:Ee,type:i,key:o,ref:s,props:n,_owner:je.current}}W.Fragment=Re,W.jsx=ue,W.jsxs=ue,de.exports=W;var me=de.exports;const Ne=()=>{const i=a.useDependency(a.IUniverInstanceService),t=a.useDependency(c.SheetsThreadCommentPopupService),r=f.useObservable(t.activePopup$),e=a.useDependency(A.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!r)return null;const{row:n,col:o,unitId:s,subUnitId:d,trigger:u}=r,m=e.getByLocation(s,d,n,o),l=`${a.Tools.chatAtABC(o)}${n+1}`,h=()=>{t.hidePopup()},v=_=>{var P,M,V;return(V=(M=(P=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:P.getSheetBySheetId(_))==null?void 0:M.getName())!=null?V:""};return me.jsx(I.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:s,subUnitId:d,type:a.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:v,autoFocus:u==="context-menu"})},Ae=()=>{var w;const i=a.useDependency(g.IMarkSelectionService),t=a.useDependency(a.IUniverInstanceService),r=a.useDependency(c.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getUnitId(),o=a.useDependency(a.ICommandService),s=E.useMemo(()=>e.activeSheet$.pipe(k.map(S=>S==null?void 0:S.getSheetId())),[e.activeSheet$]),d=f.useObservable(s,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=E.useRef(),m=a.useDependency(I.ThreadCommentPanelService),l=f.useObservable(m.activeCommentId$),h=f.useObservable(m.panelVisible$,m.panelVisible),v=E.useCallback(S=>{const O=e.getSheets(),T={};O.forEach((R,b)=>{T[R.getSheetId()]=b});const j=R=>R.map(b=>{var pe;const D=$.singleReferenceToGrid(b.ref),ot=[(pe=T[b.subUnitId])!=null?pe:0,D.row,D.column];return{...b,p:ot}}).sort((b,D)=>b.p[0]===D.p[0]?b.p[1]===D.p[1]?b.p[2]-D.p[2]:b.p[1]-D.p[1]:b.p[0]-D.p[0]);return[...j(S.filter(R=>!R.resolved)),...j(S.filter(R=>R.resolved))]},[e]),_=E.useCallback(S=>{var O;if(S.unitId===n&&S.subUnitId===d&&!S.resolved){const{row:T,column:j}=$.singleReferenceToGrid(S.ref),R=e.getSheetBySheetId(S.subUnitId),b=(O=R==null?void 0:R.getMergedCell(T,j))!=null?O:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return i.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,d,n]),P=S=>{var O,T;return(T=(O=e.getSheetBySheetId(S))==null?void 0:O.getName())!=null?T:""},M=()=>{o.executeCommand(B.id)},V=S=>{l&&l.unitId===S.unitId&&l.subUnitId===S.subUnitId&&l.commentId===S.id||(u.current&&(i.removeShape(u.current),u.current=null),u.current=_(S))},H=()=>{u.current&&(i.removeShape(u.current),u.current=null)},ne=(S,O)=>{O&&r.hidePopup()};return E.useEffect(()=>{!h&&u.current&&i.removeShape(u.current)},[i,h]),me.jsx(I.ThreadCommentPanel,{unitId:n,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:P,onResolve:ne,sortComments:v,onItemEnter:V,onItemLeave:H,onDeleteComment:()=>(H(),!0)})},Ve=i=>({id:B.id,type:f.MenuItemType.BUTTON,icon:J,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:g.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),$e=i=>({id:I.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:J,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:g.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}),Be={id:B.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:g.whenSheetEditorFocused},ke={[f.RibbonStartGroup.OTHERS]:{[I.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:$e}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[B.id]:{order:0,menuItemFactory:Ve}}}};var He=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,xe=(i,t,r,e)=>{for(var n=e>1?void 0:e?Le(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&He(t,r,n),n},X=(i,t)=>(r,e)=>t(r,e,i);let F=class extends a.Disposable{constructor(i,t,r){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Be)}_initMenu(){this._menuManagerService.mergeMenu(ke)}_initComponent(){[[ie,Ne],[I.THREAD_COMMENT_PANEL,Ae],[J,ce]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};F=xe([X(0,f.IMenuManagerService),X(1,a.Inject(f.ComponentManager)),X(2,f.IShortcutService)],F);var We=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Ge=(i,t,r,e)=>{for(var n=e>1?void 0:e?Fe(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&We(t,r,n),n},ee=(i,t)=>(r,e)=>t(r,e,i);const Ze=(i,t,r)=>{const e=$.singleReferenceToGrid(i),n=r.row-t.row,o=r.column-t.column,s={startColumn:e.column+o,startRow:e.row+n,endColumn:e.column+o,endRow:e.row+n};return $.serializeRange(s)};let G=class extends a.Disposable{constructor(t,r,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,n)=>{const{unitId:o,subUnitId:s,range:d}=r,u={row:d.rows[0],column:d.cols[0]};if(n.copyType===g.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,v={row:m.startRow,column:m.startColumn};if(!(o===l&&s===h)){const _=[];a.Range.foreach(m,(w,S)=>{const O=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,S);this._threadCommentDataSourceService.syncUpdateMutationToColla?O.forEach(T=>{_.push(T)}):O.forEach(({children:T,...j})=>{j.parentId||_.push(j)})});const P=[],M=[],V=[],H=[],ne=w=>{P.unshift({id:C.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:s,comment:{...w,ref:Ze(w.ref,v,u),unitId:o,subUnitId:s},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:l,subUnitId:h,comment:w,sync:!0}}),H.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:s,commentId:w.id}})};return _.forEach(w=>{ne(w)}),{redos:[...P,...V],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};G=Ge([ee(0,a.Inject(g.ISheetClipboardService)),ee(1,a.Inject(A.SheetsThreadCommentModel)),ee(2,C.IThreadCommentDataSourceService)],G);var ze=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Ke=(i,t,r,e)=>{for(var n=e>1?void 0:e?Ye(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&ze(t,r,n),n},Z=(i,t)=>(r,e)=>t(r,e,i);let z=class extends a.Disposable{constructor(i,t,r,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:r}=i,{unitId:e,subUnitId:n,row:o,col:s}=r,d=this._sheetsThreadCommentModel.getByLocation(e,n,o,s);if(d){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}]))return;const m=this._sheetsThreadCommentModel.getComment(e,n,d);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:n,row:o,col:s,commentId:d,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};z=Ke([Z(0,a.Inject(g.HoverManagerService)),Z(1,a.Inject(c.SheetsThreadCommentPopupService)),Z(2,a.Inject(A.SheetsThreadCommentModel)),Z(3,a.Inject(g.SheetPermissionInterceptorBaseController))],z);var qe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(i,t,r,e)=>{for(var n=e>1?void 0:e?Je(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&qe(t,r,n),n},U=(i,t)=>(r,e)=>t(r,e,i);let Y=class extends a.Disposable{constructor(t,r,e,n,o,s,d,u,m,l){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=n,this._univerInstanceService=o,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=d,this._sheetSelectionService=u,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var v,_,P;const n=(v=t[0])==null?void 0:v.range,o=this._renderManagerService.getRenderById(r),s=(_=o==null?void 0:o.with(g.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:_.skeleton;if(!s||!n)return;const d=s.getCellWithCoordByIndex(n.startRow,n.startColumn);if((((P=n.rangeType)!=null?P:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||n.endColumn-n.startColumn>0||n.endRow-n.startRow>0)&&!((d.isMerged||d.isMergedMainCell)&&a.Rectangle.equals(d.mergeInfo,n))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const m=d.actualRow,l=d.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,m,l);h&&this._commandService.executeCommand(I.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:n,subUnitId:o,commentId:s}=e;r.unitId===n&&r.subUnitId===o&&r.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:n,commentId:o,trigger:s}=t,d=this._sheetsThreadCommentModel.getComment(e,n,o);if(!d||d.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=u.getActiveSheet())==null?void 0:r.getSheetId())!==n&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:n}),this._isSwitchToCommenting=!1;const h=$.singleReferenceToGrid(d.ref),{row:v,column:_}=h;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:v,startColumn:_,endRow:v,endColumn:_}]))return;const M=1;if(await this._commandService.executeCommand(g.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-M,0),endRow:h.row+M,startColumn:Math.max(h.column-M,0),endColumn:h.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:n,row:h.row,col:h.column,commentId:d.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var v,_;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:n}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(r,e,n);if(!o)return;const s=$.singleReferenceToGrid(o.ref),{row:d,column:u}=s;if(Number.isNaN(d)||Number.isNaN(u))return null;const m=(v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getSheetBySheetId(e),l=(_=m==null?void 0:m.getMergedCell(d,u))!=null?_:{startColumn:u,endColumn:u,startRow:d,endRow:d},h=this._markSelectionService.addShape({range:l,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Y=Qe([U(0,a.ICommandService),U(1,a.Inject(c.SheetsThreadCommentPopupService)),U(2,a.Inject(A.SheetsThreadCommentModel)),U(3,a.Inject(I.ThreadCommentPanelService)),U(4,a.IUniverInstanceService),U(5,a.Inject(g.SheetPermissionInterceptorBaseController)),U(6,g.IMarkSelectionService),U(7,a.Inject(p.SheetsSelectionsService)),U(8,g.IEditorBridgeService),U(9,re.IRenderManagerService)],Y);var Xe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(i,t,r,e)=>{for(var n=e>1?void 0:e?et(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&Xe(t,r,n),n},K=(i,t)=>(r,e)=>t(r,e,i);let q=class extends a.Disposable{constructor(i,t,r,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===p.RemoveSheetCommand.id){const r=i.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const n=e.getUnitId(),o=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(n,o),d=Array.from(s.values()).filter(v=>!v.parentId),u=d.map(v=>v.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=u.map(v=>({id:C.DeleteCommentMutation.id,params:{unitId:n,subUnitId:o,commentId:v}})),h=d.map(({children:v,..._})=>({id:C.AddCommentMutation.id,params:{unitId:n,subUnitId:o,comment:{..._,children:m?v:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};q=tt([K(0,a.Inject(p.SheetInterceptorService)),K(1,a.IUniverInstanceService),K(2,a.Inject(C.ThreadCommentModel)),K(3,C.IThreadCommentDataSourceService)],q);var he=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,rt=(i,t,r)=>t in i?he(i,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[t]=r,it=(i,t,r,e)=>{for(var n=e>1?void 0:e?nt(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&he(t,r,n),n},te=(i,t)=>(r,e)=>t(r,e,i),le=(i,t,r)=>rt(i,typeof t!="symbol"?t+"":t,r);c.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=Ce,r,e,n){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=n;const{menu:o,...s}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(fe,s)}onStarting(){[[F],[x],[G],[z],[q],[Y],[c.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[B].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(F)}onReady(){this._injector.get(x),this._injector.get(q)}onRendered(){this._injector.get(G),this._injector.get(z),this._injector.get(Y)}},le(c.UniverSheetsThreadCommentUIPlugin,"pluginName",Q),le(c.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentUIPlugin=it([a.DependentOn(I.UniverThreadCommentUIPlugin,A.UniverSheetsThreadCommentPlugin),te(1,a.Inject(a.Injector)),te(2,a.Inject(a.ICommandService)),te(3,a.IConfigService)],c.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(c,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>I.IThreadCommentMentionDataService}),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>I.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"AddCommentCommand",{enumerable:!0,get:()=>C.AddCommentCommand}),Object.defineProperty(c,"DeleteCommentCommand",{enumerable:!0,get:()=>C.DeleteCommentCommand}),Object.defineProperty(c,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>C.DeleteCommentTreeCommand}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>C.IThreadCommentDataSourceService}),Object.defineProperty(c,"ResolveCommentCommand",{enumerable:!0,get:()=>C.ResolveCommentCommand}),Object.defineProperty(c,"UpdateCommentCommand",{enumerable:!0,get:()=>C.UpdateCommentCommand}),c.SHEETS_THREAD_COMMENT=Q,c.ShowAddSheetCommentModalOperation=B,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
9
+ */var Oe=E,Ee=Symbol.for("react.element"),Re=Symbol.for("react.fragment"),Ue=Object.prototype.hasOwnProperty,je=Oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,De={key:!0,ref:!0,__self:!0,__source:!0};function ue(i,t,r){var e,n={},o=null,s=null;r!==void 0&&(o=""+r),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(s=t.ref);for(e in t)Ue.call(t,e)&&!De.hasOwnProperty(e)&&(n[e]=t[e]);if(i&&i.defaultProps)for(e in t=i.defaultProps,t)n[e]===void 0&&(n[e]=t[e]);return{$$typeof:Ee,type:i,key:o,ref:s,props:n,_owner:je.current}}W.Fragment=Re,W.jsx=ue,W.jsxs=ue,de.exports=W;var me=de.exports;const Ne=()=>{const i=a.useDependency(a.IUniverInstanceService),t=a.useDependency(c.SheetsThreadCommentPopupService),r=f.useObservable(t.activePopup$),e=a.useDependency(A.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!r)return null;const{row:n,col:o,unitId:s,subUnitId:d,trigger:u}=r,m=e.getByLocation(s,d,n,o),l=`${a.Tools.chatAtABC(o)}${n+1}`,h=()=>{t.hidePopup()},v=_=>{var g,M,V;return(V=(M=(g=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getSheetBySheetId(_))==null?void 0:M.getName())!=null?V:""};return me.jsx(P.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:s,subUnitId:d,type:a.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:v,autoFocus:u==="context-menu"})},Ae=()=>{var w;const i=a.useDependency(I.IMarkSelectionService),t=a.useDependency(a.IUniverInstanceService),r=a.useDependency(c.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getUnitId(),o=a.useDependency(a.ICommandService),s=E.useMemo(()=>e.activeSheet$.pipe(k.map(S=>S==null?void 0:S.getSheetId())),[e.activeSheet$]),d=f.useObservable(s,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=E.useRef(),m=a.useDependency(P.ThreadCommentPanelService),l=f.useObservable(m.activeCommentId$),h=f.useObservable(m.panelVisible$,m.panelVisible),v=E.useCallback(S=>{const O=e.getSheets(),T={};O.forEach((R,b)=>{T[R.getSheetId()]=b});const j=R=>R.map(b=>{var pe;const D=$.singleReferenceToGrid(b.ref),ot=[(pe=T[b.subUnitId])!=null?pe:0,D.row,D.column];return{...b,p:ot}}).sort((b,D)=>b.p[0]===D.p[0]?b.p[1]===D.p[1]?b.p[2]-D.p[2]:b.p[1]-D.p[1]:b.p[0]-D.p[0]);return[...j(S.filter(R=>!R.resolved)),...j(S.filter(R=>R.resolved))]},[e]),_=E.useCallback(S=>{var O;if(S.unitId===n&&S.subUnitId===d&&!S.resolved){const{row:T,column:j}=$.singleReferenceToGrid(S.ref),R=e.getSheetBySheetId(S.subUnitId),b=(O=R==null?void 0:R.getMergedCell(T,j))!=null?O:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return i.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,d,n]),g=S=>{var O,T;return(T=(O=e.getSheetBySheetId(S))==null?void 0:O.getName())!=null?T:""},M=()=>{o.executeCommand(B.id)},V=S=>{l&&l.unitId===S.unitId&&l.subUnitId===S.subUnitId&&l.commentId===S.id||(u.current&&(i.removeShape(u.current),u.current=null),u.current=_(S))},H=()=>{u.current&&(i.removeShape(u.current),u.current=null)},ne=(S,O)=>{O&&r.hidePopup()};return E.useEffect(()=>{!h&&u.current&&i.removeShape(u.current)},[i,h]),me.jsx(P.ThreadCommentPanel,{unitId:n,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:g,onResolve:ne,sortComments:v,onItemEnter:V,onItemLeave:H,onDeleteComment:()=>(H(),!0)})},Ve=i=>({id:B.id,type:f.MenuItemType.BUTTON,icon:J,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:I.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),$e=i=>({id:P.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:J,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:I.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}),Be={id:B.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:I.whenSheetEditorFocused},ke={[f.RibbonStartGroup.OTHERS]:{[P.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:$e}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[B.id]:{order:0,menuItemFactory:Ve}}}};var He=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,xe=(i,t,r,e)=>{for(var n=e>1?void 0:e?Le(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&He(t,r,n),n},X=(i,t)=>(r,e)=>t(r,e,i);let F=class extends a.Disposable{constructor(i,t,r){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Be)}_initMenu(){this._menuManagerService.mergeMenu(ke)}_initComponent(){[[ie,Ne],[P.THREAD_COMMENT_PANEL,Ae],[J,ce]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};F=xe([X(0,f.IMenuManagerService),X(1,a.Inject(f.ComponentManager)),X(2,f.IShortcutService)],F);var We=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Ge=(i,t,r,e)=>{for(var n=e>1?void 0:e?Fe(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&We(t,r,n),n},ee=(i,t)=>(r,e)=>t(r,e,i);const Ze=(i,t,r)=>{const e=$.singleReferenceToGrid(i),n=r.row-t.row,o=r.column-t.column,s={startColumn:e.column+o,startRow:e.row+n,endColumn:e.column+o,endRow:e.row+n};return $.serializeRange(s)};let G=class extends a.Disposable{constructor(t,r,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,n)=>{const{unitId:o,subUnitId:s,range:d}=r,u={row:d.rows[0],column:d.cols[0]};if(n.copyType===I.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,v={row:m.startRow,column:m.startColumn};if(!(o===l&&s===h)){const _=[];a.Range.foreach(m,(w,S)=>{const O=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,S);this._threadCommentDataSourceService.syncUpdateMutationToColla?O.forEach(T=>{_.push(T)}):O.forEach(({children:T,...j})=>{j.parentId||_.push(j)})});const g=[],M=[],V=[],H=[],ne=w=>{g.unshift({id:C.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:s,comment:{...w,ref:Ze(w.ref,v,u),unitId:o,subUnitId:s},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:l,subUnitId:h,comment:w,sync:!0}}),H.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:s,commentId:w.id}})};return _.forEach(w=>{ne(w)}),{redos:[...g,...V],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};G=Ge([ee(0,a.Inject(I.ISheetClipboardService)),ee(1,a.Inject(A.SheetsThreadCommentModel)),ee(2,C.IThreadCommentDataSourceService)],G);var ze=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Ke=(i,t,r,e)=>{for(var n=e>1?void 0:e?Ye(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&ze(t,r,n),n},Z=(i,t)=>(r,e)=>t(r,e,i);let z=class extends a.Disposable{constructor(i,t,r,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:r}=i,{unitId:e,subUnitId:n,row:o,col:s}=r,d=this._sheetsThreadCommentModel.getByLocation(e,n,o,s);if(d){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}]))return;const m=this._sheetsThreadCommentModel.getComment(e,n,d);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:n,row:o,col:s,commentId:d,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};z=Ke([Z(0,a.Inject(I.HoverManagerService)),Z(1,a.Inject(c.SheetsThreadCommentPopupService)),Z(2,a.Inject(A.SheetsThreadCommentModel)),Z(3,a.Inject(I.SheetPermissionInterceptorBaseController))],z);var qe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(i,t,r,e)=>{for(var n=e>1?void 0:e?Je(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&qe(t,r,n),n},U=(i,t)=>(r,e)=>t(r,e,i);let Y=class extends a.Disposable{constructor(t,r,e,n,o,s,d,u,m,l){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=n,this._univerInstanceService=o,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=d,this._sheetSelectionService=u,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var v,_,g;const n=(v=t[0])==null?void 0:v.range,o=this._renderManagerService.getRenderById(r),s=(_=o==null?void 0:o.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:_.skeleton;if(!s||!n)return;const d=s.getCellWithCoordByIndex(n.startRow,n.startColumn);if((((g=n.rangeType)!=null?g:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||n.endColumn-n.startColumn>0||n.endRow-n.startRow>0)&&!((d.isMerged||d.isMergedMainCell)&&a.Rectangle.equals(d.mergeInfo,n))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const m=d.actualRow,l=d.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(P.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,m,l);h&&this._commandService.executeCommand(P.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:n,subUnitId:o,commentId:s}=e;r.unitId===n&&r.subUnitId===o&&r.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:n,commentId:o,trigger:s}=t,d=this._sheetsThreadCommentModel.getComment(e,n,o);if(!d||d.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=u.getActiveSheet())==null?void 0:r.getSheetId())!==n&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:n}),this._isSwitchToCommenting=!1;const h=$.singleReferenceToGrid(d.ref),{row:v,column:_}=h;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:v,startColumn:_,endRow:v,endColumn:_}]))return;const M=1;if(await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-M,0),endRow:h.row+M,startColumn:Math.max(h.column-M,0),endColumn:h.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:n,row:h.row,col:h.column,commentId:d.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var v,_;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:n}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(r,e,n);if(!o)return;const s=$.singleReferenceToGrid(o.ref),{row:d,column:u}=s;if(Number.isNaN(d)||Number.isNaN(u))return null;const m=(v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getSheetBySheetId(e),l=(_=m==null?void 0:m.getMergedCell(d,u))!=null?_:{startColumn:u,endColumn:u,startRow:d,endRow:d},h=this._markSelectionService.addShape({range:l,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Y=Qe([U(0,a.ICommandService),U(1,a.Inject(c.SheetsThreadCommentPopupService)),U(2,a.Inject(A.SheetsThreadCommentModel)),U(3,a.Inject(P.ThreadCommentPanelService)),U(4,a.IUniverInstanceService),U(5,a.Inject(I.SheetPermissionInterceptorBaseController)),U(6,I.IMarkSelectionService),U(7,a.Inject(p.SheetsSelectionsService)),U(8,I.IEditorBridgeService),U(9,re.IRenderManagerService)],Y);var Xe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(i,t,r,e)=>{for(var n=e>1?void 0:e?et(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&Xe(t,r,n),n},K=(i,t)=>(r,e)=>t(r,e,i);let q=class extends a.Disposable{constructor(i,t,r,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===p.RemoveSheetCommand.id){const r=i.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const n=e.getUnitId(),o=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(n,o),d=Array.from(s.values()).filter(v=>!v.parentId),u=d.map(v=>v.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=u.map(v=>({id:C.DeleteCommentMutation.id,params:{unitId:n,subUnitId:o,commentId:v}})),h=d.map(({children:v,..._})=>({id:C.AddCommentMutation.id,params:{unitId:n,subUnitId:o,comment:{..._,children:m?v:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};q=tt([K(0,a.Inject(p.SheetInterceptorService)),K(1,a.IUniverInstanceService),K(2,a.Inject(C.ThreadCommentModel)),K(3,C.IThreadCommentDataSourceService)],q);var he=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,rt=(i,t,r)=>t in i?he(i,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[t]=r,it=(i,t,r,e)=>{for(var n=e>1?void 0:e?nt(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&he(t,r,n),n},te=(i,t)=>(r,e)=>t(r,e,i),le=(i,t,r)=>rt(i,typeof t!="symbol"?t+"":t,r);c.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=Ce,r,e,n){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=n;const{menu:o,...s}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(fe,s)}onStarting(){[[F],[x],[G],[z],[q],[Y],[c.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[B].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(F)}onReady(){this._injector.get(x),this._injector.get(q)}onRendered(){this._injector.get(G),this._injector.get(z),this._injector.get(Y)}},le(c.UniverSheetsThreadCommentUIPlugin,"pluginName",Q),le(c.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentUIPlugin=it([a.DependentOn(P.UniverThreadCommentUIPlugin,A.UniverSheetsThreadCommentPlugin),te(1,a.Inject(a.Injector)),te(2,a.Inject(a.ICommandService)),te(3,a.IConfigService)],c.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>P.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"AddCommentCommand",{enumerable:!0,get:()=>C.AddCommentCommand}),Object.defineProperty(c,"DeleteCommentCommand",{enumerable:!0,get:()=>C.DeleteCommentCommand}),Object.defineProperty(c,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>C.DeleteCommentTreeCommand}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>C.IThreadCommentDataSourceService}),Object.defineProperty(c,"ResolveCommentCommand",{enumerable:!0,get:()=>C.ResolveCommentCommand}),Object.defineProperty(c,"UpdateCommentCommand",{enumerable:!0,get:()=>C.UpdateCommentCommand}),c.SHEETS_THREAD_COMMENT=Q,c.ShowAddSheetCommentModalOperation=B,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-thread-comment-ui",
3
- "version": "0.5.0-nightly.202411181606",
3
+ "version": "0.5.0-nightly.202411201606",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -52,19 +52,17 @@
52
52
  "rxjs": ">=7.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "@univerjs/icons": "^0.2.5",
55
+ "@univerjs/icons": "^0.2.7",
56
56
  "clsx": "^2.1.1",
57
- "@univerjs/core": "0.5.0-nightly.202411181606",
58
- "@univerjs/design": "0.5.0-nightly.202411181606",
59
- "@univerjs/engine-formula": "0.5.0-nightly.202411181606",
60
- "@univerjs/docs-ui": "0.5.0-nightly.202411181606",
61
- "@univerjs/sheets": "0.5.0-nightly.202411181606",
62
- "@univerjs/engine-render": "0.5.0-nightly.202411181606",
63
- "@univerjs/sheets-thread-comment": "0.5.0-nightly.202411181606",
64
- "@univerjs/sheets-ui": "0.5.0-nightly.202411181606",
65
- "@univerjs/thread-comment-ui": "0.5.0-nightly.202411181606",
66
- "@univerjs/ui": "0.5.0-nightly.202411181606",
67
- "@univerjs/thread-comment": "0.5.0-nightly.202411181606"
57
+ "@univerjs/core": "0.5.0-nightly.202411201606",
58
+ "@univerjs/engine-formula": "0.5.0-nightly.202411201606",
59
+ "@univerjs/engine-render": "0.5.0-nightly.202411201606",
60
+ "@univerjs/sheets-thread-comment": "0.5.0-nightly.202411201606",
61
+ "@univerjs/sheets": "0.5.0-nightly.202411201606",
62
+ "@univerjs/sheets-ui": "0.5.0-nightly.202411201606",
63
+ "@univerjs/thread-comment": "0.5.0-nightly.202411201606",
64
+ "@univerjs/ui": "0.5.0-nightly.202411201606",
65
+ "@univerjs/thread-comment-ui": "0.5.0-nightly.202411201606"
68
66
  },
69
67
  "devDependencies": {
70
68
  "react": "18.3.1",