@univerjs/docs-thread-comment-ui 0.5.1 → 0.5.2-nightly.202412281605
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 +3 -3
- package/lib/es/index.js +131 -127
- package/lib/index.css +1 -0
- package/lib/umd/index.js +3 -3
- package/package.json +12 -12
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var de=Object.defineProperty;var ae=(e,t,r)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var L=(e,t,r)=>ae(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),x=require("@univerjs/engine-render"),O=require("@univerjs/thread-comment-ui"),S=require("@univerjs/docs"),$=require("@univerjs/docs-ui"),A=require("@univerjs/thread-comment"),_=require("@univerjs/ui"),N=require("rxjs"),g=require("react"),me="DOC_THREAD_COMMENT_UI_PLUGIN",M="default_doc",le="docs-thread-comment-ui.config",Q={};var ue=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,fe=(e,t,r,n)=>{for(var o=n>1?void 0:n?Ce(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ue(t,r,o),o},X=(e,t)=>(r,n)=>t(r,n,e);let R=class extends c.Disposable{constructor(t,r){super();L(this,"_addingComment$",new N.BehaviorSubject(void 0));L(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=t,this._threadCommentPanelService=r,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(t){this._addingComment$.next(t)}endAdd(){this._addingComment$.next(void 0)}};R=fe([X(0,_.ISidebarService),X(1,c.Inject(O.ThreadCommentPanelService))],R);var W={exports:{}},w={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
10
|
-
`},startOffset:a.startOffset,endOffset:a.endOffset,collapsed:!0,threadId:b};return h==null||h.blurEditor(),d.startAdd(D),t.setActiveComment({unitId:v,subUnitId:u,commentId:b}),!0}};var ge=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,Oe=(e,t,r,n)=>{for(var o=n>1?void 0:n?Se(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ge(t,r,o),o},y=(e,t)=>(r,n)=>t(r,n,e);let q=class extends c.Disposable{constructor(e,t,r,n,o,i){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=r,this._docThreadCommentService=n,this._renderManagerService=o,this._threadCommentModel=i,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var r,n,o,i;if(t.id===S.SetTextSelectionsOperation.id){const s=t.params,{unitId:d,ranges:m}=s,C=this._univerInstanceService.getUnit(d,c.UniverInstanceType.UNIVER_DOC),a=m[0];if((e==null?void 0:e.startOffset)===(a==null?void 0:a.startOffset)&&(e==null?void 0:e.endOffset)===(a==null?void 0:a.endOffset))return;if(e=a,a&&C){const{startOffset:h,endOffset:v,collapsed:p}=a;let l;if(p?l=(n=(r=C.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(u=>u.startIndex<=h&&u.endIndex>=v-1):l=(i=(o=C.getBody())==null?void 0:o.customDecorations)==null?void 0:i.find(u=>u.startIndex<=h&&u.endIndex>=v-1),l){const u=this._threadCommentModel.getComment(d,M,l.id);u&&!u.resolved&&this._commandService.executeCommand(j.id,{activeComment:{unitId:d,subUnitId:M,commentId:l.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,r,n,o;if(e){const i=this._univerInstanceService.getUnit(e.unitId);if(i){const s=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with($.DocBackScrollRenderController),d=(n=(r=i.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(m=>m.id===e.commentId);d&&s&&s.scrollToRange({startOffset:d.startIndex,endOffset:d.endIndex,collapsed:!1})}}(!e||e.commentId!==((o=this._docThreadCommentService.addingComment)==null?void 0:o.id))&&this._docThreadCommentService.endAdd()}))}};q=Oe([y(0,c.Inject(O.ThreadCommentPanelService)),y(1,c.IUniverInstanceService),y(2,c.ICommandService),y(3,c.Inject(R)),y(4,x.IRenderManagerService),y(5,c.Inject(A.ThreadCommentModel))],q);var I=function(){return I=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},I.apply(this,arguments)},be=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r},te=g.forwardRef(function(e,t){var r=e.icon,n=e.id,o=e.className,i=e.extend,s=be(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),m=g.useRef("_".concat(De()));return ne(r,"".concat(n),{defIds:r.defIds,idSuffix:m.current},I({ref:t,className:d},s),i)});function ne(e,t,r,n,o){return g.createElement(e.tag,I(I({key:t},Me(e,r,o)),n),(Te(e,r).children||[]).map(function(i,s){return ne(i,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,o)}))}function Me(e,t,r){var n=I({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Te(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?I(I({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?I(I({},o),{attrs:I(I({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function De(){return Math.random().toString(36).substring(2,8)}te.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"}}]},re=g.forwardRef(function(e,t){return g.createElement(te,Object.assign({},e,{id:"comment-single",ref:t,icon:ye}))});re.displayName="CommentSingle";const Ue={[_.RibbonStartGroup.OTHERS]:{[Y.id]:{order:1,menuItemFactory:Ie}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.DATA]:{[V.id]:{order:1,menuItemFactory:_e}}}};var xe=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Pe=(e,t,r,n)=>{for(var o=n>1?void 0:n?Re(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&xe(t,r,o),o},J=(e,t)=>(r,n)=>t(r,n,e);let F=class extends c.Disposable{constructor(e,t,r){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[Z,z,j,V,Y].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Ue)}_initComponents(){[P].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",re))}};F=Pe([J(0,c.ICommandService),J(1,_.IMenuManagerService),J(2,c.Inject(_.ComponentManager))],F);var Ee=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ae=(e,t,r,n)=>{for(var o=n>1?void 0:n?we(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Ee(t,r,o),o},U=(e,t)=>(r,n)=>t(r,n,e);let G=class extends c.Disposable{constructor(e,t,r,n,o,i,s){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=r,this._docRenderController=n,this._univerInstanceService=o,this._threadCommentModel=i,this._commandService=s,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var r;if(e){this._docRenderController.reRender(e.unitId);return}const t=(r=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(S.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,r)=>{if(!e)return r(e);const{unitId:n,index:o,customDecorations:i}=t,s=this._threadCommentPanelService.activeCommentId,{commentId:d,unitId:m}=s||{},C=i.find(p=>p.id===d),a=this._threadCommentModel.getComment(n,M,e.id);if(!a)return r({...e,show:!1});const h=C&&o>=C.startIndex&&o<=C.endIndex,v=m===n&&e.id===d;return r({...e,active:v||h,show:!a.resolved})}})}_initSyncComments(){var o,i,s;const e=this._context.unit.getUnitId(),t=M,r=(s=(i=(o=this._context.unit.getBody())==null?void 0:o.customDecorations)==null?void 0:i.filter(d=>d.type===c.CustomDecorationType.COMMENT).map(d=>d.id))!=null?s:[];r.forEach(d=>{this._threadCommentModel.getComment(e,t,d)||this._threadCommentModel.addComment(e,t,{id:d,threadId:d,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),M,r);let n=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(d=>{var m,C,a;if(d.id===S.RichTextEditingMutation.id){if(d.params.unitId!==this._context.unit.getUnitId())return;const v=(a=(C=(m=this._context.unit.getBody())==null?void 0:m.customDecorations)==null?void 0:C.filter(l=>l.type===c.CustomDecorationType.COMMENT).map(l=>l.id))!=null?a:[],p=v.sort();if(JSON.stringify(n)!==JSON.stringify(p)){const l=new Set(n),u=new Set(p),b=new Set,D=new Set;v.forEach(f=>{l.has(f)||b.add(f)}),n.forEach(f=>{u.has(f)||D.add(f)}),n=p,b.forEach(f=>{this._threadCommentModel.getComment(e,t,f)||this._threadCommentModel.addComment(e,t,{id:f,threadId:f,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...b])}}}))}};G=Ae([U(1,c.Inject(S.DocInterceptorService)),U(2,c.Inject(O.ThreadCommentPanelService)),U(3,c.Inject($.DocRenderController)),U(4,c.IUniverInstanceService),U(5,c.Inject(A.ThreadCommentModel)),U(6,c.ICommandService)],G);var 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 o=n>1?void 0:n?Ne(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&oe(t,r,o),o},K=(e,t)=>(r,n)=>t(r,n,e),ie=(e,t,r)=>je(e,typeof t!="symbol"?t+"":t,r);exports.UniverDocsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=le,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(me,s)}onStarting(){[[F],[q],[R]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(q),this._injector.get(F)}_initRenderModule(){[G].forEach(t=>{this._renderManagerSrv.registerRenderModule(c.UniverInstanceType.UNIVER_DOC,t)})}};ie(exports.UniverDocsThreadCommentUIPlugin,"pluginName",ae);ie(exports.UniverDocsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_DOC);exports.UniverDocsThreadCommentUIPlugin=$e([c.DependentOn(O.UniverThreadCommentUIPlugin),K(1,c.Inject(c.Injector)),K(2,x.IRenderManagerService),K(3,c.IConfigService)],exports.UniverDocsThreadCommentUIPlugin);exports.AddDocCommentComment=Z;exports.DeleteDocCommentComment=z;exports.ShowCommentPanelOperation=j;exports.StartAddCommentOperation=V;
|
|
9
|
+
*/var k;function he(){if(k)return w;k=1;var e=g,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(d,m,C){var a,h={},v=null,p=null;C!==void 0&&(v=""+C),m.key!==void 0&&(v=""+m.key),m.ref!==void 0&&(p=m.ref);for(a in m)n.call(m,a)&&!i.hasOwnProperty(a)&&(h[a]=m[a]);if(d&&d.defaultProps)for(a in m=d.defaultProps,m)h[a]===void 0&&(h[a]=m[a]);return{$$typeof:t,type:d,key:v,ref:p,props:h,_owner:o.current}}return w.Fragment=r,w.jsx=s,w.jsxs=s,w}var ee;function ve(){return ee||(ee=1,W.exports=he()),W.exports}var pe=ve();const Z={id:"docs.command.add-comment",type:c.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{comment:r,unitId:n}=t,i=await e.get(A.IThreadCommentDataSourceService).addComment(r),s=e.get(c.ICommandService),d=$.addCustomDecorationBySelectionFactory(e,{id:i.threadId,type:c.CustomDecorationType.COMMENT});if(d){const m={id:A.AddCommentMutation.id,params:{unitId:n,subUnitId:M,comment:i}},C={id:O.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:M,commentId:i.id}};return(await c.sequenceExecute([m,d,C],s)).result}return!1}},z={id:"docs.command.delete-comment",type:c.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:r,unitId:n}=t,o=e.get(c.ICommandService),i=$.deleteCustomDecorationFactory(e,{id:r,unitId:n});return i?(await c.sequenceExecute([i],o)).result:!1}},te=e=>{const t=e.get(x.IRenderManagerService),r=e.get(S.DocSelectionManagerService),n=t.getCurrent(),o=n==null?void 0:n.with(S.DocSkeletonManagerService).getSkeleton(),i=o==null?void 0:o.getViewModel().getEditArea();if(i===x.DocumentEditArea.FOOTER||i===x.DocumentEditArea.HEADER)return!0;const s=r.getActiveTextRange();return!!(s==null||s.collapsed)};function _e(e){return{id:V.id,type:_.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:_.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_DOC,void 0,c.SHEET_EDITOR_UNITS),disabled$:new N.Observable(function(t){const n=e.get(S.DocSelectionManagerService).textSelection$.pipe(N.debounceTime(16)).subscribe(()=>{t.next(te(e))});return()=>{n.unsubscribe()}})}}function Ie(e){return{id:Y.id,type:_.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:_.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_DOC)}}const P=()=>{const e=c.useDependency(c.IUniverInstanceService),t=c.useDependency(c.Injector),r=g.useMemo(()=>e.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_DOC),[e]),n=c.useObservable(r),o=g.useMemo(()=>new N.Observable(l=>l.next(M)),[]),i=c.useDependency(S.DocSelectionManagerService),s=g.useMemo(()=>i.textSelection$.pipe(N.debounceTime(16)),[i.textSelection$]);c.useObservable(s);const d=c.useDependency(c.ICommandService),m=c.useDependency(R),C=c.useObservable(m.addingComment$),[a,h]=g.useState([]);if(g.useEffect(()=>{var D;const l=new Set,u=n==null?void 0:n.getCustomDecorations();h((D=u==null?void 0:u.map(f=>f.id).filter(f=>{const T=l.has(f);return l.add(f),!T}))!=null?D:[]);const b=d.onCommandExecuted(f=>{var T;if(f.id===S.RichTextEditingMutation.id){const E=new Set,H=n==null?void 0:n.getCustomDecorations();h((T=H==null?void 0:H.map(B=>B.id).filter(B=>{const se=E.has(B);return E.add(B),!se}))!=null?T:[])}});return()=>{b.dispose()}},[d,n]),!n)return null;const v=te(t),p=n.getUnitId();return pe.jsx(O.ThreadCommentPanel,{unitId:p,subUnitId$:o,type:c.UniverInstanceType.UNIVER_DOC,onAdd:()=>{d.executeCommand(V.id)},getSubUnitName:()=>"",disableAdd:v,tempComment:C,onAddComment:l=>{if(!l.parentId){const u={unitId:p,range:C,comment:l};return d.executeCommand(Z.id,u),m.endAdd(),!1}return!0},onDeleteComment:l=>{if(!l.parentId){const u={unitId:p,commentId:l.id};return d.executeCommand(z.id,u),!1}return!0},showComments:a})};P.componentKey="univer.doc.thread-comment-panel";const j={id:"docs.operation.show-comment-panel",type:c.CommandType.OPERATION,handler(e,t){var o;const r=e.get(O.ThreadCommentPanelService),n=e.get(_.ISidebarService);return(!r.panelVisible||((o=n.options.children)==null?void 0:o.label)!==P.componentKey)&&(n.open({header:{title:"threadCommentUI.panel.title"},children:{label:P.componentKey},width:320,onClose:()=>r.setPanelVisible(!1)}),r.setPanelVisible(!0)),t&&r.setActiveComment(t==null?void 0:t.activeComment),!0}},Y={id:"docs.operation.toggle-comment-panel",type:c.CommandType.OPERATION,handler(e){var n;const t=e.get(O.ThreadCommentPanelService),r=e.get(_.ISidebarService);return!t.panelVisible||((n=r.options.children)==null?void 0:n.label)!==P.componentKey?(r.open({header:{title:"threadCommentUI.panel.title"},children:{label:P.componentKey},width:320,onClose:()=>t.setPanelVisible(!1)}),t.setPanelVisible(!0)):(r.close(),t.setPanelVisible(!1),t.setActiveComment(null)),!0}},V={id:"docs.operation.start-add-comment",type:c.CommandType.OPERATION,handler(e){var f,T,E;const t=e.get(O.ThreadCommentPanelService),n=e.get(c.IUniverInstanceService).getCurrentUnitForType(c.UniverInstanceType.UNIVER_DOC),o=e.get(S.DocSelectionManagerService),i=e.get(x.IRenderManagerService),s=e.get(c.UserManagerService),d=e.get(R),m=e.get(c.ICommandService),C=e.get(_.ISidebarService),a=o.getActiveTextRange();if(!n||!a)return!1;const h=(f=i.getRenderById(n.getUnitId()))==null?void 0:f.with($.DocSelectionRenderService);if(a.collapsed)return t.panelVisible?(t.setPanelVisible(!1),C.close()):m.executeCommand(j.id),!0;m.executeCommand(j.id);const v=n.getUnitId(),p=((E=(T=n.getBody())==null?void 0:T.dataStream)!=null?E:"").slice(a.startOffset,a.endOffset),l=c.BuildTextUtils.transform.getPlainText(p),u=M,b="",D={unitId:v,subUnitId:u,id:b,ref:l,dT:A.getDT(),personId:s.getCurrentUser().userID,text:{dataStream:`\r
|
|
10
|
+
`},startOffset:a.startOffset,endOffset:a.endOffset,collapsed:!0,threadId:b};return h==null||h.blurEditor(),d.startAdd(D),t.setActiveComment({unitId:v,subUnitId:u,commentId:b}),!0}};var ge=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,Oe=(e,t,r,n)=>{for(var o=n>1?void 0:n?Se(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ge(t,r,o),o},y=(e,t)=>(r,n)=>t(r,n,e);let q=class extends c.Disposable{constructor(e,t,r,n,o,i){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=r,this._docThreadCommentService=n,this._renderManagerService=o,this._threadCommentModel=i,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var r,n,o,i;if(t.id===S.SetTextSelectionsOperation.id){const s=t.params,{unitId:d,ranges:m}=s,C=this._univerInstanceService.getUnit(d,c.UniverInstanceType.UNIVER_DOC),a=m[0];if((e==null?void 0:e.startOffset)===(a==null?void 0:a.startOffset)&&(e==null?void 0:e.endOffset)===(a==null?void 0:a.endOffset))return;if(e=a,a&&C){const{startOffset:h,endOffset:v,collapsed:p}=a;let l;if(p?l=(n=(r=C.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(u=>u.startIndex<=h&&u.endIndex>=v-1):l=(i=(o=C.getBody())==null?void 0:o.customDecorations)==null?void 0:i.find(u=>u.startIndex<=h&&u.endIndex>=v-1),l){const u=this._threadCommentModel.getComment(d,M,l.id);u&&!u.resolved&&this._commandService.executeCommand(j.id,{activeComment:{unitId:d,subUnitId:M,commentId:l.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,r,n,o;if(e){const i=this._univerInstanceService.getUnit(e.unitId);if(i){const s=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with($.DocBackScrollRenderController),d=(n=(r=i.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(m=>m.id===e.commentId);d&&s&&s.scrollToRange({startOffset:d.startIndex,endOffset:d.endIndex,collapsed:!1})}}(!e||e.commentId!==((o=this._docThreadCommentService.addingComment)==null?void 0:o.id))&&this._docThreadCommentService.endAdd()}))}};q=Oe([y(0,c.Inject(O.ThreadCommentPanelService)),y(1,c.IUniverInstanceService),y(2,c.ICommandService),y(3,c.Inject(R)),y(4,x.IRenderManagerService),y(5,c.Inject(A.ThreadCommentModel))],q);var I=function(){return I=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},I.apply(this,arguments)},be=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r},ne=g.forwardRef(function(e,t){var r=e.icon,n=e.id,o=e.className,i=e.extend,s=be(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),m=g.useRef("_".concat(De()));return re(r,"".concat(n),{defIds:r.defIds,idSuffix:m.current},I({ref:t,className:d},s),i)});function re(e,t,r,n,o){return g.createElement(e.tag,I(I({key:t},Me(e,r,o)),n),(Te(e,r).children||[]).map(function(i,s){return re(i,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,o)}))}function Me(e,t,r){var n=I({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Te(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?I(I({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?I(I({},o),{attrs:I(I({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function De(){return Math.random().toString(36).substring(2,8)}ne.displayName="UniverIcon";var ye={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},oe=g.forwardRef(function(e,t){return g.createElement(ne,Object.assign({},e,{id:"comment-single",ref:t,icon:ye}))});oe.displayName="CommentSingle";const Ue={[_.RibbonStartGroup.OTHERS]:{[Y.id]:{order:1,menuItemFactory:Ie}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.DATA]:{[V.id]:{order:1,menuItemFactory:_e}}}};var xe=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Pe=(e,t,r,n)=>{for(var o=n>1?void 0:n?Re(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&xe(t,r,o),o},J=(e,t)=>(r,n)=>t(r,n,e);let F=class extends c.Disposable{constructor(e,t,r){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[Z,z,j,V,Y].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Ue)}_initComponents(){[P].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",oe))}};F=Pe([J(0,c.ICommandService),J(1,_.IMenuManagerService),J(2,c.Inject(_.ComponentManager))],F);var Ee=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ae=(e,t,r,n)=>{for(var o=n>1?void 0:n?we(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&Ee(t,r,o),o},U=(e,t)=>(r,n)=>t(r,n,e);let G=class extends c.Disposable{constructor(e,t,r,n,o,i,s){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=r,this._docRenderController=n,this._univerInstanceService=o,this._threadCommentModel=i,this._commandService=s,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var r;if(e){this._docRenderController.reRender(e.unitId);return}const t=(r=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(S.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,r)=>{if(!e)return r(e);const{unitId:n,index:o,customDecorations:i}=t,s=this._threadCommentPanelService.activeCommentId,{commentId:d,unitId:m}=s||{},C=i.find(p=>p.id===d),a=this._threadCommentModel.getComment(n,M,e.id);if(!a)return r({...e,show:!1});const h=C&&o>=C.startIndex&&o<=C.endIndex,v=m===n&&e.id===d;return r({...e,active:v||h,show:!a.resolved})}})}_initSyncComments(){var o,i,s;const e=this._context.unit.getUnitId(),t=M,r=(s=(i=(o=this._context.unit.getBody())==null?void 0:o.customDecorations)==null?void 0:i.filter(d=>d.type===c.CustomDecorationType.COMMENT).map(d=>d.id))!=null?s:[];r.forEach(d=>{this._threadCommentModel.getComment(e,t,d)||this._threadCommentModel.addComment(e,t,{id:d,threadId:d,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),M,r);let n=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(d=>{var m,C,a;if(d.id===S.RichTextEditingMutation.id){if(d.params.unitId!==this._context.unit.getUnitId())return;const v=(a=(C=(m=this._context.unit.getBody())==null?void 0:m.customDecorations)==null?void 0:C.filter(l=>l.type===c.CustomDecorationType.COMMENT).map(l=>l.id))!=null?a:[],p=v.sort();if(JSON.stringify(n)!==JSON.stringify(p)){const l=new Set(n),u=new Set(p),b=new Set,D=new Set;v.forEach(f=>{l.has(f)||b.add(f)}),n.forEach(f=>{u.has(f)||D.add(f)}),n=p,b.forEach(f=>{this._threadCommentModel.getComment(e,t,f)||this._threadCommentModel.addComment(e,t,{id:f,threadId:f,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...b])}}}))}};G=Ae([U(1,c.Inject(S.DocInterceptorService)),U(2,c.Inject(O.ThreadCommentPanelService)),U(3,c.Inject($.DocRenderController)),U(4,c.IUniverInstanceService),U(5,c.Inject(A.ThreadCommentModel)),U(6,c.ICommandService)],G);var ie=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,je=(e,t,r)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$e=(e,t,r,n)=>{for(var o=n>1?void 0:n?Ne(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(o))||o);return n&&o&&ie(t,r,o),o},K=(e,t)=>(r,n)=>t(r,n,e),ce=(e,t,r)=>je(e,typeof t!="symbol"?t+"":t,r);exports.UniverDocsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=Q,r,n,o){super(),this._config=t,this._injector=r,this._renderManagerSrv=n,this._configService=o;const{menu:i,...s}=c.merge({},Q,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(le,s)}onStarting(){[[F],[q],[R]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(q),this._injector.get(F)}_initRenderModule(){[G].forEach(t=>{this._renderManagerSrv.registerRenderModule(c.UniverInstanceType.UNIVER_DOC,t)})}};ce(exports.UniverDocsThreadCommentUIPlugin,"pluginName",me);ce(exports.UniverDocsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_DOC);exports.UniverDocsThreadCommentUIPlugin=$e([c.DependentOn(O.UniverThreadCommentUIPlugin),K(1,c.Inject(c.Injector)),K(2,x.IRenderManagerService),K(3,c.IConfigService)],exports.UniverDocsThreadCommentUIPlugin);exports.AddDocCommentComment=Z;exports.DeleteDocCommentComment=z;exports.ShowCommentPanelOperation=j;exports.StartAddCommentOperation=V;
|
package/lib/es/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var K = (e, t, r) =>
|
|
4
|
-
import { Inject as p, Disposable as B, CommandType as w, ICommandService as M, CustomDecorationType as X, sequenceExecute as
|
|
1
|
+
var De = Object.defineProperty;
|
|
2
|
+
var Re = (e, t, r) => t in e ? De(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var K = (e, t, r) => Re(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { Inject as p, Disposable as B, CommandType as w, ICommandService as M, CustomDecorationType as X, sequenceExecute as se, UniverInstanceType as S, SHEET_EDITOR_UNITS as ye, useDependency as U, IUniverInstanceService as F, Injector as de, useObservable as G, UserManagerService as Te, BuildTextUtils as Pe, DependentOn as Ue, Plugin as Ee, merge as we, IConfigService as Ne } from "@univerjs/core";
|
|
5
5
|
import { IRenderManagerService as L, DocumentEditArea as te } from "@univerjs/engine-render";
|
|
6
|
-
import { ThreadCommentPanelService as T, SetActiveCommentOperation as
|
|
7
|
-
import { DocSelectionManagerService as H, DocSkeletonManagerService as
|
|
8
|
-
import { addCustomDecorationBySelectionFactory as
|
|
9
|
-
import { IThreadCommentDataSourceService as
|
|
10
|
-
import { ISidebarService as W, MenuItemType as
|
|
11
|
-
import { BehaviorSubject as
|
|
12
|
-
import
|
|
13
|
-
const
|
|
14
|
-
var
|
|
15
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
6
|
+
import { ThreadCommentPanelService as T, SetActiveCommentOperation as ce, ThreadCommentPanel as Ae, UniverThreadCommentUIPlugin as $e } from "@univerjs/thread-comment-ui";
|
|
7
|
+
import { DocSelectionManagerService as H, DocSkeletonManagerService as Ve, RichTextEditingMutation as ae, SetTextSelectionsOperation as je, DocInterceptorService as Be, DOC_INTERCEPTOR_POINT as Fe } from "@univerjs/docs";
|
|
8
|
+
import { addCustomDecorationBySelectionFactory as Le, deleteCustomDecorationFactory as He, DocSelectionRenderService as We, DocBackScrollRenderController as qe, DocRenderController as Je } from "@univerjs/docs-ui";
|
|
9
|
+
import { IThreadCommentDataSourceService as Ke, AddCommentMutation as Ge, getDT as Ze, ThreadCommentModel as me } from "@univerjs/thread-comment";
|
|
10
|
+
import { ISidebarService as W, MenuItemType as le, getMenuHiddenObservable as ue, RibbonStartGroup as ze, ContextMenuPosition as Ye, ContextMenuGroup as Qe, ComponentManager as Xe, IMenuManagerService as ke } from "@univerjs/ui";
|
|
11
|
+
import { BehaviorSubject as et, Observable as fe, debounceTime as he } from "rxjs";
|
|
12
|
+
import tt, { useMemo as Z, useState as nt, useEffect as rt, forwardRef as Ce, useRef as ot, createElement as _e } from "react";
|
|
13
|
+
const it = "DOC_THREAD_COMMENT_UI_PLUGIN", I = "default_doc", st = "docs-thread-comment-ui.config", ne = {};
|
|
14
|
+
var dt = Object.defineProperty, ct = Object.getOwnPropertyDescriptor, at = (e, t, r, n) => {
|
|
15
|
+
for (var o = n > 1 ? void 0 : n ? ct(t, r) : t, i = e.length - 1, s; i >= 0; i--)
|
|
16
16
|
(s = e[i]) && (o = (n ? s(t, r, o) : s(o)) || o);
|
|
17
|
-
return n && o &&
|
|
18
|
-
},
|
|
17
|
+
return n && o && dt(t, r, o), o;
|
|
18
|
+
}, re = (e, t) => (r, n) => t(r, n, e);
|
|
19
19
|
let R = class extends B {
|
|
20
20
|
constructor(t, r) {
|
|
21
21
|
super();
|
|
22
|
-
K(this, "_addingComment$", new
|
|
22
|
+
K(this, "_addingComment$", new et(void 0));
|
|
23
23
|
K(this, "addingComment$", this._addingComment$.asObservable());
|
|
24
24
|
this._sidebarService = t, this._threadCommentPanelService = r, this.disposeWithMe(() => {
|
|
25
25
|
this._addingComment$.complete();
|
|
@@ -35,9 +35,9 @@ let R = class extends B {
|
|
|
35
35
|
this._addingComment$.next(void 0);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
R =
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
R = at([
|
|
39
|
+
re(0, W),
|
|
40
|
+
re(1, p(T))
|
|
41
41
|
], R);
|
|
42
42
|
var z = { exports: {} }, E = {};
|
|
43
43
|
/**
|
|
@@ -49,11 +49,11 @@ var z = { exports: {} }, E = {};
|
|
|
49
49
|
* This source code is licensed under the MIT license found in the
|
|
50
50
|
* LICENSE file in the root directory of this source tree.
|
|
51
51
|
*/
|
|
52
|
-
var
|
|
53
|
-
function
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
var e =
|
|
52
|
+
var oe;
|
|
53
|
+
function mt() {
|
|
54
|
+
if (oe) return E;
|
|
55
|
+
oe = 1;
|
|
56
|
+
var e = tt, t = Symbol.for("react.element"), r = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, o = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
57
57
|
function s(d, a, u) {
|
|
58
58
|
var c, h = {}, C = null, _ = null;
|
|
59
59
|
u !== void 0 && (C = "" + u), a.key !== void 0 && (C = "" + a.key), a.ref !== void 0 && (_ = a.ref);
|
|
@@ -63,18 +63,18 @@ function at() {
|
|
|
63
63
|
}
|
|
64
64
|
return E.Fragment = r, E.jsx = s, E.jsxs = s, E;
|
|
65
65
|
}
|
|
66
|
-
var
|
|
67
|
-
function
|
|
68
|
-
return
|
|
66
|
+
var ie;
|
|
67
|
+
function lt() {
|
|
68
|
+
return ie || (ie = 1, z.exports = mt()), z.exports;
|
|
69
69
|
}
|
|
70
|
-
var
|
|
71
|
-
const
|
|
70
|
+
var ut = lt();
|
|
71
|
+
const ve = {
|
|
72
72
|
id: "docs.command.add-comment",
|
|
73
73
|
type: w.COMMAND,
|
|
74
74
|
async handler(e, t) {
|
|
75
75
|
if (!t)
|
|
76
76
|
return !1;
|
|
77
|
-
const { comment: r, unitId: n } = t, i = await e.get(
|
|
77
|
+
const { comment: r, unitId: n } = t, i = await e.get(Ke).addComment(r), s = e.get(M), d = Le(
|
|
78
78
|
e,
|
|
79
79
|
{
|
|
80
80
|
id: i.threadId,
|
|
@@ -83,54 +83,54 @@ const _e = {
|
|
|
83
83
|
);
|
|
84
84
|
if (d) {
|
|
85
85
|
const a = {
|
|
86
|
-
id:
|
|
86
|
+
id: Ge.id,
|
|
87
87
|
params: {
|
|
88
88
|
unitId: n,
|
|
89
89
|
subUnitId: I,
|
|
90
90
|
comment: i
|
|
91
91
|
}
|
|
92
92
|
}, u = {
|
|
93
|
-
id:
|
|
93
|
+
id: ce.id,
|
|
94
94
|
params: {
|
|
95
95
|
unitId: n,
|
|
96
96
|
subUnitId: I,
|
|
97
97
|
commentId: i.id
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
-
return (await
|
|
100
|
+
return (await se([a, d, u], s)).result;
|
|
101
101
|
}
|
|
102
102
|
return !1;
|
|
103
103
|
}
|
|
104
|
-
},
|
|
104
|
+
}, pe = {
|
|
105
105
|
id: "docs.command.delete-comment",
|
|
106
106
|
type: w.COMMAND,
|
|
107
107
|
async handler(e, t) {
|
|
108
108
|
if (!t)
|
|
109
109
|
return !1;
|
|
110
|
-
const { commentId: r, unitId: n } = t, o = e.get(M), i =
|
|
110
|
+
const { commentId: r, unitId: n } = t, o = e.get(M), i = He(e, {
|
|
111
111
|
id: r,
|
|
112
112
|
unitId: n
|
|
113
113
|
});
|
|
114
|
-
return i ? (await
|
|
114
|
+
return i ? (await se([i], o)).result : !1;
|
|
115
115
|
}
|
|
116
|
-
},
|
|
117
|
-
const t = e.get(L), r = e.get(H), n = t.getCurrent(), o = n == null ? void 0 : n.with(
|
|
116
|
+
}, ge = (e) => {
|
|
117
|
+
const t = e.get(L), r = e.get(H), n = t.getCurrent(), o = n == null ? void 0 : n.with(Ve).getSkeleton(), i = o == null ? void 0 : o.getViewModel().getEditArea();
|
|
118
118
|
if (i === te.FOOTER || i === te.HEADER)
|
|
119
119
|
return !0;
|
|
120
120
|
const s = r.getActiveTextRange();
|
|
121
121
|
return !!(s == null || s.collapsed);
|
|
122
122
|
};
|
|
123
|
-
function
|
|
123
|
+
function ft(e) {
|
|
124
124
|
return {
|
|
125
125
|
id: q.id,
|
|
126
|
-
type:
|
|
126
|
+
type: le.BUTTON,
|
|
127
127
|
icon: "CommentSingle",
|
|
128
128
|
title: "threadCommentUI.panel.addComment",
|
|
129
129
|
tooltip: "threadCommentUI.panel.addComment",
|
|
130
|
-
hidden$:
|
|
131
|
-
disabled$: new
|
|
132
|
-
const n = e.get(H).textSelection$.pipe(
|
|
133
|
-
t.next(
|
|
130
|
+
hidden$: ue(e, S.UNIVER_DOC, void 0, ye),
|
|
131
|
+
disabled$: new fe(function(t) {
|
|
132
|
+
const n = e.get(H).textSelection$.pipe(he(16)).subscribe(() => {
|
|
133
|
+
t.next(ge(e));
|
|
134
134
|
});
|
|
135
135
|
return () => {
|
|
136
136
|
n.unsubscribe();
|
|
@@ -138,24 +138,24 @@ function ut(e) {
|
|
|
138
138
|
})
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function ht(e) {
|
|
142
142
|
return {
|
|
143
143
|
id: ee.id,
|
|
144
|
-
type:
|
|
144
|
+
type: le.BUTTON,
|
|
145
145
|
icon: "CommentSingle",
|
|
146
146
|
title: "threadCommentUI.panel.addComment",
|
|
147
147
|
tooltip: "threadCommentUI.panel.addComment",
|
|
148
|
-
hidden$:
|
|
148
|
+
hidden$: ue(e, S.UNIVER_DOC)
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
const y = () => {
|
|
152
|
-
const e = U(F), t = U(
|
|
153
|
-
() => i.textSelection$.pipe(
|
|
152
|
+
const e = U(F), t = U(de), r = Z(() => e.getCurrentTypeOfUnit$(S.UNIVER_DOC), [e]), n = G(r), o = Z(() => new fe((m) => m.next(I)), []), i = U(H), s = Z(
|
|
153
|
+
() => i.textSelection$.pipe(he(16)),
|
|
154
154
|
[i.textSelection$]
|
|
155
155
|
);
|
|
156
156
|
G(s);
|
|
157
|
-
const d = U(M), a = U(R), u = G(a.addingComment$), [c, h] =
|
|
158
|
-
if (
|
|
157
|
+
const d = U(M), a = U(R), u = G(a.addingComment$), [c, h] = nt([]);
|
|
158
|
+
if (rt(() => {
|
|
159
159
|
var b;
|
|
160
160
|
const m = /* @__PURE__ */ new Set(), l = n == null ? void 0 : n.getCustomDecorations();
|
|
161
161
|
h((b = l == null ? void 0 : l.map((f) => f.id).filter((f) => {
|
|
@@ -164,11 +164,11 @@ const y = () => {
|
|
|
164
164
|
})) != null ? b : []);
|
|
165
165
|
const g = d.onCommandExecuted((f) => {
|
|
166
166
|
var O;
|
|
167
|
-
if (f.id ===
|
|
167
|
+
if (f.id === ae.id) {
|
|
168
168
|
const P = /* @__PURE__ */ new Set(), J = n == null ? void 0 : n.getCustomDecorations();
|
|
169
169
|
h((O = J == null ? void 0 : J.map((N) => N.id).filter((N) => {
|
|
170
|
-
const
|
|
171
|
-
return P.add(N), !
|
|
170
|
+
const xe = P.has(N);
|
|
171
|
+
return P.add(N), !xe;
|
|
172
172
|
})) != null ? O : []);
|
|
173
173
|
}
|
|
174
174
|
});
|
|
@@ -177,9 +177,9 @@ const y = () => {
|
|
|
177
177
|
};
|
|
178
178
|
}, [d, n]), !n)
|
|
179
179
|
return null;
|
|
180
|
-
const C =
|
|
181
|
-
return /* @__PURE__ */
|
|
182
|
-
|
|
180
|
+
const C = ge(t), _ = n.getUnitId();
|
|
181
|
+
return /* @__PURE__ */ ut.jsx(
|
|
182
|
+
Ae,
|
|
183
183
|
{
|
|
184
184
|
unitId: _,
|
|
185
185
|
subUnitId$: o,
|
|
@@ -197,7 +197,7 @@ const y = () => {
|
|
|
197
197
|
range: u,
|
|
198
198
|
comment: m
|
|
199
199
|
};
|
|
200
|
-
return d.executeCommand(
|
|
200
|
+
return d.executeCommand(ve.id, l), a.endAdd(), !1;
|
|
201
201
|
}
|
|
202
202
|
return !0;
|
|
203
203
|
},
|
|
@@ -207,7 +207,7 @@ const y = () => {
|
|
|
207
207
|
unitId: _,
|
|
208
208
|
commentId: m.id
|
|
209
209
|
};
|
|
210
|
-
return d.executeCommand(
|
|
210
|
+
return d.executeCommand(pe.id, l), !1;
|
|
211
211
|
}
|
|
212
212
|
return !0;
|
|
213
213
|
},
|
|
@@ -247,19 +247,19 @@ const A = {
|
|
|
247
247
|
type: w.OPERATION,
|
|
248
248
|
handler(e) {
|
|
249
249
|
var f, O, P;
|
|
250
|
-
const t = e.get(T), n = e.get(F).getCurrentUnitForType(S.UNIVER_DOC), o = e.get(H), i = e.get(L), s = e.get(
|
|
250
|
+
const t = e.get(T), n = e.get(F).getCurrentUnitForType(S.UNIVER_DOC), o = e.get(H), i = e.get(L), s = e.get(Te), d = e.get(R), a = e.get(M), u = e.get(W), c = o.getActiveTextRange();
|
|
251
251
|
if (!n || !c)
|
|
252
252
|
return !1;
|
|
253
|
-
const h = (f = i.getRenderById(n.getUnitId())) == null ? void 0 : f.with(
|
|
253
|
+
const h = (f = i.getRenderById(n.getUnitId())) == null ? void 0 : f.with(We);
|
|
254
254
|
if (c.collapsed)
|
|
255
255
|
return t.panelVisible ? (t.setPanelVisible(!1), u.close()) : a.executeCommand(A.id), !0;
|
|
256
256
|
a.executeCommand(A.id);
|
|
257
|
-
const C = n.getUnitId(), _ = ((P = (O = n.getBody()) == null ? void 0 : O.dataStream) != null ? P : "").slice(c.startOffset, c.endOffset), m =
|
|
257
|
+
const C = n.getUnitId(), _ = ((P = (O = n.getBody()) == null ? void 0 : O.dataStream) != null ? P : "").slice(c.startOffset, c.endOffset), m = Pe.transform.getPlainText(_), l = I, g = "", b = {
|
|
258
258
|
unitId: C,
|
|
259
259
|
subUnitId: l,
|
|
260
260
|
id: g,
|
|
261
261
|
ref: m,
|
|
262
|
-
dT:
|
|
262
|
+
dT: Ze(),
|
|
263
263
|
personId: s.getCurrentUser().userID,
|
|
264
264
|
text: {
|
|
265
265
|
dataStream: `\r
|
|
@@ -277,10 +277,10 @@ const A = {
|
|
|
277
277
|
}), !0;
|
|
278
278
|
}
|
|
279
279
|
};
|
|
280
|
-
var
|
|
281
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
280
|
+
var Ct = Object.defineProperty, _t = Object.getOwnPropertyDescriptor, vt = (e, t, r, n) => {
|
|
281
|
+
for (var o = n > 1 ? void 0 : n ? _t(t, r) : t, i = e.length - 1, s; i >= 0; i--)
|
|
282
282
|
(s = e[i]) && (o = (n ? s(t, r, o) : s(o)) || o);
|
|
283
|
-
return n && o &&
|
|
283
|
+
return n && o && Ct(t, r, o), o;
|
|
284
284
|
}, x = (e, t) => (r, n) => t(r, n, e);
|
|
285
285
|
let $ = class extends B {
|
|
286
286
|
constructor(e, t, r, n, o, i) {
|
|
@@ -291,7 +291,7 @@ let $ = class extends B {
|
|
|
291
291
|
this.disposeWithMe(
|
|
292
292
|
this._commandService.onCommandExecuted((t) => {
|
|
293
293
|
var r, n, o, i;
|
|
294
|
-
if (t.id ===
|
|
294
|
+
if (t.id === je.id) {
|
|
295
295
|
const s = t.params, { unitId: d, ranges: a } = s, u = this._univerInstanceService.getUnit(d, S.UNIVER_DOC), c = a[0];
|
|
296
296
|
if ((e == null ? void 0 : e.startOffset) === (c == null ? void 0 : c.startOffset) && (e == null ? void 0 : e.endOffset) === (c == null ? void 0 : c.endOffset))
|
|
297
297
|
return;
|
|
@@ -312,7 +312,7 @@ let $ = class extends B {
|
|
|
312
312
|
}
|
|
313
313
|
if (!this._threadCommentPanelService.activeCommentId)
|
|
314
314
|
return;
|
|
315
|
-
this._commandService.executeCommand(
|
|
315
|
+
this._commandService.executeCommand(ce.id);
|
|
316
316
|
}
|
|
317
317
|
})
|
|
318
318
|
);
|
|
@@ -323,7 +323,7 @@ let $ = class extends B {
|
|
|
323
323
|
if (e) {
|
|
324
324
|
const i = this._univerInstanceService.getUnit(e.unitId);
|
|
325
325
|
if (i) {
|
|
326
|
-
const s = (t = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : t.with(
|
|
326
|
+
const s = (t = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : t.with(qe), d = (n = (r = i.getBody()) == null ? void 0 : r.customDecorations) == null ? void 0 : n.find((a) => a.id === e.commentId);
|
|
327
327
|
d && s && s.scrollToRange({
|
|
328
328
|
startOffset: d.startIndex,
|
|
329
329
|
endOffset: d.endIndex,
|
|
@@ -335,13 +335,13 @@ let $ = class extends B {
|
|
|
335
335
|
}));
|
|
336
336
|
}
|
|
337
337
|
};
|
|
338
|
-
$ =
|
|
338
|
+
$ = vt([
|
|
339
339
|
x(0, p(T)),
|
|
340
340
|
x(1, F),
|
|
341
341
|
x(2, M),
|
|
342
342
|
x(3, p(R)),
|
|
343
343
|
x(4, L),
|
|
344
|
-
x(5, p(
|
|
344
|
+
x(5, p(me))
|
|
345
345
|
], $);
|
|
346
346
|
var v = function() {
|
|
347
347
|
return v = Object.assign || function(e) {
|
|
@@ -351,23 +351,23 @@ var v = function() {
|
|
|
351
351
|
}
|
|
352
352
|
return e;
|
|
353
353
|
}, v.apply(this, arguments);
|
|
354
|
-
},
|
|
354
|
+
}, pt = function(e, t) {
|
|
355
355
|
var r = {};
|
|
356
356
|
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
357
357
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
358
358
|
for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
|
|
359
359
|
t.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (r[n[o]] = e[n[o]]);
|
|
360
360
|
return r;
|
|
361
|
-
},
|
|
362
|
-
var r = e.icon, n = e.id, o = e.className, i = e.extend, s =
|
|
363
|
-
return
|
|
361
|
+
}, Ie = Ce(function(e, t) {
|
|
362
|
+
var r = e.icon, n = e.id, o = e.className, i = e.extend, s = pt(e, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), a = ot("_".concat(St()));
|
|
363
|
+
return Se(r, "".concat(n), { defIds: r.defIds, idSuffix: a.current }, v({ ref: t, className: d }, s), i);
|
|
364
364
|
});
|
|
365
|
-
function
|
|
366
|
-
return
|
|
367
|
-
return
|
|
365
|
+
function Se(e, t, r, n, o) {
|
|
366
|
+
return _e(e.tag, v(v({ key: t }, gt(e, r, o)), n), (It(e, r).children || []).map(function(i, s) {
|
|
367
|
+
return Se(i, "".concat(t, "-").concat(e.tag, "-").concat(s), r, void 0, o);
|
|
368
368
|
}));
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function gt(e, t, r) {
|
|
371
371
|
var n = v({}, e.attrs);
|
|
372
372
|
r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1);
|
|
373
373
|
var o = t.defIds;
|
|
@@ -376,44 +376,44 @@ function pt(e, t, r) {
|
|
|
376
376
|
typeof d == "string" && (n[s] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
|
|
377
377
|
})), n;
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function It(e, t) {
|
|
380
380
|
var r, n = t.defIds;
|
|
381
381
|
return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? v(v({}, e), { children: e.children.map(function(o) {
|
|
382
382
|
return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ? v(v({}, o), { attrs: v(v({}, o.attrs), { id: o.attrs.id + t.idSuffix }) }) : o;
|
|
383
383
|
}) }) : e;
|
|
384
384
|
}
|
|
385
|
-
function
|
|
385
|
+
function St() {
|
|
386
386
|
return Math.random().toString(36).substring(2, 8);
|
|
387
387
|
}
|
|
388
|
-
|
|
389
|
-
var
|
|
390
|
-
return
|
|
388
|
+
Ie.displayName = "UniverIcon";
|
|
389
|
+
var Ot = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Oe = Ce(function(e, t) {
|
|
390
|
+
return _e(Ie, Object.assign({}, e, {
|
|
391
391
|
id: "comment-single",
|
|
392
392
|
ref: t,
|
|
393
|
-
icon:
|
|
393
|
+
icon: Ot
|
|
394
394
|
}));
|
|
395
395
|
});
|
|
396
|
-
|
|
397
|
-
const
|
|
398
|
-
[
|
|
396
|
+
Oe.displayName = "CommentSingle";
|
|
397
|
+
const Mt = {
|
|
398
|
+
[ze.OTHERS]: {
|
|
399
399
|
[ee.id]: {
|
|
400
400
|
order: 1,
|
|
401
|
-
menuItemFactory:
|
|
401
|
+
menuItemFactory: ht
|
|
402
402
|
}
|
|
403
403
|
},
|
|
404
|
-
[
|
|
405
|
-
[
|
|
404
|
+
[Ye.MAIN_AREA]: {
|
|
405
|
+
[Qe.DATA]: {
|
|
406
406
|
[q.id]: {
|
|
407
407
|
order: 1,
|
|
408
|
-
menuItemFactory:
|
|
408
|
+
menuItemFactory: ft
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
};
|
|
413
|
-
var
|
|
414
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
413
|
+
var bt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, Dt = (e, t, r, n) => {
|
|
414
|
+
for (var o = n > 1 ? void 0 : n ? xt(t, r) : t, i = e.length - 1, s; i >= 0; i--)
|
|
415
415
|
(s = e[i]) && (o = (n ? s(t, r, o) : s(o)) || o);
|
|
416
|
-
return n && o &&
|
|
416
|
+
return n && o && bt(t, r, o), o;
|
|
417
417
|
}, Y = (e, t) => (r, n) => t(r, n, e);
|
|
418
418
|
let V = class extends B {
|
|
419
419
|
constructor(e, t, r) {
|
|
@@ -421,8 +421,8 @@ let V = class extends B {
|
|
|
421
421
|
}
|
|
422
422
|
_initCommands() {
|
|
423
423
|
[
|
|
424
|
-
_e,
|
|
425
424
|
ve,
|
|
425
|
+
pe,
|
|
426
426
|
A,
|
|
427
427
|
q,
|
|
428
428
|
ee
|
|
@@ -431,23 +431,23 @@ let V = class extends B {
|
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
433
|
_initMenus() {
|
|
434
|
-
this._menuManagerService.mergeMenu(
|
|
434
|
+
this._menuManagerService.mergeMenu(Mt);
|
|
435
435
|
}
|
|
436
436
|
_initComponents() {
|
|
437
437
|
[y].forEach((e) => {
|
|
438
438
|
this.disposeWithMe(this._componentManager.register(e.componentKey, e));
|
|
439
|
-
}), this.disposeWithMe(this._componentManager.register("CommentSingle",
|
|
439
|
+
}), this.disposeWithMe(this._componentManager.register("CommentSingle", Oe));
|
|
440
440
|
}
|
|
441
441
|
};
|
|
442
|
-
V =
|
|
442
|
+
V = Dt([
|
|
443
443
|
Y(0, M),
|
|
444
|
-
Y(1,
|
|
445
|
-
Y(2, p(
|
|
444
|
+
Y(1, ke),
|
|
445
|
+
Y(2, p(Xe))
|
|
446
446
|
], V);
|
|
447
|
-
var
|
|
448
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
447
|
+
var Rt = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, Tt = (e, t, r, n) => {
|
|
448
|
+
for (var o = n > 1 ? void 0 : n ? yt(t, r) : t, i = e.length - 1, s; i >= 0; i--)
|
|
449
449
|
(s = e[i]) && (o = (n ? s(t, r, o) : s(o)) || o);
|
|
450
|
-
return n && o &&
|
|
450
|
+
return n && o && Rt(t, r, o), o;
|
|
451
451
|
}, D = (e, t) => (r, n) => t(r, n, e);
|
|
452
452
|
let k = class extends B {
|
|
453
453
|
constructor(e, t, r, n, o, i, s) {
|
|
@@ -467,7 +467,7 @@ let k = class extends B {
|
|
|
467
467
|
}));
|
|
468
468
|
}
|
|
469
469
|
_interceptorViewModel() {
|
|
470
|
-
this._docInterceptorService.intercept(
|
|
470
|
+
this._docInterceptorService.intercept(Fe.CUSTOM_DECORATION, {
|
|
471
471
|
handler: (e, t, r) => {
|
|
472
472
|
if (!e)
|
|
473
473
|
return r(e);
|
|
@@ -495,7 +495,7 @@ let k = class extends B {
|
|
|
495
495
|
let n = r.sort();
|
|
496
496
|
this.disposeWithMe(this._commandService.onCommandExecuted((d) => {
|
|
497
497
|
var a, u, c;
|
|
498
|
-
if (d.id ===
|
|
498
|
+
if (d.id === ae.id) {
|
|
499
499
|
if (d.params.unitId !== this._context.unit.getUnitId())
|
|
500
500
|
return;
|
|
501
501
|
const C = (c = (u = (a = this._context.unit.getBody()) == null ? void 0 : a.customDecorations) == null ? void 0 : u.filter((m) => m.type === X.COMMENT).map((m) => m.id)) != null ? c : [], _ = C.sort();
|
|
@@ -513,24 +513,28 @@ let k = class extends B {
|
|
|
513
513
|
}));
|
|
514
514
|
}
|
|
515
515
|
};
|
|
516
|
-
k =
|
|
517
|
-
D(1, p(
|
|
516
|
+
k = Tt([
|
|
517
|
+
D(1, p(Be)),
|
|
518
518
|
D(2, p(T)),
|
|
519
|
-
D(3, p(
|
|
519
|
+
D(3, p(Je)),
|
|
520
520
|
D(4, F),
|
|
521
|
-
D(5, p(
|
|
521
|
+
D(5, p(me)),
|
|
522
522
|
D(6, M)
|
|
523
523
|
], k);
|
|
524
|
-
var
|
|
525
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
524
|
+
var Me = Object.defineProperty, Pt = Object.getOwnPropertyDescriptor, Ut = (e, t, r) => t in e ? Me(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, Et = (e, t, r, n) => {
|
|
525
|
+
for (var o = n > 1 ? void 0 : n ? Pt(t, r) : t, i = e.length - 1, s; i >= 0; i--)
|
|
526
526
|
(s = e[i]) && (o = (n ? s(t, r, o) : s(o)) || o);
|
|
527
|
-
return n && o &&
|
|
528
|
-
}, Q = (e, t) => (r, n) => t(r, n, e),
|
|
529
|
-
let j = class extends
|
|
530
|
-
constructor(e =
|
|
527
|
+
return n && o && Me(t, r, o), o;
|
|
528
|
+
}, Q = (e, t) => (r, n) => t(r, n, e), be = (e, t, r) => Ut(e, typeof t != "symbol" ? t + "" : t, r);
|
|
529
|
+
let j = class extends Ee {
|
|
530
|
+
constructor(e = ne, t, r, n) {
|
|
531
531
|
super(), this._config = e, this._injector = t, this._renderManagerSrv = r, this._configService = n;
|
|
532
|
-
const { menu: o, ...i } =
|
|
533
|
-
|
|
532
|
+
const { menu: o, ...i } = we(
|
|
533
|
+
{},
|
|
534
|
+
ne,
|
|
535
|
+
this._config
|
|
536
|
+
);
|
|
537
|
+
o && this._configService.setConfig("menu", o, { merge: !0 }), this._configService.setConfig(st, i);
|
|
534
538
|
}
|
|
535
539
|
onStarting() {
|
|
536
540
|
[
|
|
@@ -550,17 +554,17 @@ let j = class extends Ue {
|
|
|
550
554
|
});
|
|
551
555
|
}
|
|
552
556
|
};
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
j =
|
|
556
|
-
|
|
557
|
-
Q(1, p(
|
|
557
|
+
be(j, "pluginName", it);
|
|
558
|
+
be(j, "type", S.UNIVER_DOC);
|
|
559
|
+
j = Et([
|
|
560
|
+
Ue($e),
|
|
561
|
+
Q(1, p(de)),
|
|
558
562
|
Q(2, L),
|
|
559
|
-
Q(3,
|
|
563
|
+
Q(3, Ne)
|
|
560
564
|
], j);
|
|
561
565
|
export {
|
|
562
|
-
|
|
563
|
-
|
|
566
|
+
ve as AddDocCommentComment,
|
|
567
|
+
pe as DeleteDocCommentComment,
|
|
564
568
|
A as ShowCommentPanelOperation,
|
|
565
569
|
q as StartAddCommentOperation,
|
|
566
570
|
j as UniverDocsThreadCommentUIPlugin
|
package/lib/index.css
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(l,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/thread-comment-ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/thread-comment-ui","@univerjs/docs","@univerjs/docs-ui","@univerjs/thread-comment","@univerjs/ui","rxjs","react"],o):(l=typeof globalThis<"u"?globalThis:l||self,o(l.UniverDocsThreadCommentUi={},l.UniverCore,l.UniverEngineRender,l.UniverThreadCommentUi,l.UniverDocs,l.UniverDocsUi,l.UniverThreadComment,l.UniverUi,l.rxjs,l.React))})(this,function(l,o,g,T,M,j,w,I,A,O){"use strict";var Ve=Object.defineProperty;var $e=(l,o,g)=>o in l?Ve(l,o,{enumerable:!0,configurable:!0,writable:!0,value:g}):l[o]=g;var Q=(l,o,g)=>$e(l,typeof o!="symbol"?o+"":o,g);const
|
|
1
|
+
(function(l,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/thread-comment-ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/thread-comment-ui","@univerjs/docs","@univerjs/docs-ui","@univerjs/thread-comment","@univerjs/ui","rxjs","react"],o):(l=typeof globalThis<"u"?globalThis:l||self,o(l.UniverDocsThreadCommentUi={},l.UniverCore,l.UniverEngineRender,l.UniverThreadCommentUi,l.UniverDocs,l.UniverDocsUi,l.UniverThreadComment,l.UniverUi,l.rxjs,l.React))})(this,function(l,o,g,T,M,j,w,I,A,O){"use strict";var Ve=Object.defineProperty;var $e=(l,o,g)=>o in l?Ve(l,o,{enumerable:!0,configurable:!0,writable:!0,value:g}):l[o]=g;var Q=(l,o,g)=>$e(l,typeof o!="symbol"?o+"":o,g);const ae="DOC_THREAD_COMMENT_UI_PLUGIN",D="default_doc",ce="docs-thread-comment-ui.config",X={};var me=Object.defineProperty,le=Object.getOwnPropertyDescriptor,ue=(e,t,r,n)=>{for(var i=n>1?void 0:n?le(t,r):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(i=(n?d(t,r,i):d(i))||i);return n&&i&&me(t,r,i),i},k=(e,t)=>(r,n)=>t(r,n,e);let U=class extends o.Disposable{constructor(t,r){super();Q(this,"_addingComment$",new A.BehaviorSubject(void 0));Q(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=t,this._threadCommentPanelService=r,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(t){this._addingComment$.next(t)}endAdd(){this._addingComment$.next(void 0)}};U=ue([k(0,I.ISidebarService),k(1,o.Inject(T.ThreadCommentPanelService))],U);var W={exports:{}},N={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
10
|
-
`},startOffset:c.startOffset,endOffset:c.endOffset,collapsed:!0,threadId:y};return C==null||C.blurEditor(),a.startAdd(E),t.setActiveComment({unitId:p,subUnitId:v,commentId:y}),!0}};var _e=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Se=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ie(t,r):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(i=(n?d(t,r,i):d(i))||i);return n&&i&&_e(t,r,i),i},x=(e,t)=>(r,n)=>t(r,n,e);let F=class extends o.Disposable{constructor(e,t,r,n,i,s){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=r,this._docThreadCommentService=n,this._renderManagerService=i,this._threadCommentModel=s,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var r,n,i,s;if(t.id===M.SetTextSelectionsOperation.id){const d=t.params,{unitId:a,ranges:m}=d,f=this._univerInstanceService.getUnit(a,o.UniverInstanceType.UNIVER_DOC),c=m[0];if((e==null?void 0:e.startOffset)===(c==null?void 0:c.startOffset)&&(e==null?void 0:e.endOffset)===(c==null?void 0:c.endOffset))return;if(e=c,c&&f){const{startOffset:C,endOffset:p,collapsed:_}=c;let u;if(_?u=(n=(r=f.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(v=>v.startIndex<=C&&v.endIndex>=p-1):u=(s=(i=f.getBody())==null?void 0:i.customDecorations)==null?void 0:s.find(v=>v.startIndex<=C&&v.endIndex>=p-1),u){const v=this._threadCommentModel.getComment(a,D,u.id);v&&!v.resolved&&this._commandService.executeCommand(V.id,{activeComment:{unitId:a,subUnitId:D,commentId:u.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(T.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,r,n,i;if(e){const s=this._univerInstanceService.getUnit(e.unitId);if(s){const d=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(j.DocBackScrollRenderController),a=(n=(r=s.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(m=>m.id===e.commentId);a&&d&&d.scrollToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1})}}(!e||e.commentId!==((i=this._docThreadCommentService.addingComment)==null?void 0:i.id))&&this._docThreadCommentService.endAdd()}))}};F=Se([x(0,o.Inject(T.ThreadCommentPanelService)),x(1,o.IUniverInstanceService),x(2,o.ICommandService),x(3,o.Inject(U)),x(4,g.IRenderManagerService),x(5,o.Inject(w.ThreadCommentModel))],F);var S=function(){return S=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},S.apply(this,arguments)},ge=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},ne=O.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,s=e.extend,d=ge(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),m=O.useRef("_".concat(Me()));return re(r,"".concat(n),{defIds:r.defIds,idSuffix:m.current},S({ref:t,className:a},d),s)});function re(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 re(s,"".concat(t,"-").concat(e.tag,"-").concat(d),r,void 0,i)}))}function Oe(e,t,r){var n=S({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var d=s[0],a=s[1];typeof a=="string"&&(n[d]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Te(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?S(S({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?S(S({},i),{attrs:S(S({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function Me(){return Math.random().toString(36).substring(2,8)}ne.displayName="UniverIcon";var De={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=O.forwardRef(function(e,t){return O.createElement(ne,Object.assign({},e,{id:"comment-single",ref:t,icon:De}))});ie.displayName="CommentSingle";const ye={[I.RibbonStartGroup.OTHERS]:{[q.id]:{order:1,menuItemFactory:pe}},[I.ContextMenuPosition.MAIN_AREA]:{[I.ContextMenuGroup.DATA]:{[$.id]:{order:1,menuItemFactory:Ce}}}};var be=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Re=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ue(t,r):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(i=(n?d(t,r,i):d(i))||i);return n&&i&&be(t,r,i),i},G=(e,t)=>(r,n)=>t(r,n,e);let H=class extends o.Disposable{constructor(e,t,r){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[J,K,V,$,q].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(ye)}_initComponents(){[R].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",ie))}};H=Re([G(0,o.ICommandService),G(1,I.IMenuManagerService),G(2,o.Inject(I.ComponentManager))],H);var xe=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Ee=(e,t,r,n)=>{for(var i=n>1?void 0:n?Pe(t,r):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(i=(n?d(t,r,i):d(i))||i);return n&&i&&xe(t,r,i),i},P=(e,t)=>(r,n)=>t(r,n,e);let Z=class extends o.Disposable{constructor(e,t,r,n,i,s,d){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=r,this._docRenderController=n,this._univerInstanceService=i,this._threadCommentModel=s,this._commandService=d,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var r;if(e){this._docRenderController.reRender(e.unitId);return}const t=(r=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(M.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,r)=>{if(!e)return r(e);const{unitId:n,index:i,customDecorations:s}=t,d=this._threadCommentPanelService.activeCommentId,{commentId:a,unitId:m}=d||{},f=s.find(_=>_.id===a),c=this._threadCommentModel.getComment(n,D,e.id);if(!c)return r({...e,show:!1});const C=f&&i>=f.startIndex&&i<=f.endIndex,p=m===n&&e.id===a;return r({...e,active:p||C,show:!c.resolved})}})}_initSyncComments(){var i,s,d;const e=this._context.unit.getUnitId(),t=D,r=(d=(s=(i=this._context.unit.getBody())==null?void 0:i.customDecorations)==null?void 0:s.filter(a=>a.type===o.CustomDecorationType.COMMENT).map(a=>a.id))!=null?d:[];r.forEach(a=>{this._threadCommentModel.getComment(e,t,a)||this._threadCommentModel.addComment(e,t,{id:a,threadId:a,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),D,r);let n=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(a=>{var m,f,c;if(a.id===M.RichTextEditingMutation.id){if(a.params.unitId!==this._context.unit.getUnitId())return;const p=(c=(f=(m=this._context.unit.getBody())==null?void 0:m.customDecorations)==null?void 0:f.filter(u=>u.type===o.CustomDecorationType.COMMENT).map(u=>u.id))!=null?c:[],_=p.sort();if(JSON.stringify(n)!==JSON.stringify(_)){const u=new Set(n),v=new Set(_),y=new Set,E=new Set;p.forEach(h=>{u.has(h)||y.add(h)}),n.forEach(h=>{v.has(h)||E.add(h)}),n=_,y.forEach(h=>{this._threadCommentModel.getComment(e,t,h)||this._threadCommentModel.addComment(e,t,{id:h,threadId:h,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...y])}}}))}};Z=Ee([P(1,o.Inject(M.DocInterceptorService)),P(2,o.Inject(T.ThreadCommentPanelService)),P(3,o.Inject(j.DocRenderController)),P(4,o.IUniverInstanceService),P(5,o.Inject(w.ThreadCommentModel)),P(6,o.ICommandService)],Z);var oe=Object.defineProperty,je=Object.getOwnPropertyDescriptor,we=(e,t,r)=>t in e?oe(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&&oe(t,r,i),i},z=(e,t)=>(r,n)=>t(r,n,e),se=(e,t,r)=>we(e,typeof t!="symbol"?t+"":t,r);l.UniverDocsThreadCommentUIPlugin=class extends o.Plugin{constructor(t=ce,r,n,i){super(),this._config=t,this._injector=r,this._renderManagerSrv=n,this._configService=i;const{menu:s,...d}=this._config;s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(ae,d)}onStarting(){[[H],[F],[U]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(F),this._injector.get(H)}_initRenderModule(){[Z].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}},se(l.UniverDocsThreadCommentUIPlugin,"pluginName",de),se(l.UniverDocsThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),l.UniverDocsThreadCommentUIPlugin=Ae([o.DependentOn(T.UniverThreadCommentUIPlugin),z(1,o.Inject(o.Injector)),z(2,g.IRenderManagerService),z(3,o.IConfigService)],l.UniverDocsThreadCommentUIPlugin),l.AddDocCommentComment=J,l.DeleteDocCommentComment=K,l.ShowCommentPanelOperation=V,l.StartAddCommentOperation=$,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var ee;function ve(){if(ee)return N;ee=1;var e=O,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function d(a,m,f){var c,C={},p=null,_=null;f!==void 0&&(p=""+f),m.key!==void 0&&(p=""+m.key),m.ref!==void 0&&(_=m.ref);for(c in m)n.call(m,c)&&!s.hasOwnProperty(c)&&(C[c]=m[c]);if(a&&a.defaultProps)for(c in m=a.defaultProps,m)C[c]===void 0&&(C[c]=m[c]);return{$$typeof:t,type:a,key:p,ref:_,props:C,_owner:i.current}}return N.Fragment=r,N.jsx=d,N.jsxs=d,N}var te;function fe(){return te||(te=1,W.exports=ve()),W.exports}var he=fe();const J={id:"docs.command.add-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{comment:r,unitId:n}=t,s=await e.get(w.IThreadCommentDataSourceService).addComment(r),d=e.get(o.ICommandService),a=j.addCustomDecorationBySelectionFactory(e,{id:s.threadId,type:o.CustomDecorationType.COMMENT});if(a){const m={id:w.AddCommentMutation.id,params:{unitId:n,subUnitId:D,comment:s}},f={id:T.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:D,commentId:s.id}};return(await o.sequenceExecute([m,a,f],d)).result}return!1}},K={id:"docs.command.delete-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:r,unitId:n}=t,i=e.get(o.ICommandService),s=j.deleteCustomDecorationFactory(e,{id:r,unitId:n});return s?(await o.sequenceExecute([s],i)).result:!1}},ne=e=>{const t=e.get(g.IRenderManagerService),r=e.get(M.DocSelectionManagerService),n=t.getCurrent(),i=n==null?void 0:n.with(M.DocSkeletonManagerService).getSkeleton(),s=i==null?void 0:i.getViewModel().getEditArea();if(s===g.DocumentEditArea.FOOTER||s===g.DocumentEditArea.HEADER)return!0;const d=r.getActiveTextRange();return!!(d==null||d.collapsed)};function Ce(e){return{id:$.id,type:I.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:I.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,void 0,o.SHEET_EDITOR_UNITS),disabled$:new A.Observable(function(t){const n=e.get(M.DocSelectionManagerService).textSelection$.pipe(A.debounceTime(16)).subscribe(()=>{t.next(ne(e))});return()=>{n.unsubscribe()}})}}function pe(e){return{id:q.id,type:I.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:I.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC)}}const R=()=>{const e=o.useDependency(o.IUniverInstanceService),t=o.useDependency(o.Injector),r=O.useMemo(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC),[e]),n=o.useObservable(r),i=O.useMemo(()=>new A.Observable(u=>u.next(D)),[]),s=o.useDependency(M.DocSelectionManagerService),d=O.useMemo(()=>s.textSelection$.pipe(A.debounceTime(16)),[s.textSelection$]);o.useObservable(d);const a=o.useDependency(o.ICommandService),m=o.useDependency(U),f=o.useObservable(m.addingComment$),[c,C]=O.useState([]);if(O.useEffect(()=>{var E;const u=new Set,v=n==null?void 0:n.getCustomDecorations();C((E=v==null?void 0:v.map(h=>h.id).filter(h=>{const b=u.has(h);return u.add(h),!b}))!=null?E:[]);const y=a.onCommandExecuted(h=>{var b;if(h.id===M.RichTextEditingMutation.id){const B=new Set,Y=n==null?void 0:n.getCustomDecorations();C((b=Y==null?void 0:Y.map(L=>L.id).filter(L=>{const Ne=B.has(L);return B.add(L),!Ne}))!=null?b:[])}});return()=>{y.dispose()}},[a,n]),!n)return null;const p=ne(t),_=n.getUnitId();return he.jsx(T.ThreadCommentPanel,{unitId:_,subUnitId$:i,type:o.UniverInstanceType.UNIVER_DOC,onAdd:()=>{a.executeCommand($.id)},getSubUnitName:()=>"",disableAdd:p,tempComment:f,onAddComment:u=>{if(!u.parentId){const v={unitId:_,range:f,comment:u};return a.executeCommand(J.id,v),m.endAdd(),!1}return!0},onDeleteComment:u=>{if(!u.parentId){const v={unitId:_,commentId:u.id};return a.executeCommand(K.id,v),!1}return!0},showComments:c})};R.componentKey="univer.doc.thread-comment-panel";const V={id:"docs.operation.show-comment-panel",type:o.CommandType.OPERATION,handler(e,t){var i;const r=e.get(T.ThreadCommentPanelService),n=e.get(I.ISidebarService);return(!r.panelVisible||((i=n.options.children)==null?void 0:i.label)!==R.componentKey)&&(n.open({header:{title:"threadCommentUI.panel.title"},children:{label:R.componentKey},width:320,onClose:()=>r.setPanelVisible(!1)}),r.setPanelVisible(!0)),t&&r.setActiveComment(t==null?void 0:t.activeComment),!0}},q={id:"docs.operation.toggle-comment-panel",type:o.CommandType.OPERATION,handler(e){var n;const t=e.get(T.ThreadCommentPanelService),r=e.get(I.ISidebarService);return!t.panelVisible||((n=r.options.children)==null?void 0:n.label)!==R.componentKey?(r.open({header:{title:"threadCommentUI.panel.title"},children:{label:R.componentKey},width:320,onClose:()=>t.setPanelVisible(!1)}),t.setPanelVisible(!0)):(r.close(),t.setPanelVisible(!1),t.setActiveComment(null)),!0}},$={id:"docs.operation.start-add-comment",type:o.CommandType.OPERATION,handler(e){var h,b,B;const t=e.get(T.ThreadCommentPanelService),n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),i=e.get(M.DocSelectionManagerService),s=e.get(g.IRenderManagerService),d=e.get(o.UserManagerService),a=e.get(U),m=e.get(o.ICommandService),f=e.get(I.ISidebarService),c=i.getActiveTextRange();if(!n||!c)return!1;const C=(h=s.getRenderById(n.getUnitId()))==null?void 0:h.with(j.DocSelectionRenderService);if(c.collapsed)return t.panelVisible?(t.setPanelVisible(!1),f.close()):m.executeCommand(V.id),!0;m.executeCommand(V.id);const p=n.getUnitId(),_=((B=(b=n.getBody())==null?void 0:b.dataStream)!=null?B:"").slice(c.startOffset,c.endOffset),u=o.BuildTextUtils.transform.getPlainText(_),v=D,y="",E={unitId:p,subUnitId:v,id:y,ref:u,dT:w.getDT(),personId:d.getCurrentUser().userID,text:{dataStream:`\r
|
|
10
|
+
`},startOffset:c.startOffset,endOffset:c.endOffset,collapsed:!0,threadId:y};return C==null||C.blurEditor(),a.startAdd(E),t.setActiveComment({unitId:p,subUnitId:v,commentId:y}),!0}};var _e=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Se=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ie(t,r):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(i=(n?d(t,r,i):d(i))||i);return n&&i&&_e(t,r,i),i},x=(e,t)=>(r,n)=>t(r,n,e);let F=class extends o.Disposable{constructor(e,t,r,n,i,s){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=r,this._docThreadCommentService=n,this._renderManagerService=i,this._threadCommentModel=s,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var r,n,i,s;if(t.id===M.SetTextSelectionsOperation.id){const d=t.params,{unitId:a,ranges:m}=d,f=this._univerInstanceService.getUnit(a,o.UniverInstanceType.UNIVER_DOC),c=m[0];if((e==null?void 0:e.startOffset)===(c==null?void 0:c.startOffset)&&(e==null?void 0:e.endOffset)===(c==null?void 0:c.endOffset))return;if(e=c,c&&f){const{startOffset:C,endOffset:p,collapsed:_}=c;let u;if(_?u=(n=(r=f.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(v=>v.startIndex<=C&&v.endIndex>=p-1):u=(s=(i=f.getBody())==null?void 0:i.customDecorations)==null?void 0:s.find(v=>v.startIndex<=C&&v.endIndex>=p-1),u){const v=this._threadCommentModel.getComment(a,D,u.id);v&&!v.resolved&&this._commandService.executeCommand(V.id,{activeComment:{unitId:a,subUnitId:D,commentId:u.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(T.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,r,n,i;if(e){const s=this._univerInstanceService.getUnit(e.unitId);if(s){const d=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(j.DocBackScrollRenderController),a=(n=(r=s.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(m=>m.id===e.commentId);a&&d&&d.scrollToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1})}}(!e||e.commentId!==((i=this._docThreadCommentService.addingComment)==null?void 0:i.id))&&this._docThreadCommentService.endAdd()}))}};F=Se([x(0,o.Inject(T.ThreadCommentPanelService)),x(1,o.IUniverInstanceService),x(2,o.ICommandService),x(3,o.Inject(U)),x(4,g.IRenderManagerService),x(5,o.Inject(w.ThreadCommentModel))],F);var S=function(){return S=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},S.apply(this,arguments)},ge=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},re=O.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,s=e.extend,d=ge(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),m=O.useRef("_".concat(Me()));return ie(r,"".concat(n),{defIds:r.defIds,idSuffix:m.current},S({ref:t,className:a},d),s)});function ie(e,t,r,n,i){return O.createElement(e.tag,S(S({key:t},Oe(e,r,i)),n),(Te(e,r).children||[]).map(function(s,d){return ie(s,"".concat(t,"-").concat(e.tag,"-").concat(d),r,void 0,i)}))}function Oe(e,t,r){var n=S({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var d=s[0],a=s[1];typeof a=="string"&&(n[d]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Te(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?S(S({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?S(S({},i),{attrs:S(S({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function Me(){return Math.random().toString(36).substring(2,8)}re.displayName="UniverIcon";var De={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},oe=O.forwardRef(function(e,t){return O.createElement(re,Object.assign({},e,{id:"comment-single",ref:t,icon:De}))});oe.displayName="CommentSingle";const ye={[I.RibbonStartGroup.OTHERS]:{[q.id]:{order:1,menuItemFactory:pe}},[I.ContextMenuPosition.MAIN_AREA]:{[I.ContextMenuGroup.DATA]:{[$.id]:{order:1,menuItemFactory:Ce}}}};var be=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Re=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ue(t,r):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(i=(n?d(t,r,i):d(i))||i);return n&&i&&be(t,r,i),i},G=(e,t)=>(r,n)=>t(r,n,e);let H=class extends o.Disposable{constructor(e,t,r){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[J,K,V,$,q].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(ye)}_initComponents(){[R].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",oe))}};H=Re([G(0,o.ICommandService),G(1,I.IMenuManagerService),G(2,o.Inject(I.ComponentManager))],H);var xe=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Ee=(e,t,r,n)=>{for(var i=n>1?void 0:n?Pe(t,r):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(i=(n?d(t,r,i):d(i))||i);return n&&i&&xe(t,r,i),i},P=(e,t)=>(r,n)=>t(r,n,e);let Z=class extends o.Disposable{constructor(e,t,r,n,i,s,d){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=r,this._docRenderController=n,this._univerInstanceService=i,this._threadCommentModel=s,this._commandService=d,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var r;if(e){this._docRenderController.reRender(e.unitId);return}const t=(r=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(M.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,r)=>{if(!e)return r(e);const{unitId:n,index:i,customDecorations:s}=t,d=this._threadCommentPanelService.activeCommentId,{commentId:a,unitId:m}=d||{},f=s.find(_=>_.id===a),c=this._threadCommentModel.getComment(n,D,e.id);if(!c)return r({...e,show:!1});const C=f&&i>=f.startIndex&&i<=f.endIndex,p=m===n&&e.id===a;return r({...e,active:p||C,show:!c.resolved})}})}_initSyncComments(){var i,s,d;const e=this._context.unit.getUnitId(),t=D,r=(d=(s=(i=this._context.unit.getBody())==null?void 0:i.customDecorations)==null?void 0:s.filter(a=>a.type===o.CustomDecorationType.COMMENT).map(a=>a.id))!=null?d:[];r.forEach(a=>{this._threadCommentModel.getComment(e,t,a)||this._threadCommentModel.addComment(e,t,{id:a,threadId:a,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),D,r);let n=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(a=>{var m,f,c;if(a.id===M.RichTextEditingMutation.id){if(a.params.unitId!==this._context.unit.getUnitId())return;const p=(c=(f=(m=this._context.unit.getBody())==null?void 0:m.customDecorations)==null?void 0:f.filter(u=>u.type===o.CustomDecorationType.COMMENT).map(u=>u.id))!=null?c:[],_=p.sort();if(JSON.stringify(n)!==JSON.stringify(_)){const u=new Set(n),v=new Set(_),y=new Set,E=new Set;p.forEach(h=>{u.has(h)||y.add(h)}),n.forEach(h=>{v.has(h)||E.add(h)}),n=_,y.forEach(h=>{this._threadCommentModel.getComment(e,t,h)||this._threadCommentModel.addComment(e,t,{id:h,threadId:h,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...y])}}}))}};Z=Ee([P(1,o.Inject(M.DocInterceptorService)),P(2,o.Inject(T.ThreadCommentPanelService)),P(3,o.Inject(j.DocRenderController)),P(4,o.IUniverInstanceService),P(5,o.Inject(w.ThreadCommentModel)),P(6,o.ICommandService)],Z);var se=Object.defineProperty,je=Object.getOwnPropertyDescriptor,we=(e,t,r)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ae=(e,t,r,n)=>{for(var i=n>1?void 0:n?je(t,r):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(i=(n?d(t,r,i):d(i))||i);return n&&i&&se(t,r,i),i},z=(e,t)=>(r,n)=>t(r,n,e),de=(e,t,r)=>we(e,typeof t!="symbol"?t+"":t,r);l.UniverDocsThreadCommentUIPlugin=class extends o.Plugin{constructor(t=X,r,n,i){super(),this._config=t,this._injector=r,this._renderManagerSrv=n,this._configService=i;const{menu:s,...d}=o.merge({},X,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(ce,d)}onStarting(){[[H],[F],[U]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(F),this._injector.get(H)}_initRenderModule(){[Z].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}},de(l.UniverDocsThreadCommentUIPlugin,"pluginName",ae),de(l.UniverDocsThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),l.UniverDocsThreadCommentUIPlugin=Ae([o.DependentOn(T.UniverThreadCommentUIPlugin),z(1,o.Inject(o.Injector)),z(2,g.IRenderManagerService),z(3,o.IConfigService)],l.UniverDocsThreadCommentUIPlugin),l.AddDocCommentComment=J,l.DeleteDocCommentComment=K,l.ShowCommentPanelOperation=V,l.StartAddCommentOperation=$,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-thread-comment-ui",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2-nightly.202412281605",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -49,23 +49,23 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@univerjs/icons": "^0.2.8",
|
|
51
51
|
"clsx": "^2.1.1",
|
|
52
|
-
"@univerjs/core": "0.5.
|
|
53
|
-
"@univerjs/docs": "0.5.
|
|
54
|
-
"@univerjs/
|
|
55
|
-
"@univerjs/
|
|
56
|
-
"@univerjs/
|
|
57
|
-
"@univerjs/thread-comment": "0.5.
|
|
58
|
-
"@univerjs/ui": "0.5.
|
|
52
|
+
"@univerjs/core": "0.5.2-nightly.202412281605",
|
|
53
|
+
"@univerjs/docs": "0.5.2-nightly.202412281605",
|
|
54
|
+
"@univerjs/docs-ui": "0.5.2-nightly.202412281605",
|
|
55
|
+
"@univerjs/engine-render": "0.5.2-nightly.202412281605",
|
|
56
|
+
"@univerjs/thread-comment": "0.5.2-nightly.202412281605",
|
|
57
|
+
"@univerjs/thread-comment-ui": "0.5.2-nightly.202412281605",
|
|
58
|
+
"@univerjs/ui": "0.5.2-nightly.202412281605"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"postcss": "^8.4.49",
|
|
62
62
|
"react": "18.3.1",
|
|
63
63
|
"rxjs": "^7.8.1",
|
|
64
|
-
"tailwindcss": "^3.4.
|
|
64
|
+
"tailwindcss": "^3.4.16",
|
|
65
65
|
"typescript": "^5.7.2",
|
|
66
|
-
"vite": "^6.0.
|
|
67
|
-
"vitest": "^2.1.
|
|
68
|
-
"@univerjs-infra/shared": "0.5.
|
|
66
|
+
"vite": "^6.0.3",
|
|
67
|
+
"vitest": "^2.1.8",
|
|
68
|
+
"@univerjs-infra/shared": "0.5.2"
|
|
69
69
|
},
|
|
70
70
|
"space": {
|
|
71
71
|
".": {
|
package/LICENSE
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|