@univerjs/docs-thread-comment-ui 0.5.3-nightly.202501071618 → 0.5.3-nightly.202501090742

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,Ce=Object.getOwnPropertyDescriptor,fe=(e,t,r,n)=>{for(var o=n>1?void 0:n?Ce(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ue(t,r,o),o},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=fe([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 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={};/**
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,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(d,m,C){var a,h={},v=null,p=null;C!==void 0&&(v=""+C),m.key!==void 0&&(v=""+m.key),m.ref!==void 0&&(p=m.ref);for(a in m)n.call(m,a)&&!i.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:o.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,i=await e.get(A.IThreadCommentDataSourceService).addComment(r),s=e.get(c.ICommandService),d=$.addCustomDecorationBySelectionFactory(e,{id:i.threadId,type:c.CustomDecorationType.COMMENT});if(d){const m={id:A.AddCommentMutation.id,params:{unitId:n,subUnitId:M,comment:i}},C={id:O.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:M,commentId:i.id}};return(await c.sequenceExecute([m,d,C],s)).result}return!1}},z={id:"docs.command.delete-comment",type:c.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:r,unitId:n}=t,o=e.get(c.ICommandService),i=$.deleteCustomDecorationFactory(e,{id:r,unitId:n});return i?(await c.sequenceExecute([i],o)).result:!1}},te=e=>{const t=e.get(x.IRenderManagerService),r=e.get(S.DocSelectionManagerService),n=t.getCurrent(),o=n==null?void 0:n.with(S.DocSkeletonManagerService).getSkeleton(),i=o==null?void 0:o.getViewModel().getEditArea();if(i===x.DocumentEditArea.FOOTER||i===x.DocumentEditArea.HEADER)return!0;const s=r.getActiveTextRange();return!!(s==null||s.collapsed)};function _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),o=g.useMemo(()=>new N.Observable(l=>l.next(M)),[]),i=c.useDependency(S.DocSelectionManagerService),s=g.useMemo(()=>i.textSelection$.pipe(N.debounceTime(16)),[i.textSelection$]);c.useObservable(s);const d=c.useDependency(c.ICommandService),m=c.useDependency(R),C=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(f=>f.id).filter(f=>{const T=l.has(f);return l.add(f),!T}))!=null?D:[]);const b=d.onCommandExecuted(f=>{var T;if(f.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$:o,type:c.UniverInstanceType.UNIVER_DOC,onAdd:()=>{d.executeCommand(V.id)},getSubUnitName:()=>"",disableAdd:v,tempComment:C,onAddComment:l=>{if(!l.parentId){const u={unitId:p,range:C,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 o;const r=e.get(O.ThreadCommentPanelService),n=e.get(_.ISidebarService);return(!r.panelVisible||((o=n.options.children)==null?void 0:o.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 f,T,E;const t=e.get(O.ThreadCommentPanelService),n=e.get(c.IUniverInstanceService).getCurrentUnitForType(c.UniverInstanceType.UNIVER_DOC),o=e.get(S.DocSelectionManagerService),i=e.get(x.IRenderManagerService),s=e.get(c.UserManagerService),d=e.get(R),m=e.get(c.ICommandService),C=e.get(_.ISidebarService),a=o.getActiveTextRange();if(!n||!a)return!1;const h=(f=i.getRenderById(n.getUnitId()))==null?void 0:f.with($.DocSelectionRenderService);if(a.collapsed)return t.panelVisible?(t.setPanelVisible(!1),C.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 o=n>1?void 0:n?Se(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ge(t,r,o),o},y=(e,t)=>(r,n)=>t(r,n,e);let q=class extends c.Disposable{constructor(e,t,r,n,o,i){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=r,this._docThreadCommentService=n,this._renderManagerService=o,this._threadCommentModel=i,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var r,n,o,i;if(t.id===S.SetTextSelectionsOperation.id){const s=t.params,{unitId:d,ranges:m}=s,C=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&&C){const{startOffset:h,endOffset:v,collapsed:p}=a;let l;if(p?l=(n=(r=C.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(u=>u.startIndex<=h&&u.endIndex>=v-1):l=(i=(o=C.getBody())==null?void 0:o.customDecorations)==null?void 0:i.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,o;if(e){const i=this._univerInstanceService.getUnit(e.unitId);if(i){const s=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with($.DocBackScrollRenderController),d=(n=(r=i.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!==((o=this._docThreadCommentService.addingComment)==null?void 0:o.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 o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}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 o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r},ne=g.forwardRef(function(e,t){var r=e.icon,n=e.id,o=e.className,i=e.extend,s=be(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),m=g.useRef("_".concat(De()));return re(r,"".concat(n),{defIds:r.defIds,idSuffix:m.current},I({ref:t,className:d},s),i)});function re(e,t,r,n,o){return g.createElement(e.tag,I(I({key:t},Me(e,r,o)),n),(Te(e,r).children||[]).map(function(i,s){return re(i,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,o)}))}function Me(e,t,r){var n=I({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function 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(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?I(I({},o),{attrs:I(I({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):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"}}]},oe=g.forwardRef(function(e,t){return g.createElement(ne,Object.assign({},e,{id:"comment-single",ref:t,icon:ye}))});oe.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 o=n>1?void 0:n?Re(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&xe(t,r,o),o},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",oe))}};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 o=n>1?void 0:n?we(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Ee(t,r,o),o},U=(e,t)=>(r,n)=>t(r,n,e);let G=class extends c.Disposable{constructor(e,t,r,n,o,i,s){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=r,this._docRenderController=n,this._univerInstanceService=o,this._threadCommentModel=i,this._commandService=s,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var r;if(e){this._docRenderController.reRender(e.unitId);return}const t=(r=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(S.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,r)=>{if(!e)return r(e);const{unitId:n,index:o,customDecorations:i}=t,s=this._threadCommentPanelService.activeCommentId,{commentId:d,unitId:m}=s||{},C=i.find(p=>p.id===d),a=this._threadCommentModel.getComment(n,M,e.id);if(!a)return r({...e,show:!1});const h=C&&o>=C.startIndex&&o<=C.endIndex,v=m===n&&e.id===d;return r({...e,active:v||h,show:!a.resolved})}})}_initSyncComments(){var o,i,s;const e=this._context.unit.getUnitId(),t=M,r=(s=(i=(o=this._context.unit.getBody())==null?void 0:o.customDecorations)==null?void 0:i.filter(d=>d.type===c.CustomDecorationType.COMMENT).map(d=>d.id))!=null?s:[];r.forEach(d=>{this._threadCommentModel.getComment(e,t,d)||this._threadCommentModel.addComment(e,t,{id:d,threadId:d,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),M,r);let n=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(d=>{var m,C,a;if(d.id===S.RichTextEditingMutation.id){if(d.params.unitId!==this._context.unit.getUnitId())return;const v=(a=(C=(m=this._context.unit.getBody())==null?void 0:m.customDecorations)==null?void 0:C.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(f=>{l.has(f)||b.add(f)}),n.forEach(f=>{u.has(f)||D.add(f)}),n=p,b.forEach(f=>{this._threadCommentModel.getComment(e,t,f)||this._threadCommentModel.addComment(e,t,{id:f,threadId:f,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...b])}}}))}};G=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 ie=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,je=(e,t,r)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$e=(e,t,r,n)=>{for(var o=n>1?void 0:n?Ne(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ie(t,r,o),o},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,o){super(),this._config=t,this._injector=r,this._renderManagerSrv=n,this._configService=o;const{menu:i,...s}=c.merge({},Q,this._config);i&&this._configService.setConfig("menu",i,{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 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;
package/lib/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var De = Object.defineProperty;
2
2
  var Re = (e, t, r) => t in e ? De(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var K = (e, t, r) => Re(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { Inject as p, 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";
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";
5
5
  import { IRenderManagerService as L, DocumentEditArea as te } from "@univerjs/engine-render";
6
6
  import { ThreadCommentPanelService as T, SetActiveCommentOperation as ce, ThreadCommentPanel as Ae, UniverThreadCommentUIPlugin as $e } from "@univerjs/thread-comment-ui";
7
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";
@@ -9,12 +9,12 @@ import { addCustomDecorationBySelectionFactory as Le, deleteCustomDecorationFact
9
9
  import { IThreadCommentDataSourceService as Ke, AddCommentMutation as Ge, getDT as Ze, ThreadCommentModel as me } from "@univerjs/thread-comment";
10
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
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 ot, createElement as _e } from "react";
13
- const it = "DOC_THREAD_COMMENT_UI_PLUGIN", I = "default_doc", st = "docs-thread-comment-ui.config", ne = {};
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
14
  var dt = Object.defineProperty, ct = Object.getOwnPropertyDescriptor, at = (e, t, r, n) => {
15
- for (var o = n > 1 ? void 0 : n ? ct(t, r) : t, i = e.length - 1, s; i >= 0; i--)
16
- (s = e[i]) && (o = (n ? s(t, r, o) : s(o)) || o);
17
- return n && o && dt(t, r, o), o;
15
+ for (var i = n > 1 ? void 0 : n ? ct(t, r) : t, o = e.length - 1, s; o >= 0; o--)
16
+ (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
17
+ return n && i && dt(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) {
@@ -37,7 +37,7 @@ let R = class extends B {
37
37
  };
38
38
  R = at([
39
39
  re(0, W),
40
- re(1, p(T))
40
+ re(1, v(T))
41
41
  ], R);
42
42
  var z = { exports: {} }, E = {};
43
43
  /**
@@ -49,35 +49,35 @@ var z = { exports: {} }, E = {};
49
49
  * This source code is licensed under the MIT license found in the
50
50
  * LICENSE file in the root directory of this source tree.
51
51
  */
52
- var oe;
52
+ var ie;
53
53
  function mt() {
54
- if (oe) return E;
55
- oe = 1;
56
- var e = tt, t = Symbol.for("react.element"), r = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, o = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
54
+ if (ie) return E;
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 };
57
57
  function s(d, a, u) {
58
58
  var c, h = {}, 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) && !i.hasOwnProperty(c) && (h[c] = a[c]);
60
+ for (c in a) n.call(a, c) && !o.hasOwnProperty(c) && (h[c] = a[c]);
61
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: o.current };
62
+ return { $$typeof: t, type: d, key: C, ref: _, props: h, _owner: i.current };
63
63
  }
64
64
  return E.Fragment = r, E.jsx = s, E.jsxs = s, E;
65
65
  }
66
- var ie;
66
+ var oe;
67
67
  function lt() {
68
- return ie || (ie = 1, z.exports = mt()), z.exports;
68
+ return oe || (oe = 1, z.exports = mt()), z.exports;
69
69
  }
70
70
  var ut = lt();
71
- const ve = {
71
+ const pe = {
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, i = await e.get(Ke).addComment(r), s = e.get(M), d = Le(
77
+ const { comment: r, unitId: n } = t, o = await e.get(Ke).addComment(r), s = e.get(M), d = Le(
78
78
  e,
79
79
  {
80
- id: i.threadId,
80
+ id: o.threadId,
81
81
  type: X.COMMENT
82
82
  }
83
83
  );
@@ -87,35 +87,35 @@ const ve = {
87
87
  params: {
88
88
  unitId: n,
89
89
  subUnitId: I,
90
- comment: i
90
+ comment: o
91
91
  }
92
92
  }, u = {
93
93
  id: ce.id,
94
94
  params: {
95
95
  unitId: n,
96
96
  subUnitId: I,
97
- commentId: i.id
97
+ commentId: o.id
98
98
  }
99
99
  };
100
100
  return (await se([a, d, u], s)).result;
101
101
  }
102
102
  return !1;
103
103
  }
104
- }, pe = {
104
+ }, ve = {
105
105
  id: "docs.command.delete-comment",
106
106
  type: w.COMMAND,
107
107
  async handler(e, t) {
108
108
  if (!t)
109
109
  return !1;
110
- const { commentId: r, unitId: n } = t, o = e.get(M), i = He(e, {
110
+ const { commentId: r, unitId: n } = t, i = e.get(M), o = He(e, {
111
111
  id: r,
112
112
  unitId: n
113
113
  });
114
- return i ? (await se([i], o)).result : !1;
114
+ return o ? (await se([o], i)).result : !1;
115
115
  }
116
116
  }, ge = (e) => {
117
- const t = e.get(L), r = e.get(H), n = t.getCurrent(), o = n == null ? void 0 : n.with(Ve).getSkeleton(), i = o == null ? void 0 : o.getViewModel().getEditArea();
118
- if (i === te.FOOTER || i === te.HEADER)
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();
118
+ if (o === te.FOOTER || o === te.HEADER)
119
119
  return !0;
120
120
  const s = r.getActiveTextRange();
121
121
  return !!(s == null || s.collapsed);
@@ -149,9 +149,9 @@ function ht(e) {
149
149
  };
150
150
  }
151
151
  const y = () => {
152
- const e = U(F), t = U(de), r = Z(() => e.getCurrentTypeOfUnit$(S.UNIVER_DOC), [e]), n = G(r), o = Z(() => new fe((m) => m.next(I)), []), i = U(H), s = Z(
153
- () => i.textSelection$.pipe(he(16)),
154
- [i.textSelection$]
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)),
154
+ [o.textSelection$]
155
155
  );
156
156
  G(s);
157
157
  const d = U(M), a = U(R), u = G(a.addingComment$), [c, h] = nt([]);
@@ -182,7 +182,7 @@ const y = () => {
182
182
  Ae,
183
183
  {
184
184
  unitId: _,
185
- subUnitId$: o,
185
+ subUnitId$: i,
186
186
  type: S.UNIVER_DOC,
187
187
  onAdd: () => {
188
188
  d.executeCommand(q.id);
@@ -197,7 +197,7 @@ const y = () => {
197
197
  range: u,
198
198
  comment: m
199
199
  };
200
- return d.executeCommand(ve.id, l), a.endAdd(), !1;
200
+ return d.executeCommand(pe.id, l), a.endAdd(), !1;
201
201
  }
202
202
  return !0;
203
203
  },
@@ -207,7 +207,7 @@ const y = () => {
207
207
  unitId: _,
208
208
  commentId: m.id
209
209
  };
210
- return d.executeCommand(pe.id, l), !1;
210
+ return d.executeCommand(ve.id, l), !1;
211
211
  }
212
212
  return !0;
213
213
  },
@@ -220,9 +220,9 @@ const A = {
220
220
  id: "docs.operation.show-comment-panel",
221
221
  type: w.OPERATION,
222
222
  handler(e, t) {
223
- var o;
223
+ var i;
224
224
  const r = e.get(T), n = e.get(W);
225
- return (!r.panelVisible || ((o = n.options.children) == null ? void 0 : o.label) !== y.componentKey) && (n.open({
225
+ return (!r.panelVisible || ((i = n.options.children) == null ? void 0 : i.label) !== y.componentKey) && (n.open({
226
226
  header: { title: "threadCommentUI.panel.title" },
227
227
  children: { label: y.componentKey },
228
228
  width: 320,
@@ -247,10 +247,10 @@ const A = {
247
247
  type: w.OPERATION,
248
248
  handler(e) {
249
249
  var f, O, P;
250
- const t = e.get(T), n = e.get(F).getCurrentUnitForType(S.UNIVER_DOC), o = e.get(H), i = e.get(L), s = e.get(Te), d = e.get(R), a = e.get(M), u = e.get(W), c = o.getActiveTextRange();
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();
251
251
  if (!n || !c)
252
252
  return !1;
253
- const h = (f = i.getRenderById(n.getUnitId())) == null ? void 0 : f.with(We);
253
+ const h = (f = o.getRenderById(n.getUnitId())) == null ? void 0 : f.with(We);
254
254
  if (c.collapsed)
255
255
  return t.panelVisible ? (t.setPanelVisible(!1), u.close()) : a.executeCommand(A.id), !0;
256
256
  a.executeCommand(A.id);
@@ -277,20 +277,20 @@ const A = {
277
277
  }), !0;
278
278
  }
279
279
  };
280
- var Ct = Object.defineProperty, _t = Object.getOwnPropertyDescriptor, vt = (e, t, r, n) => {
281
- for (var o = n > 1 ? void 0 : n ? _t(t, r) : t, i = e.length - 1, s; i >= 0; i--)
282
- (s = e[i]) && (o = (n ? s(t, r, o) : s(o)) || o);
283
- return n && o && Ct(t, r, o), o;
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--)
282
+ (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
283
+ return n && i && Ct(t, r, i), i;
284
284
  }, x = (e, t) => (r, n) => t(r, n, e);
285
285
  let $ = class extends B {
286
- constructor(e, t, r, n, o, i) {
287
- super(), this._threadCommentPanelService = e, this._univerInstanceService = t, this._commandService = r, this._docThreadCommentService = n, this._renderManagerService = o, this._threadCommentModel = i, this._initSelectionChange(), this._initActiveCommandChange();
286
+ constructor(e, t, r, n, i, o) {
287
+ super(), this._threadCommentPanelService = e, this._univerInstanceService = t, this._commandService = r, this._docThreadCommentService = n, this._renderManagerService = i, this._threadCommentModel = o, this._initSelectionChange(), this._initActiveCommandChange();
288
288
  }
289
289
  _initSelectionChange() {
290
290
  let e;
291
291
  this.disposeWithMe(
292
292
  this._commandService.onCommandExecuted((t) => {
293
- var r, n, o, i;
293
+ var r, n, i, o;
294
294
  if (t.id === je.id) {
295
295
  const s = t.params, { unitId: d, ranges: a } = s, u = this._univerInstanceService.getUnit(d, S.UNIVER_DOC), c = a[0];
296
296
  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))
@@ -298,7 +298,7 @@ let $ = class extends B {
298
298
  if (e = c, c && u) {
299
299
  const { startOffset: h, endOffset: C, collapsed: _ } = c;
300
300
  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 = (i = (o = u.getBody()) == null ? void 0 : o.customDecorations) == null ? void 0 : i.find((l) => l.startIndex <= h && l.endIndex >= C - 1), 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) {
302
302
  const l = this._threadCommentModel.getComment(d, I, m.id);
303
303
  l && !l.resolved && this._commandService.executeCommand(A.id, {
304
304
  activeComment: {
@@ -319,11 +319,11 @@ let $ = class extends B {
319
319
  }
320
320
  _initActiveCommandChange() {
321
321
  this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((e) => {
322
- var t, r, n, o;
322
+ var t, r, n, i;
323
323
  if (e) {
324
- const i = this._univerInstanceService.getUnit(e.unitId);
325
- if (i) {
326
- const s = (t = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : t.with(qe), d = (n = (r = i.getBody()) == null ? void 0 : r.customDecorations) == null ? void 0 : n.find((a) => a.id === e.commentId);
324
+ const o = this._univerInstanceService.getUnit(e.unitId);
325
+ 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);
327
327
  d && s && s.scrollToRange({
328
328
  startOffset: d.startIndex,
329
329
  endOffset: d.endIndex,
@@ -331,55 +331,55 @@ let $ = class extends B {
331
331
  });
332
332
  }
333
333
  }
334
- (!e || e.commentId !== ((o = this._docThreadCommentService.addingComment) == null ? void 0 : o.id)) && this._docThreadCommentService.endAdd();
334
+ (!e || e.commentId !== ((i = this._docThreadCommentService.addingComment) == null ? void 0 : i.id)) && this._docThreadCommentService.endAdd();
335
335
  }));
336
336
  }
337
337
  };
338
- $ = vt([
339
- x(0, p(T)),
338
+ $ = pt([
339
+ x(0, v(T)),
340
340
  x(1, F),
341
341
  x(2, M),
342
- x(3, p(R)),
342
+ x(3, v(R)),
343
343
  x(4, L),
344
- x(5, p(me))
344
+ x(5, v(me))
345
345
  ], $);
346
- var v = function() {
347
- return v = Object.assign || function(e) {
346
+ var p = function() {
347
+ return p = Object.assign || function(e) {
348
348
  for (var t, r = 1, n = arguments.length; r < n; r++) {
349
349
  t = arguments[r];
350
- for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
350
+ for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
351
351
  }
352
352
  return e;
353
- }, v.apply(this, arguments);
354
- }, pt = function(e, t) {
353
+ }, p.apply(this, arguments);
354
+ }, vt = function(e, t) {
355
355
  var r = {};
356
356
  for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
357
357
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
358
- for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
359
- t.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (r[n[o]] = e[n[o]]);
358
+ for (var i = 0, n = Object.getOwnPropertySymbols(e); i < n.length; i++)
359
+ t.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[i]) && (r[n[i]] = e[n[i]]);
360
360
  return r;
361
361
  }, Ie = Ce(function(e, t) {
362
- var r = e.icon, n = e.id, o = e.className, i = e.extend, s = pt(e, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), a = ot("_".concat(St()));
363
- return Se(r, "".concat(n), { defIds: r.defIds, idSuffix: a.current }, v({ ref: t, className: d }, s), i);
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
364
  });
365
- function Se(e, t, r, n, o) {
366
- return _e(e.tag, v(v({ key: t }, gt(e, r, o)), n), (It(e, r).children || []).map(function(i, s) {
367
- return Se(i, "".concat(t, "-").concat(e.tag, "-").concat(s), r, void 0, o);
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
368
  }));
369
369
  }
370
370
  function gt(e, t, r) {
371
- var n = v({}, e.attrs);
371
+ var n = p({}, e.attrs);
372
372
  r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1);
373
- var o = t.defIds;
374
- return !o || o.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(i) {
375
- var s = i[0], d = i[1];
373
+ var i = t.defIds;
374
+ 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) {
375
+ var s = o[0], d = o[1];
376
376
  typeof d == "string" && (n[s] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
377
377
  })), n;
378
378
  }
379
379
  function It(e, t) {
380
380
  var r, n = t.defIds;
381
- return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? v(v({}, e), { children: e.children.map(function(o) {
382
- return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ? v(v({}, o), { attrs: v(v({}, o.attrs), { id: o.attrs.id + t.idSuffix }) }) : o;
381
+ 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
+ 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
383
  }) }) : e;
384
384
  }
385
385
  function St() {
@@ -411,9 +411,9 @@ const Mt = {
411
411
  }
412
412
  };
413
413
  var bt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, Dt = (e, t, r, n) => {
414
- for (var o = n > 1 ? void 0 : n ? xt(t, r) : t, i = e.length - 1, s; i >= 0; i--)
415
- (s = e[i]) && (o = (n ? s(t, r, o) : s(o)) || o);
416
- return n && o && bt(t, r, o), o;
414
+ for (var i = n > 1 ? void 0 : n ? xt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
415
+ (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
416
+ return n && i && bt(t, r, i), i;
417
417
  }, Y = (e, t) => (r, n) => t(r, n, e);
418
418
  let V = class extends B {
419
419
  constructor(e, t, r) {
@@ -421,8 +421,8 @@ let V = class extends B {
421
421
  }
422
422
  _initCommands() {
423
423
  [
424
- ve,
425
424
  pe,
425
+ ve,
426
426
  A,
427
427
  q,
428
428
  ee
@@ -442,16 +442,16 @@ let V = class extends B {
442
442
  V = Dt([
443
443
  Y(0, M),
444
444
  Y(1, ke),
445
- Y(2, p(Xe))
445
+ Y(2, v(Xe))
446
446
  ], V);
447
447
  var Rt = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, Tt = (e, t, r, n) => {
448
- for (var o = n > 1 ? void 0 : n ? yt(t, r) : t, i = e.length - 1, s; i >= 0; i--)
449
- (s = e[i]) && (o = (n ? s(t, r, o) : s(o)) || o);
450
- return n && o && Rt(t, r, o), o;
448
+ for (var i = n > 1 ? void 0 : n ? yt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
449
+ (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
450
+ return n && i && Rt(t, r, i), i;
451
451
  }, D = (e, t) => (r, n) => t(r, n, e);
452
452
  let k = class extends B {
453
- constructor(e, t, r, n, o, i, s) {
454
- super(), this._context = e, this._docInterceptorService = t, this._threadCommentPanelService = r, this._docRenderController = n, this._univerInstanceService = o, this._threadCommentModel = i, this._commandService = s, this._interceptorViewModel(), this._initReRender(), this._initSyncComments();
453
+ constructor(e, t, r, n, i, o, s) {
454
+ 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();
455
455
  }
456
456
  _initReRender() {
457
457
  this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((e) => {
@@ -471,13 +471,13 @@ let k = class extends B {
471
471
  handler: (e, t, r) => {
472
472
  if (!e)
473
473
  return r(e);
474
- const { unitId: n, index: o, customDecorations: i } = t, s = this._threadCommentPanelService.activeCommentId, { commentId: d, unitId: a } = s || {}, u = i.find((_) => _.id === d), c = this._threadCommentModel.getComment(n, I, e.id);
474
+ const { unitId: n, index: i, customDecorations: o } = t, s = this._threadCommentPanelService.activeCommentId, { commentId: d, unitId: a } = s || {}, u = o.find((_) => _.id === d), c = this._threadCommentModel.getComment(n, I, e.id);
475
475
  if (!c)
476
476
  return r({
477
477
  ...e,
478
478
  show: !1
479
479
  });
480
- const h = u && o >= u.startIndex && o <= u.endIndex, C = a === n && e.id === d;
480
+ const h = u && i >= u.startIndex && i <= u.endIndex, C = a === n && e.id === d;
481
481
  return r({
482
482
  ...e,
483
483
  active: C || h,
@@ -487,8 +487,8 @@ let k = class extends B {
487
487
  });
488
488
  }
489
489
  _initSyncComments() {
490
- var o, i, s;
491
- const e = this._context.unit.getUnitId(), t = I, r = (s = (i = (o = this._context.unit.getBody()) == null ? void 0 : o.customDecorations) == null ? void 0 : i.filter((d) => d.type === X.COMMENT).map((d) => d.id)) != null ? s : [];
490
+ var i, o, s;
491
+ const e = this._context.unit.getUnitId(), t = I, r = (s = (o = (i = this._context.unit.getBody()) == null ? void 0 : i.customDecorations) == null ? void 0 : o.filter((d) => d.type === X.COMMENT).map((d) => d.id)) != null ? s : [];
492
492
  r.forEach((d) => {
493
493
  this._threadCommentModel.getComment(e, t, d) || this._threadCommentModel.addComment(e, t, { id: d, threadId: d, ref: "", dT: "", personId: "", text: { dataStream: "" }, unitId: e, subUnitId: t });
494
494
  }), r.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), I, r);
@@ -514,27 +514,27 @@ let k = class extends B {
514
514
  }
515
515
  };
516
516
  k = Tt([
517
- D(1, p(Be)),
518
- D(2, p(T)),
519
- D(3, p(Je)),
517
+ D(1, v(Be)),
518
+ D(2, v(T)),
519
+ D(3, v(Je)),
520
520
  D(4, F),
521
- D(5, p(me)),
521
+ D(5, v(me)),
522
522
  D(6, M)
523
523
  ], k);
524
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 o = n > 1 ? void 0 : n ? Pt(t, r) : t, i = e.length - 1, s; i >= 0; i--)
526
- (s = e[i]) && (o = (n ? s(t, r, o) : s(o)) || o);
527
- return n && o && Me(t, r, o), o;
525
+ for (var i = n > 1 ? void 0 : n ? Pt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
526
+ (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
527
+ return n && i && Me(t, r, i), i;
528
528
  }, Q = (e, t) => (r, n) => t(r, n, e), be = (e, t, r) => Ut(e, typeof t != "symbol" ? t + "" : t, r);
529
529
  let j = class extends Ee {
530
530
  constructor(e = ne, t, r, n) {
531
531
  super(), this._config = e, this._injector = t, this._renderManagerSrv = r, this._configService = n;
532
- const { menu: o, ...i } = we(
532
+ const { menu: i, ...o } = we(
533
533
  {},
534
534
  ne,
535
535
  this._config
536
536
  );
537
- o && this._configService.setConfig("menu", o, { merge: !0 }), this._configService.setConfig(st, i);
537
+ i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig(st, o);
538
538
  }
539
539
  onStarting() {
540
540
  [
@@ -554,17 +554,17 @@ let j = class extends Ee {
554
554
  });
555
555
  }
556
556
  };
557
- be(j, "pluginName", it);
557
+ be(j, "pluginName", ot);
558
558
  be(j, "type", S.UNIVER_DOC);
559
559
  j = Et([
560
560
  Ue($e),
561
- Q(1, p(de)),
561
+ Q(1, v(de)),
562
562
  Q(2, L),
563
563
  Q(3, Ne)
564
564
  ], j);
565
565
  export {
566
- ve as AddDocCommentComment,
567
- pe as DeleteDocCommentComment,
566
+ pe as AddDocCommentComment,
567
+ ve as DeleteDocCommentComment,
568
568
  A as ShowCommentPanelOperation,
569
569
  q as StartAddCommentOperation,
570
570
  j as UniverDocsThreadCommentUIPlugin
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(l,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):(l=typeof globalThis<"u"?globalThis:l||self,o(l.UniverDocsThreadCommentUi={},l.UniverCore,l.UniverEngineRender,l.UniverThreadCommentUi,l.UniverDocs,l.UniverDocsUi,l.UniverThreadComment,l.UniverUi,l.rxjs,l.React))})(this,function(l,o,g,T,M,j,w,I,A,O){"use strict";var Ve=Object.defineProperty;var $e=(l,o,g)=>o in l?Ve(l,o,{enumerable:!0,configurable:!0,writable:!0,value:g}):l[o]=g;var Q=(l,o,g)=>$e(l,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,le=Object.getOwnPropertyDescriptor,ue=(e,t,r,n)=>{for(var i=n>1?void 0:n?le(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=ue([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,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={};/**
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 ve(){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,f){var c,C={},p=null,_=null;f!==void 0&&(p=""+f),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 fe(){return te||(te=1,W.exports=ve()),W.exports}var he=fe();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}},f={id:T.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:D,commentId:s.id}};return(await o.sequenceExecute([m,a,f],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(u=>u.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),f=o.useObservable(m.addingComment$),[c,C]=O.useState([]);if(O.useEffect(()=>{var E;const u=new Set,v=n==null?void 0:n.getCustomDecorations();C((E=v==null?void 0:v.map(h=>h.id).filter(h=>{const b=u.has(h);return u.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:f,onAddComment:u=>{if(!u.parentId){const v={unitId:_,range:f,comment:u};return a.executeCommand(J.id,v),m.endAdd(),!1}return!0},onDeleteComment:u=>{if(!u.parentId){const v={unitId:_,commentId:u.id};return a.executeCommand(K.id,v),!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),f=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),f.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),u=o.BuildTextUtils.transform.getPlainText(_),v=D,y="",E={unitId:p,subUnitId:v,id:y,ref:u,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:v,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,f=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&&f){const{startOffset:C,endOffset:p,collapsed:_}=c;let u;if(_?u=(n=(r=f.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(v=>v.startIndex<=C&&v.endIndex>=p-1):u=(s=(i=f.getBody())==null?void 0:i.customDecorations)==null?void 0:s.find(v=>v.startIndex<=C&&v.endIndex>=p-1),u){const v=this._threadCommentModel.getComment(a,D,u.id);v&&!v.resolved&&this._commandService.executeCommand(V.id,{activeComment:{unitId:a,subUnitId:D,commentId:u.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||{},f=s.find(_=>_.id===a),c=this._threadCommentModel.getComment(n,D,e.id);if(!c)return r({...e,show:!1});const C=f&&i>=f.startIndex&&i<=f.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,f,c;if(a.id===M.RichTextEditingMutation.id){if(a.params.unitId!==this._context.unit.getUnitId())return;const p=(c=(f=(m=this._context.unit.getBody())==null?void 0:m.customDecorations)==null?void 0:f.filter(u=>u.type===o.CustomDecorationType.COMMENT).map(u=>u.id))!=null?c:[],_=p.sort();if(JSON.stringify(n)!==JSON.stringify(_)){const u=new Set(n),v=new Set(_),y=new Set,E=new Set;p.forEach(h=>{u.has(h)||y.add(h)}),n.forEach(h=>{v.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);l.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(l.UniverDocsThreadCommentUIPlugin,"pluginName",ae),de(l.UniverDocsThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),l.UniverDocsThreadCommentUIPlugin=Ae([o.DependentOn(T.UniverThreadCommentUIPlugin),z(1,o.Inject(o.Injector)),z(2,g.IRenderManagerService),z(3,o.IConfigService)],l.UniverDocsThreadCommentUIPlugin),l.AddDocCommentComment=J,l.DeleteDocCommentComment=K,l.ShowCommentPanelOperation=V,l.StartAddCommentOperation=$,Object.defineProperty(l,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,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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-thread-comment-ui",
3
- "version": "0.5.3-nightly.202501071618",
3
+ "version": "0.5.3-nightly.202501090742",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -47,22 +47,23 @@
47
47
  "rxjs": ">=7.0.0"
48
48
  },
49
49
  "dependencies": {
50
- "@univerjs/icons": "^0.2.11",
50
+ "@univerjs/icons": "^0.2.12",
51
51
  "clsx": "^2.1.1",
52
- "@univerjs/core": "0.5.3-nightly.202501071618",
53
- "@univerjs/docs": "0.5.3-nightly.202501071618",
54
- "@univerjs/docs-ui": "0.5.3-nightly.202501071618",
55
- "@univerjs/engine-render": "0.5.3-nightly.202501071618",
56
- "@univerjs/thread-comment": "0.5.3-nightly.202501071618",
57
- "@univerjs/thread-comment-ui": "0.5.3-nightly.202501071618",
58
- "@univerjs/ui": "0.5.3-nightly.202501071618"
52
+ "@univerjs/core": "0.5.3-nightly.202501090742",
53
+ "@univerjs/docs-ui": "0.5.3-nightly.202501090742",
54
+ "@univerjs/docs": "0.5.3-nightly.202501090742",
55
+ "@univerjs/engine-render": "0.5.3-nightly.202501090742",
56
+ "@univerjs/thread-comment": "0.5.3-nightly.202501090742",
57
+ "@univerjs/thread-comment-ui": "0.5.3-nightly.202501090742",
58
+ "@univerjs/ui": "0.5.3-nightly.202501090742"
59
59
  },
60
60
  "devDependencies": {
61
61
  "postcss": "^8.4.49",
62
62
  "react": "18.3.1",
63
63
  "rxjs": "^7.8.1",
64
+ "tailwindcss": "^3.4.17",
64
65
  "typescript": "^5.7.2",
65
- "vite": "^6.0.6",
66
+ "vite": "^6.0.7",
66
67
  "vitest": "^2.1.8",
67
68
  "@univerjs-infra/shared": "0.5.3"
68
69
  },