@univerjs/docs-thread-comment-ui 0.6.0-nightly.202502111606 → 0.6.0-nightly.202502131606

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var ie=Object.defineProperty;var oe=(e,t,r)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var H=(e,t,r)=>oe(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),P=require("@univerjs/engine-render"),O=require("@univerjs/thread-comment-ui"),_=require("@univerjs/docs"),j=require("@univerjs/docs-ui"),w=require("@univerjs/thread-comment"),I=require("@univerjs/ui"),x=require("rxjs"),ce=require("react/jsx-runtime"),S=require("react"),se="DOC_THREAD_COMMENT_UI_PLUGIN",b="default_doc",de="docs-thread-comment-ui.config",J={};var ae=Object.defineProperty,me=Object.getOwnPropertyDescriptor,le=(e,t,r,n)=>{for(var i=n>1?void 0:n?me(t,r):t,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&ae(t,r,i),i},Y=(e,t)=>(r,n)=>t(r,n,e);let R=class extends o.Disposable{constructor(t,r){super();H(this,"_addingComment$",new x.BehaviorSubject(void 0));H(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=t,this._threadCommentPanelService=r,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(t){this._addingComment$.next(t)}endAdd(){this._addingComment$.next(void 0)}};R=le([Y(0,I.ISidebarService),Y(1,o.Inject(O.ThreadCommentPanelService))],R);const G={id:"docs.command.add-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{comment:r,unitId:n}=t,c=await e.get(w.IThreadCommentDataSourceService).addComment(r),s=e.get(o.ICommandService),d=j.addCustomDecorationBySelectionFactory(e,{id:c.threadId,type:o.CustomDecorationType.COMMENT,unitId:n});if(d){const u={id:w.AddCommentMutation.id,params:{unitId:n,subUnitId:b,comment:c}},f={id:O.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:b,commentId:c.id}};return(await o.sequenceExecute([u,d,f],s)).result}return!1}},Z={id:"docs.command.delete-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:r,unitId:n}=t,i=e.get(o.ICommandService),c=j.deleteCustomDecorationFactory(e,{id:r,unitId:n});return c?(await o.sequenceExecute([c],i)).result:!1}},Q=e=>{const t=e.get(P.IRenderManagerService),r=e.get(_.DocSelectionManagerService),n=t.getCurrent(),i=n==null?void 0:n.with(_.DocSkeletonManagerService).getSkeleton(),c=i==null?void 0:i.getViewModel().getEditArea();if(c===P.DocumentEditArea.FOOTER||c===P.DocumentEditArea.HEADER)return!0;const s=r.getActiveTextRange();return!!(s==null||s.collapsed)};function ue(e){return{id:V.id,type:I.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:I.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,void 0,o.SHEET_EDITOR_UNITS),disabled$:new x.Observable(function(t){const n=e.get(_.DocSelectionManagerService).textSelection$.pipe(x.debounceTime(16)).subscribe(()=>{t.next(Q(e))});return()=>{n.unsubscribe()}})}}function Ce(e){return{id:z.id,type:I.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:I.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC)}}const E=()=>{const e=o.useDependency(o.IUniverInstanceService),t=o.useDependency(o.Injector),r=S.useMemo(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC).pipe(x.filter(a=>!!a&&!o.isInternalEditorID(a.getUnitId()))),[e]),n=o.useObservable(r),i=S.useMemo(()=>new x.Observable(a=>a.next(b)),[]),c=o.useDependency(_.DocSelectionManagerService),s=S.useMemo(()=>c.textSelection$.pipe(x.debounceTime(16)),[c.textSelection$]);o.useObservable(s);const d=o.useDependency(o.ICommandService),u=o.useDependency(R),f=o.useObservable(u.addingComment$),[m,h]=S.useState([]);if(S.useEffect(()=>{var T;const a=new Set,l=n==null?void 0:n.getCustomDecorations();h((T=l==null?void 0:l.map(C=>C.id).filter(C=>{const D=a.has(C);return a.add(C),!D}))!=null?T:[]);const M=d.onCommandExecuted(C=>{var D;if(C.id===_.RichTextEditingMutation.id){const A=new Set,F=n==null?void 0:n.getCustomDecorations();h((D=F==null?void 0:F.map($=>$.id).filter($=>{const re=A.has($);return A.add($),!re}))!=null?D:[])}});return()=>{M.dispose()}},[d,n]),!n)return null;const g=Q(t),v=n.getUnitId();return ce.jsx(O.ThreadCommentPanel,{unitId:v,subUnitId$:i,type:o.UniverInstanceType.UNIVER_DOC,onAdd:()=>{d.executeCommand(V.id)},getSubUnitName:()=>"",disableAdd:g,tempComment:f,onAddComment:a=>{if(!a.parentId){const l={unitId:v,range:f,comment:a};return d.executeCommand(G.id,l),u.endAdd(),!1}return!0},onDeleteComment:a=>{if(!a.parentId){const l={unitId:v,commentId:a.id};return d.executeCommand(Z.id,l),!1}return!0},showComments:m})};E.componentKey="univer.doc.thread-comment-panel";const N={id:"docs.operation.show-comment-panel",type:o.CommandType.OPERATION,handler(e,t){var i;const r=e.get(O.ThreadCommentPanelService),n=e.get(I.ISidebarService);return(!r.panelVisible||((i=n.options.children)==null?void 0:i.label)!==E.componentKey)&&(n.open({header:{title:"threadCommentUI.panel.title"},children:{label:E.componentKey},width:320,onClose:()=>r.setPanelVisible(!1)}),r.setPanelVisible(!0)),t&&r.setActiveComment(t==null?void 0:t.activeComment),!0}},z={id:"docs.operation.toggle-comment-panel",type:o.CommandType.OPERATION,handler(e){var n;const t=e.get(O.ThreadCommentPanelService),r=e.get(I.ISidebarService);return!t.panelVisible||((n=r.options.children)==null?void 0:n.label)!==E.componentKey?(r.open({header:{title:"threadCommentUI.panel.title"},children:{label:E.componentKey},width:320,onClose:()=>t.setPanelVisible(!1)}),t.setPanelVisible(!0)):(r.close(),t.setPanelVisible(!1),t.setActiveComment(null)),!0}},V={id:"docs.operation.start-add-comment",type:o.CommandType.OPERATION,handler(e){var C,D,A;const t=e.get(O.ThreadCommentPanelService),n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),i=e.get(_.DocSelectionManagerService),c=e.get(P.IRenderManagerService),s=e.get(o.UserManagerService),d=e.get(R),u=e.get(o.ICommandService),f=e.get(I.ISidebarService),m=i.getActiveTextRange();if(!n||!m)return!1;const h=(C=c.getRenderById(n.getUnitId()))==null?void 0:C.with(j.DocSelectionRenderService);if(h==null||h.setReserveRangesStatus(!0),m.collapsed)return t.panelVisible?(t.setPanelVisible(!1),f.close()):u.executeCommand(N.id),!0;u.executeCommand(N.id);const g=n.getUnitId(),v=((A=(D=n.getBody())==null?void 0:D.dataStream)!=null?A:"").slice(m.startOffset,m.endOffset),a=o.BuildTextUtils.transform.getPlainText(v),l=b,M="",T={unitId:g,subUnitId:l,id:M,ref:a,dT:w.getDT(),personId:s.getCurrentUser().userID,text:{dataStream:`\r
2
- `},startOffset:m.startOffset,endOffset:m.endOffset,collapsed:!0,threadId:M};return h==null||h.blur(),d.startAdd(T),t.setActiveComment({unitId:g,subUnitId:l,commentId:M}),!0}};var fe=Object.defineProperty,he=Object.getOwnPropertyDescriptor,ve=(e,t,r,n)=>{for(var i=n>1?void 0:n?he(t,r):t,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&fe(t,r,i),i},y=(e,t)=>(r,n)=>t(r,n,e);let B=class extends o.Disposable{constructor(e,t,r,n,i,c){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=r,this._docThreadCommentService=n,this._renderManagerService=i,this._threadCommentModel=c,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var r,n,i,c;if(t.id===_.SetTextSelectionsOperation.id){const s=t.params,{unitId:d,ranges:u}=s;if(o.isInternalEditorID(d))return;const f=this._univerInstanceService.getUnit(d,o.UniverInstanceType.UNIVER_DOC),m=u[0];if((e==null?void 0:e.startOffset)===(m==null?void 0:m.startOffset)&&(e==null?void 0:e.endOffset)===(m==null?void 0:m.endOffset))return;if(e=m,m&&f){const{startOffset:h,endOffset:g,collapsed:v}=m;let a;if(v?a=(n=(r=f.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(l=>l.startIndex<=h&&l.endIndex>=g-1):a=(c=(i=f.getBody())==null?void 0:i.customDecorations)==null?void 0:c.find(l=>l.startIndex<=h&&l.endIndex>=g-1),a){const l=this._threadCommentModel.getComment(d,b,a.id);l&&!l.resolved&&this._commandService.executeCommand(N.id,{activeComment:{unitId:d,subUnitId:b,commentId:a.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,r,n,i;if(e){const c=this._univerInstanceService.getUnit(e.unitId);if(c){const s=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(j.DocBackScrollRenderController),d=(n=(r=c.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(u=>u.id===e.commentId);d&&s&&s.scrollToRange({startOffset:d.startIndex,endOffset:d.endIndex,collapsed:!1})}}(!e||e.commentId!==((i=this._docThreadCommentService.addingComment)==null?void 0:i.id))&&this._docThreadCommentService.endAdd()}))}};B=ve([y(0,o.Inject(O.ThreadCommentPanelService)),y(1,o.IUniverInstanceService),y(2,o.ICommandService),y(3,o.Inject(R)),y(4,P.IRenderManagerService),y(5,o.Inject(w.ThreadCommentModel))],B);var p=function(){return p=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},p.apply(this,arguments)},Ie=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},X=S.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,c=e.extend,s=Ie(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),u=S.useRef("_".concat(Se()));return k(r,"".concat(n),{defIds:r.defIds,idSuffix:u.current},p({ref:t,className:d},s),c)});function k(e,t,r,n,i){return S.createElement(e.tag,p(p({key:t},ge(e,r,i)),n),(pe(e,r).children||[]).map(function(c,s){return k(c,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function ge(e,t,r){var n=p({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(c){var s=c[0],d=c[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function pe(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?p(p({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?p(p({},i),{attrs:p(p({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function Se(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var _e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ee=S.forwardRef(function(e,t){return S.createElement(X,Object.assign({},e,{id:"comment-single",ref:t,icon:_e}))});ee.displayName="CommentSingle";const Oe={[I.RibbonStartGroup.OTHERS]:{[z.id]:{order:1,menuItemFactory:Ce}},[I.ContextMenuPosition.MAIN_AREA]:{[I.ContextMenuGroup.DATA]:{[V.id]:{order:1,menuItemFactory:ue}}}};var Me=Object.defineProperty,be=Object.getOwnPropertyDescriptor,De=(e,t,r,n)=>{for(var i=n>1?void 0:n?be(t,r):t,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Me(t,r,i),i},L=(e,t)=>(r,n)=>t(r,n,e);let q=class extends o.Disposable{constructor(e,t,r){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[G,Z,N,V,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Oe)}_initComponents(){[E].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",ee))}};q=De([L(0,o.ICommandService),L(1,I.IMenuManagerService),L(2,o.Inject(I.ComponentManager))],q);var Te=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Ue=(e,t,r,n)=>{for(var i=n>1?void 0:n?ye(t,r):t,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Te(t,r,i),i},U=(e,t)=>(r,n)=>t(r,n,e);let K=class extends o.Disposable{constructor(e,t,r,n,i,c,s){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=r,this._docRenderController=n,this._univerInstanceService=i,this._threadCommentModel=c,this._commandService=s,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var r;if(e){this._docRenderController.reRender(e.unitId);return}const t=(r=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(_.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,r)=>{if(!e)return r(e);const{unitId:n,index:i,customDecorations:c}=t,s=this._threadCommentPanelService.activeCommentId,{commentId:d,unitId:u}=s||{},f=c.find(v=>v.id===d),m=this._threadCommentModel.getComment(n,b,e.id);if(!m)return r({...e,show:!1});const h=f&&i>=f.startIndex&&i<=f.endIndex,g=u===n&&e.id===d;return r({...e,active:g||h,show:!m.resolved})}})}_initSyncComments(){var i,c,s;const e=this._context.unit.getUnitId(),t=b,r=(s=(c=(i=this._context.unit.getBody())==null?void 0:i.customDecorations)==null?void 0:c.filter(d=>d.type===o.CustomDecorationType.COMMENT).map(d=>d.id))!=null?s:[];r.forEach(d=>{this._threadCommentModel.getComment(e,t,d)||this._threadCommentModel.addComment(e,t,{id:d,threadId:d,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),b,r);let n=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(d=>{var u,f,m;if(d.id===_.RichTextEditingMutation.id){if(d.params.unitId!==this._context.unit.getUnitId())return;const g=(m=(f=(u=this._context.unit.getBody())==null?void 0:u.customDecorations)==null?void 0:f.filter(a=>a.type===o.CustomDecorationType.COMMENT).map(a=>a.id))!=null?m:[],v=g.sort();if(JSON.stringify(n)!==JSON.stringify(v)){const a=new Set(n),l=new Set(v),M=new Set,T=new Set;g.forEach(C=>{a.has(C)||M.add(C)}),n.forEach(C=>{l.has(C)||T.add(C)}),n=v,M.forEach(C=>{this._threadCommentModel.getComment(e,t,C)||this._threadCommentModel.addComment(e,t,{id:C,threadId:C,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...M])}}}))}};K=Ue([U(1,o.Inject(_.DocInterceptorService)),U(2,o.Inject(O.ThreadCommentPanelService)),U(3,o.Inject(j.DocRenderController)),U(4,o.IUniverInstanceService),U(5,o.Inject(w.ThreadCommentModel)),U(6,o.ICommandService)],K);var te=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,xe=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Re=(e,t,r,n)=>{for(var i=n>1?void 0:n?Pe(t,r):t,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&te(t,r,i),i},W=(e,t)=>(r,n)=>t(r,n,e),ne=(e,t,r)=>xe(e,typeof t!="symbol"?t+"":t,r);exports.UniverDocsThreadCommentUIPlugin=class extends o.Plugin{constructor(t=J,r,n,i){super(),this._config=t,this._injector=r,this._renderManagerSrv=n,this._configService=i;const{menu:c,...s}=o.merge({},J,this._config);c&&this._configService.setConfig("menu",c,{merge:!0}),this._configService.setConfig(de,s)}onStarting(){[[q],[B],[R]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(q)}_initRenderModule(){[K].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}};ne(exports.UniverDocsThreadCommentUIPlugin,"pluginName",se);ne(exports.UniverDocsThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC);exports.UniverDocsThreadCommentUIPlugin=Re([o.DependentOn(O.UniverThreadCommentUIPlugin),W(1,o.Inject(o.Injector)),W(2,P.IRenderManagerService),W(3,o.IConfigService)],exports.UniverDocsThreadCommentUIPlugin);exports.AddDocCommentComment=G;exports.DeleteDocCommentComment=Z;exports.ShowCommentPanelOperation=N;exports.StartAddCommentOperation=V;
1
+ "use strict";var re=Object.defineProperty;var ie=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var H=(e,t,r)=>ie(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),x=require("@univerjs/engine-render"),O=require("@univerjs/thread-comment-ui"),_=require("@univerjs/docs"),V=require("@univerjs/docs-ui"),w=require("@univerjs/thread-comment"),u=require("@univerjs/ui"),R=require("rxjs"),oe=require("react/jsx-runtime"),S=require("react"),ce="DOC_THREAD_COMMENT_UI_PLUGIN",D="default_doc",se="docs-thread-comment-ui.config",J={};var ae=Object.getOwnPropertyDescriptor,de=(e,t,r,n)=>{for(var i=n>1?void 0:n?ae(t,r):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Y=(e,t)=>(r,n)=>t(r,n,e);let P=class extends c.Disposable{constructor(t,r){super();H(this,"_addingComment$",new R.BehaviorSubject(void 0));H(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=t,this._threadCommentPanelService=r,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(t){this._addingComment$.next(t)}endAdd(){this._addingComment$.next(void 0)}};P=de([Y(0,u.ISidebarService),Y(1,c.Inject(O.ThreadCommentPanelService))],P);const G={id:"docs.command.add-comment",type:c.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{comment:r,unitId:n}=t,o=await e.get(w.IThreadCommentDataSourceService).addComment(r),s=e.get(c.ICommandService),a=V.addCustomDecorationBySelectionFactory(e,{id:o.threadId,type:c.CustomDecorationType.COMMENT,unitId:n});if(a){const C={id:w.AddCommentMutation.id,params:{unitId:n,subUnitId:D,comment:o}},v={id:O.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:D,commentId:o.id}};return(await c.sequenceExecute([C,a,v],s)).result}return!1}},Z={id:"docs.command.delete-comment",type:c.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:r,unitId:n}=t,i=e.get(c.ICommandService),o=V.deleteCustomDecorationFactory(e,{id:r,unitId:n});return o?(await c.sequenceExecute([o],i)).result:!1}},Q=e=>{const t=e.get(x.IRenderManagerService),r=e.get(_.DocSelectionManagerService),n=t.getCurrent(),i=n==null?void 0:n.with(_.DocSkeletonManagerService).getSkeleton(),o=i==null?void 0:i.getViewModel().getEditArea();if(o===x.DocumentEditArea.FOOTER||o===x.DocumentEditArea.HEADER)return!0;const s=r.getActiveTextRange();return!!(s==null||s.collapsed)};function me(e){return{id:j.id,type:u.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_DOC,void 0,c.SHEET_EDITOR_UNITS),disabled$:new R.Observable(function(t){const n=e.get(_.DocSelectionManagerService).textSelection$.pipe(R.debounceTime(16)).subscribe(()=>{t.next(Q(e))});return()=>{n.unsubscribe()}})}}function le(e){return{id:z.id,type:u.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_DOC)}}const E=()=>{const e=u.useDependency(c.IUniverInstanceService),t=u.useDependency(c.Injector),r=S.useMemo(()=>e.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_DOC).pipe(R.filter(d=>!!d&&!c.isInternalEditorID(d.getUnitId()))),[e]),n=u.useObservable(r),i=S.useMemo(()=>new R.Observable(d=>d.next(D)),[]),o=u.useDependency(_.DocSelectionManagerService),s=S.useMemo(()=>o.textSelection$.pipe(R.debounceTime(16)),[o.textSelection$]);u.useObservable(s);const a=u.useDependency(c.ICommandService),C=u.useDependency(P),v=u.useObservable(C.addingComment$),[m,f]=S.useState([]);if(S.useEffect(()=>{var b;const d=new Set,l=n==null?void 0:n.getCustomDecorations();f((b=l==null?void 0:l.map(h=>h.id).filter(h=>{const T=d.has(h);return d.add(h),!T}))!=null?b:[]);const M=a.onCommandExecuted(h=>{var T;if(h.id===_.RichTextEditingMutation.id){const A=new Set,F=n==null?void 0:n.getCustomDecorations();f((T=F==null?void 0:F.map($=>$.id).filter($=>{const ne=A.has($);return A.add($),!ne}))!=null?T:[])}});return()=>{M.dispose()}},[a,n]),!n)return null;const I=Q(t),g=n.getUnitId();return oe.jsx(O.ThreadCommentPanel,{unitId:g,subUnitId$:i,type:c.UniverInstanceType.UNIVER_DOC,onAdd:()=>{a.executeCommand(j.id)},getSubUnitName:()=>"",disableAdd:I,tempComment:v,onAddComment:d=>{if(!d.parentId){const l={unitId:g,range:v,comment:d};return a.executeCommand(G.id,l),C.endAdd(),!1}return!0},onDeleteComment:d=>{if(!d.parentId){const l={unitId:g,commentId:d.id};return a.executeCommand(Z.id,l),!1}return!0},showComments:m})};E.componentKey="univer.doc.thread-comment-panel";const N={id:"docs.operation.show-comment-panel",type:c.CommandType.OPERATION,handler(e,t){var i;const r=e.get(O.ThreadCommentPanelService),n=e.get(u.ISidebarService);return(!r.panelVisible||((i=n.options.children)==null?void 0:i.label)!==E.componentKey)&&(n.open({header:{title:"threadCommentUI.panel.title"},children:{label:E.componentKey},width:320,onClose:()=>r.setPanelVisible(!1)}),r.setPanelVisible(!0)),t&&r.setActiveComment(t==null?void 0:t.activeComment),!0}},z={id:"docs.operation.toggle-comment-panel",type:c.CommandType.OPERATION,handler(e){var n;const t=e.get(O.ThreadCommentPanelService),r=e.get(u.ISidebarService);return!t.panelVisible||((n=r.options.children)==null?void 0:n.label)!==E.componentKey?(r.open({header:{title:"threadCommentUI.panel.title"},children:{label:E.componentKey},width:320,onClose:()=>t.setPanelVisible(!1)}),t.setPanelVisible(!0)):(r.close(),t.setPanelVisible(!1),t.setActiveComment(null)),!0}},j={id:"docs.operation.start-add-comment",type:c.CommandType.OPERATION,handler(e){var h,T,A;const t=e.get(O.ThreadCommentPanelService),n=e.get(c.IUniverInstanceService).getCurrentUnitForType(c.UniverInstanceType.UNIVER_DOC),i=e.get(_.DocSelectionManagerService),o=e.get(x.IRenderManagerService),s=e.get(c.UserManagerService),a=e.get(P),C=e.get(c.ICommandService),v=e.get(u.ISidebarService),m=i.getActiveTextRange();if(!n||!m)return!1;const f=(h=o.getRenderById(n.getUnitId()))==null?void 0:h.with(V.DocSelectionRenderService);if(f==null||f.setReserveRangesStatus(!0),m.collapsed)return t.panelVisible?(t.setPanelVisible(!1),v.close()):C.executeCommand(N.id),!0;C.executeCommand(N.id);const I=n.getUnitId(),g=((A=(T=n.getBody())==null?void 0:T.dataStream)!=null?A:"").slice(m.startOffset,m.endOffset),d=c.BuildTextUtils.transform.getPlainText(g),l=D,M="",b={unitId:I,subUnitId:l,id:M,ref:d,dT:w.getDT(),personId:s.getCurrentUser().userID,text:{dataStream:`\r
2
+ `},startOffset:m.startOffset,endOffset:m.endOffset,collapsed:!0,threadId:M};return f==null||f.blur(),a.startAdd(b),t.setActiveComment({unitId:I,subUnitId:l,commentId:M}),!0}};var ue=Object.getOwnPropertyDescriptor,Ce=(e,t,r,n)=>{for(var i=n>1?void 0:n?ue(t,r):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},y=(e,t)=>(r,n)=>t(r,n,e);let B=class extends c.Disposable{constructor(e,t,r,n,i,o){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=r,this._docThreadCommentService=n,this._renderManagerService=i,this._threadCommentModel=o,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var r,n,i,o;if(t.id===_.SetTextSelectionsOperation.id){const s=t.params,{unitId:a,ranges:C}=s;if(c.isInternalEditorID(a))return;const v=this._univerInstanceService.getUnit(a,c.UniverInstanceType.UNIVER_DOC),m=C[0];if((e==null?void 0:e.startOffset)===(m==null?void 0:m.startOffset)&&(e==null?void 0:e.endOffset)===(m==null?void 0:m.endOffset))return;if(e=m,m&&v){const{startOffset:f,endOffset:I,collapsed:g}=m;let d;if(g?d=(n=(r=v.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(l=>l.startIndex<=f&&l.endIndex>=I-1):d=(o=(i=v.getBody())==null?void 0:i.customDecorations)==null?void 0:o.find(l=>l.startIndex<=f&&l.endIndex>=I-1),d){const l=this._threadCommentModel.getComment(a,D,d.id);l&&!l.resolved&&this._commandService.executeCommand(N.id,{activeComment:{unitId:a,subUnitId:D,commentId:d.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,r,n,i;if(e){const o=this._univerInstanceService.getUnit(e.unitId);if(o){const s=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(V.DocBackScrollRenderController),a=(n=(r=o.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(C=>C.id===e.commentId);a&&s&&s.scrollToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1})}}(!e||e.commentId!==((i=this._docThreadCommentService.addingComment)==null?void 0:i.id))&&this._docThreadCommentService.endAdd()}))}};B=Ce([y(0,c.Inject(O.ThreadCommentPanelService)),y(1,c.IUniverInstanceService),y(2,c.ICommandService),y(3,c.Inject(P)),y(4,x.IRenderManagerService),y(5,c.Inject(w.ThreadCommentModel))],B);var p=function(){return p=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},p.apply(this,arguments)},he=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},X=S.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,o=e.extend,s=he(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),C=S.useRef("_".concat(ge()));return k(r,"".concat(n),{defIds:r.defIds,idSuffix:C.current},p({ref:t,className:a},s),o)});function k(e,t,r,n,i){return S.createElement(e.tag,p(p({key:t},ve(e,r,i)),n),(fe(e,r).children||[]).map(function(o,s){return k(o,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function ve(e,t,r){var n=p({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function fe(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?p(p({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?p(p({},i),{attrs:p(p({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function ge(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var Ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ee=S.forwardRef(function(e,t){return S.createElement(X,Object.assign({},e,{id:"comment-single",ref:t,icon:Ie}))});ee.displayName="CommentSingle";const pe={[u.RibbonStartGroup.OTHERS]:{[z.id]:{order:1,menuItemFactory:le}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[j.id]:{order:1,menuItemFactory:me}}}};var Se=Object.getOwnPropertyDescriptor,_e=(e,t,r,n)=>{for(var i=n>1?void 0:n?Se(t,r):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},L=(e,t)=>(r,n)=>t(r,n,e);let q=class extends c.Disposable{constructor(e,t,r){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[G,Z,N,j,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(pe)}_initComponents(){[E].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",ee))}};q=_e([L(0,c.ICommandService),L(1,u.IMenuManagerService),L(2,c.Inject(u.ComponentManager))],q);var Oe=Object.getOwnPropertyDescriptor,Me=(e,t,r,n)=>{for(var i=n>1?void 0:n?Oe(t,r):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},U=(e,t)=>(r,n)=>t(r,n,e);let K=class extends c.Disposable{constructor(e,t,r,n,i,o,s){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=r,this._docRenderController=n,this._univerInstanceService=i,this._threadCommentModel=o,this._commandService=s,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var r;if(e){this._docRenderController.reRender(e.unitId);return}const t=(r=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(_.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,r)=>{if(!e)return r(e);const{unitId:n,index:i,customDecorations:o}=t,s=this._threadCommentPanelService.activeCommentId,{commentId:a,unitId:C}=s||{},v=o.find(g=>g.id===a),m=this._threadCommentModel.getComment(n,D,e.id);if(!m)return r({...e,show:!1});const f=v&&i>=v.startIndex&&i<=v.endIndex,I=C===n&&e.id===a;return r({...e,active:I||f,show:!m.resolved})}})}_initSyncComments(){var i,o,s;const e=this._context.unit.getUnitId(),t=D,r=(s=(o=(i=this._context.unit.getBody())==null?void 0:i.customDecorations)==null?void 0:o.filter(a=>a.type===c.CustomDecorationType.COMMENT).map(a=>a.id))!=null?s:[];r.forEach(a=>{this._threadCommentModel.getComment(e,t,a)||this._threadCommentModel.addComment(e,t,{id:a,threadId:a,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),D,r);let n=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(a=>{var C,v,m;if(a.id===_.RichTextEditingMutation.id){if(a.params.unitId!==this._context.unit.getUnitId())return;const I=(m=(v=(C=this._context.unit.getBody())==null?void 0:C.customDecorations)==null?void 0:v.filter(d=>d.type===c.CustomDecorationType.COMMENT).map(d=>d.id))!=null?m:[],g=I.sort();if(JSON.stringify(n)!==JSON.stringify(g)){const d=new Set(n),l=new Set(g),M=new Set,b=new Set;I.forEach(h=>{d.has(h)||M.add(h)}),n.forEach(h=>{l.has(h)||b.add(h)}),n=g,M.forEach(h=>{this._threadCommentModel.getComment(e,t,h)||this._threadCommentModel.addComment(e,t,{id:h,threadId:h,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...M])}}}))}};K=Me([U(1,c.Inject(_.DocInterceptorService)),U(2,c.Inject(O.ThreadCommentPanelService)),U(3,c.Inject(V.DocRenderController)),U(4,c.IUniverInstanceService),U(5,c.Inject(w.ThreadCommentModel)),U(6,c.ICommandService)],K);var De=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(e,t,r)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t,r,n)=>{for(var i=n>1?void 0:n?Te(t,r):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},W=(e,t)=>(r,n)=>t(r,n,e),te=(e,t,r)=>be(e,typeof t!="symbol"?t+"":t,r);exports.UniverDocsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=J,r,n,i){super(),this._config=t,this._injector=r,this._renderManagerSrv=n,this._configService=i;const{menu:o,...s}=c.merge({},J,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(se,s)}onStarting(){[[q],[B],[P]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(q)}_initRenderModule(){[K].forEach(t=>{this._renderManagerSrv.registerRenderModule(c.UniverInstanceType.UNIVER_DOC,t)})}};te(exports.UniverDocsThreadCommentUIPlugin,"pluginName",ce);te(exports.UniverDocsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_DOC);exports.UniverDocsThreadCommentUIPlugin=ye([c.DependentOn(O.UniverThreadCommentUIPlugin),W(1,c.Inject(c.Injector)),W(2,x.IRenderManagerService),W(3,c.IConfigService)],exports.UniverDocsThreadCommentUIPlugin);exports.AddDocCommentComment=G;exports.DeleteDocCommentComment=Z;exports.ShowCommentPanelOperation=N;exports.StartAddCommentOperation=j;
package/lib/es/index.js CHANGED
@@ -1,26 +1,26 @@
1
- var Me = Object.defineProperty;
2
- var be = (e, t, r) => t in e ? Me(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var G = (e, t, r) => be(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { Inject as v, Disposable as j, CommandType as E, ICommandService as M, CustomDecorationType as Y, sequenceExecute as ne, UniverInstanceType as S, SHEET_EDITOR_UNITS as De, useDependency as P, IUniverInstanceService as B, Injector as re, isInternalEditorID as ie, useObservable as Z, UserManagerService as Te, BuildTextUtils as xe, DependentOn as ye, Plugin as Ue, merge as Re, IConfigService as Pe } from "@univerjs/core";
1
+ var Oe = Object.defineProperty;
2
+ var Me = (e, t, r) => t in e ? Oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var G = (e, t, r) => Me(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { Inject as _, Disposable as j, CommandType as P, ICommandService as M, CustomDecorationType as Y, sequenceExecute as ne, UniverInstanceType as S, SHEET_EDITOR_UNITS as be, IUniverInstanceService as B, Injector as re, isInternalEditorID as oe, UserManagerService as De, BuildTextUtils as ye, DependentOn as Te, IConfigService as xe, Plugin as Ue, merge as Re } from "@univerjs/core";
5
5
  import { IRenderManagerService as F, DocumentEditArea as k } from "@univerjs/engine-render";
6
- import { ThreadCommentPanelService as U, SetActiveCommentOperation as oe, ThreadCommentPanel as Ee, UniverThreadCommentUIPlugin as Ae } from "@univerjs/thread-comment-ui";
7
- import { DocSelectionManagerService as H, DocSkeletonManagerService as we, RichTextEditingMutation as se, SetTextSelectionsOperation as Ne, DocInterceptorService as Ve, DOC_INTERCEPTOR_POINT as $e } from "@univerjs/docs";
8
- import { addCustomDecorationBySelectionFactory as je, deleteCustomDecorationFactory as Be, DocSelectionRenderService as Fe, DocBackScrollRenderController as He, DocRenderController as Le } from "@univerjs/docs-ui";
9
- import { IThreadCommentDataSourceService as We, AddCommentMutation as Ke, getDT as Ge, ThreadCommentModel as de } from "@univerjs/thread-comment";
10
- import { ISidebarService as L, MenuItemType as ce, getMenuHiddenObservable as ae, RibbonStartGroup as Ze, ContextMenuPosition as ze, ContextMenuGroup as Je, ComponentManager as qe, IMenuManagerService as Ye } from "@univerjs/ui";
11
- import { BehaviorSubject as Qe, Observable as me, debounceTime as le, filter as Xe } from "rxjs";
12
- import { jsx as ke } from "react/jsx-runtime";
13
- import { useMemo as z, useState as et, useEffect as tt, forwardRef as ue, useRef as nt, createElement as fe } from "react";
14
- const rt = "DOC_THREAD_COMMENT_UI_PLUGIN", I = "default_doc", it = "docs-thread-comment-ui.config", ee = {};
15
- var ot = Object.defineProperty, st = Object.getOwnPropertyDescriptor, dt = (e, t, r, n) => {
16
- for (var i = n > 1 ? void 0 : n ? st(t, r) : t, o = e.length - 1, s; o >= 0; o--)
17
- (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
18
- return n && i && ot(t, r, i), i;
6
+ import { ThreadCommentPanelService as U, SetActiveCommentOperation as ie, ThreadCommentPanel as Ee, UniverThreadCommentUIPlugin as Pe } from "@univerjs/thread-comment-ui";
7
+ import { DocSelectionManagerService as H, DocSkeletonManagerService as Ae, RichTextEditingMutation as se, SetTextSelectionsOperation as we, DocInterceptorService as Ne, DOC_INTERCEPTOR_POINT as Ve } from "@univerjs/docs";
8
+ import { addCustomDecorationBySelectionFactory as $e, deleteCustomDecorationFactory as je, DocSelectionRenderService as Be, DocBackScrollRenderController as Fe, DocRenderController as He } from "@univerjs/docs-ui";
9
+ import { IThreadCommentDataSourceService as Le, AddCommentMutation as We, getDT as Ke, ThreadCommentModel as de } from "@univerjs/thread-comment";
10
+ import { ISidebarService as L, getMenuHiddenObservable as ce, MenuItemType as ae, useDependency as E, useObservable as Z, ContextMenuPosition as Ge, ContextMenuGroup as Ze, RibbonStartGroup as ze, IMenuManagerService as Je, ComponentManager as qe } from "@univerjs/ui";
11
+ import { BehaviorSubject as Ye, Observable as me, debounceTime as le, filter as Qe } from "rxjs";
12
+ import { jsx as Xe } from "react/jsx-runtime";
13
+ import { useMemo as z, useState as ke, useEffect as et, forwardRef as ue, useRef as tt, createElement as he } from "react";
14
+ const nt = "DOC_THREAD_COMMENT_UI_PLUGIN", I = "default_doc", rt = "docs-thread-comment-ui.config", ee = {};
15
+ var ot = Object.getOwnPropertyDescriptor, it = (e, t, r, n) => {
16
+ for (var o = n > 1 ? void 0 : n ? ot(t, r) : t, i = e.length - 1, s; i >= 0; i--)
17
+ (s = e[i]) && (o = s(o) || o);
18
+ return o;
19
19
  }, te = (e, t) => (r, n) => t(r, n, e);
20
- let x = class extends j {
20
+ let T = class extends j {
21
21
  constructor(t, r) {
22
22
  super();
23
- G(this, "_addingComment$", new Qe(void 0));
23
+ G(this, "_addingComment$", new Ye(void 0));
24
24
  G(this, "addingComment$", this._addingComment$.asObservable());
25
25
  this._sidebarService = t, this._threadCommentPanelService = r, this.disposeWithMe(() => {
26
26
  this._addingComment$.complete();
@@ -36,74 +36,74 @@ let x = class extends j {
36
36
  this._addingComment$.next(void 0);
37
37
  }
38
38
  };
39
- x = dt([
39
+ T = it([
40
40
  te(0, L),
41
- te(1, v(U))
42
- ], x);
43
- const he = {
41
+ te(1, _(U))
42
+ ], T);
43
+ const fe = {
44
44
  id: "docs.command.add-comment",
45
- type: E.COMMAND,
45
+ type: P.COMMAND,
46
46
  async handler(e, t) {
47
47
  if (!t)
48
48
  return !1;
49
- const { comment: r, unitId: n } = t, o = await e.get(We).addComment(r), s = e.get(M), d = je(
49
+ const { comment: r, unitId: n } = t, i = await e.get(Le).addComment(r), s = e.get(M), d = $e(
50
50
  e,
51
51
  {
52
- id: o.threadId,
52
+ id: i.threadId,
53
53
  type: Y.COMMENT,
54
54
  unitId: n
55
55
  }
56
56
  );
57
57
  if (d) {
58
58
  const l = {
59
- id: Ke.id,
59
+ id: We.id,
60
60
  params: {
61
61
  unitId: n,
62
62
  subUnitId: I,
63
- comment: o
63
+ comment: i
64
64
  }
65
- }, f = {
66
- id: oe.id,
65
+ }, h = {
66
+ id: ie.id,
67
67
  params: {
68
68
  unitId: n,
69
69
  subUnitId: I,
70
- commentId: o.id
70
+ commentId: i.id
71
71
  }
72
72
  };
73
- return (await ne([l, d, f], s)).result;
73
+ return (await ne([l, d, h], s)).result;
74
74
  }
75
75
  return !1;
76
76
  }
77
77
  }, Ce = {
78
78
  id: "docs.command.delete-comment",
79
- type: E.COMMAND,
79
+ type: P.COMMAND,
80
80
  async handler(e, t) {
81
81
  if (!t)
82
82
  return !1;
83
- const { commentId: r, unitId: n } = t, i = e.get(M), o = Be(e, {
83
+ const { commentId: r, unitId: n } = t, o = e.get(M), i = je(e, {
84
84
  id: r,
85
85
  unitId: n
86
86
  });
87
- return o ? (await ne([o], i)).result : !1;
87
+ return i ? (await ne([i], o)).result : !1;
88
88
  }
89
- }, _e = (e) => {
90
- const t = e.get(F), r = e.get(H), n = t.getCurrent(), i = n == null ? void 0 : n.with(we).getSkeleton(), o = i == null ? void 0 : i.getViewModel().getEditArea();
91
- if (o === k.FOOTER || o === k.HEADER)
89
+ }, ge = (e) => {
90
+ const t = e.get(F), r = e.get(H), n = t.getCurrent(), o = n == null ? void 0 : n.with(Ae).getSkeleton(), i = o == null ? void 0 : o.getViewModel().getEditArea();
91
+ if (i === k.FOOTER || i === k.HEADER)
92
92
  return !0;
93
93
  const s = r.getActiveTextRange();
94
94
  return !!(s == null || s.collapsed);
95
95
  };
96
- function ct(e) {
96
+ function st(e) {
97
97
  return {
98
98
  id: W.id,
99
- type: ce.BUTTON,
99
+ type: ae.BUTTON,
100
100
  icon: "CommentSingle",
101
101
  title: "threadCommentUI.panel.addComment",
102
102
  tooltip: "threadCommentUI.panel.addComment",
103
- hidden$: ae(e, S.UNIVER_DOC, void 0, De),
103
+ hidden$: ce(e, S.UNIVER_DOC, void 0, be),
104
104
  disabled$: new me(function(t) {
105
105
  const n = e.get(H).textSelection$.pipe(le(16)).subscribe(() => {
106
- t.next(_e(e));
106
+ t.next(ge(e));
107
107
  });
108
108
  return () => {
109
109
  n.unsubscribe();
@@ -111,27 +111,27 @@ function ct(e) {
111
111
  })
112
112
  };
113
113
  }
114
- function at(e) {
114
+ function dt(e) {
115
115
  return {
116
116
  id: X.id,
117
- type: ce.BUTTON,
117
+ type: ae.BUTTON,
118
118
  icon: "CommentSingle",
119
119
  title: "threadCommentUI.panel.addComment",
120
120
  tooltip: "threadCommentUI.panel.addComment",
121
- hidden$: ae(e, S.UNIVER_DOC)
121
+ hidden$: ce(e, S.UNIVER_DOC)
122
122
  };
123
123
  }
124
- const y = () => {
125
- const e = P(B), t = P(re), r = z(() => e.getCurrentTypeOfUnit$(S.UNIVER_DOC).pipe(Xe((c) => !!c && !ie(c.getUnitId()))), [e]), n = Z(r), i = z(() => new me((c) => c.next(I)), []), o = P(H), s = z(
126
- () => o.textSelection$.pipe(le(16)),
127
- [o.textSelection$]
124
+ const x = () => {
125
+ const e = E(B), t = E(re), r = z(() => e.getCurrentTypeOfUnit$(S.UNIVER_DOC).pipe(Qe((c) => !!c && !oe(c.getUnitId()))), [e]), n = Z(r), o = z(() => new me((c) => c.next(I)), []), i = E(H), s = z(
126
+ () => i.textSelection$.pipe(le(16)),
127
+ [i.textSelection$]
128
128
  );
129
129
  Z(s);
130
- const d = P(M), l = P(x), f = Z(l.addingComment$), [a, h] = et([]);
131
- if (tt(() => {
130
+ const d = E(M), l = E(T), h = Z(l.addingComment$), [a, f] = ke([]);
131
+ if (et(() => {
132
132
  var b;
133
133
  const c = /* @__PURE__ */ new Set(), m = n == null ? void 0 : n.getCustomDecorations();
134
- h((b = m == null ? void 0 : m.map((u) => u.id).filter((u) => {
134
+ f((b = m == null ? void 0 : m.map((u) => u.id).filter((u) => {
135
135
  const O = c.has(u);
136
136
  return c.add(u), !O;
137
137
  })) != null ? b : []);
@@ -139,9 +139,9 @@ const y = () => {
139
139
  var O;
140
140
  if (u.id === se.id) {
141
141
  const R = /* @__PURE__ */ new Set(), K = n == null ? void 0 : n.getCustomDecorations();
142
- h((O = K == null ? void 0 : K.map((A) => A.id).filter((A) => {
143
- const Oe = R.has(A);
144
- return R.add(A), !Oe;
142
+ f((O = K == null ? void 0 : K.map((A) => A.id).filter((A) => {
143
+ const Se = R.has(A);
144
+ return R.add(A), !Se;
145
145
  })) != null ? O : []);
146
146
  }
147
147
  });
@@ -150,27 +150,27 @@ const y = () => {
150
150
  };
151
151
  }, [d, n]), !n)
152
152
  return null;
153
- const _ = _e(t), C = n.getUnitId();
154
- return /* @__PURE__ */ ke(
153
+ const g = ge(t), C = n.getUnitId();
154
+ return /* @__PURE__ */ Xe(
155
155
  Ee,
156
156
  {
157
157
  unitId: C,
158
- subUnitId$: i,
158
+ subUnitId$: o,
159
159
  type: S.UNIVER_DOC,
160
160
  onAdd: () => {
161
161
  d.executeCommand(W.id);
162
162
  },
163
163
  getSubUnitName: () => "",
164
- disableAdd: _,
165
- tempComment: f,
164
+ disableAdd: g,
165
+ tempComment: h,
166
166
  onAddComment: (c) => {
167
167
  if (!c.parentId) {
168
168
  const m = {
169
169
  unitId: C,
170
- range: f,
170
+ range: h,
171
171
  comment: c
172
172
  };
173
- return d.executeCommand(he.id, m), l.endAdd(), !1;
173
+ return d.executeCommand(fe.id, m), l.endAdd(), !1;
174
174
  }
175
175
  return !0;
176
176
  },
@@ -188,51 +188,51 @@ const y = () => {
188
188
  }
189
189
  );
190
190
  };
191
- y.componentKey = "univer.doc.thread-comment-panel";
191
+ x.componentKey = "univer.doc.thread-comment-panel";
192
192
  const w = {
193
193
  id: "docs.operation.show-comment-panel",
194
- type: E.OPERATION,
194
+ type: P.OPERATION,
195
195
  handler(e, t) {
196
- var i;
196
+ var o;
197
197
  const r = e.get(U), n = e.get(L);
198
- return (!r.panelVisible || ((i = n.options.children) == null ? void 0 : i.label) !== y.componentKey) && (n.open({
198
+ return (!r.panelVisible || ((o = n.options.children) == null ? void 0 : o.label) !== x.componentKey) && (n.open({
199
199
  header: { title: "threadCommentUI.panel.title" },
200
- children: { label: y.componentKey },
200
+ children: { label: x.componentKey },
201
201
  width: 320,
202
202
  onClose: () => r.setPanelVisible(!1)
203
203
  }), r.setPanelVisible(!0)), t && r.setActiveComment(t == null ? void 0 : t.activeComment), !0;
204
204
  }
205
205
  }, X = {
206
206
  id: "docs.operation.toggle-comment-panel",
207
- type: E.OPERATION,
207
+ type: P.OPERATION,
208
208
  handler(e) {
209
209
  var n;
210
210
  const t = e.get(U), r = e.get(L);
211
- return !t.panelVisible || ((n = r.options.children) == null ? void 0 : n.label) !== y.componentKey ? (r.open({
211
+ return !t.panelVisible || ((n = r.options.children) == null ? void 0 : n.label) !== x.componentKey ? (r.open({
212
212
  header: { title: "threadCommentUI.panel.title" },
213
- children: { label: y.componentKey },
213
+ children: { label: x.componentKey },
214
214
  width: 320,
215
215
  onClose: () => t.setPanelVisible(!1)
216
216
  }), t.setPanelVisible(!0)) : (r.close(), t.setPanelVisible(!1), t.setActiveComment(null)), !0;
217
217
  }
218
218
  }, W = {
219
219
  id: "docs.operation.start-add-comment",
220
- type: E.OPERATION,
220
+ type: P.OPERATION,
221
221
  handler(e) {
222
222
  var u, O, R;
223
- const t = e.get(U), n = e.get(B).getCurrentUnitForType(S.UNIVER_DOC), i = e.get(H), o = e.get(F), s = e.get(Te), d = e.get(x), l = e.get(M), f = e.get(L), a = i.getActiveTextRange();
223
+ const t = e.get(U), n = e.get(B).getCurrentUnitForType(S.UNIVER_DOC), o = e.get(H), i = e.get(F), s = e.get(De), d = e.get(T), l = e.get(M), h = e.get(L), a = o.getActiveTextRange();
224
224
  if (!n || !a)
225
225
  return !1;
226
- const h = (u = o.getRenderById(n.getUnitId())) == null ? void 0 : u.with(Fe);
227
- if (h == null || h.setReserveRangesStatus(!0), a.collapsed)
228
- return t.panelVisible ? (t.setPanelVisible(!1), f.close()) : l.executeCommand(w.id), !0;
226
+ const f = (u = i.getRenderById(n.getUnitId())) == null ? void 0 : u.with(Be);
227
+ if (f == null || f.setReserveRangesStatus(!0), a.collapsed)
228
+ return t.panelVisible ? (t.setPanelVisible(!1), h.close()) : l.executeCommand(w.id), !0;
229
229
  l.executeCommand(w.id);
230
- const _ = n.getUnitId(), C = ((R = (O = n.getBody()) == null ? void 0 : O.dataStream) != null ? R : "").slice(a.startOffset, a.endOffset), c = xe.transform.getPlainText(C), m = I, p = "", b = {
231
- unitId: _,
230
+ const g = n.getUnitId(), C = ((R = (O = n.getBody()) == null ? void 0 : O.dataStream) != null ? R : "").slice(a.startOffset, a.endOffset), c = ye.transform.getPlainText(C), m = I, p = "", b = {
231
+ unitId: g,
232
232
  subUnitId: m,
233
233
  id: p,
234
234
  ref: c,
235
- dT: Ge(),
235
+ dT: Ke(),
236
236
  personId: s.getCurrentUser().userID,
237
237
  text: {
238
238
  dataStream: `\r
@@ -243,37 +243,37 @@ const w = {
243
243
  collapsed: !0,
244
244
  threadId: p
245
245
  };
246
- return h == null || h.blur(), d.startAdd(b), t.setActiveComment({
247
- unitId: _,
246
+ return f == null || f.blur(), d.startAdd(b), t.setActiveComment({
247
+ unitId: g,
248
248
  subUnitId: m,
249
249
  commentId: p
250
250
  }), !0;
251
251
  }
252
252
  };
253
- var mt = Object.defineProperty, lt = Object.getOwnPropertyDescriptor, ut = (e, t, r, n) => {
254
- for (var i = n > 1 ? void 0 : n ? lt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
255
- (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
256
- return n && i && mt(t, r, i), i;
253
+ var ct = Object.getOwnPropertyDescriptor, at = (e, t, r, n) => {
254
+ for (var o = n > 1 ? void 0 : n ? ct(t, r) : t, i = e.length - 1, s; i >= 0; i--)
255
+ (s = e[i]) && (o = s(o) || o);
256
+ return o;
257
257
  }, D = (e, t) => (r, n) => t(r, n, e);
258
258
  let N = class extends j {
259
- constructor(e, t, r, n, i, o) {
260
- super(), this._threadCommentPanelService = e, this._univerInstanceService = t, this._commandService = r, this._docThreadCommentService = n, this._renderManagerService = i, this._threadCommentModel = o, this._initSelectionChange(), this._initActiveCommandChange();
259
+ constructor(e, t, r, n, o, i) {
260
+ super(), this._threadCommentPanelService = e, this._univerInstanceService = t, this._commandService = r, this._docThreadCommentService = n, this._renderManagerService = o, this._threadCommentModel = i, this._initSelectionChange(), this._initActiveCommandChange();
261
261
  }
262
262
  _initSelectionChange() {
263
263
  let e;
264
264
  this.disposeWithMe(
265
265
  this._commandService.onCommandExecuted((t) => {
266
- var r, n, i, o;
267
- if (t.id === Ne.id) {
266
+ var r, n, o, i;
267
+ if (t.id === we.id) {
268
268
  const s = t.params, { unitId: d, ranges: l } = s;
269
- if (ie(d)) return;
270
- const f = this._univerInstanceService.getUnit(d, S.UNIVER_DOC), a = l[0];
269
+ if (oe(d)) return;
270
+ const h = this._univerInstanceService.getUnit(d, S.UNIVER_DOC), a = l[0];
271
271
  if ((e == null ? void 0 : e.startOffset) === (a == null ? void 0 : a.startOffset) && (e == null ? void 0 : e.endOffset) === (a == null ? void 0 : a.endOffset))
272
272
  return;
273
- if (e = a, a && f) {
274
- const { startOffset: h, endOffset: _, collapsed: C } = a;
273
+ if (e = a, a && h) {
274
+ const { startOffset: f, endOffset: g, collapsed: C } = a;
275
275
  let c;
276
- if (C ? c = (n = (r = f.getBody()) == null ? void 0 : r.customDecorations) == null ? void 0 : n.find((m) => m.startIndex <= h && m.endIndex >= _ - 1) : c = (o = (i = f.getBody()) == null ? void 0 : i.customDecorations) == null ? void 0 : o.find((m) => m.startIndex <= h && m.endIndex >= _ - 1), c) {
276
+ if (C ? c = (n = (r = h.getBody()) == null ? void 0 : r.customDecorations) == null ? void 0 : n.find((m) => m.startIndex <= f && m.endIndex >= g - 1) : c = (i = (o = h.getBody()) == null ? void 0 : o.customDecorations) == null ? void 0 : i.find((m) => m.startIndex <= f && m.endIndex >= g - 1), c) {
277
277
  const m = this._threadCommentModel.getComment(d, I, c.id);
278
278
  m && !m.resolved && this._commandService.executeCommand(w.id, {
279
279
  activeComment: {
@@ -287,18 +287,18 @@ let N = class extends j {
287
287
  }
288
288
  if (!this._threadCommentPanelService.activeCommentId)
289
289
  return;
290
- this._commandService.executeCommand(oe.id);
290
+ this._commandService.executeCommand(ie.id);
291
291
  }
292
292
  })
293
293
  );
294
294
  }
295
295
  _initActiveCommandChange() {
296
296
  this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((e) => {
297
- var t, r, n, i;
297
+ var t, r, n, o;
298
298
  if (e) {
299
- const o = this._univerInstanceService.getUnit(e.unitId);
300
- if (o) {
301
- const s = (t = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : t.with(He), d = (n = (r = o.getBody()) == null ? void 0 : r.customDecorations) == null ? void 0 : n.find((l) => l.id === e.commentId);
299
+ const i = this._univerInstanceService.getUnit(e.unitId);
300
+ if (i) {
301
+ const s = (t = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : t.with(Fe), d = (n = (r = i.getBody()) == null ? void 0 : r.customDecorations) == null ? void 0 : n.find((l) => l.id === e.commentId);
302
302
  d && s && s.scrollToRange({
303
303
  startOffset: d.startIndex,
304
304
  endOffset: d.endIndex,
@@ -306,89 +306,89 @@ let N = class extends j {
306
306
  });
307
307
  }
308
308
  }
309
- (!e || e.commentId !== ((i = this._docThreadCommentService.addingComment) == null ? void 0 : i.id)) && this._docThreadCommentService.endAdd();
309
+ (!e || e.commentId !== ((o = this._docThreadCommentService.addingComment) == null ? void 0 : o.id)) && this._docThreadCommentService.endAdd();
310
310
  }));
311
311
  }
312
312
  };
313
- N = ut([
314
- D(0, v(U)),
313
+ N = at([
314
+ D(0, _(U)),
315
315
  D(1, B),
316
316
  D(2, M),
317
- D(3, v(x)),
317
+ D(3, _(T)),
318
318
  D(4, F),
319
- D(5, v(de))
319
+ D(5, _(de))
320
320
  ], N);
321
- var g = function() {
322
- return g = Object.assign || function(e) {
321
+ var v = function() {
322
+ return v = Object.assign || function(e) {
323
323
  for (var t, r = 1, n = arguments.length; r < n; r++) {
324
324
  t = arguments[r];
325
- for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
325
+ for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
326
326
  }
327
327
  return e;
328
- }, g.apply(this, arguments);
329
- }, ft = function(e, t) {
328
+ }, v.apply(this, arguments);
329
+ }, mt = function(e, t) {
330
330
  var r = {};
331
331
  for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
332
332
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
333
- for (var i = 0, n = Object.getOwnPropertySymbols(e); i < n.length; i++)
334
- t.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[i]) && (r[n[i]] = e[n[i]]);
333
+ for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
334
+ t.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (r[n[o]] = e[n[o]]);
335
335
  return r;
336
- }, ge = ue(function(e, t) {
337
- var r = e.icon, n = e.id, i = e.className, o = e.extend, s = ft(e, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(n, " ").concat(i || "").trim(), l = nt("_".concat(_t()));
338
- return ve(r, "".concat(n), { defIds: r.defIds, idSuffix: l.current }, g({ ref: t, className: d }, s), o);
336
+ }, ve = ue(function(e, t) {
337
+ var r = e.icon, n = e.id, o = e.className, i = e.extend, s = mt(e, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), l = tt("_".concat(ht()));
338
+ return _e(r, "".concat(n), { defIds: r.defIds, idSuffix: l.current }, v({ ref: t, className: d }, s), i);
339
339
  });
340
- function ve(e, t, r, n, i) {
341
- return fe(e.tag, g(g({ key: t }, ht(e, r, i)), n), (Ct(e, r).children || []).map(function(o, s) {
342
- return ve(o, "".concat(t, "-").concat(e.tag, "-").concat(s), r, void 0, i);
340
+ function _e(e, t, r, n, o) {
341
+ return he(e.tag, v(v({ key: t }, lt(e, r, o)), n), (ut(e, r).children || []).map(function(i, s) {
342
+ return _e(i, "".concat(t, "-").concat(e.tag, "-").concat(s), r, void 0, o);
343
343
  }));
344
344
  }
345
- function ht(e, t, r) {
346
- var n = g({}, e.attrs);
345
+ function lt(e, t, r) {
346
+ var n = v({}, e.attrs);
347
347
  r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1);
348
- var i = t.defIds;
349
- return !i || i.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(o) {
350
- var s = o[0], d = o[1];
348
+ var o = t.defIds;
349
+ return !o || o.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(i) {
350
+ var s = i[0], d = i[1];
351
351
  typeof d == "string" && (n[s] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
352
352
  })), n;
353
353
  }
354
- function Ct(e, t) {
354
+ function ut(e, t) {
355
355
  var r, n = t.defIds;
356
- return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? g(g({}, e), { children: e.children.map(function(i) {
357
- return typeof i.attrs.id == "string" && n && n.indexOf(i.attrs.id) > -1 ? g(g({}, i), { attrs: g(g({}, i.attrs), { id: i.attrs.id + t.idSuffix }) }) : i;
356
+ return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? v(v({}, e), { children: e.children.map(function(o) {
357
+ return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ? v(v({}, o), { attrs: v(v({}, o.attrs), { id: o.attrs.id + t.idSuffix }) }) : o;
358
358
  }) }) : e;
359
359
  }
360
- function _t() {
360
+ function ht() {
361
361
  return Math.random().toString(36).substring(2, 8);
362
362
  }
363
- ge.displayName = "UniverIcon";
364
- var gt = { 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" } }] }, pe = ue(function(e, t) {
365
- return fe(ge, Object.assign({}, e, {
363
+ ve.displayName = "UniverIcon";
364
+ var ft = { 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" } }] }, pe = ue(function(e, t) {
365
+ return he(ve, Object.assign({}, e, {
366
366
  id: "comment-single",
367
367
  ref: t,
368
- icon: gt
368
+ icon: ft
369
369
  }));
370
370
  });
371
371
  pe.displayName = "CommentSingle";
372
- const vt = {
373
- [Ze.OTHERS]: {
372
+ const Ct = {
373
+ [ze.OTHERS]: {
374
374
  [X.id]: {
375
375
  order: 1,
376
- menuItemFactory: at
376
+ menuItemFactory: dt
377
377
  }
378
378
  },
379
- [ze.MAIN_AREA]: {
380
- [Je.DATA]: {
379
+ [Ge.MAIN_AREA]: {
380
+ [Ze.DATA]: {
381
381
  [W.id]: {
382
382
  order: 1,
383
- menuItemFactory: ct
383
+ menuItemFactory: st
384
384
  }
385
385
  }
386
386
  }
387
387
  };
388
- var pt = Object.defineProperty, It = Object.getOwnPropertyDescriptor, St = (e, t, r, n) => {
389
- for (var i = n > 1 ? void 0 : n ? It(t, r) : t, o = e.length - 1, s; o >= 0; o--)
390
- (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
391
- return n && i && pt(t, r, i), i;
388
+ var gt = Object.getOwnPropertyDescriptor, vt = (e, t, r, n) => {
389
+ for (var o = n > 1 ? void 0 : n ? gt(t, r) : t, i = e.length - 1, s; i >= 0; i--)
390
+ (s = e[i]) && (o = s(o) || o);
391
+ return o;
392
392
  }, J = (e, t) => (r, n) => t(r, n, e);
393
393
  let V = class extends j {
394
394
  constructor(e, t, r) {
@@ -396,7 +396,7 @@ let V = class extends j {
396
396
  }
397
397
  _initCommands() {
398
398
  [
399
- he,
399
+ fe,
400
400
  Ce,
401
401
  w,
402
402
  W,
@@ -406,27 +406,27 @@ let V = class extends j {
406
406
  });
407
407
  }
408
408
  _initMenus() {
409
- this._menuManagerService.mergeMenu(vt);
409
+ this._menuManagerService.mergeMenu(Ct);
410
410
  }
411
411
  _initComponents() {
412
- [y].forEach((e) => {
412
+ [x].forEach((e) => {
413
413
  this.disposeWithMe(this._componentManager.register(e.componentKey, e));
414
414
  }), this.disposeWithMe(this._componentManager.register("CommentSingle", pe));
415
415
  }
416
416
  };
417
- V = St([
417
+ V = vt([
418
418
  J(0, M),
419
- J(1, Ye),
420
- J(2, v(qe))
419
+ J(1, Je),
420
+ J(2, _(qe))
421
421
  ], V);
422
- var Ot = Object.defineProperty, Mt = Object.getOwnPropertyDescriptor, bt = (e, t, r, n) => {
423
- for (var i = n > 1 ? void 0 : n ? Mt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
424
- (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
425
- return n && i && Ot(t, r, i), i;
426
- }, T = (e, t) => (r, n) => t(r, n, e);
422
+ var _t = Object.getOwnPropertyDescriptor, pt = (e, t, r, n) => {
423
+ for (var o = n > 1 ? void 0 : n ? _t(t, r) : t, i = e.length - 1, s; i >= 0; i--)
424
+ (s = e[i]) && (o = s(o) || o);
425
+ return o;
426
+ }, y = (e, t) => (r, n) => t(r, n, e);
427
427
  let Q = class extends j {
428
- constructor(e, t, r, n, i, o, s) {
429
- super(), this._context = e, this._docInterceptorService = t, this._threadCommentPanelService = r, this._docRenderController = n, this._univerInstanceService = i, this._threadCommentModel = o, this._commandService = s, this._interceptorViewModel(), this._initReRender(), this._initSyncComments();
428
+ constructor(e, t, r, n, o, i, s) {
429
+ super(), this._context = e, this._docInterceptorService = t, this._threadCommentPanelService = r, this._docRenderController = n, this._univerInstanceService = o, this._threadCommentModel = i, this._commandService = s, this._interceptorViewModel(), this._initReRender(), this._initSyncComments();
430
430
  }
431
431
  _initReRender() {
432
432
  this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((e) => {
@@ -442,41 +442,41 @@ let Q = class extends j {
442
442
  }));
443
443
  }
444
444
  _interceptorViewModel() {
445
- this._docInterceptorService.intercept($e.CUSTOM_DECORATION, {
445
+ this._docInterceptorService.intercept(Ve.CUSTOM_DECORATION, {
446
446
  handler: (e, t, r) => {
447
447
  if (!e)
448
448
  return r(e);
449
- const { unitId: n, index: i, customDecorations: o } = t, s = this._threadCommentPanelService.activeCommentId, { commentId: d, unitId: l } = s || {}, f = o.find((C) => C.id === d), a = this._threadCommentModel.getComment(n, I, e.id);
449
+ const { unitId: n, index: o, customDecorations: i } = t, s = this._threadCommentPanelService.activeCommentId, { commentId: d, unitId: l } = s || {}, h = i.find((C) => C.id === d), a = this._threadCommentModel.getComment(n, I, e.id);
450
450
  if (!a)
451
451
  return r({
452
452
  ...e,
453
453
  show: !1
454
454
  });
455
- const h = f && i >= f.startIndex && i <= f.endIndex, _ = l === n && e.id === d;
455
+ const f = h && o >= h.startIndex && o <= h.endIndex, g = l === n && e.id === d;
456
456
  return r({
457
457
  ...e,
458
- active: _ || h,
458
+ active: g || f,
459
459
  show: !a.resolved
460
460
  });
461
461
  }
462
462
  });
463
463
  }
464
464
  _initSyncComments() {
465
- var i, o, s;
466
- const e = this._context.unit.getUnitId(), t = I, r = (s = (o = (i = this._context.unit.getBody()) == null ? void 0 : i.customDecorations) == null ? void 0 : o.filter((d) => d.type === Y.COMMENT).map((d) => d.id)) != null ? s : [];
465
+ var o, i, s;
466
+ const e = this._context.unit.getUnitId(), t = I, r = (s = (i = (o = this._context.unit.getBody()) == null ? void 0 : o.customDecorations) == null ? void 0 : i.filter((d) => d.type === Y.COMMENT).map((d) => d.id)) != null ? s : [];
467
467
  r.forEach((d) => {
468
468
  this._threadCommentModel.getComment(e, t, d) || this._threadCommentModel.addComment(e, t, { id: d, threadId: d, ref: "", dT: "", personId: "", text: { dataStream: "" }, unitId: e, subUnitId: t });
469
469
  }), r.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), I, r);
470
470
  let n = r.sort();
471
471
  this.disposeWithMe(this._commandService.onCommandExecuted((d) => {
472
- var l, f, a;
472
+ var l, h, a;
473
473
  if (d.id === se.id) {
474
474
  if (d.params.unitId !== this._context.unit.getUnitId())
475
475
  return;
476
- const _ = (a = (f = (l = this._context.unit.getBody()) == null ? void 0 : l.customDecorations) == null ? void 0 : f.filter((c) => c.type === Y.COMMENT).map((c) => c.id)) != null ? a : [], C = _.sort();
476
+ const g = (a = (h = (l = this._context.unit.getBody()) == null ? void 0 : l.customDecorations) == null ? void 0 : h.filter((c) => c.type === Y.COMMENT).map((c) => c.id)) != null ? a : [], C = g.sort();
477
477
  if (JSON.stringify(n) !== JSON.stringify(C)) {
478
478
  const c = new Set(n), m = new Set(C), p = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Set();
479
- _.forEach((u) => {
479
+ g.forEach((u) => {
480
480
  c.has(u) || p.add(u);
481
481
  }), n.forEach((u) => {
482
482
  m.has(u) || b.add(u);
@@ -488,34 +488,34 @@ let Q = class extends j {
488
488
  }));
489
489
  }
490
490
  };
491
- Q = bt([
492
- T(1, v(Ve)),
493
- T(2, v(U)),
494
- T(3, v(Le)),
495
- T(4, B),
496
- T(5, v(de)),
497
- T(6, M)
491
+ Q = pt([
492
+ y(1, _(Ne)),
493
+ y(2, _(U)),
494
+ y(3, _(He)),
495
+ y(4, B),
496
+ y(5, _(de)),
497
+ y(6, M)
498
498
  ], Q);
499
- var Ie = Object.defineProperty, Dt = Object.getOwnPropertyDescriptor, Tt = (e, t, r) => t in e ? Ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, xt = (e, t, r, n) => {
500
- for (var i = n > 1 ? void 0 : n ? Dt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
501
- (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
502
- return n && i && Ie(t, r, i), i;
503
- }, q = (e, t) => (r, n) => t(r, n, e), Se = (e, t, r) => Tt(e, typeof t != "symbol" ? t + "" : t, r);
499
+ var It = Object.defineProperty, St = Object.getOwnPropertyDescriptor, Ot = (e, t, r) => t in e ? It(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, Mt = (e, t, r, n) => {
500
+ for (var o = n > 1 ? void 0 : n ? St(t, r) : t, i = e.length - 1, s; i >= 0; i--)
501
+ (s = e[i]) && (o = s(o) || o);
502
+ return o;
503
+ }, q = (e, t) => (r, n) => t(r, n, e), Ie = (e, t, r) => Ot(e, typeof t != "symbol" ? t + "" : t, r);
504
504
  let $ = class extends Ue {
505
505
  constructor(e = ee, t, r, n) {
506
506
  super(), this._config = e, this._injector = t, this._renderManagerSrv = r, this._configService = n;
507
- const { menu: i, ...o } = Re(
507
+ const { menu: o, ...i } = Re(
508
508
  {},
509
509
  ee,
510
510
  this._config
511
511
  );
512
- i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig(it, o);
512
+ o && this._configService.setConfig("menu", o, { merge: !0 }), this._configService.setConfig(rt, i);
513
513
  }
514
514
  onStarting() {
515
515
  [
516
516
  [V],
517
517
  [N],
518
- [x]
518
+ [T]
519
519
  ].forEach((e) => {
520
520
  this._injector.add(e);
521
521
  });
@@ -529,16 +529,16 @@ let $ = class extends Ue {
529
529
  });
530
530
  }
531
531
  };
532
- Se($, "pluginName", rt);
533
- Se($, "type", S.UNIVER_DOC);
534
- $ = xt([
535
- ye(Ae),
536
- q(1, v(re)),
532
+ Ie($, "pluginName", nt);
533
+ Ie($, "type", S.UNIVER_DOC);
534
+ $ = Mt([
535
+ Te(Pe),
536
+ q(1, _(re)),
537
537
  q(2, F),
538
- q(3, Pe)
538
+ q(3, xe)
539
539
  ], $);
540
540
  export {
541
- he as AddDocCommentComment,
541
+ fe as AddDocCommentComment,
542
542
  Ce as DeleteDocCommentComment,
543
543
  w as ShowCommentPanelOperation,
544
544
  W as StartAddCommentOperation,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2023-present DreamNum Inc.
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2023-present DreamNum Inc.
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2023-present DreamNum Inc.
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
package/lib/umd/index.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/thread-comment-ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/thread-comment-ui","@univerjs/docs","@univerjs/docs-ui","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","react"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverDocsThreadCommentUi={},c.UniverCore,c.UniverEngineRender,c.UniverThreadCommentUi,c.UniverDocs,c.UniverDocsUi,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.React))})(this,function(c,o,_,O,T,A,w,I,U,re,D){"use strict";var xe=Object.defineProperty;var Ee=(c,o,_)=>o in c?xe(c,o,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[o]=_;var J=(c,o,_)=>Ee(c,typeof o!="symbol"?o+"":o,_);const oe="DOC_THREAD_COMMENT_UI_PLUGIN",M="default_doc",se="docs-thread-comment-ui.config",Y={};var de=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,ce=(e,t,i,n)=>{for(var r=n>1?void 0:n?ae(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=(n?d(t,i,r):d(r))||r);return n&&r&&de(t,i,r),r},Q=(e,t)=>(i,n)=>t(i,n,e);let P=class extends o.Disposable{constructor(t,i){super();J(this,"_addingComment$",new U.BehaviorSubject(void 0));J(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=t,this._threadCommentPanelService=i,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(t){this._addingComment$.next(t)}endAdd(){this._addingComment$.next(void 0)}};P=ce([Q(0,I.ISidebarService),Q(1,o.Inject(O.ThreadCommentPanelService))],P);const H={id:"docs.command.add-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{comment:i,unitId:n}=t,s=await e.get(w.IThreadCommentDataSourceService).addComment(i),d=e.get(o.ICommandService),a=A.addCustomDecorationBySelectionFactory(e,{id:s.threadId,type:o.CustomDecorationType.COMMENT,unitId:n});if(a){const f={id:w.AddCommentMutation.id,params:{unitId:n,subUnitId:M,comment:s}},C={id:O.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:M,commentId:s.id}};return(await o.sequenceExecute([f,a,C],d)).result}return!1}},L={id:"docs.command.delete-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:i,unitId:n}=t,r=e.get(o.ICommandService),s=A.deleteCustomDecorationFactory(e,{id:i,unitId:n});return s?(await o.sequenceExecute([s],r)).result:!1}},X=e=>{const t=e.get(_.IRenderManagerService),i=e.get(T.DocSelectionManagerService),n=t.getCurrent(),r=n==null?void 0:n.with(T.DocSkeletonManagerService).getSkeleton(),s=r==null?void 0:r.getViewModel().getEditArea();if(s===_.DocumentEditArea.FOOTER||s===_.DocumentEditArea.HEADER)return!0;const d=i.getActiveTextRange();return!!(d==null||d.collapsed)};function me(e){return{id:V.id,type:I.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:I.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,void 0,o.SHEET_EDITOR_UNITS),disabled$:new U.Observable(function(t){const n=e.get(T.DocSelectionManagerService).textSelection$.pipe(U.debounceTime(16)).subscribe(()=>{t.next(X(e))});return()=>{n.unsubscribe()}})}}function ue(e){return{id:W.id,type:I.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:I.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC)}}const R=()=>{const e=o.useDependency(o.IUniverInstanceService),t=o.useDependency(o.Injector),i=D.useMemo(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC).pipe(U.filter(m=>!!m&&!o.isInternalEditorID(m.getUnitId()))),[e]),n=o.useObservable(i),r=D.useMemo(()=>new U.Observable(m=>m.next(M)),[]),s=o.useDependency(T.DocSelectionManagerService),d=D.useMemo(()=>s.textSelection$.pipe(U.debounceTime(16)),[s.textSelection$]);o.useObservable(d);const a=o.useDependency(o.ICommandService),f=o.useDependency(P),C=o.useObservable(f.addingComment$),[u,h]=D.useState([]);if(D.useEffect(()=>{var j;const m=new Set,l=n==null?void 0:n.getCustomDecorations();h((j=l==null?void 0:l.map(v=>v.id).filter(v=>{const y=m.has(v);return m.add(v),!y}))!=null?j:[]);const b=a.onCommandExecuted(v=>{var y;if(v.id===T.RichTextEditingMutation.id){const $=new Set,z=n==null?void 0:n.getCustomDecorations();h((y=z==null?void 0:z.map(F=>F.id).filter(F=>{const Re=$.has(F);return $.add(F),!Re}))!=null?y:[])}});return()=>{b.dispose()}},[a,n]),!n)return null;const g=X(t),p=n.getUnitId();return re.jsx(O.ThreadCommentPanel,{unitId:p,subUnitId$:r,type:o.UniverInstanceType.UNIVER_DOC,onAdd:()=>{a.executeCommand(V.id)},getSubUnitName:()=>"",disableAdd:g,tempComment:C,onAddComment:m=>{if(!m.parentId){const l={unitId:p,range:C,comment:m};return a.executeCommand(H.id,l),f.endAdd(),!1}return!0},onDeleteComment:m=>{if(!m.parentId){const l={unitId:p,commentId:m.id};return a.executeCommand(L.id,l),!1}return!0},showComments:u})};R.componentKey="univer.doc.thread-comment-panel";const N={id:"docs.operation.show-comment-panel",type:o.CommandType.OPERATION,handler(e,t){var r;const i=e.get(O.ThreadCommentPanelService),n=e.get(I.ISidebarService);return(!i.panelVisible||((r=n.options.children)==null?void 0:r.label)!==R.componentKey)&&(n.open({header:{title:"threadCommentUI.panel.title"},children:{label:R.componentKey},width:320,onClose:()=>i.setPanelVisible(!1)}),i.setPanelVisible(!0)),t&&i.setActiveComment(t==null?void 0:t.activeComment),!0}},W={id:"docs.operation.toggle-comment-panel",type:o.CommandType.OPERATION,handler(e){var n;const t=e.get(O.ThreadCommentPanelService),i=e.get(I.ISidebarService);return!t.panelVisible||((n=i.options.children)==null?void 0:n.label)!==R.componentKey?(i.open({header:{title:"threadCommentUI.panel.title"},children:{label:R.componentKey},width:320,onClose:()=>t.setPanelVisible(!1)}),t.setPanelVisible(!0)):(i.close(),t.setPanelVisible(!1),t.setActiveComment(null)),!0}},V={id:"docs.operation.start-add-comment",type:o.CommandType.OPERATION,handler(e){var v,y,$;const t=e.get(O.ThreadCommentPanelService),n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),r=e.get(T.DocSelectionManagerService),s=e.get(_.IRenderManagerService),d=e.get(o.UserManagerService),a=e.get(P),f=e.get(o.ICommandService),C=e.get(I.ISidebarService),u=r.getActiveTextRange();if(!n||!u)return!1;const h=(v=s.getRenderById(n.getUnitId()))==null?void 0:v.with(A.DocSelectionRenderService);if(h==null||h.setReserveRangesStatus(!0),u.collapsed)return t.panelVisible?(t.setPanelVisible(!1),C.close()):f.executeCommand(N.id),!0;f.executeCommand(N.id);const g=n.getUnitId(),p=(($=(y=n.getBody())==null?void 0:y.dataStream)!=null?$:"").slice(u.startOffset,u.endOffset),m=o.BuildTextUtils.transform.getPlainText(p),l=M,b="",j={unitId:g,subUnitId:l,id:b,ref:m,dT:w.getDT(),personId:d.getCurrentUser().userID,text:{dataStream:`\r
2
- `},startOffset:u.startOffset,endOffset:u.endOffset,collapsed:!0,threadId:b};return h==null||h.blur(),a.startAdd(j),t.setActiveComment({unitId:g,subUnitId:l,commentId:b}),!0}};var le=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,ve=(e,t,i,n)=>{for(var r=n>1?void 0:n?fe(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=(n?d(t,i,r):d(r))||r);return n&&r&&le(t,i,r),r},x=(e,t)=>(i,n)=>t(i,n,e);let B=class extends o.Disposable{constructor(e,t,i,n,r,s){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=i,this._docThreadCommentService=n,this._renderManagerService=r,this._threadCommentModel=s,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var i,n,r,s;if(t.id===T.SetTextSelectionsOperation.id){const d=t.params,{unitId:a,ranges:f}=d;if(o.isInternalEditorID(a))return;const C=this._univerInstanceService.getUnit(a,o.UniverInstanceType.UNIVER_DOC),u=f[0];if((e==null?void 0:e.startOffset)===(u==null?void 0:u.startOffset)&&(e==null?void 0:e.endOffset)===(u==null?void 0:u.endOffset))return;if(e=u,u&&C){const{startOffset:h,endOffset:g,collapsed:p}=u;let m;if(p?m=(n=(i=C.getBody())==null?void 0:i.customDecorations)==null?void 0:n.find(l=>l.startIndex<=h&&l.endIndex>=g-1):m=(s=(r=C.getBody())==null?void 0:r.customDecorations)==null?void 0:s.find(l=>l.startIndex<=h&&l.endIndex>=g-1),m){const l=this._threadCommentModel.getComment(a,M,m.id);l&&!l.resolved&&this._commandService.executeCommand(N.id,{activeComment:{unitId:a,subUnitId:M,commentId:m.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,i,n,r;if(e){const s=this._univerInstanceService.getUnit(e.unitId);if(s){const d=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(A.DocBackScrollRenderController),a=(n=(i=s.getBody())==null?void 0:i.customDecorations)==null?void 0:n.find(f=>f.id===e.commentId);a&&d&&d.scrollToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1})}}(!e||e.commentId!==((r=this._docThreadCommentService.addingComment)==null?void 0:r.id))&&this._docThreadCommentService.endAdd()}))}};B=ve([x(0,o.Inject(O.ThreadCommentPanelService)),x(1,o.IUniverInstanceService),x(2,o.ICommandService),x(3,o.Inject(P)),x(4,_.IRenderManagerService),x(5,o.Inject(w.ThreadCommentModel))],B);var S=function(){return S=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)},Ce=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]]);return i},k=D.forwardRef(function(e,t){var i=e.icon,n=e.id,r=e.className,s=e.extend,d=Ce(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),f=D.useRef("_".concat(pe()));return ee(i,"".concat(n),{defIds:i.defIds,idSuffix:f.current},S({ref:t,className:a},d),s)});function ee(e,t,i,n,r){return D.createElement(e.tag,S(S({key:t},he(e,i,r)),n),(Ie(e,i).children||[]).map(function(s,d){return ee(s,"".concat(t,"-").concat(e.tag,"-").concat(d),i,void 0,r)}))}function he(e,t,i){var n=S({},e.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1);var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var d=s[0],a=s[1];typeof a=="string"&&(n[d]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ie(e,t){var i,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((i=e.children)===null||i===void 0)&&i.length)?S(S({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function pe(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var Se={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"}}]},te=D.forwardRef(function(e,t){return D.createElement(k,Object.assign({},e,{id:"comment-single",ref:t,icon:Se}))});te.displayName="CommentSingle";const ge={[I.RibbonStartGroup.OTHERS]:{[W.id]:{order:1,menuItemFactory:ue}},[I.ContextMenuPosition.MAIN_AREA]:{[I.ContextMenuGroup.DATA]:{[V.id]:{order:1,menuItemFactory:me}}}};var _e=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Te=(e,t,i,n)=>{for(var r=n>1?void 0:n?Oe(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=(n?d(t,i,r):d(r))||r);return n&&r&&_e(t,i,r),r},K=(e,t)=>(i,n)=>t(i,n,e);let q=class extends o.Disposable{constructor(e,t,i){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=i,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[H,L,N,V,W].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(ge)}_initComponents(){[R].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",te))}};q=Te([K(0,o.ICommandService),K(1,I.IMenuManagerService),K(2,o.Inject(I.ComponentManager))],q);var De=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,be=(e,t,i,n)=>{for(var r=n>1?void 0:n?Me(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=(n?d(t,i,r):d(r))||r);return n&&r&&De(t,i,r),r},E=(e,t)=>(i,n)=>t(i,n,e);let G=class extends o.Disposable{constructor(e,t,i,n,r,s,d){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=i,this._docRenderController=n,this._univerInstanceService=r,this._threadCommentModel=s,this._commandService=d,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var i;if(e){this._docRenderController.reRender(e.unitId);return}const t=(i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:i.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(T.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,i)=>{if(!e)return i(e);const{unitId:n,index:r,customDecorations:s}=t,d=this._threadCommentPanelService.activeCommentId,{commentId:a,unitId:f}=d||{},C=s.find(p=>p.id===a),u=this._threadCommentModel.getComment(n,M,e.id);if(!u)return i({...e,show:!1});const h=C&&r>=C.startIndex&&r<=C.endIndex,g=f===n&&e.id===a;return i({...e,active:g||h,show:!u.resolved})}})}_initSyncComments(){var r,s,d;const e=this._context.unit.getUnitId(),t=M,i=(d=(s=(r=this._context.unit.getBody())==null?void 0:r.customDecorations)==null?void 0:s.filter(a=>a.type===o.CustomDecorationType.COMMENT).map(a=>a.id))!=null?d:[];i.forEach(a=>{this._threadCommentModel.getComment(e,t,a)||this._threadCommentModel.addComment(e,t,{id:a,threadId:a,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),i.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),M,i);let n=i.sort();this.disposeWithMe(this._commandService.onCommandExecuted(a=>{var f,C,u;if(a.id===T.RichTextEditingMutation.id){if(a.params.unitId!==this._context.unit.getUnitId())return;const g=(u=(C=(f=this._context.unit.getBody())==null?void 0:f.customDecorations)==null?void 0:C.filter(m=>m.type===o.CustomDecorationType.COMMENT).map(m=>m.id))!=null?u:[],p=g.sort();if(JSON.stringify(n)!==JSON.stringify(p)){const m=new Set(n),l=new Set(p),b=new Set,j=new Set;g.forEach(v=>{m.has(v)||b.add(v)}),n.forEach(v=>{l.has(v)||j.add(v)}),n=p,b.forEach(v=>{this._threadCommentModel.getComment(e,t,v)||this._threadCommentModel.addComment(e,t,{id:v,threadId:v,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...b])}}}))}};G=be([E(1,o.Inject(T.DocInterceptorService)),E(2,o.Inject(O.ThreadCommentPanelService)),E(3,o.Inject(A.DocRenderController)),E(4,o.IUniverInstanceService),E(5,o.Inject(w.ThreadCommentModel)),E(6,o.ICommandService)],G);var ne=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Ue=(e,t,i)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Pe=(e,t,i,n)=>{for(var r=n>1?void 0:n?ye(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=(n?d(t,i,r):d(r))||r);return n&&r&&ne(t,i,r),r},Z=(e,t)=>(i,n)=>t(i,n,e),ie=(e,t,i)=>Ue(e,typeof t!="symbol"?t+"":t,i);c.UniverDocsThreadCommentUIPlugin=class extends o.Plugin{constructor(t=Y,i,n,r){super(),this._config=t,this._injector=i,this._renderManagerSrv=n,this._configService=r;const{menu:s,...d}=o.merge({},Y,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(se,d)}onStarting(){[[q],[B],[P]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(q)}_initRenderModule(){[G].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}},ie(c.UniverDocsThreadCommentUIPlugin,"pluginName",oe),ie(c.UniverDocsThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),c.UniverDocsThreadCommentUIPlugin=Pe([o.DependentOn(O.UniverThreadCommentUIPlugin),Z(1,o.Inject(o.Injector)),Z(2,_.IRenderManagerService),Z(3,o.IConfigService)],c.UniverDocsThreadCommentUIPlugin),c.AddDocCommentComment=H,c.DeleteDocCommentComment=L,c.ShowCommentPanelOperation=N,c.StartAddCommentOperation=V,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/thread-comment-ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/thread-comment-ui","@univerjs/docs","@univerjs/docs-ui","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","react"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverDocsThreadCommentUi={},c.UniverCore,c.UniverEngineRender,c.UniverThreadCommentUi,c.UniverDocs,c.UniverDocsUi,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.React))})(this,function(c,o,_,O,T,A,w,u,U,ie,D){"use strict";var be=Object.defineProperty;var Ue=(c,o,_)=>o in c?be(c,o,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[o]=_;var J=(c,o,_)=>Ue(c,typeof o!="symbol"?o+"":o,_);const re="DOC_THREAD_COMMENT_UI_PLUGIN",M="default_doc",oe="docs-thread-comment-ui.config",Y={};var se=Object.getOwnPropertyDescriptor,de=(e,t,i,n)=>{for(var r=n>1?void 0:n?se(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},Q=(e,t)=>(i,n)=>t(i,n,e);let P=class extends o.Disposable{constructor(t,i){super();J(this,"_addingComment$",new U.BehaviorSubject(void 0));J(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=t,this._threadCommentPanelService=i,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(t){this._addingComment$.next(t)}endAdd(){this._addingComment$.next(void 0)}};P=de([Q(0,u.ISidebarService),Q(1,o.Inject(O.ThreadCommentPanelService))],P);const H={id:"docs.command.add-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{comment:i,unitId:n}=t,s=await e.get(w.IThreadCommentDataSourceService).addComment(i),d=e.get(o.ICommandService),a=A.addCustomDecorationBySelectionFactory(e,{id:s.threadId,type:o.CustomDecorationType.COMMENT,unitId:n});if(a){const C={id:w.AddCommentMutation.id,params:{unitId:n,subUnitId:M,comment:s}},f={id:O.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:M,commentId:s.id}};return(await o.sequenceExecute([C,a,f],d)).result}return!1}},L={id:"docs.command.delete-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:i,unitId:n}=t,r=e.get(o.ICommandService),s=A.deleteCustomDecorationFactory(e,{id:i,unitId:n});return s?(await o.sequenceExecute([s],r)).result:!1}},X=e=>{const t=e.get(_.IRenderManagerService),i=e.get(T.DocSelectionManagerService),n=t.getCurrent(),r=n==null?void 0:n.with(T.DocSkeletonManagerService).getSkeleton(),s=r==null?void 0:r.getViewModel().getEditArea();if(s===_.DocumentEditArea.FOOTER||s===_.DocumentEditArea.HEADER)return!0;const d=i.getActiveTextRange();return!!(d==null||d.collapsed)};function ae(e){return{id:V.id,type:u.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,void 0,o.SHEET_EDITOR_UNITS),disabled$:new U.Observable(function(t){const n=e.get(T.DocSelectionManagerService).textSelection$.pipe(U.debounceTime(16)).subscribe(()=>{t.next(X(e))});return()=>{n.unsubscribe()}})}}function ce(e){return{id:W.id,type:u.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC)}}const R=()=>{const e=u.useDependency(o.IUniverInstanceService),t=u.useDependency(o.Injector),i=D.useMemo(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC).pipe(U.filter(m=>!!m&&!o.isInternalEditorID(m.getUnitId()))),[e]),n=u.useObservable(i),r=D.useMemo(()=>new U.Observable(m=>m.next(M)),[]),s=u.useDependency(T.DocSelectionManagerService),d=D.useMemo(()=>s.textSelection$.pipe(U.debounceTime(16)),[s.textSelection$]);u.useObservable(d);const a=u.useDependency(o.ICommandService),C=u.useDependency(P),f=u.useObservable(C.addingComment$),[l,I]=D.useState([]);if(D.useEffect(()=>{var j;const m=new Set,v=n==null?void 0:n.getCustomDecorations();I((j=v==null?void 0:v.map(h=>h.id).filter(h=>{const b=m.has(h);return m.add(h),!b}))!=null?j:[]);const y=a.onCommandExecuted(h=>{var b;if(h.id===T.RichTextEditingMutation.id){const $=new Set,z=n==null?void 0:n.getCustomDecorations();I((b=z==null?void 0:z.map(F=>F.id).filter(F=>{const ye=$.has(F);return $.add(F),!ye}))!=null?b:[])}});return()=>{y.dispose()}},[a,n]),!n)return null;const p=X(t),g=n.getUnitId();return ie.jsx(O.ThreadCommentPanel,{unitId:g,subUnitId$:r,type:o.UniverInstanceType.UNIVER_DOC,onAdd:()=>{a.executeCommand(V.id)},getSubUnitName:()=>"",disableAdd:p,tempComment:f,onAddComment:m=>{if(!m.parentId){const v={unitId:g,range:f,comment:m};return a.executeCommand(H.id,v),C.endAdd(),!1}return!0},onDeleteComment:m=>{if(!m.parentId){const v={unitId:g,commentId:m.id};return a.executeCommand(L.id,v),!1}return!0},showComments:l})};R.componentKey="univer.doc.thread-comment-panel";const N={id:"docs.operation.show-comment-panel",type:o.CommandType.OPERATION,handler(e,t){var r;const i=e.get(O.ThreadCommentPanelService),n=e.get(u.ISidebarService);return(!i.panelVisible||((r=n.options.children)==null?void 0:r.label)!==R.componentKey)&&(n.open({header:{title:"threadCommentUI.panel.title"},children:{label:R.componentKey},width:320,onClose:()=>i.setPanelVisible(!1)}),i.setPanelVisible(!0)),t&&i.setActiveComment(t==null?void 0:t.activeComment),!0}},W={id:"docs.operation.toggle-comment-panel",type:o.CommandType.OPERATION,handler(e){var n;const t=e.get(O.ThreadCommentPanelService),i=e.get(u.ISidebarService);return!t.panelVisible||((n=i.options.children)==null?void 0:n.label)!==R.componentKey?(i.open({header:{title:"threadCommentUI.panel.title"},children:{label:R.componentKey},width:320,onClose:()=>t.setPanelVisible(!1)}),t.setPanelVisible(!0)):(i.close(),t.setPanelVisible(!1),t.setActiveComment(null)),!0}},V={id:"docs.operation.start-add-comment",type:o.CommandType.OPERATION,handler(e){var h,b,$;const t=e.get(O.ThreadCommentPanelService),n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),r=e.get(T.DocSelectionManagerService),s=e.get(_.IRenderManagerService),d=e.get(o.UserManagerService),a=e.get(P),C=e.get(o.ICommandService),f=e.get(u.ISidebarService),l=r.getActiveTextRange();if(!n||!l)return!1;const I=(h=s.getRenderById(n.getUnitId()))==null?void 0:h.with(A.DocSelectionRenderService);if(I==null||I.setReserveRangesStatus(!0),l.collapsed)return t.panelVisible?(t.setPanelVisible(!1),f.close()):C.executeCommand(N.id),!0;C.executeCommand(N.id);const p=n.getUnitId(),g=(($=(b=n.getBody())==null?void 0:b.dataStream)!=null?$:"").slice(l.startOffset,l.endOffset),m=o.BuildTextUtils.transform.getPlainText(g),v=M,y="",j={unitId:p,subUnitId:v,id:y,ref:m,dT:w.getDT(),personId:d.getCurrentUser().userID,text:{dataStream:`\r
2
+ `},startOffset:l.startOffset,endOffset:l.endOffset,collapsed:!0,threadId:y};return I==null||I.blur(),a.startAdd(j),t.setActiveComment({unitId:p,subUnitId:v,commentId:y}),!0}};var me=Object.getOwnPropertyDescriptor,le=(e,t,i,n)=>{for(var r=n>1?void 0:n?me(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},x=(e,t)=>(i,n)=>t(i,n,e);let B=class extends o.Disposable{constructor(e,t,i,n,r,s){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=i,this._docThreadCommentService=n,this._renderManagerService=r,this._threadCommentModel=s,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var i,n,r,s;if(t.id===T.SetTextSelectionsOperation.id){const d=t.params,{unitId:a,ranges:C}=d;if(o.isInternalEditorID(a))return;const f=this._univerInstanceService.getUnit(a,o.UniverInstanceType.UNIVER_DOC),l=C[0];if((e==null?void 0:e.startOffset)===(l==null?void 0:l.startOffset)&&(e==null?void 0:e.endOffset)===(l==null?void 0:l.endOffset))return;if(e=l,l&&f){const{startOffset:I,endOffset:p,collapsed:g}=l;let m;if(g?m=(n=(i=f.getBody())==null?void 0:i.customDecorations)==null?void 0:n.find(v=>v.startIndex<=I&&v.endIndex>=p-1):m=(s=(r=f.getBody())==null?void 0:r.customDecorations)==null?void 0:s.find(v=>v.startIndex<=I&&v.endIndex>=p-1),m){const v=this._threadCommentModel.getComment(a,M,m.id);v&&!v.resolved&&this._commandService.executeCommand(N.id,{activeComment:{unitId:a,subUnitId:M,commentId:m.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,i,n,r;if(e){const s=this._univerInstanceService.getUnit(e.unitId);if(s){const d=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(A.DocBackScrollRenderController),a=(n=(i=s.getBody())==null?void 0:i.customDecorations)==null?void 0:n.find(C=>C.id===e.commentId);a&&d&&d.scrollToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1})}}(!e||e.commentId!==((r=this._docThreadCommentService.addingComment)==null?void 0:r.id))&&this._docThreadCommentService.endAdd()}))}};B=le([x(0,o.Inject(O.ThreadCommentPanelService)),x(1,o.IUniverInstanceService),x(2,o.ICommandService),x(3,o.Inject(P)),x(4,_.IRenderManagerService),x(5,o.Inject(w.ThreadCommentModel))],B);var S=function(){return S=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)},ue=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]]);return i},k=D.forwardRef(function(e,t){var i=e.icon,n=e.id,r=e.className,s=e.extend,d=ue(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),C=D.useRef("_".concat(he()));return ee(i,"".concat(n),{defIds:i.defIds,idSuffix:C.current},S({ref:t,className:a},d),s)});function ee(e,t,i,n,r){return D.createElement(e.tag,S(S({key:t},ve(e,i,r)),n),(Ce(e,i).children||[]).map(function(s,d){return ee(s,"".concat(t,"-").concat(e.tag,"-").concat(d),i,void 0,r)}))}function ve(e,t,i){var n=S({},e.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1);var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var d=s[0],a=s[1];typeof a=="string"&&(n[d]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ce(e,t){var i,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((i=e.children)===null||i===void 0)&&i.length)?S(S({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function he(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var fe={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"}}]},te=D.forwardRef(function(e,t){return D.createElement(k,Object.assign({},e,{id:"comment-single",ref:t,icon:fe}))});te.displayName="CommentSingle";const Ie={[u.RibbonStartGroup.OTHERS]:{[W.id]:{order:1,menuItemFactory:ce}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[V.id]:{order:1,menuItemFactory:ae}}}};var ge=Object.getOwnPropertyDescriptor,Se=(e,t,i,n)=>{for(var r=n>1?void 0:n?ge(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},K=(e,t)=>(i,n)=>t(i,n,e);let q=class extends o.Disposable{constructor(e,t,i){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=i,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[H,L,N,V,W].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Ie)}_initComponents(){[R].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",te))}};q=Se([K(0,o.ICommandService),K(1,u.IMenuManagerService),K(2,o.Inject(u.ComponentManager))],q);var pe=Object.getOwnPropertyDescriptor,_e=(e,t,i,n)=>{for(var r=n>1?void 0:n?pe(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},E=(e,t)=>(i,n)=>t(i,n,e);let G=class extends o.Disposable{constructor(e,t,i,n,r,s,d){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=i,this._docRenderController=n,this._univerInstanceService=r,this._threadCommentModel=s,this._commandService=d,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var i;if(e){this._docRenderController.reRender(e.unitId);return}const t=(i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:i.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(T.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,i)=>{if(!e)return i(e);const{unitId:n,index:r,customDecorations:s}=t,d=this._threadCommentPanelService.activeCommentId,{commentId:a,unitId:C}=d||{},f=s.find(g=>g.id===a),l=this._threadCommentModel.getComment(n,M,e.id);if(!l)return i({...e,show:!1});const I=f&&r>=f.startIndex&&r<=f.endIndex,p=C===n&&e.id===a;return i({...e,active:p||I,show:!l.resolved})}})}_initSyncComments(){var r,s,d;const e=this._context.unit.getUnitId(),t=M,i=(d=(s=(r=this._context.unit.getBody())==null?void 0:r.customDecorations)==null?void 0:s.filter(a=>a.type===o.CustomDecorationType.COMMENT).map(a=>a.id))!=null?d:[];i.forEach(a=>{this._threadCommentModel.getComment(e,t,a)||this._threadCommentModel.addComment(e,t,{id:a,threadId:a,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),i.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),M,i);let n=i.sort();this.disposeWithMe(this._commandService.onCommandExecuted(a=>{var C,f,l;if(a.id===T.RichTextEditingMutation.id){if(a.params.unitId!==this._context.unit.getUnitId())return;const p=(l=(f=(C=this._context.unit.getBody())==null?void 0:C.customDecorations)==null?void 0:f.filter(m=>m.type===o.CustomDecorationType.COMMENT).map(m=>m.id))!=null?l:[],g=p.sort();if(JSON.stringify(n)!==JSON.stringify(g)){const m=new Set(n),v=new Set(g),y=new Set,j=new Set;p.forEach(h=>{m.has(h)||y.add(h)}),n.forEach(h=>{v.has(h)||j.add(h)}),n=g,y.forEach(h=>{this._threadCommentModel.getComment(e,t,h)||this._threadCommentModel.addComment(e,t,{id:h,threadId:h,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...y])}}}))}};G=_e([E(1,o.Inject(T.DocInterceptorService)),E(2,o.Inject(O.ThreadCommentPanelService)),E(3,o.Inject(A.DocRenderController)),E(4,o.IUniverInstanceService),E(5,o.Inject(w.ThreadCommentModel)),E(6,o.ICommandService)],G);var Oe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,De=(e,t,i)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Me=(e,t,i,n)=>{for(var r=n>1?void 0:n?Te(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},Z=(e,t)=>(i,n)=>t(i,n,e),ne=(e,t,i)=>De(e,typeof t!="symbol"?t+"":t,i);c.UniverDocsThreadCommentUIPlugin=class extends o.Plugin{constructor(t=Y,i,n,r){super(),this._config=t,this._injector=i,this._renderManagerSrv=n,this._configService=r;const{menu:s,...d}=o.merge({},Y,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(oe,d)}onStarting(){[[q],[B],[P]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(q)}_initRenderModule(){[G].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}},ne(c.UniverDocsThreadCommentUIPlugin,"pluginName",re),ne(c.UniverDocsThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),c.UniverDocsThreadCommentUIPlugin=Me([o.DependentOn(O.UniverThreadCommentUIPlugin),Z(1,o.Inject(o.Injector)),Z(2,_.IRenderManagerService),Z(3,o.IConfigService)],c.UniverDocsThreadCommentUIPlugin),c.AddDocCommentComment=H,c.DeleteDocCommentComment=L,c.ShowCommentPanelOperation=N,c.StartAddCommentOperation=V,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-thread-comment-ui",
3
- "version": "0.6.0-nightly.202502111606",
3
+ "version": "0.6.0-nightly.202502131606",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -47,24 +47,24 @@
47
47
  "rxjs": ">=7.0.0"
48
48
  },
49
49
  "dependencies": {
50
- "@univerjs/icons": "^0.2.14",
50
+ "@univerjs/icons": "^0.2.15",
51
51
  "clsx": "^2.1.1",
52
- "@univerjs/core": "0.6.0-nightly.202502111606",
53
- "@univerjs/docs": "0.6.0-nightly.202502111606",
54
- "@univerjs/docs-ui": "0.6.0-nightly.202502111606",
55
- "@univerjs/engine-render": "0.6.0-nightly.202502111606",
56
- "@univerjs/thread-comment": "0.6.0-nightly.202502111606",
57
- "@univerjs/thread-comment-ui": "0.6.0-nightly.202502111606",
58
- "@univerjs/ui": "0.6.0-nightly.202502111606"
52
+ "@univerjs/core": "0.6.0-nightly.202502131606",
53
+ "@univerjs/docs-ui": "0.6.0-nightly.202502131606",
54
+ "@univerjs/docs": "0.6.0-nightly.202502131606",
55
+ "@univerjs/engine-render": "0.6.0-nightly.202502131606",
56
+ "@univerjs/thread-comment": "0.6.0-nightly.202502131606",
57
+ "@univerjs/thread-comment-ui": "0.6.0-nightly.202502131606",
58
+ "@univerjs/ui": "0.6.0-nightly.202502131606"
59
59
  },
60
60
  "devDependencies": {
61
- "postcss": "^8.5.1",
61
+ "postcss": "^8.5.2",
62
62
  "react": "18.3.1",
63
63
  "rxjs": "^7.8.1",
64
64
  "tailwindcss": "^3.4.17",
65
65
  "typescript": "^5.7.3",
66
- "vite": "^6.0.11",
67
- "vitest": "^3.0.4",
66
+ "vite": "^6.1.0",
67
+ "vitest": "^3.0.5",
68
68
  "@univerjs-infra/shared": "0.6.0-alpha.0"
69
69
  },
70
70
  "scripts": {