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