@univerjs/docs-thread-comment-ui 0.5.3-nightly.202501121605 → 0.5.4-experimental.20250114-7c09c35

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