@univerjs/docs-thread-comment-ui 0.3.0 → 0.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),threadCommentUi=require("@univerjs/thread-comment-ui"),engineRender=require("@univerjs/engine-render"),ui=require("@univerjs/ui"),docsUi=require("@univerjs/docs-ui"),threadComment=require("@univerjs/thread-comment"),docs=require("@univerjs/docs"),React=require("react"),rxjs=require("rxjs"),PLUGIN_NAME="DOC_THREAD_COMMENT_UI_PLUGIN",DEFAULT_DOC_SUBUNIT_ID="default_doc";var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a6){var key=_a6[0],value=_a6[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a6,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a6=node.children)===null||_a6===void 0)&&_a6.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element={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"}}]},CommentSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"comment-single",ref,icon:element}))});CommentSingle.displayName="CommentSingle";const AddDocCommentComment={id:"docs.command.add-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{comment:originComment,unitId}=params,comment=await accessor.get(threadComment.IThreadCommentDataSourceService).addComment(originComment),commandService=accessor.get(core.ICommandService),doMutation=docsUi.addCustomDecorationBySelectionFactory(accessor,{id:comment.id,type:core.CustomDecorationType.COMMENT});if(doMutation){const addComment={id:threadComment.AddCommentMutation.id,params:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,comment}},activeOperation={id:threadCommentUi.SetActiveCommentOperation.id,params:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,commentId:comment.id}};return(await core.sequenceExecuteAsync([addComment,doMutation,activeOperation],commandService)).result}return!1}},DeleteDocCommentComment={id:"docs.command.delete-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{commentId,unitId}=params,commandService=accessor.get(core.ICommandService),doMutation=docsUi.deleteCustomDecorationFactory(accessor,{id:commentId,unitId});return doMutation?(await core.sequenceExecute([doMutation],commandService)).result:!1}};var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4"),_a;let DocThreadCommentService=(_a=class extends core.Disposable{constructor(_sidebarService,_threadCommentPanelService){super();__publicField(this,"_addingComment$",new rxjs.BehaviorSubject(void 0));__publicField(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=_sidebarService,this._threadCommentPanelService=_threadCommentPanelService,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(comment){this._addingComment$.next(comment)}endAdd(){this._addingComment$.next(void 0)}},__name(_a,"DocThreadCommentService"),_a);DocThreadCommentService=__decorateClass$4([__decorateParam$4(0,ui.ISidebarService),__decorateParam$4(1,core.Inject(threadCommentUi.ThreadCommentPanelService))],DocThreadCommentService);const ShowCommentPanelOperation={id:"docs.operation.show-comment-panel",type:core.CommandType.OPERATION,handler(accessor,params){var _a6;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),sidebarService=accessor.get(ui.ISidebarService);return(!panelService.panelVisible||((_a6=sidebarService.options.children)==null?void 0:_a6.label)!==DocThreadCommentPanel.componentKey)&&(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:DocThreadCommentPanel.componentKey},width:320,onClose:__name(()=>panelService.setPanelVisible(!1),"onClose")}),panelService.setPanelVisible(!0)),params&&panelService.setActiveComment(params==null?void 0:params.activeComment),!0}},ToggleCommentPanelOperation={id:"docs.operation.toggle-comment-panel",type:core.CommandType.OPERATION,handler(accessor){var _a6;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),sidebarService=accessor.get(ui.ISidebarService);return!panelService.panelVisible||((_a6=sidebarService.options.children)==null?void 0:_a6.label)!==DocThreadCommentPanel.componentKey?(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:DocThreadCommentPanel.componentKey},width:320,onClose:__name(()=>panelService.setPanelVisible(!1),"onClose")}),panelService.setPanelVisible(!0)):(sidebarService.close(),panelService.setPanelVisible(!1),panelService.setActiveComment(null)),!0}},StartAddCommentOperation={id:"docs.operation.start-add-comment",type:core.CommandType.OPERATION,handler(accessor){var _a6,_b,_c;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),doc=accessor.get(core.IUniverInstanceService).getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC),docSelectionManagerService=accessor.get(docs.DocSelectionManagerService),renderManagerService=accessor.get(engineRender.IRenderManagerService),userManagerService=accessor.get(core.UserManagerService),docCommentService=accessor.get(DocThreadCommentService),commandService=accessor.get(core.ICommandService),sidebarService=accessor.get(ui.ISidebarService),textRange=docSelectionManagerService.getActiveTextRange();if(!doc||!textRange)return!1;const docSelectionRenderManager=(_a6=renderManagerService.getRenderById(doc.getUnitId()))==null?void 0:_a6.with(docsUi.DocSelectionRenderService);if(textRange.collapsed)return panelService.panelVisible?(panelService.setPanelVisible(!1),sidebarService.close()):commandService.executeCommand(ShowCommentPanelOperation.id),!0;commandService.executeCommand(ShowCommentPanelOperation.id);const unitId=doc.getUnitId(),dataStream=((_c=(_b=doc.getBody())==null?void 0:_b.dataStream)!=null?_c:"").slice(textRange.startOffset,textRange.endOffset),text=core.BuildTextUtils.transform.getPlainText(dataStream),subUnitId=DEFAULT_DOC_SUBUNIT_ID,commentId="",comment={unitId,subUnitId,id:commentId,ref:text,dT:threadCommentUi.getDT(),personId:userManagerService.getCurrentUser().userID,text:{dataStream:`\r
|
|
2
|
-
`},startOffset:textRange.startOffset,endOffset:textRange.endOffset,collapsed:!0,threadId:commentId};return docSelectionRenderManager==null||docSelectionRenderManager.blurEditor(),docCommentService.startAdd(comment),panelService.setActiveComment({unitId,subUnitId,commentId}),!0}},shouldDisableAddComment=__name(accessor=>{const renderManagerService=accessor.get(engineRender.IRenderManagerService),docSelectionManagerService=accessor.get(docs.DocSelectionManagerService),render2=renderManagerService.getCurrent(),skeleton=render2==null?void 0:render2.with(docs.DocSkeletonManagerService).getSkeleton(),editArea=skeleton==null?void 0:skeleton.getViewModel().getEditArea();if(editArea===engineRender.DocumentEditArea.FOOTER||editArea===engineRender.DocumentEditArea.HEADER)return!0;const range=docSelectionManagerService.getActiveTextRange();return!!(range==null||range.collapsed)},"shouldDisableAddComment");function AddDocCommentMenuItemFactory(accessor){return{id:StartAddCommentOperation.id,type:ui.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC),disabled$:new rxjs.Observable(function(subscribe){const observer=accessor.get(docs.DocSelectionManagerService).textSelection$.pipe(rxjs.debounceTime(16)).subscribe(()=>{subscribe.next(shouldDisableAddComment(accessor))});return()=>{observer.unsubscribe()}})}}__name(AddDocCommentMenuItemFactory,"AddDocCommentMenuItemFactory");function ToolbarDocCommentMenuItemFactory(accessor){return{id:ToggleCommentPanelOperation.id,type:ui.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC)}}__name(ToolbarDocCommentMenuItemFactory,"ToolbarDocCommentMenuItemFactory");const DocThreadCommentPanel=__name(()=>{const univerInstanceService=core.useDependency(core.IUniverInstanceService),injector=core.useDependency(core.Injector),doc$=React.useMemo(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_DOC),[univerInstanceService]),doc=core.useObservable(doc$),subUnitId$=React.useMemo(()=>new rxjs.Observable(sub=>sub.next(DEFAULT_DOC_SUBUNIT_ID)),[]),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),selectionChange$=React.useMemo(()=>docSelectionManagerService.textSelection$.pipe(rxjs.debounceTime(16)),[docSelectionManagerService.textSelection$]);core.useObservable(selectionChange$);const commandService=core.useDependency(core.ICommandService),docCommentService=core.useDependency(DocThreadCommentService),tempComment=core.useObservable(docCommentService.addingComment$),[commentIds,setCommentIds]=React.useState([]);if(React.useEffect(()=>{var _a6;const set=new Set,customRanges=doc==null?void 0:doc.getCustomDecorations();setCommentIds((_a6=customRanges==null?void 0:customRanges.map(r=>r.id).filter(i=>{const hasRepeat=set.has(i);return set.add(i),!hasRepeat}))!=null?_a6:[]);const dispose=commandService.onCommandExecuted(command=>{var _a7;if(command.id===docs.RichTextEditingMutation.id){const set2=new Set,customRanges2=doc==null?void 0:doc.getCustomDecorations();setCommentIds((_a7=customRanges2==null?void 0:customRanges2.map(r=>r.id).filter(i=>{const hasRepeat=set2.has(i);return set2.add(i),!hasRepeat}))!=null?_a7:[])}});return()=>{dispose.dispose()}},[commandService,doc]),!doc)return null;const isInValidSelection=shouldDisableAddComment(injector),unitId=doc.getUnitId();return React.createElement(threadCommentUi.ThreadCommentPanel,{unitId,subUnitId$,type:core.UniverInstanceType.UNIVER_DOC,onAdd:__name(()=>{commandService.executeCommand(StartAddCommentOperation.id)},"onAdd"),getSubUnitName:__name(()=>"","getSubUnitName"),disableAdd:isInValidSelection,tempComment,onAddComment:__name(comment=>{if(!comment.parentId){const params={unitId,range:tempComment,comment};return commandService.executeCommand(AddDocCommentComment.id,params),docCommentService.endAdd(),!1}return!0},"onAddComment"),onDeleteComment:__name(comment=>{if(!comment.parentId){const params={unitId,commentId:comment.id};return commandService.executeCommand(DeleteDocCommentComment.id,params),!1}return!0},"onDeleteComment"),showComments:commentIds})},"DocThreadCommentPanel");DocThreadCommentPanel.componentKey="univer.doc.thread-comment-panel";const menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ToggleCommentPanelOperation.id]:{order:1,menuItemFactory:ToolbarDocCommentMenuItemFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.DATA]:{[StartAddCommentOperation.id]:{order:1,menuItemFactory:AddDocCommentMenuItemFactory}}}};var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3"),_a2;let DocThreadCommentUIController=(_a2=class extends core.Disposable{constructor(_commandService,_menuManagerService,_componentManager){super(),this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._componentManager=_componentManager,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[AddDocCommentComment,DeleteDocCommentComment,ShowCommentPanelOperation,StartAddCommentOperation,ToggleCommentPanelOperation].forEach(command=>{this.disposeWithMe(this._commandService.registerCommand(command))})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}_initComponents(){[DocThreadCommentPanel].forEach(comp=>{this.disposeWithMe(this._componentManager.register(comp.componentKey,comp))}),this.disposeWithMe(this._componentManager.register("CommentSingle",CommentSingle))}},__name(_a2,"DocThreadCommentUIController"),_a2);DocThreadCommentUIController=__decorateClass$3([core.OnLifecycle(core.LifecycleStages.Rendered,DocThreadCommentUIController),__decorateParam$3(0,core.ICommandService),__decorateParam$3(1,ui.IMenuManagerService),__decorateParam$3(2,core.Inject(ui.ComponentManager))],DocThreadCommentUIController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a3;let DocThreadCommentSelectionController=(_a3=class extends core.Disposable{constructor(_threadCommentPanelService,_univerInstanceService,_commandService,_docThreadCommentService,_renderManagerService,_threadCommentModel){super(),this._threadCommentPanelService=_threadCommentPanelService,this._univerInstanceService=_univerInstanceService,this._commandService=_commandService,this._docThreadCommentService=_docThreadCommentService,this._renderManagerService=_renderManagerService,this._threadCommentModel=_threadCommentModel,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let lastSelection;this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{var _a6,_b,_c,_d;if(commandInfo.id===docs.SetTextSelectionsOperation.id){const params=commandInfo.params,{unitId,ranges}=params,doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),primary=ranges[0];if((lastSelection==null?void 0:lastSelection.startOffset)===(primary==null?void 0:primary.startOffset)&&(lastSelection==null?void 0:lastSelection.endOffset)===(primary==null?void 0:primary.endOffset))return;if(lastSelection=primary,primary&&doc){const{startOffset,endOffset,collapsed}=primary;let customRange;if(collapsed?customRange=(_b=(_a6=doc.getBody())==null?void 0:_a6.customDecorations)==null?void 0:_b.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1):customRange=(_d=(_c=doc.getBody())==null?void 0:_c.customDecorations)==null?void 0:_d.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1),customRange){const comment=this._threadCommentModel.getComment(unitId,DEFAULT_DOC_SUBUNIT_ID,customRange.id);comment&&!comment.resolved&&this._commandService.executeCommand(ShowCommentPanelOperation.id,{activeComment:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,commentId:customRange.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(activeComment=>{var _a6,_b,_c,_d;if(activeComment){const doc=this._univerInstanceService.getUnit(activeComment.unitId);if(doc){const backScrollController=(_a6=this._renderManagerService.getRenderById(activeComment.unitId))==null?void 0:_a6.with(docsUi.DocBackScrollRenderController),customRange=(_c=(_b=doc.getBody())==null?void 0:_b.customDecorations)==null?void 0:_c.find(range=>range.id===activeComment.commentId);customRange&&backScrollController&&backScrollController.scrollToRange({startOffset:customRange.startIndex,endOffset:customRange.endIndex,collapsed:!1})}}(!activeComment||activeComment.commentId!==((_d=this._docThreadCommentService.addingComment)==null?void 0:_d.id))&&this._docThreadCommentService.endAdd()}))}},__name(_a3,"DocThreadCommentSelectionController"),_a3);DocThreadCommentSelectionController=__decorateClass$2([core.OnLifecycle(core.LifecycleStages.Rendered,DocThreadCommentSelectionController),__decorateParam$2(0,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$2(1,core.IUniverInstanceService),__decorateParam$2(2,core.ICommandService),__decorateParam$2(3,core.Inject(DocThreadCommentService)),__decorateParam$2(4,engineRender.IRenderManagerService),__decorateParam$2(5,core.Inject(threadComment.ThreadCommentModel))],DocThreadCommentSelectionController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1"),_a4;let DocThreadCommentRenderController=(_a4=class extends core.Disposable{constructor(_context,_docInterceptorService,_threadCommentPanelService,_docRenderController,_univerInstanceService,_threadCommentModel){super(),this._context=_context,this._docInterceptorService=_docInterceptorService,this._threadCommentPanelService=_threadCommentPanelService,this._docRenderController=_docRenderController,this._univerInstanceService=_univerInstanceService,this._threadCommentModel=_threadCommentModel,this._interceptorViewModel(),this._initReRender()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(activeComment=>{var _a6;if(activeComment){this._docRenderController.reRender(activeComment.unitId);return}const unitId=(_a6=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a6.getUnitId();unitId&&this._docRenderController.reRender(unitId)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(update=>{update.type==="resolve"&&this._docRenderController.reRender(update.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(docs.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:__name((data,pos,next)=>{if(!data)return next(data);const{unitId,index,customDecorations}=pos,activeComment=this._threadCommentPanelService.activeCommentId,{commentId,unitId:commentUnitID}=activeComment||{},activeCustomDecoration=customDecorations.find(i=>i.id===commentId),comment=this._threadCommentModel.getComment(unitId,DEFAULT_DOC_SUBUNIT_ID,data.id);if(!comment)return next({...data,show:!1});const isActiveIndex=activeCustomDecoration&&index>=activeCustomDecoration.startIndex&&index<=activeCustomDecoration.endIndex,isActive=commentUnitID===unitId&&data.id===commentId;return next({...data,active:isActive||isActiveIndex,show:!comment.resolved})},"handler")})}},__name(_a4,"DocThreadCommentRenderController"),_a4);DocThreadCommentRenderController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,DocThreadCommentRenderController),__decorateParam$1(1,core.Inject(docs.DocInterceptorService)),__decorateParam$1(2,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$1(3,core.Inject(docsUi.DocRenderController)),__decorateParam$1(4,core.IUniverInstanceService),__decorateParam$1(5,core.Inject(threadComment.ThreadCommentModel))],DocThreadCommentRenderController);const PLUGIN_CONFIG_KEY="docs-thread-comment-ui.config",defaultPluginConfig={};var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField"),_a5;exports.UniverDocsThreadCommentUIPlugin=(_a5=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_renderManagerSrv,_configService){super(),this._config=_config,this._injector=_injector,this._renderManagerSrv=_renderManagerSrv,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocThreadCommentUIController],[DocThreadCommentSelectionController],[DocThreadCommentService]].forEach(dep=>{this._injector.add(dep)})}onRendered(){this._initRenderModule()}_initRenderModule(){[DocThreadCommentRenderController].forEach(dep=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,dep)})}},__name(_a5,"UniverDocsThreadCommentUIPlugin"),_a5);__publicField2(exports.UniverDocsThreadCommentUIPlugin,"pluginName",PLUGIN_NAME);__publicField2(exports.UniverDocsThreadCommentUIPlugin,"type",core.UniverInstanceType.UNIVER_DOC);exports.UniverDocsThreadCommentUIPlugin=__decorateClass([core.DependentOn(threadCommentUi.UniverThreadCommentUIPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService),__decorateParam(3,core.IConfigService)],exports.UniverDocsThreadCommentUIPlugin);exports.AddDocCommentComment=AddDocCommentComment;exports.DeleteDocCommentComment=DeleteDocCommentComment;exports.ShowCommentPanelOperation=ShowCommentPanelOperation;exports.StartAddCommentOperation=StartAddCommentOperation;
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),engineRender=require("@univerjs/engine-render"),threadCommentUi=require("@univerjs/thread-comment-ui"),docs=require("@univerjs/docs"),docsUi=require("@univerjs/docs-ui"),threadComment=require("@univerjs/thread-comment"),ui=require("@univerjs/ui"),rxjs=require("rxjs"),React=require("react"),PLUGIN_NAME="DOC_THREAD_COMMENT_UI_PLUGIN",DEFAULT_DOC_SUBUNIT_ID="default_doc",PLUGIN_CONFIG_KEY="docs-thread-comment-ui.config",defaultPluginConfig={};var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4"),_a;let DocThreadCommentService=(_a=class extends core.Disposable{constructor(_sidebarService,_threadCommentPanelService){super();__publicField(this,"_addingComment$",new rxjs.BehaviorSubject(void 0));__publicField(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=_sidebarService,this._threadCommentPanelService=_threadCommentPanelService,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(comment){this._addingComment$.next(comment)}endAdd(){this._addingComment$.next(void 0)}},__name(_a,"DocThreadCommentService"),_a);DocThreadCommentService=__decorateClass$4([__decorateParam$4(0,ui.ISidebarService),__decorateParam$4(1,core.Inject(threadCommentUi.ThreadCommentPanelService))],DocThreadCommentService);const AddDocCommentComment={id:"docs.command.add-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{comment:originComment,unitId}=params,comment=await accessor.get(threadComment.IThreadCommentDataSourceService).addComment(originComment),commandService=accessor.get(core.ICommandService),doMutation=docsUi.addCustomDecorationBySelectionFactory(accessor,{id:comment.id,type:core.CustomDecorationType.COMMENT});if(doMutation){const addComment={id:threadComment.AddCommentMutation.id,params:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,comment}},activeOperation={id:threadCommentUi.SetActiveCommentOperation.id,params:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,commentId:comment.id}};return(await core.sequenceExecuteAsync([addComment,doMutation,activeOperation],commandService)).result}return!1}},DeleteDocCommentComment={id:"docs.command.delete-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{commentId,unitId}=params,commandService=accessor.get(core.ICommandService),doMutation=docsUi.deleteCustomDecorationFactory(accessor,{id:commentId,unitId});return doMutation?(await core.sequenceExecute([doMutation],commandService)).result:!1}},shouldDisableAddComment=__name(accessor=>{const renderManagerService=accessor.get(engineRender.IRenderManagerService),docSelectionManagerService=accessor.get(docs.DocSelectionManagerService),render2=renderManagerService.getCurrent(),skeleton=render2==null?void 0:render2.with(docs.DocSkeletonManagerService).getSkeleton(),editArea=skeleton==null?void 0:skeleton.getViewModel().getEditArea();if(editArea===engineRender.DocumentEditArea.FOOTER||editArea===engineRender.DocumentEditArea.HEADER)return!0;const range=docSelectionManagerService.getActiveTextRange();return!!(range==null||range.collapsed)},"shouldDisableAddComment");function AddDocCommentMenuItemFactory(accessor){return{id:StartAddCommentOperation.id,type:ui.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC),disabled$:new rxjs.Observable(function(subscribe){const observer=accessor.get(docs.DocSelectionManagerService).textSelection$.pipe(rxjs.debounceTime(16)).subscribe(()=>{subscribe.next(shouldDisableAddComment(accessor))});return()=>{observer.unsubscribe()}})}}__name(AddDocCommentMenuItemFactory,"AddDocCommentMenuItemFactory");function ToolbarDocCommentMenuItemFactory(accessor){return{id:ToggleCommentPanelOperation.id,type:ui.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC)}}__name(ToolbarDocCommentMenuItemFactory,"ToolbarDocCommentMenuItemFactory");const DocThreadCommentPanel=__name(()=>{const univerInstanceService=core.useDependency(core.IUniverInstanceService),injector=core.useDependency(core.Injector),doc$=React.useMemo(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_DOC),[univerInstanceService]),doc=core.useObservable(doc$),subUnitId$=React.useMemo(()=>new rxjs.Observable(sub=>sub.next(DEFAULT_DOC_SUBUNIT_ID)),[]),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),selectionChange$=React.useMemo(()=>docSelectionManagerService.textSelection$.pipe(rxjs.debounceTime(16)),[docSelectionManagerService.textSelection$]);core.useObservable(selectionChange$);const commandService=core.useDependency(core.ICommandService),docCommentService=core.useDependency(DocThreadCommentService),tempComment=core.useObservable(docCommentService.addingComment$),[commentIds,setCommentIds]=React.useState([]);if(React.useEffect(()=>{var _a6;const set=new Set,customRanges=doc==null?void 0:doc.getCustomDecorations();setCommentIds((_a6=customRanges==null?void 0:customRanges.map(r=>r.id).filter(i=>{const hasRepeat=set.has(i);return set.add(i),!hasRepeat}))!=null?_a6:[]);const dispose=commandService.onCommandExecuted(command=>{var _a7;if(command.id===docs.RichTextEditingMutation.id){const set2=new Set,customRanges2=doc==null?void 0:doc.getCustomDecorations();setCommentIds((_a7=customRanges2==null?void 0:customRanges2.map(r=>r.id).filter(i=>{const hasRepeat=set2.has(i);return set2.add(i),!hasRepeat}))!=null?_a7:[])}});return()=>{dispose.dispose()}},[commandService,doc]),!doc)return null;const isInValidSelection=shouldDisableAddComment(injector),unitId=doc.getUnitId();return React.createElement(threadCommentUi.ThreadCommentPanel,{unitId,subUnitId$,type:core.UniverInstanceType.UNIVER_DOC,onAdd:__name(()=>{commandService.executeCommand(StartAddCommentOperation.id)},"onAdd"),getSubUnitName:__name(()=>"","getSubUnitName"),disableAdd:isInValidSelection,tempComment,onAddComment:__name(comment=>{if(!comment.parentId){const params={unitId,range:tempComment,comment};return commandService.executeCommand(AddDocCommentComment.id,params),docCommentService.endAdd(),!1}return!0},"onAddComment"),onDeleteComment:__name(comment=>{if(!comment.parentId){const params={unitId,commentId:comment.id};return commandService.executeCommand(DeleteDocCommentComment.id,params),!1}return!0},"onDeleteComment"),showComments:commentIds})},"DocThreadCommentPanel");DocThreadCommentPanel.componentKey="univer.doc.thread-comment-panel";const ShowCommentPanelOperation={id:"docs.operation.show-comment-panel",type:core.CommandType.OPERATION,handler(accessor,params){var _a6;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),sidebarService=accessor.get(ui.ISidebarService);return(!panelService.panelVisible||((_a6=sidebarService.options.children)==null?void 0:_a6.label)!==DocThreadCommentPanel.componentKey)&&(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:DocThreadCommentPanel.componentKey},width:320,onClose:__name(()=>panelService.setPanelVisible(!1),"onClose")}),panelService.setPanelVisible(!0)),params&&panelService.setActiveComment(params==null?void 0:params.activeComment),!0}},ToggleCommentPanelOperation={id:"docs.operation.toggle-comment-panel",type:core.CommandType.OPERATION,handler(accessor){var _a6;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),sidebarService=accessor.get(ui.ISidebarService);return!panelService.panelVisible||((_a6=sidebarService.options.children)==null?void 0:_a6.label)!==DocThreadCommentPanel.componentKey?(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:DocThreadCommentPanel.componentKey},width:320,onClose:__name(()=>panelService.setPanelVisible(!1),"onClose")}),panelService.setPanelVisible(!0)):(sidebarService.close(),panelService.setPanelVisible(!1),panelService.setActiveComment(null)),!0}},StartAddCommentOperation={id:"docs.operation.start-add-comment",type:core.CommandType.OPERATION,handler(accessor){var _a6,_b,_c;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),doc=accessor.get(core.IUniverInstanceService).getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC),docSelectionManagerService=accessor.get(docs.DocSelectionManagerService),renderManagerService=accessor.get(engineRender.IRenderManagerService),userManagerService=accessor.get(core.UserManagerService),docCommentService=accessor.get(DocThreadCommentService),commandService=accessor.get(core.ICommandService),sidebarService=accessor.get(ui.ISidebarService),textRange=docSelectionManagerService.getActiveTextRange();if(!doc||!textRange)return!1;const docSelectionRenderManager=(_a6=renderManagerService.getRenderById(doc.getUnitId()))==null?void 0:_a6.with(docsUi.DocSelectionRenderService);if(textRange.collapsed)return panelService.panelVisible?(panelService.setPanelVisible(!1),sidebarService.close()):commandService.executeCommand(ShowCommentPanelOperation.id),!0;commandService.executeCommand(ShowCommentPanelOperation.id);const unitId=doc.getUnitId(),dataStream=((_c=(_b=doc.getBody())==null?void 0:_b.dataStream)!=null?_c:"").slice(textRange.startOffset,textRange.endOffset),text=core.BuildTextUtils.transform.getPlainText(dataStream),subUnitId=DEFAULT_DOC_SUBUNIT_ID,commentId="",comment={unitId,subUnitId,id:commentId,ref:text,dT:threadCommentUi.getDT(),personId:userManagerService.getCurrentUser().userID,text:{dataStream:`\r
|
|
2
|
+
`},startOffset:textRange.startOffset,endOffset:textRange.endOffset,collapsed:!0,threadId:commentId};return docSelectionRenderManager==null||docSelectionRenderManager.blurEditor(),docCommentService.startAdd(comment),panelService.setActiveComment({unitId,subUnitId,commentId}),!0}};var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3"),_a2;let DocThreadCommentSelectionController=(_a2=class extends core.Disposable{constructor(_threadCommentPanelService,_univerInstanceService,_commandService,_docThreadCommentService,_renderManagerService,_threadCommentModel){super(),this._threadCommentPanelService=_threadCommentPanelService,this._univerInstanceService=_univerInstanceService,this._commandService=_commandService,this._docThreadCommentService=_docThreadCommentService,this._renderManagerService=_renderManagerService,this._threadCommentModel=_threadCommentModel,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let lastSelection;this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{var _a6,_b,_c,_d;if(commandInfo.id===docs.SetTextSelectionsOperation.id){const params=commandInfo.params,{unitId,ranges}=params,doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),primary=ranges[0];if((lastSelection==null?void 0:lastSelection.startOffset)===(primary==null?void 0:primary.startOffset)&&(lastSelection==null?void 0:lastSelection.endOffset)===(primary==null?void 0:primary.endOffset))return;if(lastSelection=primary,primary&&doc){const{startOffset,endOffset,collapsed}=primary;let customRange;if(collapsed?customRange=(_b=(_a6=doc.getBody())==null?void 0:_a6.customDecorations)==null?void 0:_b.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1):customRange=(_d=(_c=doc.getBody())==null?void 0:_c.customDecorations)==null?void 0:_d.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1),customRange){const comment=this._threadCommentModel.getComment(unitId,DEFAULT_DOC_SUBUNIT_ID,customRange.id);comment&&!comment.resolved&&this._commandService.executeCommand(ShowCommentPanelOperation.id,{activeComment:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,commentId:customRange.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(activeComment=>{var _a6,_b,_c,_d;if(activeComment){const doc=this._univerInstanceService.getUnit(activeComment.unitId);if(doc){const backScrollController=(_a6=this._renderManagerService.getRenderById(activeComment.unitId))==null?void 0:_a6.with(docsUi.DocBackScrollRenderController),customRange=(_c=(_b=doc.getBody())==null?void 0:_b.customDecorations)==null?void 0:_c.find(range=>range.id===activeComment.commentId);customRange&&backScrollController&&backScrollController.scrollToRange({startOffset:customRange.startIndex,endOffset:customRange.endIndex,collapsed:!1})}}(!activeComment||activeComment.commentId!==((_d=this._docThreadCommentService.addingComment)==null?void 0:_d.id))&&this._docThreadCommentService.endAdd()}))}},__name(_a2,"DocThreadCommentSelectionController"),_a2);DocThreadCommentSelectionController=__decorateClass$3([__decorateParam$3(0,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$3(1,core.IUniverInstanceService),__decorateParam$3(2,core.ICommandService),__decorateParam$3(3,core.Inject(DocThreadCommentService)),__decorateParam$3(4,engineRender.IRenderManagerService),__decorateParam$3(5,core.Inject(threadComment.ThreadCommentModel))],DocThreadCommentSelectionController);var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a6){var key=_a6[0],value=_a6[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a6,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a6=node.children)===null||_a6===void 0)&&_a6.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element={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"}}]},CommentSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"comment-single",ref,icon:element}))});CommentSingle.displayName="CommentSingle";const menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ToggleCommentPanelOperation.id]:{order:1,menuItemFactory:ToolbarDocCommentMenuItemFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.DATA]:{[StartAddCommentOperation.id]:{order:1,menuItemFactory:AddDocCommentMenuItemFactory}}}};var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a3;let DocThreadCommentUIController=(_a3=class extends core.Disposable{constructor(_commandService,_menuManagerService,_componentManager){super(),this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._componentManager=_componentManager,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[AddDocCommentComment,DeleteDocCommentComment,ShowCommentPanelOperation,StartAddCommentOperation,ToggleCommentPanelOperation].forEach(command=>{this.disposeWithMe(this._commandService.registerCommand(command))})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}_initComponents(){[DocThreadCommentPanel].forEach(comp=>{this.disposeWithMe(this._componentManager.register(comp.componentKey,comp))}),this.disposeWithMe(this._componentManager.register("CommentSingle",CommentSingle))}},__name(_a3,"DocThreadCommentUIController"),_a3);DocThreadCommentUIController=__decorateClass$2([__decorateParam$2(0,core.ICommandService),__decorateParam$2(1,ui.IMenuManagerService),__decorateParam$2(2,core.Inject(ui.ComponentManager))],DocThreadCommentUIController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1"),_a4;let DocThreadCommentRenderController=(_a4=class extends core.Disposable{constructor(_context,_docInterceptorService,_threadCommentPanelService,_docRenderController,_univerInstanceService,_threadCommentModel){super(),this._context=_context,this._docInterceptorService=_docInterceptorService,this._threadCommentPanelService=_threadCommentPanelService,this._docRenderController=_docRenderController,this._univerInstanceService=_univerInstanceService,this._threadCommentModel=_threadCommentModel,this._interceptorViewModel(),this._initReRender()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(activeComment=>{var _a6;if(activeComment){this._docRenderController.reRender(activeComment.unitId);return}const unitId=(_a6=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a6.getUnitId();unitId&&this._docRenderController.reRender(unitId)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(update=>{update.type==="resolve"&&this._docRenderController.reRender(update.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(docs.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:__name((data,pos,next)=>{if(!data)return next(data);const{unitId,index,customDecorations}=pos,activeComment=this._threadCommentPanelService.activeCommentId,{commentId,unitId:commentUnitID}=activeComment||{},activeCustomDecoration=customDecorations.find(i=>i.id===commentId),comment=this._threadCommentModel.getComment(unitId,DEFAULT_DOC_SUBUNIT_ID,data.id);if(!comment)return next({...data,show:!1});const isActiveIndex=activeCustomDecoration&&index>=activeCustomDecoration.startIndex&&index<=activeCustomDecoration.endIndex,isActive=commentUnitID===unitId&&data.id===commentId;return next({...data,active:isActive||isActiveIndex,show:!comment.resolved})},"handler")})}},__name(_a4,"DocThreadCommentRenderController"),_a4);DocThreadCommentRenderController=__decorateClass$1([__decorateParam$1(1,core.Inject(docs.DocInterceptorService)),__decorateParam$1(2,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$1(3,core.Inject(docsUi.DocRenderController)),__decorateParam$1(4,core.IUniverInstanceService),__decorateParam$1(5,core.Inject(threadComment.ThreadCommentModel))],DocThreadCommentRenderController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField"),_a5;exports.UniverDocsThreadCommentUIPlugin=(_a5=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_renderManagerSrv,_configService){super(),this._config=_config,this._injector=_injector,this._renderManagerSrv=_renderManagerSrv,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocThreadCommentUIController],[DocThreadCommentSelectionController],[DocThreadCommentService]].forEach(dep=>{this._injector.add(dep)})}onRendered(){this._initRenderModule(),this._injector.get(DocThreadCommentSelectionController),this._injector.get(DocThreadCommentUIController)}_initRenderModule(){[DocThreadCommentRenderController].forEach(dep=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,dep)})}},__name(_a5,"UniverDocsThreadCommentUIPlugin"),_a5);__publicField2(exports.UniverDocsThreadCommentUIPlugin,"pluginName",PLUGIN_NAME);__publicField2(exports.UniverDocsThreadCommentUIPlugin,"type",core.UniverInstanceType.UNIVER_DOC);exports.UniverDocsThreadCommentUIPlugin=__decorateClass([core.DependentOn(threadCommentUi.UniverThreadCommentUIPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService),__decorateParam(3,core.IConfigService)],exports.UniverDocsThreadCommentUIPlugin);exports.AddDocCommentComment=AddDocCommentComment;exports.DeleteDocCommentComment=DeleteDocCommentComment;exports.ShowCommentPanelOperation=ShowCommentPanelOperation;exports.StartAddCommentOperation=StartAddCommentOperation;
|
package/lib/es/index.js
CHANGED
|
@@ -2,71 +2,44 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { CommandType, ICommandService, CustomDecorationType, sequenceExecuteAsync, sequenceExecute,
|
|
6
|
-
import { SetActiveCommentOperation, ThreadCommentPanelService, getDT, ThreadCommentPanel, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
|
|
5
|
+
import { Inject, Disposable, CommandType, ICommandService, CustomDecorationType, sequenceExecuteAsync, sequenceExecute, UniverInstanceType, useDependency, IUniverInstanceService, Injector, useObservable, UserManagerService, BuildTextUtils, DependentOn, Plugin, IConfigService } from "@univerjs/core";
|
|
7
6
|
import { IRenderManagerService, DocumentEditArea } from "@univerjs/engine-render";
|
|
8
|
-
import {
|
|
7
|
+
import { ThreadCommentPanelService, SetActiveCommentOperation, ThreadCommentPanel, getDT, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
|
|
8
|
+
import { DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, SetTextSelectionsOperation, DocInterceptorService, DOC_INTERCEPTOR_POINT } from "@univerjs/docs";
|
|
9
9
|
import { addCustomDecorationBySelectionFactory, deleteCustomDecorationFactory, DocSelectionRenderService, DocBackScrollRenderController, DocRenderController } from "@univerjs/docs-ui";
|
|
10
10
|
import { IThreadCommentDataSourceService, AddCommentMutation, ThreadCommentModel } from "@univerjs/thread-comment";
|
|
11
|
-
import {
|
|
12
|
-
import React, { forwardRef, useRef, createElement, useMemo, useState, useEffect } from "react";
|
|
11
|
+
import { ISidebarService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IMenuManagerService } from "@univerjs/ui";
|
|
13
12
|
import { BehaviorSubject, Observable, debounceTime } from "rxjs";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
__name(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a6) {
|
|
45
|
-
var key = _a6[0], value = _a6[1];
|
|
46
|
-
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
47
|
-
})), attrs;
|
|
48
|
-
}
|
|
49
|
-
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
50
|
-
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
51
|
-
var _a6, defIds = runtimeProps.defIds;
|
|
52
|
-
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a6 = node.children) === null || _a6 === void 0) && _a6.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
53
|
-
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
54
|
-
}) }) : node;
|
|
55
|
-
}
|
|
56
|
-
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
57
|
-
function generateShortUuid() {
|
|
58
|
-
return Math.random().toString(36).substring(2, 8);
|
|
59
|
-
}
|
|
60
|
-
__name(generateShortUuid, "generateShortUuid");
|
|
61
|
-
IconBase.displayName = "UniverIcon";
|
|
62
|
-
var element = { 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" } }] }, CommentSingle = forwardRef(function(props, ref) {
|
|
63
|
-
return createElement(IconBase, Object.assign({}, props, {
|
|
64
|
-
id: "comment-single",
|
|
65
|
-
ref,
|
|
66
|
-
icon: element
|
|
67
|
-
}));
|
|
68
|
-
});
|
|
69
|
-
CommentSingle.displayName = "CommentSingle";
|
|
13
|
+
import React, { useMemo, useState, useEffect, forwardRef, useRef, createElement } from "react";
|
|
14
|
+
const PLUGIN_NAME = "DOC_THREAD_COMMENT_UI_PLUGIN", DEFAULT_DOC_SUBUNIT_ID = "default_doc", PLUGIN_CONFIG_KEY = "docs-thread-comment-ui.config", defaultPluginConfig = {};
|
|
15
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
16
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
17
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
18
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
19
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a;
|
|
20
|
+
let DocThreadCommentService = (_a = class extends Disposable {
|
|
21
|
+
constructor(_sidebarService, _threadCommentPanelService) {
|
|
22
|
+
super();
|
|
23
|
+
__publicField(this, "_addingComment$", new BehaviorSubject(void 0));
|
|
24
|
+
__publicField(this, "addingComment$", this._addingComment$.asObservable());
|
|
25
|
+
this._sidebarService = _sidebarService, this._threadCommentPanelService = _threadCommentPanelService, this.disposeWithMe(() => {
|
|
26
|
+
this._addingComment$.complete();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
get addingComment() {
|
|
30
|
+
return this._addingComment$.getValue();
|
|
31
|
+
}
|
|
32
|
+
startAdd(comment) {
|
|
33
|
+
this._addingComment$.next(comment);
|
|
34
|
+
}
|
|
35
|
+
endAdd() {
|
|
36
|
+
this._addingComment$.next(void 0);
|
|
37
|
+
}
|
|
38
|
+
}, __name(_a, "DocThreadCommentService"), _a);
|
|
39
|
+
DocThreadCommentService = __decorateClass$4([
|
|
40
|
+
__decorateParam$4(0, ISidebarService),
|
|
41
|
+
__decorateParam$4(1, Inject(ThreadCommentPanelService))
|
|
42
|
+
], DocThreadCommentService);
|
|
70
43
|
const AddDocCommentComment = {
|
|
71
44
|
id: "docs.command.add-comment",
|
|
72
45
|
type: CommandType.COMMAND,
|
|
@@ -112,95 +85,6 @@ const AddDocCommentComment = {
|
|
|
112
85
|
});
|
|
113
86
|
return doMutation ? (await sequenceExecute([doMutation], commandService)).result : !1;
|
|
114
87
|
}
|
|
115
|
-
};
|
|
116
|
-
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
117
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
118
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
119
|
-
return kind && result && __defProp$4(target, key, result), result;
|
|
120
|
-
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a;
|
|
121
|
-
let DocThreadCommentService = (_a = class extends Disposable {
|
|
122
|
-
constructor(_sidebarService, _threadCommentPanelService) {
|
|
123
|
-
super();
|
|
124
|
-
__publicField(this, "_addingComment$", new BehaviorSubject(void 0));
|
|
125
|
-
__publicField(this, "addingComment$", this._addingComment$.asObservable());
|
|
126
|
-
this._sidebarService = _sidebarService, this._threadCommentPanelService = _threadCommentPanelService, this.disposeWithMe(() => {
|
|
127
|
-
this._addingComment$.complete();
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
get addingComment() {
|
|
131
|
-
return this._addingComment$.getValue();
|
|
132
|
-
}
|
|
133
|
-
startAdd(comment) {
|
|
134
|
-
this._addingComment$.next(comment);
|
|
135
|
-
}
|
|
136
|
-
endAdd() {
|
|
137
|
-
this._addingComment$.next(void 0);
|
|
138
|
-
}
|
|
139
|
-
}, __name(_a, "DocThreadCommentService"), _a);
|
|
140
|
-
DocThreadCommentService = __decorateClass$4([
|
|
141
|
-
__decorateParam$4(0, ISidebarService),
|
|
142
|
-
__decorateParam$4(1, Inject(ThreadCommentPanelService))
|
|
143
|
-
], DocThreadCommentService);
|
|
144
|
-
const ShowCommentPanelOperation = {
|
|
145
|
-
id: "docs.operation.show-comment-panel",
|
|
146
|
-
type: CommandType.OPERATION,
|
|
147
|
-
handler(accessor, params) {
|
|
148
|
-
var _a6;
|
|
149
|
-
const panelService = accessor.get(ThreadCommentPanelService), sidebarService = accessor.get(ISidebarService);
|
|
150
|
-
return (!panelService.panelVisible || ((_a6 = sidebarService.options.children) == null ? void 0 : _a6.label) !== DocThreadCommentPanel.componentKey) && (sidebarService.open({
|
|
151
|
-
header: { title: "threadCommentUI.panel.title" },
|
|
152
|
-
children: { label: DocThreadCommentPanel.componentKey },
|
|
153
|
-
width: 320,
|
|
154
|
-
onClose: /* @__PURE__ */ __name(() => panelService.setPanelVisible(!1), "onClose")
|
|
155
|
-
}), panelService.setPanelVisible(!0)), params && panelService.setActiveComment(params == null ? void 0 : params.activeComment), !0;
|
|
156
|
-
}
|
|
157
|
-
}, ToggleCommentPanelOperation = {
|
|
158
|
-
id: "docs.operation.toggle-comment-panel",
|
|
159
|
-
type: CommandType.OPERATION,
|
|
160
|
-
handler(accessor) {
|
|
161
|
-
var _a6;
|
|
162
|
-
const panelService = accessor.get(ThreadCommentPanelService), sidebarService = accessor.get(ISidebarService);
|
|
163
|
-
return !panelService.panelVisible || ((_a6 = sidebarService.options.children) == null ? void 0 : _a6.label) !== DocThreadCommentPanel.componentKey ? (sidebarService.open({
|
|
164
|
-
header: { title: "threadCommentUI.panel.title" },
|
|
165
|
-
children: { label: DocThreadCommentPanel.componentKey },
|
|
166
|
-
width: 320,
|
|
167
|
-
onClose: /* @__PURE__ */ __name(() => panelService.setPanelVisible(!1), "onClose")
|
|
168
|
-
}), panelService.setPanelVisible(!0)) : (sidebarService.close(), panelService.setPanelVisible(!1), panelService.setActiveComment(null)), !0;
|
|
169
|
-
}
|
|
170
|
-
}, StartAddCommentOperation = {
|
|
171
|
-
id: "docs.operation.start-add-comment",
|
|
172
|
-
type: CommandType.OPERATION,
|
|
173
|
-
handler(accessor) {
|
|
174
|
-
var _a6, _b, _c;
|
|
175
|
-
const panelService = accessor.get(ThreadCommentPanelService), doc = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docSelectionManagerService = accessor.get(DocSelectionManagerService), renderManagerService = accessor.get(IRenderManagerService), userManagerService = accessor.get(UserManagerService), docCommentService = accessor.get(DocThreadCommentService), commandService = accessor.get(ICommandService), sidebarService = accessor.get(ISidebarService), textRange = docSelectionManagerService.getActiveTextRange();
|
|
176
|
-
if (!doc || !textRange)
|
|
177
|
-
return !1;
|
|
178
|
-
const docSelectionRenderManager = (_a6 = renderManagerService.getRenderById(doc.getUnitId())) == null ? void 0 : _a6.with(DocSelectionRenderService);
|
|
179
|
-
if (textRange.collapsed)
|
|
180
|
-
return panelService.panelVisible ? (panelService.setPanelVisible(!1), sidebarService.close()) : commandService.executeCommand(ShowCommentPanelOperation.id), !0;
|
|
181
|
-
commandService.executeCommand(ShowCommentPanelOperation.id);
|
|
182
|
-
const unitId = doc.getUnitId(), dataStream = ((_c = (_b = doc.getBody()) == null ? void 0 : _b.dataStream) != null ? _c : "").slice(textRange.startOffset, textRange.endOffset), text = BuildTextUtils.transform.getPlainText(dataStream), subUnitId = DEFAULT_DOC_SUBUNIT_ID, commentId = "", comment = {
|
|
183
|
-
unitId,
|
|
184
|
-
subUnitId,
|
|
185
|
-
id: commentId,
|
|
186
|
-
ref: text,
|
|
187
|
-
dT: getDT(),
|
|
188
|
-
personId: userManagerService.getCurrentUser().userID,
|
|
189
|
-
text: {
|
|
190
|
-
dataStream: `\r
|
|
191
|
-
`
|
|
192
|
-
},
|
|
193
|
-
startOffset: textRange.startOffset,
|
|
194
|
-
endOffset: textRange.endOffset,
|
|
195
|
-
collapsed: !0,
|
|
196
|
-
threadId: commentId
|
|
197
|
-
};
|
|
198
|
-
return docSelectionRenderManager == null || docSelectionRenderManager.blurEditor(), docCommentService.startAdd(comment), panelService.setActiveComment({
|
|
199
|
-
unitId,
|
|
200
|
-
subUnitId,
|
|
201
|
-
commentId
|
|
202
|
-
}), !0;
|
|
203
|
-
}
|
|
204
88
|
}, shouldDisableAddComment = /* @__PURE__ */ __name((accessor) => {
|
|
205
89
|
const renderManagerService = accessor.get(IRenderManagerService), docSelectionManagerService = accessor.get(DocSelectionManagerService), render2 = renderManagerService.getCurrent(), skeleton = render2 == null ? void 0 : render2.with(DocSkeletonManagerService).getSkeleton(), editArea = skeleton == null ? void 0 : skeleton.getViewModel().getEditArea();
|
|
206
90
|
if (editArea === DocumentEditArea.FOOTER || editArea === DocumentEditArea.HEADER)
|
|
@@ -306,20 +190,65 @@ const DocThreadCommentPanel = /* @__PURE__ */ __name(() => {
|
|
|
306
190
|
);
|
|
307
191
|
}, "DocThreadCommentPanel");
|
|
308
192
|
DocThreadCommentPanel.componentKey = "univer.doc.thread-comment-panel";
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
193
|
+
const ShowCommentPanelOperation = {
|
|
194
|
+
id: "docs.operation.show-comment-panel",
|
|
195
|
+
type: CommandType.OPERATION,
|
|
196
|
+
handler(accessor, params) {
|
|
197
|
+
var _a6;
|
|
198
|
+
const panelService = accessor.get(ThreadCommentPanelService), sidebarService = accessor.get(ISidebarService);
|
|
199
|
+
return (!panelService.panelVisible || ((_a6 = sidebarService.options.children) == null ? void 0 : _a6.label) !== DocThreadCommentPanel.componentKey) && (sidebarService.open({
|
|
200
|
+
header: { title: "threadCommentUI.panel.title" },
|
|
201
|
+
children: { label: DocThreadCommentPanel.componentKey },
|
|
202
|
+
width: 320,
|
|
203
|
+
onClose: /* @__PURE__ */ __name(() => panelService.setPanelVisible(!1), "onClose")
|
|
204
|
+
}), panelService.setPanelVisible(!0)), params && panelService.setActiveComment(params == null ? void 0 : params.activeComment), !0;
|
|
205
|
+
}
|
|
206
|
+
}, ToggleCommentPanelOperation = {
|
|
207
|
+
id: "docs.operation.toggle-comment-panel",
|
|
208
|
+
type: CommandType.OPERATION,
|
|
209
|
+
handler(accessor) {
|
|
210
|
+
var _a6;
|
|
211
|
+
const panelService = accessor.get(ThreadCommentPanelService), sidebarService = accessor.get(ISidebarService);
|
|
212
|
+
return !panelService.panelVisible || ((_a6 = sidebarService.options.children) == null ? void 0 : _a6.label) !== DocThreadCommentPanel.componentKey ? (sidebarService.open({
|
|
213
|
+
header: { title: "threadCommentUI.panel.title" },
|
|
214
|
+
children: { label: DocThreadCommentPanel.componentKey },
|
|
215
|
+
width: 320,
|
|
216
|
+
onClose: /* @__PURE__ */ __name(() => panelService.setPanelVisible(!1), "onClose")
|
|
217
|
+
}), panelService.setPanelVisible(!0)) : (sidebarService.close(), panelService.setPanelVisible(!1), panelService.setActiveComment(null)), !0;
|
|
218
|
+
}
|
|
219
|
+
}, StartAddCommentOperation = {
|
|
220
|
+
id: "docs.operation.start-add-comment",
|
|
221
|
+
type: CommandType.OPERATION,
|
|
222
|
+
handler(accessor) {
|
|
223
|
+
var _a6, _b, _c;
|
|
224
|
+
const panelService = accessor.get(ThreadCommentPanelService), doc = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docSelectionManagerService = accessor.get(DocSelectionManagerService), renderManagerService = accessor.get(IRenderManagerService), userManagerService = accessor.get(UserManagerService), docCommentService = accessor.get(DocThreadCommentService), commandService = accessor.get(ICommandService), sidebarService = accessor.get(ISidebarService), textRange = docSelectionManagerService.getActiveTextRange();
|
|
225
|
+
if (!doc || !textRange)
|
|
226
|
+
return !1;
|
|
227
|
+
const docSelectionRenderManager = (_a6 = renderManagerService.getRenderById(doc.getUnitId())) == null ? void 0 : _a6.with(DocSelectionRenderService);
|
|
228
|
+
if (textRange.collapsed)
|
|
229
|
+
return panelService.panelVisible ? (panelService.setPanelVisible(!1), sidebarService.close()) : commandService.executeCommand(ShowCommentPanelOperation.id), !0;
|
|
230
|
+
commandService.executeCommand(ShowCommentPanelOperation.id);
|
|
231
|
+
const unitId = doc.getUnitId(), dataStream = ((_c = (_b = doc.getBody()) == null ? void 0 : _b.dataStream) != null ? _c : "").slice(textRange.startOffset, textRange.endOffset), text = BuildTextUtils.transform.getPlainText(dataStream), subUnitId = DEFAULT_DOC_SUBUNIT_ID, commentId = "", comment = {
|
|
232
|
+
unitId,
|
|
233
|
+
subUnitId,
|
|
234
|
+
id: commentId,
|
|
235
|
+
ref: text,
|
|
236
|
+
dT: getDT(),
|
|
237
|
+
personId: userManagerService.getCurrentUser().userID,
|
|
238
|
+
text: {
|
|
239
|
+
dataStream: `\r
|
|
240
|
+
`
|
|
241
|
+
},
|
|
242
|
+
startOffset: textRange.startOffset,
|
|
243
|
+
endOffset: textRange.endOffset,
|
|
244
|
+
collapsed: !0,
|
|
245
|
+
threadId: commentId
|
|
246
|
+
};
|
|
247
|
+
return docSelectionRenderManager == null || docSelectionRenderManager.blurEditor(), docCommentService.startAdd(comment), panelService.setActiveComment({
|
|
248
|
+
unitId,
|
|
249
|
+
subUnitId,
|
|
250
|
+
commentId
|
|
251
|
+
}), !0;
|
|
323
252
|
}
|
|
324
253
|
};
|
|
325
254
|
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
@@ -327,42 +256,7 @@ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPrope
|
|
|
327
256
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
328
257
|
return kind && result && __defProp$3(target, key, result), result;
|
|
329
258
|
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a2;
|
|
330
|
-
let
|
|
331
|
-
constructor(_commandService, _menuManagerService, _componentManager) {
|
|
332
|
-
super(), this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._componentManager = _componentManager, this._initCommands(), this._initMenus(), this._initComponents();
|
|
333
|
-
}
|
|
334
|
-
_initCommands() {
|
|
335
|
-
[
|
|
336
|
-
AddDocCommentComment,
|
|
337
|
-
DeleteDocCommentComment,
|
|
338
|
-
ShowCommentPanelOperation,
|
|
339
|
-
StartAddCommentOperation,
|
|
340
|
-
ToggleCommentPanelOperation
|
|
341
|
-
].forEach((command) => {
|
|
342
|
-
this.disposeWithMe(this._commandService.registerCommand(command));
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
_initMenus() {
|
|
346
|
-
this._menuManagerService.mergeMenu(menuSchema);
|
|
347
|
-
}
|
|
348
|
-
_initComponents() {
|
|
349
|
-
[DocThreadCommentPanel].forEach((comp) => {
|
|
350
|
-
this.disposeWithMe(this._componentManager.register(comp.componentKey, comp));
|
|
351
|
-
}), this.disposeWithMe(this._componentManager.register("CommentSingle", CommentSingle));
|
|
352
|
-
}
|
|
353
|
-
}, __name(_a2, "DocThreadCommentUIController"), _a2);
|
|
354
|
-
DocThreadCommentUIController = __decorateClass$3([
|
|
355
|
-
OnLifecycle(LifecycleStages.Rendered, DocThreadCommentUIController),
|
|
356
|
-
__decorateParam$3(0, ICommandService),
|
|
357
|
-
__decorateParam$3(1, IMenuManagerService),
|
|
358
|
-
__decorateParam$3(2, Inject(ComponentManager))
|
|
359
|
-
], DocThreadCommentUIController);
|
|
360
|
-
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
361
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
362
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
363
|
-
return kind && result && __defProp$2(target, key, result), result;
|
|
364
|
-
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a3;
|
|
365
|
-
let DocThreadCommentSelectionController = (_a3 = class extends Disposable {
|
|
259
|
+
let DocThreadCommentSelectionController = (_a2 = class extends Disposable {
|
|
366
260
|
constructor(_threadCommentPanelService, _univerInstanceService, _commandService, _docThreadCommentService, _renderManagerService, _threadCommentModel) {
|
|
367
261
|
super(), this._threadCommentPanelService = _threadCommentPanelService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._docThreadCommentService = _docThreadCommentService, this._renderManagerService = _renderManagerService, this._threadCommentModel = _threadCommentModel, this._initSelectionChange(), this._initActiveCommandChange();
|
|
368
262
|
}
|
|
@@ -414,16 +308,120 @@ let DocThreadCommentSelectionController = (_a3 = class extends Disposable {
|
|
|
414
308
|
(!activeComment || activeComment.commentId !== ((_d = this._docThreadCommentService.addingComment) == null ? void 0 : _d.id)) && this._docThreadCommentService.endAdd();
|
|
415
309
|
}));
|
|
416
310
|
}
|
|
417
|
-
}, __name(
|
|
418
|
-
DocThreadCommentSelectionController = __decorateClass$
|
|
419
|
-
|
|
420
|
-
__decorateParam$
|
|
421
|
-
__decorateParam$2
|
|
422
|
-
__decorateParam$
|
|
423
|
-
__decorateParam$
|
|
424
|
-
__decorateParam$
|
|
425
|
-
__decorateParam$2(5, Inject(ThreadCommentModel))
|
|
311
|
+
}, __name(_a2, "DocThreadCommentSelectionController"), _a2);
|
|
312
|
+
DocThreadCommentSelectionController = __decorateClass$3([
|
|
313
|
+
__decorateParam$3(0, Inject(ThreadCommentPanelService)),
|
|
314
|
+
__decorateParam$3(1, IUniverInstanceService),
|
|
315
|
+
__decorateParam$3(2, ICommandService),
|
|
316
|
+
__decorateParam$3(3, Inject(DocThreadCommentService)),
|
|
317
|
+
__decorateParam$3(4, IRenderManagerService),
|
|
318
|
+
__decorateParam$3(5, Inject(ThreadCommentModel))
|
|
426
319
|
], DocThreadCommentSelectionController);
|
|
320
|
+
var __assign = function() {
|
|
321
|
+
return __assign = Object.assign || function(t) {
|
|
322
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
323
|
+
s = arguments[i];
|
|
324
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
325
|
+
}
|
|
326
|
+
return t;
|
|
327
|
+
}, __assign.apply(this, arguments);
|
|
328
|
+
}, __rest = function(s, e) {
|
|
329
|
+
var t = {};
|
|
330
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
331
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
332
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
333
|
+
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
334
|
+
return t;
|
|
335
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
336
|
+
var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
|
|
337
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
338
|
+
});
|
|
339
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
340
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
341
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
342
|
+
}));
|
|
343
|
+
}
|
|
344
|
+
__name(render, "render");
|
|
345
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
346
|
+
var attrs = __assign({}, node.attrs);
|
|
347
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
348
|
+
var defIds = runtimeProps.defIds;
|
|
349
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a6) {
|
|
350
|
+
var key = _a6[0], value = _a6[1];
|
|
351
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
352
|
+
})), attrs;
|
|
353
|
+
}
|
|
354
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
355
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
356
|
+
var _a6, defIds = runtimeProps.defIds;
|
|
357
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a6 = node.children) === null || _a6 === void 0) && _a6.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
358
|
+
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
359
|
+
}) }) : node;
|
|
360
|
+
}
|
|
361
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
362
|
+
function generateShortUuid() {
|
|
363
|
+
return Math.random().toString(36).substring(2, 8);
|
|
364
|
+
}
|
|
365
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
366
|
+
IconBase.displayName = "UniverIcon";
|
|
367
|
+
var element = { 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" } }] }, CommentSingle = forwardRef(function(props, ref) {
|
|
368
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
369
|
+
id: "comment-single",
|
|
370
|
+
ref,
|
|
371
|
+
icon: element
|
|
372
|
+
}));
|
|
373
|
+
});
|
|
374
|
+
CommentSingle.displayName = "CommentSingle";
|
|
375
|
+
const menuSchema = {
|
|
376
|
+
[RibbonStartGroup.OTHERS]: {
|
|
377
|
+
[ToggleCommentPanelOperation.id]: {
|
|
378
|
+
order: 1,
|
|
379
|
+
menuItemFactory: ToolbarDocCommentMenuItemFactory
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
[ContextMenuPosition.MAIN_AREA]: {
|
|
383
|
+
[ContextMenuGroup.DATA]: {
|
|
384
|
+
[StartAddCommentOperation.id]: {
|
|
385
|
+
order: 1,
|
|
386
|
+
menuItemFactory: AddDocCommentMenuItemFactory
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
392
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
393
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
394
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
395
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a3;
|
|
396
|
+
let DocThreadCommentUIController = (_a3 = class extends Disposable {
|
|
397
|
+
constructor(_commandService, _menuManagerService, _componentManager) {
|
|
398
|
+
super(), this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._componentManager = _componentManager, this._initCommands(), this._initMenus(), this._initComponents();
|
|
399
|
+
}
|
|
400
|
+
_initCommands() {
|
|
401
|
+
[
|
|
402
|
+
AddDocCommentComment,
|
|
403
|
+
DeleteDocCommentComment,
|
|
404
|
+
ShowCommentPanelOperation,
|
|
405
|
+
StartAddCommentOperation,
|
|
406
|
+
ToggleCommentPanelOperation
|
|
407
|
+
].forEach((command) => {
|
|
408
|
+
this.disposeWithMe(this._commandService.registerCommand(command));
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
_initMenus() {
|
|
412
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
413
|
+
}
|
|
414
|
+
_initComponents() {
|
|
415
|
+
[DocThreadCommentPanel].forEach((comp) => {
|
|
416
|
+
this.disposeWithMe(this._componentManager.register(comp.componentKey, comp));
|
|
417
|
+
}), this.disposeWithMe(this._componentManager.register("CommentSingle", CommentSingle));
|
|
418
|
+
}
|
|
419
|
+
}, __name(_a3, "DocThreadCommentUIController"), _a3);
|
|
420
|
+
DocThreadCommentUIController = __decorateClass$2([
|
|
421
|
+
__decorateParam$2(0, ICommandService),
|
|
422
|
+
__decorateParam$2(1, IMenuManagerService),
|
|
423
|
+
__decorateParam$2(2, Inject(ComponentManager))
|
|
424
|
+
], DocThreadCommentUIController);
|
|
427
425
|
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
428
426
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
429
427
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -468,14 +466,12 @@ let DocThreadCommentRenderController = (_a4 = class extends Disposable {
|
|
|
468
466
|
}
|
|
469
467
|
}, __name(_a4, "DocThreadCommentRenderController"), _a4);
|
|
470
468
|
DocThreadCommentRenderController = __decorateClass$1([
|
|
471
|
-
OnLifecycle(LifecycleStages.Starting, DocThreadCommentRenderController),
|
|
472
469
|
__decorateParam$1(1, Inject(DocInterceptorService)),
|
|
473
470
|
__decorateParam$1(2, Inject(ThreadCommentPanelService)),
|
|
474
471
|
__decorateParam$1(3, Inject(DocRenderController)),
|
|
475
472
|
__decorateParam$1(4, IUniverInstanceService),
|
|
476
473
|
__decorateParam$1(5, Inject(ThreadCommentModel))
|
|
477
474
|
], DocThreadCommentRenderController);
|
|
478
|
-
const PLUGIN_CONFIG_KEY = "docs-thread-comment-ui.config", defaultPluginConfig = {};
|
|
479
475
|
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
480
476
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
481
477
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -497,7 +493,7 @@ let UniverDocsThreadCommentUIPlugin = (_a5 = class extends Plugin {
|
|
|
497
493
|
});
|
|
498
494
|
}
|
|
499
495
|
onRendered() {
|
|
500
|
-
this._initRenderModule();
|
|
496
|
+
this._initRenderModule(), this._injector.get(DocThreadCommentSelectionController), this._injector.get(DocThreadCommentUIController);
|
|
501
497
|
}
|
|
502
498
|
_initRenderModule() {
|
|
503
499
|
[DocThreadCommentRenderController].forEach((dep) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DocumentDataModel, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
|
|
2
3
|
import { DocInterceptorService } from '@univerjs/docs';
|
|
3
4
|
import { DocRenderController } from '@univerjs/docs-ui';
|
|
4
|
-
import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
|
|
5
5
|
import { ThreadCommentModel } from '@univerjs/thread-comment';
|
|
6
6
|
import { ThreadCommentPanelService } from '@univerjs/thread-comment-ui';
|
|
7
7
|
export declare class DocThreadCommentRenderController extends Disposable implements IRenderModule {
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { IUniverDocsThreadCommentUIConfig } from './controllers/config.schema';
|
|
1
2
|
import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
3
|
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
3
|
-
import { IUniverDocsThreadCommentUIConfig } from './controllers/config.schema';
|
|
4
4
|
export declare class UniverDocsThreadCommentUIPlugin extends Plugin {
|
|
5
5
|
private readonly _config;
|
|
6
6
|
protected _injector: Injector;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/thread-comment-ui"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/docs"),require("react"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment-ui","@univerjs/engine-render","@univerjs/ui","@univerjs/docs-ui","@univerjs/thread-comment","@univerjs/docs","react","rxjs"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverDocsThreadCommentUi={},global.UniverCore,global.UniverThreadCommentUi,global.UniverEngineRender,global.UniverUi,global.UniverDocsUi,global.UniverThreadComment,global.UniverDocs,global.React,global.rxjs))})(this,function(exports2,core,threadCommentUi,engineRender,ui,docsUi,threadComment,docs,React,rxjs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e;const PLUGIN_NAME="DOC_THREAD_COMMENT_UI_PLUGIN",DEFAULT_DOC_SUBUNIT_ID="default_doc";var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element={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"}}]},CommentSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"comment-single",ref,icon:element}))});CommentSingle.displayName="CommentSingle";const AddDocCommentComment={id:"docs.command.add-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{comment:originComment,unitId}=params,comment=await accessor.get(threadComment.IThreadCommentDataSourceService).addComment(originComment),commandService=accessor.get(core.ICommandService),doMutation=docsUi.addCustomDecorationBySelectionFactory(accessor,{id:comment.id,type:core.CustomDecorationType.COMMENT});if(doMutation){const addComment={id:threadComment.AddCommentMutation.id,params:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,comment}},activeOperation={id:threadCommentUi.SetActiveCommentOperation.id,params:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,commentId:comment.id}};return(await core.sequenceExecuteAsync([addComment,doMutation,activeOperation],commandService)).result}return!1}},DeleteDocCommentComment={id:"docs.command.delete-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{commentId,unitId}=params,commandService=accessor.get(core.ICommandService),doMutation=docsUi.deleteCustomDecorationFactory(accessor,{id:commentId,unitId});return doMutation?(await core.sequenceExecute([doMutation],commandService)).result:!1}};var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");let DocThreadCommentService=(_a=class extends core.Disposable{constructor(_sidebarService,_threadCommentPanelService){super();__publicField(this,"_addingComment$",new rxjs.BehaviorSubject(void 0));__publicField(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=_sidebarService,this._threadCommentPanelService=_threadCommentPanelService,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(comment){this._addingComment$.next(comment)}endAdd(){this._addingComment$.next(void 0)}},__name(_a,"DocThreadCommentService"),_a);DocThreadCommentService=__decorateClass$4([__decorateParam$4(0,ui.ISidebarService),__decorateParam$4(1,core.Inject(threadCommentUi.ThreadCommentPanelService))],DocThreadCommentService);const ShowCommentPanelOperation={id:"docs.operation.show-comment-panel",type:core.CommandType.OPERATION,handler(accessor,params){var _a2;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),sidebarService=accessor.get(ui.ISidebarService);return(!panelService.panelVisible||((_a2=sidebarService.options.children)==null?void 0:_a2.label)!==DocThreadCommentPanel.componentKey)&&(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:DocThreadCommentPanel.componentKey},width:320,onClose:__name(()=>panelService.setPanelVisible(!1),"onClose")}),panelService.setPanelVisible(!0)),params&&panelService.setActiveComment(params==null?void 0:params.activeComment),!0}},ToggleCommentPanelOperation={id:"docs.operation.toggle-comment-panel",type:core.CommandType.OPERATION,handler(accessor){var _a2;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),sidebarService=accessor.get(ui.ISidebarService);return!panelService.panelVisible||((_a2=sidebarService.options.children)==null?void 0:_a2.label)!==DocThreadCommentPanel.componentKey?(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:DocThreadCommentPanel.componentKey},width:320,onClose:__name(()=>panelService.setPanelVisible(!1),"onClose")}),panelService.setPanelVisible(!0)):(sidebarService.close(),panelService.setPanelVisible(!1),panelService.setActiveComment(null)),!0}},StartAddCommentOperation={id:"docs.operation.start-add-comment",type:core.CommandType.OPERATION,handler(accessor){var _a2,_b2,_c2;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),doc=accessor.get(core.IUniverInstanceService).getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC),docSelectionManagerService=accessor.get(docs.DocSelectionManagerService),renderManagerService=accessor.get(engineRender.IRenderManagerService),userManagerService=accessor.get(core.UserManagerService),docCommentService=accessor.get(DocThreadCommentService),commandService=accessor.get(core.ICommandService),sidebarService=accessor.get(ui.ISidebarService),textRange=docSelectionManagerService.getActiveTextRange();if(!doc||!textRange)return!1;const docSelectionRenderManager=(_a2=renderManagerService.getRenderById(doc.getUnitId()))==null?void 0:_a2.with(docsUi.DocSelectionRenderService);if(textRange.collapsed)return panelService.panelVisible?(panelService.setPanelVisible(!1),sidebarService.close()):commandService.executeCommand(ShowCommentPanelOperation.id),!0;commandService.executeCommand(ShowCommentPanelOperation.id);const unitId=doc.getUnitId(),dataStream=((_c2=(_b2=doc.getBody())==null?void 0:_b2.dataStream)!=null?_c2:"").slice(textRange.startOffset,textRange.endOffset),text=core.BuildTextUtils.transform.getPlainText(dataStream),subUnitId=DEFAULT_DOC_SUBUNIT_ID,commentId="",comment={unitId,subUnitId,id:commentId,ref:text,dT:threadCommentUi.getDT(),personId:userManagerService.getCurrentUser().userID,text:{dataStream:`\r
|
|
2
|
-
`},startOffset:textRange.startOffset,endOffset:textRange.endOffset,collapsed:!0,threadId:commentId};return docSelectionRenderManager==null||docSelectionRenderManager.blurEditor(),docCommentService.startAdd(comment),panelService.setActiveComment({unitId,subUnitId,commentId}),!0}},shouldDisableAddComment=__name(accessor=>{const renderManagerService=accessor.get(engineRender.IRenderManagerService),docSelectionManagerService=accessor.get(docs.DocSelectionManagerService),render2=renderManagerService.getCurrent(),skeleton=render2==null?void 0:render2.with(docs.DocSkeletonManagerService).getSkeleton(),editArea=skeleton==null?void 0:skeleton.getViewModel().getEditArea();if(editArea===engineRender.DocumentEditArea.FOOTER||editArea===engineRender.DocumentEditArea.HEADER)return!0;const range=docSelectionManagerService.getActiveTextRange();return!!(range==null||range.collapsed)},"shouldDisableAddComment");function AddDocCommentMenuItemFactory(accessor){return{id:StartAddCommentOperation.id,type:ui.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC),disabled$:new rxjs.Observable(function(subscribe){const observer=accessor.get(docs.DocSelectionManagerService).textSelection$.pipe(rxjs.debounceTime(16)).subscribe(()=>{subscribe.next(shouldDisableAddComment(accessor))});return()=>{observer.unsubscribe()}})}}__name(AddDocCommentMenuItemFactory,"AddDocCommentMenuItemFactory");function ToolbarDocCommentMenuItemFactory(accessor){return{id:ToggleCommentPanelOperation.id,type:ui.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC)}}__name(ToolbarDocCommentMenuItemFactory,"ToolbarDocCommentMenuItemFactory");const DocThreadCommentPanel=__name(()=>{const univerInstanceService=core.useDependency(core.IUniverInstanceService),injector=core.useDependency(core.Injector),doc$=React.useMemo(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_DOC),[univerInstanceService]),doc=core.useObservable(doc$),subUnitId$=React.useMemo(()=>new rxjs.Observable(sub=>sub.next(DEFAULT_DOC_SUBUNIT_ID)),[]),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),selectionChange$=React.useMemo(()=>docSelectionManagerService.textSelection$.pipe(rxjs.debounceTime(16)),[docSelectionManagerService.textSelection$]);core.useObservable(selectionChange$);const commandService=core.useDependency(core.ICommandService),docCommentService=core.useDependency(DocThreadCommentService),tempComment=core.useObservable(docCommentService.addingComment$),[commentIds,setCommentIds]=React.useState([]);if(React.useEffect(()=>{var _a2;const set=new Set,customRanges=doc==null?void 0:doc.getCustomDecorations();setCommentIds((_a2=customRanges==null?void 0:customRanges.map(r=>r.id).filter(i=>{const hasRepeat=set.has(i);return set.add(i),!hasRepeat}))!=null?_a2:[]);const dispose=commandService.onCommandExecuted(command=>{var _a3;if(command.id===docs.RichTextEditingMutation.id){const set2=new Set,customRanges2=doc==null?void 0:doc.getCustomDecorations();setCommentIds((_a3=customRanges2==null?void 0:customRanges2.map(r=>r.id).filter(i=>{const hasRepeat=set2.has(i);return set2.add(i),!hasRepeat}))!=null?_a3:[])}});return()=>{dispose.dispose()}},[commandService,doc]),!doc)return null;const isInValidSelection=shouldDisableAddComment(injector),unitId=doc.getUnitId();return React.createElement(threadCommentUi.ThreadCommentPanel,{unitId,subUnitId$,type:core.UniverInstanceType.UNIVER_DOC,onAdd:__name(()=>{commandService.executeCommand(StartAddCommentOperation.id)},"onAdd"),getSubUnitName:__name(()=>"","getSubUnitName"),disableAdd:isInValidSelection,tempComment,onAddComment:__name(comment=>{if(!comment.parentId){const params={unitId,range:tempComment,comment};return commandService.executeCommand(AddDocCommentComment.id,params),docCommentService.endAdd(),!1}return!0},"onAddComment"),onDeleteComment:__name(comment=>{if(!comment.parentId){const params={unitId,commentId:comment.id};return commandService.executeCommand(DeleteDocCommentComment.id,params),!1}return!0},"onDeleteComment"),showComments:commentIds})},"DocThreadCommentPanel");DocThreadCommentPanel.componentKey="univer.doc.thread-comment-panel";const menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ToggleCommentPanelOperation.id]:{order:1,menuItemFactory:ToolbarDocCommentMenuItemFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.DATA]:{[StartAddCommentOperation.id]:{order:1,menuItemFactory:AddDocCommentMenuItemFactory}}}};var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");let DocThreadCommentUIController=(_b=class extends core.Disposable{constructor(_commandService,_menuManagerService,_componentManager){super(),this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._componentManager=_componentManager,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[AddDocCommentComment,DeleteDocCommentComment,ShowCommentPanelOperation,StartAddCommentOperation,ToggleCommentPanelOperation].forEach(command=>{this.disposeWithMe(this._commandService.registerCommand(command))})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}_initComponents(){[DocThreadCommentPanel].forEach(comp=>{this.disposeWithMe(this._componentManager.register(comp.componentKey,comp))}),this.disposeWithMe(this._componentManager.register("CommentSingle",CommentSingle))}},__name(_b,"DocThreadCommentUIController"),_b);DocThreadCommentUIController=__decorateClass$3([core.OnLifecycle(core.LifecycleStages.Rendered,DocThreadCommentUIController),__decorateParam$3(0,core.ICommandService),__decorateParam$3(1,ui.IMenuManagerService),__decorateParam$3(2,core.Inject(ui.ComponentManager))],DocThreadCommentUIController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let DocThreadCommentSelectionController=(_c=class extends core.Disposable{constructor(_threadCommentPanelService,_univerInstanceService,_commandService,_docThreadCommentService,_renderManagerService,_threadCommentModel){super(),this._threadCommentPanelService=_threadCommentPanelService,this._univerInstanceService=_univerInstanceService,this._commandService=_commandService,this._docThreadCommentService=_docThreadCommentService,this._renderManagerService=_renderManagerService,this._threadCommentModel=_threadCommentModel,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let lastSelection;this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{var _a2,_b2,_c2,_d2;if(commandInfo.id===docs.SetTextSelectionsOperation.id){const params=commandInfo.params,{unitId,ranges}=params,doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),primary=ranges[0];if((lastSelection==null?void 0:lastSelection.startOffset)===(primary==null?void 0:primary.startOffset)&&(lastSelection==null?void 0:lastSelection.endOffset)===(primary==null?void 0:primary.endOffset))return;if(lastSelection=primary,primary&&doc){const{startOffset,endOffset,collapsed}=primary;let customRange;if(collapsed?customRange=(_b2=(_a2=doc.getBody())==null?void 0:_a2.customDecorations)==null?void 0:_b2.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1):customRange=(_d2=(_c2=doc.getBody())==null?void 0:_c2.customDecorations)==null?void 0:_d2.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1),customRange){const comment=this._threadCommentModel.getComment(unitId,DEFAULT_DOC_SUBUNIT_ID,customRange.id);comment&&!comment.resolved&&this._commandService.executeCommand(ShowCommentPanelOperation.id,{activeComment:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,commentId:customRange.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(activeComment=>{var _a2,_b2,_c2,_d2;if(activeComment){const doc=this._univerInstanceService.getUnit(activeComment.unitId);if(doc){const backScrollController=(_a2=this._renderManagerService.getRenderById(activeComment.unitId))==null?void 0:_a2.with(docsUi.DocBackScrollRenderController),customRange=(_c2=(_b2=doc.getBody())==null?void 0:_b2.customDecorations)==null?void 0:_c2.find(range=>range.id===activeComment.commentId);customRange&&backScrollController&&backScrollController.scrollToRange({startOffset:customRange.startIndex,endOffset:customRange.endIndex,collapsed:!1})}}(!activeComment||activeComment.commentId!==((_d2=this._docThreadCommentService.addingComment)==null?void 0:_d2.id))&&this._docThreadCommentService.endAdd()}))}},__name(_c,"DocThreadCommentSelectionController"),_c);DocThreadCommentSelectionController=__decorateClass$2([core.OnLifecycle(core.LifecycleStages.Rendered,DocThreadCommentSelectionController),__decorateParam$2(0,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$2(1,core.IUniverInstanceService),__decorateParam$2(2,core.ICommandService),__decorateParam$2(3,core.Inject(DocThreadCommentService)),__decorateParam$2(4,engineRender.IRenderManagerService),__decorateParam$2(5,core.Inject(threadComment.ThreadCommentModel))],DocThreadCommentSelectionController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let DocThreadCommentRenderController=(_d=class extends core.Disposable{constructor(_context,_docInterceptorService,_threadCommentPanelService,_docRenderController,_univerInstanceService,_threadCommentModel){super(),this._context=_context,this._docInterceptorService=_docInterceptorService,this._threadCommentPanelService=_threadCommentPanelService,this._docRenderController=_docRenderController,this._univerInstanceService=_univerInstanceService,this._threadCommentModel=_threadCommentModel,this._interceptorViewModel(),this._initReRender()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(activeComment=>{var _a2;if(activeComment){this._docRenderController.reRender(activeComment.unitId);return}const unitId=(_a2=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a2.getUnitId();unitId&&this._docRenderController.reRender(unitId)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(update=>{update.type==="resolve"&&this._docRenderController.reRender(update.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(docs.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:__name((data,pos,next)=>{if(!data)return next(data);const{unitId,index,customDecorations}=pos,activeComment=this._threadCommentPanelService.activeCommentId,{commentId,unitId:commentUnitID}=activeComment||{},activeCustomDecoration=customDecorations.find(i=>i.id===commentId),comment=this._threadCommentModel.getComment(unitId,DEFAULT_DOC_SUBUNIT_ID,data.id);if(!comment)return next({...data,show:!1});const isActiveIndex=activeCustomDecoration&&index>=activeCustomDecoration.startIndex&&index<=activeCustomDecoration.endIndex,isActive=commentUnitID===unitId&&data.id===commentId;return next({...data,active:isActive||isActiveIndex,show:!comment.resolved})},"handler")})}},__name(_d,"DocThreadCommentRenderController"),_d);DocThreadCommentRenderController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,DocThreadCommentRenderController),__decorateParam$1(1,core.Inject(docs.DocInterceptorService)),__decorateParam$1(2,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$1(3,core.Inject(docsUi.DocRenderController)),__decorateParam$1(4,core.IUniverInstanceService),__decorateParam$1(5,core.Inject(threadComment.ThreadCommentModel))],DocThreadCommentRenderController);const PLUGIN_CONFIG_KEY="docs-thread-comment-ui.config",defaultPluginConfig={};var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverDocsThreadCommentUIPlugin=(_e=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_renderManagerSrv,_configService){super(),this._config=_config,this._injector=_injector,this._renderManagerSrv=_renderManagerSrv,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocThreadCommentUIController],[DocThreadCommentSelectionController],[DocThreadCommentService]].forEach(dep=>{this._injector.add(dep)})}onRendered(){this._initRenderModule()}_initRenderModule(){[DocThreadCommentRenderController].forEach(dep=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,dep)})}},__name(_e,"UniverDocsThreadCommentUIPlugin"),_e),__publicField2(exports2.UniverDocsThreadCommentUIPlugin,"pluginName",PLUGIN_NAME),__publicField2(exports2.UniverDocsThreadCommentUIPlugin,"type",core.UniverInstanceType.UNIVER_DOC),exports2.UniverDocsThreadCommentUIPlugin=__decorateClass([core.DependentOn(threadCommentUi.UniverThreadCommentUIPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService),__decorateParam(3,core.IConfigService)],exports2.UniverDocsThreadCommentUIPlugin),exports2.AddDocCommentComment=AddDocCommentComment,exports2.DeleteDocCommentComment=DeleteDocCommentComment,exports2.ShowCommentPanelOperation=ShowCommentPanelOperation,exports2.StartAddCommentOperation=StartAddCommentOperation,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(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"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverDocsThreadCommentUi={},global.UniverCore,global.UniverEngineRender,global.UniverThreadCommentUi,global.UniverDocs,global.UniverDocsUi,global.UniverThreadComment,global.UniverUi,global.rxjs,global.React))})(this,function(exports2,core,engineRender,threadCommentUi,docs,docsUi,threadComment,ui,rxjs,React){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e;const PLUGIN_NAME="DOC_THREAD_COMMENT_UI_PLUGIN",DEFAULT_DOC_SUBUNIT_ID="default_doc",PLUGIN_CONFIG_KEY="docs-thread-comment-ui.config",defaultPluginConfig={};var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");let DocThreadCommentService=(_a=class extends core.Disposable{constructor(_sidebarService,_threadCommentPanelService){super();__publicField(this,"_addingComment$",new rxjs.BehaviorSubject(void 0));__publicField(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=_sidebarService,this._threadCommentPanelService=_threadCommentPanelService,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(comment){this._addingComment$.next(comment)}endAdd(){this._addingComment$.next(void 0)}},__name(_a,"DocThreadCommentService"),_a);DocThreadCommentService=__decorateClass$4([__decorateParam$4(0,ui.ISidebarService),__decorateParam$4(1,core.Inject(threadCommentUi.ThreadCommentPanelService))],DocThreadCommentService);const AddDocCommentComment={id:"docs.command.add-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{comment:originComment,unitId}=params,comment=await accessor.get(threadComment.IThreadCommentDataSourceService).addComment(originComment),commandService=accessor.get(core.ICommandService),doMutation=docsUi.addCustomDecorationBySelectionFactory(accessor,{id:comment.id,type:core.CustomDecorationType.COMMENT});if(doMutation){const addComment={id:threadComment.AddCommentMutation.id,params:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,comment}},activeOperation={id:threadCommentUi.SetActiveCommentOperation.id,params:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,commentId:comment.id}};return(await core.sequenceExecuteAsync([addComment,doMutation,activeOperation],commandService)).result}return!1}},DeleteDocCommentComment={id:"docs.command.delete-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{commentId,unitId}=params,commandService=accessor.get(core.ICommandService),doMutation=docsUi.deleteCustomDecorationFactory(accessor,{id:commentId,unitId});return doMutation?(await core.sequenceExecute([doMutation],commandService)).result:!1}},shouldDisableAddComment=__name(accessor=>{const renderManagerService=accessor.get(engineRender.IRenderManagerService),docSelectionManagerService=accessor.get(docs.DocSelectionManagerService),render2=renderManagerService.getCurrent(),skeleton=render2==null?void 0:render2.with(docs.DocSkeletonManagerService).getSkeleton(),editArea=skeleton==null?void 0:skeleton.getViewModel().getEditArea();if(editArea===engineRender.DocumentEditArea.FOOTER||editArea===engineRender.DocumentEditArea.HEADER)return!0;const range=docSelectionManagerService.getActiveTextRange();return!!(range==null||range.collapsed)},"shouldDisableAddComment");function AddDocCommentMenuItemFactory(accessor){return{id:StartAddCommentOperation.id,type:ui.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC),disabled$:new rxjs.Observable(function(subscribe){const observer=accessor.get(docs.DocSelectionManagerService).textSelection$.pipe(rxjs.debounceTime(16)).subscribe(()=>{subscribe.next(shouldDisableAddComment(accessor))});return()=>{observer.unsubscribe()}})}}__name(AddDocCommentMenuItemFactory,"AddDocCommentMenuItemFactory");function ToolbarDocCommentMenuItemFactory(accessor){return{id:ToggleCommentPanelOperation.id,type:ui.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC)}}__name(ToolbarDocCommentMenuItemFactory,"ToolbarDocCommentMenuItemFactory");const DocThreadCommentPanel=__name(()=>{const univerInstanceService=core.useDependency(core.IUniverInstanceService),injector=core.useDependency(core.Injector),doc$=React.useMemo(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_DOC),[univerInstanceService]),doc=core.useObservable(doc$),subUnitId$=React.useMemo(()=>new rxjs.Observable(sub=>sub.next(DEFAULT_DOC_SUBUNIT_ID)),[]),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),selectionChange$=React.useMemo(()=>docSelectionManagerService.textSelection$.pipe(rxjs.debounceTime(16)),[docSelectionManagerService.textSelection$]);core.useObservable(selectionChange$);const commandService=core.useDependency(core.ICommandService),docCommentService=core.useDependency(DocThreadCommentService),tempComment=core.useObservable(docCommentService.addingComment$),[commentIds,setCommentIds]=React.useState([]);if(React.useEffect(()=>{var _a2;const set=new Set,customRanges=doc==null?void 0:doc.getCustomDecorations();setCommentIds((_a2=customRanges==null?void 0:customRanges.map(r=>r.id).filter(i=>{const hasRepeat=set.has(i);return set.add(i),!hasRepeat}))!=null?_a2:[]);const dispose=commandService.onCommandExecuted(command=>{var _a3;if(command.id===docs.RichTextEditingMutation.id){const set2=new Set,customRanges2=doc==null?void 0:doc.getCustomDecorations();setCommentIds((_a3=customRanges2==null?void 0:customRanges2.map(r=>r.id).filter(i=>{const hasRepeat=set2.has(i);return set2.add(i),!hasRepeat}))!=null?_a3:[])}});return()=>{dispose.dispose()}},[commandService,doc]),!doc)return null;const isInValidSelection=shouldDisableAddComment(injector),unitId=doc.getUnitId();return React.createElement(threadCommentUi.ThreadCommentPanel,{unitId,subUnitId$,type:core.UniverInstanceType.UNIVER_DOC,onAdd:__name(()=>{commandService.executeCommand(StartAddCommentOperation.id)},"onAdd"),getSubUnitName:__name(()=>"","getSubUnitName"),disableAdd:isInValidSelection,tempComment,onAddComment:__name(comment=>{if(!comment.parentId){const params={unitId,range:tempComment,comment};return commandService.executeCommand(AddDocCommentComment.id,params),docCommentService.endAdd(),!1}return!0},"onAddComment"),onDeleteComment:__name(comment=>{if(!comment.parentId){const params={unitId,commentId:comment.id};return commandService.executeCommand(DeleteDocCommentComment.id,params),!1}return!0},"onDeleteComment"),showComments:commentIds})},"DocThreadCommentPanel");DocThreadCommentPanel.componentKey="univer.doc.thread-comment-panel";const ShowCommentPanelOperation={id:"docs.operation.show-comment-panel",type:core.CommandType.OPERATION,handler(accessor,params){var _a2;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),sidebarService=accessor.get(ui.ISidebarService);return(!panelService.panelVisible||((_a2=sidebarService.options.children)==null?void 0:_a2.label)!==DocThreadCommentPanel.componentKey)&&(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:DocThreadCommentPanel.componentKey},width:320,onClose:__name(()=>panelService.setPanelVisible(!1),"onClose")}),panelService.setPanelVisible(!0)),params&&panelService.setActiveComment(params==null?void 0:params.activeComment),!0}},ToggleCommentPanelOperation={id:"docs.operation.toggle-comment-panel",type:core.CommandType.OPERATION,handler(accessor){var _a2;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),sidebarService=accessor.get(ui.ISidebarService);return!panelService.panelVisible||((_a2=sidebarService.options.children)==null?void 0:_a2.label)!==DocThreadCommentPanel.componentKey?(sidebarService.open({header:{title:"threadCommentUI.panel.title"},children:{label:DocThreadCommentPanel.componentKey},width:320,onClose:__name(()=>panelService.setPanelVisible(!1),"onClose")}),panelService.setPanelVisible(!0)):(sidebarService.close(),panelService.setPanelVisible(!1),panelService.setActiveComment(null)),!0}},StartAddCommentOperation={id:"docs.operation.start-add-comment",type:core.CommandType.OPERATION,handler(accessor){var _a2,_b2,_c2;const panelService=accessor.get(threadCommentUi.ThreadCommentPanelService),doc=accessor.get(core.IUniverInstanceService).getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC),docSelectionManagerService=accessor.get(docs.DocSelectionManagerService),renderManagerService=accessor.get(engineRender.IRenderManagerService),userManagerService=accessor.get(core.UserManagerService),docCommentService=accessor.get(DocThreadCommentService),commandService=accessor.get(core.ICommandService),sidebarService=accessor.get(ui.ISidebarService),textRange=docSelectionManagerService.getActiveTextRange();if(!doc||!textRange)return!1;const docSelectionRenderManager=(_a2=renderManagerService.getRenderById(doc.getUnitId()))==null?void 0:_a2.with(docsUi.DocSelectionRenderService);if(textRange.collapsed)return panelService.panelVisible?(panelService.setPanelVisible(!1),sidebarService.close()):commandService.executeCommand(ShowCommentPanelOperation.id),!0;commandService.executeCommand(ShowCommentPanelOperation.id);const unitId=doc.getUnitId(),dataStream=((_c2=(_b2=doc.getBody())==null?void 0:_b2.dataStream)!=null?_c2:"").slice(textRange.startOffset,textRange.endOffset),text=core.BuildTextUtils.transform.getPlainText(dataStream),subUnitId=DEFAULT_DOC_SUBUNIT_ID,commentId="",comment={unitId,subUnitId,id:commentId,ref:text,dT:threadCommentUi.getDT(),personId:userManagerService.getCurrentUser().userID,text:{dataStream:`\r
|
|
2
|
+
`},startOffset:textRange.startOffset,endOffset:textRange.endOffset,collapsed:!0,threadId:commentId};return docSelectionRenderManager==null||docSelectionRenderManager.blurEditor(),docCommentService.startAdd(comment),panelService.setActiveComment({unitId,subUnitId,commentId}),!0}};var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");let DocThreadCommentSelectionController=(_b=class extends core.Disposable{constructor(_threadCommentPanelService,_univerInstanceService,_commandService,_docThreadCommentService,_renderManagerService,_threadCommentModel){super(),this._threadCommentPanelService=_threadCommentPanelService,this._univerInstanceService=_univerInstanceService,this._commandService=_commandService,this._docThreadCommentService=_docThreadCommentService,this._renderManagerService=_renderManagerService,this._threadCommentModel=_threadCommentModel,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let lastSelection;this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{var _a2,_b2,_c2,_d2;if(commandInfo.id===docs.SetTextSelectionsOperation.id){const params=commandInfo.params,{unitId,ranges}=params,doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),primary=ranges[0];if((lastSelection==null?void 0:lastSelection.startOffset)===(primary==null?void 0:primary.startOffset)&&(lastSelection==null?void 0:lastSelection.endOffset)===(primary==null?void 0:primary.endOffset))return;if(lastSelection=primary,primary&&doc){const{startOffset,endOffset,collapsed}=primary;let customRange;if(collapsed?customRange=(_b2=(_a2=doc.getBody())==null?void 0:_a2.customDecorations)==null?void 0:_b2.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1):customRange=(_d2=(_c2=doc.getBody())==null?void 0:_c2.customDecorations)==null?void 0:_d2.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1),customRange){const comment=this._threadCommentModel.getComment(unitId,DEFAULT_DOC_SUBUNIT_ID,customRange.id);comment&&!comment.resolved&&this._commandService.executeCommand(ShowCommentPanelOperation.id,{activeComment:{unitId,subUnitId:DEFAULT_DOC_SUBUNIT_ID,commentId:customRange.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(activeComment=>{var _a2,_b2,_c2,_d2;if(activeComment){const doc=this._univerInstanceService.getUnit(activeComment.unitId);if(doc){const backScrollController=(_a2=this._renderManagerService.getRenderById(activeComment.unitId))==null?void 0:_a2.with(docsUi.DocBackScrollRenderController),customRange=(_c2=(_b2=doc.getBody())==null?void 0:_b2.customDecorations)==null?void 0:_c2.find(range=>range.id===activeComment.commentId);customRange&&backScrollController&&backScrollController.scrollToRange({startOffset:customRange.startIndex,endOffset:customRange.endIndex,collapsed:!1})}}(!activeComment||activeComment.commentId!==((_d2=this._docThreadCommentService.addingComment)==null?void 0:_d2.id))&&this._docThreadCommentService.endAdd()}))}},__name(_b,"DocThreadCommentSelectionController"),_b);DocThreadCommentSelectionController=__decorateClass$3([__decorateParam$3(0,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$3(1,core.IUniverInstanceService),__decorateParam$3(2,core.ICommandService),__decorateParam$3(3,core.Inject(DocThreadCommentService)),__decorateParam$3(4,engineRender.IRenderManagerService),__decorateParam$3(5,core.Inject(threadComment.ThreadCommentModel))],DocThreadCommentSelectionController);var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element={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"}}]},CommentSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"comment-single",ref,icon:element}))});CommentSingle.displayName="CommentSingle";const menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ToggleCommentPanelOperation.id]:{order:1,menuItemFactory:ToolbarDocCommentMenuItemFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.DATA]:{[StartAddCommentOperation.id]:{order:1,menuItemFactory:AddDocCommentMenuItemFactory}}}};var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let DocThreadCommentUIController=(_c=class extends core.Disposable{constructor(_commandService,_menuManagerService,_componentManager){super(),this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._componentManager=_componentManager,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[AddDocCommentComment,DeleteDocCommentComment,ShowCommentPanelOperation,StartAddCommentOperation,ToggleCommentPanelOperation].forEach(command=>{this.disposeWithMe(this._commandService.registerCommand(command))})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}_initComponents(){[DocThreadCommentPanel].forEach(comp=>{this.disposeWithMe(this._componentManager.register(comp.componentKey,comp))}),this.disposeWithMe(this._componentManager.register("CommentSingle",CommentSingle))}},__name(_c,"DocThreadCommentUIController"),_c);DocThreadCommentUIController=__decorateClass$2([__decorateParam$2(0,core.ICommandService),__decorateParam$2(1,ui.IMenuManagerService),__decorateParam$2(2,core.Inject(ui.ComponentManager))],DocThreadCommentUIController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let DocThreadCommentRenderController=(_d=class extends core.Disposable{constructor(_context,_docInterceptorService,_threadCommentPanelService,_docRenderController,_univerInstanceService,_threadCommentModel){super(),this._context=_context,this._docInterceptorService=_docInterceptorService,this._threadCommentPanelService=_threadCommentPanelService,this._docRenderController=_docRenderController,this._univerInstanceService=_univerInstanceService,this._threadCommentModel=_threadCommentModel,this._interceptorViewModel(),this._initReRender()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(activeComment=>{var _a2;if(activeComment){this._docRenderController.reRender(activeComment.unitId);return}const unitId=(_a2=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a2.getUnitId();unitId&&this._docRenderController.reRender(unitId)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(update=>{update.type==="resolve"&&this._docRenderController.reRender(update.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(docs.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:__name((data,pos,next)=>{if(!data)return next(data);const{unitId,index,customDecorations}=pos,activeComment=this._threadCommentPanelService.activeCommentId,{commentId,unitId:commentUnitID}=activeComment||{},activeCustomDecoration=customDecorations.find(i=>i.id===commentId),comment=this._threadCommentModel.getComment(unitId,DEFAULT_DOC_SUBUNIT_ID,data.id);if(!comment)return next({...data,show:!1});const isActiveIndex=activeCustomDecoration&&index>=activeCustomDecoration.startIndex&&index<=activeCustomDecoration.endIndex,isActive=commentUnitID===unitId&&data.id===commentId;return next({...data,active:isActive||isActiveIndex,show:!comment.resolved})},"handler")})}},__name(_d,"DocThreadCommentRenderController"),_d);DocThreadCommentRenderController=__decorateClass$1([__decorateParam$1(1,core.Inject(docs.DocInterceptorService)),__decorateParam$1(2,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$1(3,core.Inject(docsUi.DocRenderController)),__decorateParam$1(4,core.IUniverInstanceService),__decorateParam$1(5,core.Inject(threadComment.ThreadCommentModel))],DocThreadCommentRenderController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverDocsThreadCommentUIPlugin=(_e=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_renderManagerSrv,_configService){super(),this._config=_config,this._injector=_injector,this._renderManagerSrv=_renderManagerSrv,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocThreadCommentUIController],[DocThreadCommentSelectionController],[DocThreadCommentService]].forEach(dep=>{this._injector.add(dep)})}onRendered(){this._initRenderModule(),this._injector.get(DocThreadCommentSelectionController),this._injector.get(DocThreadCommentUIController)}_initRenderModule(){[DocThreadCommentRenderController].forEach(dep=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,dep)})}},__name(_e,"UniverDocsThreadCommentUIPlugin"),_e),__publicField2(exports2.UniverDocsThreadCommentUIPlugin,"pluginName",PLUGIN_NAME),__publicField2(exports2.UniverDocsThreadCommentUIPlugin,"type",core.UniverInstanceType.UNIVER_DOC),exports2.UniverDocsThreadCommentUIPlugin=__decorateClass([core.DependentOn(threadCommentUi.UniverThreadCommentUIPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService),__decorateParam(3,core.IConfigService)],exports2.UniverDocsThreadCommentUIPlugin),exports2.AddDocCommentComment=AddDocCommentComment,exports2.DeleteDocCommentComment=DeleteDocCommentComment,exports2.ShowCommentPanelOperation=ShowCommentPanelOperation,exports2.StartAddCommentOperation=StartAddCommentOperation,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-thread-comment-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-alpha.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -45,32 +45,28 @@
|
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
48
|
-
"rxjs": ">=7.0.0"
|
|
49
|
-
"@univerjs/core": "0.3.0",
|
|
50
|
-
"@univerjs/docs-ui": "0.3.0",
|
|
51
|
-
"@univerjs/docs": "0.3.0",
|
|
52
|
-
"@univerjs/engine-render": "0.3.0",
|
|
53
|
-
"@univerjs/thread-comment": "0.3.0",
|
|
54
|
-
"@univerjs/ui": "0.3.0",
|
|
55
|
-
"@univerjs/thread-comment-ui": "0.3.0"
|
|
48
|
+
"rxjs": ">=7.0.0"
|
|
56
49
|
},
|
|
57
50
|
"dependencies": {
|
|
58
|
-
"@univerjs/icons": "^0.1.
|
|
51
|
+
"@univerjs/icons": "^0.1.79",
|
|
59
52
|
"clsx": "^2.1.1",
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/
|
|
53
|
+
"@univerjs/design": "0.4.0-alpha.1",
|
|
54
|
+
"@univerjs/core": "0.4.0-alpha.1",
|
|
55
|
+
"@univerjs/docs": "0.4.0-alpha.1",
|
|
56
|
+
"@univerjs/docs-ui": "0.4.0-alpha.1",
|
|
57
|
+
"@univerjs/engine-formula": "0.4.0-alpha.1",
|
|
58
|
+
"@univerjs/engine-render": "0.4.0-alpha.1",
|
|
59
|
+
"@univerjs/thread-comment": "0.4.0-alpha.1",
|
|
60
|
+
"@univerjs/thread-comment-ui": "0.4.0-alpha.1",
|
|
61
|
+
"@univerjs/ui": "0.4.0-alpha.1"
|
|
66
62
|
},
|
|
67
63
|
"devDependencies": {
|
|
68
64
|
"react": "18.3.1",
|
|
69
65
|
"rxjs": "^7.8.1",
|
|
70
|
-
"typescript": "^5.6.
|
|
66
|
+
"typescript": "^5.6.3",
|
|
71
67
|
"vite": "^5.4.8",
|
|
72
|
-
"vitest": "^2.1.
|
|
73
|
-
"@univerjs-infra/shared": "0.
|
|
68
|
+
"vitest": "^2.1.2",
|
|
69
|
+
"@univerjs-infra/shared": "0.4.0-alpha.1"
|
|
74
70
|
},
|
|
75
71
|
"univerSpace": {
|
|
76
72
|
".": {
|