@univerjs/docs-thread-comment-ui 0.4.2-nightly.202411081606 → 0.4.2-nightly.202411091134

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