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