@univerjs/thread-comment-ui 0.20.1 → 0.21.0-insiders.20260422-d7fcb4d

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.
Files changed (42) hide show
  1. package/lib/cjs/index.js +844 -4
  2. package/lib/cjs/locale/ca-ES.js +37 -1
  3. package/lib/cjs/locale/en-US.js +52 -1
  4. package/lib/cjs/locale/es-ES.js +37 -1
  5. package/lib/cjs/locale/fa-IR.js +37 -1
  6. package/lib/cjs/locale/fr-FR.js +37 -1
  7. package/lib/cjs/locale/ja-JP.js +37 -1
  8. package/lib/cjs/locale/ko-KR.js +37 -1
  9. package/lib/cjs/locale/ru-RU.js +37 -1
  10. package/lib/cjs/locale/sk-SK.js +37 -1
  11. package/lib/cjs/locale/vi-VN.js +37 -1
  12. package/lib/cjs/locale/zh-CN.js +37 -1
  13. package/lib/cjs/locale/zh-TW.js +37 -1
  14. package/lib/es/index.js +828 -4
  15. package/lib/es/locale/ca-ES.js +36 -1
  16. package/lib/es/locale/en-US.js +51 -1
  17. package/lib/es/locale/es-ES.js +36 -1
  18. package/lib/es/locale/fa-IR.js +36 -1
  19. package/lib/es/locale/fr-FR.js +36 -1
  20. package/lib/es/locale/ja-JP.js +36 -1
  21. package/lib/es/locale/ko-KR.js +36 -1
  22. package/lib/es/locale/ru-RU.js +36 -1
  23. package/lib/es/locale/sk-SK.js +36 -1
  24. package/lib/es/locale/vi-VN.js +36 -1
  25. package/lib/es/locale/zh-CN.js +36 -1
  26. package/lib/es/locale/zh-TW.js +36 -1
  27. package/lib/index.js +828 -4
  28. package/lib/locale/ca-ES.js +36 -1
  29. package/lib/locale/en-US.js +51 -1
  30. package/lib/locale/es-ES.js +36 -1
  31. package/lib/locale/fa-IR.js +36 -1
  32. package/lib/locale/fr-FR.js +36 -1
  33. package/lib/locale/ja-JP.js +36 -1
  34. package/lib/locale/ko-KR.js +36 -1
  35. package/lib/locale/ru-RU.js +36 -1
  36. package/lib/locale/sk-SK.js +36 -1
  37. package/lib/locale/vi-VN.js +36 -1
  38. package/lib/locale/zh-CN.js +36 -1
  39. package/lib/locale/zh-TW.js +36 -1
  40. package/lib/umd/index.js +1 -1
  41. package/package.json +9 -9
  42. package/LICENSE +0 -176
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,844 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/ui`),n=require(`rxjs`),r=require(`@univerjs/thread-comment`),i=require(`@univerjs/design`),a=require(`@univerjs/icons`),o=require(`react`),s=require(`@univerjs/docs-ui`),c=require(`react/jsx-runtime`);function l(e){"@babel/helpers - typeof";return l=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},l(e)}function u(e,t){if(l(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(l(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function d(e){var t=u(e,`string`);return l(t)==`symbol`?t:t+``}function f(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){return function(n,r){t(n,r,e)}}function m(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let h=class extends e.Disposable{constructor(e,t){super(),this._sidebarService=e,this._univerInstanceService=t,f(this,`_panelVisible`,!1),f(this,`_panelVisible$`,new n.BehaviorSubject(!1)),f(this,`_activeCommentId`,void 0),f(this,`_activeCommentId$`,new n.BehaviorSubject(void 0)),f(this,`panelVisible$`,this._panelVisible$.asObservable()),f(this,`activeCommentId$`,this._activeCommentId$.asObservable()),this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(e.UniverInstanceType.UNIVER_SHEET).pipe((0,n.filter)(e=>!e)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(e){this._panelVisible=e,this._panelVisible$.next(e)}setActiveComment(e){this._activeCommentId=e,this._activeCommentId$.next(e)}};h=m([p(0,(0,e.Inject)(t.ISidebarService)),p(1,e.IUniverInstanceService)],h);const g={id:`thread-comment-ui.operation.set-active-comment`,type:e.CommandType.OPERATION,handler(e,t){return e.get(h).setActiveComment(t),!0}};var _=`@univerjs/thread-comment-ui`,v=`0.20.1`;const y=`thread-comment-ui.config`;Symbol(y);const b={};let x=class extends e.Plugin{constructor(t=b,n,r,i){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,e.merge)({},b,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(y,o)}onStarting(){var t;(0,e.mergeOverrideWithDependencies)([[h]],(t=this._config)==null?void 0:t.overrides).forEach(e=>{this._injector.add(e)}),[g].forEach(e=>{this._commandService.registerCommand(e)})}};f(x,`pluginName`,`UNIVER_THREAD_COMMENT_UI_PLUGIN`),f(x,`packageName`,_),f(x,`version`,v),f(x,`type`,e.UniverInstanceType.UNIVER_UNKNOWN),x=m([(0,e.DependentOn)(r.UniverThreadCommentPlugin),p(1,(0,e.Inject)(e.Injector)),p(2,e.ICommandService),p(3,e.IConfigService)],x);function S(e){return{id:`d`,body:e,documentStyle:{}}}const C=(0,o.forwardRef)((n,r)=>{var a;let{comment:l,onSave:u,id:d,onCancel:f,autoFocus:p,unitId:m,type:h,editorId:_}=n,v=(0,t.useDependency)(e.ICommandService),y=(0,t.useDependency)(e.LocaleService),[b,x]=(0,o.useState)(!1),C=(0,t.useDependency)(s.IEditorService),w=(0,o.useRef)(null),T=h===e.UniverInstanceType.UNIVER_DOC?e.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:m,[E,D]=(0,o.useState)(()=>{var t,n;return e.BuildTextUtils.transform.getPlainText((t=(n=w.current)==null||(n=n.getDocumentData().body)==null?void 0:n.dataStream)==null?``:t)});(0,o.useEffect)(()=>{var t,n,r;D(e.BuildTextUtils.transform.getPlainText((t=(n=w.current)==null||(n=n.getDocumentData().body)==null?void 0:n.dataStream)==null?``:t));let i=(r=w.current)==null?void 0:r.selectionChange$.subscribe(()=>{var t,n;D(e.BuildTextUtils.transform.getPlainText((t=(n=w.current)==null||(n=n.getDocumentData().body)==null?void 0:n.dataStream)==null?``:t))});return()=>i==null?void 0:i.unsubscribe()},[(a=w.current)==null?void 0:a.selectionChange$]);let O=(0,o.useMemo)(()=>({keyCodes:[{keyCode:t.KeyCode.ENTER}],handler:e=>{e===t.KeyCode.ENTER&&v.executeCommand(s.BreakLineCommand.id)}}),[v]);return(0,o.useImperativeHandle)(r,()=>({reply(e){var t,n;if(!w.current)return;C.focus((t=w.current.getEditorId())==null?``:t);let r=S(e);(n=w.current)==null||n.setDocumentData(r,[{startOffset:r.body.dataStream.length-2,endOffset:r.body.dataStream.length-2,collapsed:!0}])}})),(0,c.jsxs)(`div`,{onClick:e=>e.preventDefault(),children:[(0,c.jsx)(s.RichTextEditor,{className:`univer-w-full`,editorRef:w,editorId:_,autoFocus:p,keyboardEventConfig:O,placeholder:y.t(`threadCommentUI.editor.placeholder`),initialValue:(l==null?void 0:l.text)&&S(l.text),onFocusChange:e=>e&&x(e),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{C.focus(T)},30)}}),b?(0,c.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[(0,c.jsx)(i.Button,{onClick:()=>{var e;f==null||f(),x(!1),(e=w.current)==null||e.replaceText(``,!0),v.executeCommand(g.id)},children:y.t(`threadCommentUI.editor.cancel`)}),(0,c.jsx)(i.Button,{variant:`primary`,disabled:!E,onClick:()=>{if(w.current){let t=e.Tools.deepClone(w.current.getDocumentData().body);x(!1),u==null||u({...l,text:t}),w.current.replaceText(``),setTimeout(()=>{var e,t;(e=w.current)==null||e.setSelectionRanges([]),(t=w.current)==null||t.blur()},10)}},children:y.t(d?`threadCommentUI.editor.save`:`threadCommentUI.editor.reply`)})]}):null]})}),w=e=>{let{dataStream:t,customRanges:n}=e,r=t.endsWith(`\r
2
- `)?t.length-2:t.length,i=[],a=0;return n==null||n.forEach(e=>{a<e.startIndex&&i.push({type:`text`,content:t.slice(a,e.startIndex)}),i.push({type:`mention`,content:{label:t.slice(e.startIndex,e.endIndex+1),id:e.rangeId}}),a=e.endIndex+1}),i.push({type:`text`,content:t.slice(a,r)}),i},T=t=>{if(!t)return[];let{paragraphs:n=[]}=t;return n.map((r,i)=>w((0,e.getBodySlice)(t,i===0?0:n[i-1].startIndex+1,r.startIndex)))},E=t=>{let n=``,r=[];return t.forEach(t=>{switch(t.type){case`text`:n+=t.content;break;case`mention`:{let i=n.length;n+=t.content.label;let a=n.length-1;r.push({rangeId:t.content.id,rangeType:e.CustomRangeType.MENTION,startIndex:i,endIndex:a,properties:{},wholeEntity:!0});break}default:break}}),n+=`\r
3
- `,{textRuns:[],paragraphs:[{startIndex:n.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:n.length-1}],dataStream:n,customRanges:r}};let D=function(e){return e.CELL=`CELL`,e.PANEL=`PANEL`,e}({});const O=`__mock__`,k=n=>{let{item:s,unitId:l,subUnitId:u,editing:d,onEditingChange:f,onReply:p,resolved:m,isRoot:h,onClose:g,onDeleteComment:_,type:v,threadCommentEditorId:y}=n,b=(0,t.useDependency)(e.ICommandService),x=(0,t.useDependency)(e.LocaleService),S=(0,t.useDependency)(e.UserManagerService),w=S.getUser(s.personId),E=(0,t.useObservable)(S.currentUser$),D=(E==null?void 0:E.userID)===s.personId,k=s.id===O,[A,j]=(0,o.useState)(!1),M=(0,t.useConfigValue)(t.UI_PLUGIN_CONFIG_KEY),N=M==null?void 0:M.avatarFallback;return(0,c.jsxs)(`div`,{className:`univer-relative univer-mb-3 univer-pl-[30px]`,onMouseLeave:()=>j(!1),onMouseEnter:()=>j(!0),children:[(0,c.jsx)(`div`,{className:`univer-absolute univer-left-0 univer-top-0 univer-size-6 univer-rounded-full univer-bg-cover univer-bg-center univer-bg-no-repeat`,style:{backgroundImage:`url(${(w==null?void 0:w.avatar)||N})`}}),w?(0,c.jsxs)(`div`,{className:`univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between`,children:[(0,c.jsx)(`div`,{className:`univer-text-sm univer-font-medium univer-leading-5`,children:(w==null?void 0:w.name)||` `}),(0,c.jsxs)(`div`,{children:[k||m?null:A&&w?(0,c.jsx)(`div`,{className:`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50`,onClick:()=>p(w),children:(0,c.jsx)(a.ReplyToCommentIcon,{})}):null,D&&!k&&!m?(0,c.jsx)(i.Dropdown,{overlay:(0,c.jsx)(`div`,{className:`univer-rounded-lg`,children:(0,c.jsxs)(`ul`,{className:`univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors`,children:[(0,c.jsx)(`li`,{children:(0,c.jsx)(`a`,{className:`hover:univer-bg-gray-200`,onClick:()=>f==null?void 0:f(!0),children:x.t(`threadCommentUI.item.edit`)})}),(0,c.jsx)(`li`,{children:(0,c.jsx)(`a`,{className:`hover:univer-bg-gray-200`,onClick:()=>{(_==null?void 0:_(s))!==!1&&(b.executeCommand(h?r.DeleteCommentTreeCommand.id:r.DeleteCommentCommand.id,{unitId:l,subUnitId:u,commentId:s.id}),h&&(g==null||g()))},children:x.t(`threadCommentUI.item.delete`)})})]})}),children:(0,c.jsx)(`div`,{className:`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50`,children:(0,c.jsx)(a.MoreHorizontalIcon,{})})}):null]})]}):null,(0,c.jsx)(`time`,{className:`univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200`,children:s.dT}),d?(0,c.jsx)(C,{type:v,id:s.id,comment:s,onCancel:()=>f==null?void 0:f(!1),autoFocus:!0,unitId:l,subUnitId:u,editorId:y,onSave:({text:e,attachments:t})=>{f==null||f(!1),b.executeCommand(r.UpdateCommentCommand.id,{unitId:l,subUnitId:u,payload:{commentId:s.id,text:e,attachments:t}})}}):(0,c.jsx)(`div`,{className:`univer-text-sm univer-text-gray-900 dark:!univer-text-white`,children:T(s.text).map((e,t)=>(0,c.jsx)(`div`,{className:`univer-break-words`,children:e.map((e,t)=>{switch(e.type){case`mention`:return(0,c.jsxs)(`a`,{className:`univer-text-primary-600`,children:[e.content.label,` `]},t);default:return e.content}})},t))})]})},A=s=>{var l,u,d;let{id:f,unitId:p,subUnitId:m,refStr:h,showEdit:_=!0,onClick:v,showHighlight:y,onClose:b,getSubUnitName:x,location:S,autoFocus:w,onMouseEnter:T,onMouseLeave:A,onAddComment:j,onDeleteComment:M,onResolve:N,type:P,style:F,full:I}=s,L=(0,t.useDependency)(r.ThreadCommentModel),[R,z]=(0,o.useState)(!1),[B,V]=(0,o.useState)(``);(0,t.useObservable)((0,o.useMemo)(()=>L.commentUpdate$.pipe((0,n.debounceTime)(16)),[L]));let H=f?L.getCommentWithChildren(p,m,f):null,U=(0,t.useDependency)(e.ICommandService),W=(0,t.useDependency)(e.UserManagerService),G=H==null?void 0:H.root.resolved,K=(0,t.useObservable)(W.currentUser$),q=(0,o.useRef)(null),J=[...H?[H.root]:[{id:O,text:{dataStream:`
4
- \r`},personId:(l=K==null?void 0:K.userID)==null?``:l,ref:h==null?``:h,dT:``,unitId:p,subUnitId:m,threadId:``}],...(u=H==null?void 0:H.children)==null?[]:u],Y=(0,o.useRef)(null),X=e=>{e.stopPropagation(),G?U.executeCommand(g.id,{unitId:p,subUnitId:m,commentId:f}):U.executeCommand(g.id),U.executeCommand(r.ResolveCommentCommand.id,{unitId:p,subUnitId:m,commentId:f,resolved:!G}),N==null||N(!G)},ee=e=>{e.stopPropagation(),U.executeCommand(g.id),!(H!=null&&H.root&&(M==null?void 0:M(H.root))===!1)&&(U.executeCommand(r.DeleteCommentTreeCommand.id,{unitId:p,subUnitId:m,commentId:f}),b==null||b())};(0,o.useEffect)(()=>A==null?void 0:A(),[]);let Z=x((d=H==null?void 0:H.root.subUnitId)==null?m:d),te=_&&!B&&!G,Q=`${h||(H==null?void 0:H.root.ref)||``}${Z?` · `:``}${Z}`,$=`${e.DOCS_COMMENT_EDITOR_UNIT_ID_KEY}_${S}`;return(0,c.jsxs)(`div`,{id:`${S}-${p}-${m}-${f}`,className:(0,i.clsx)(`univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white`,i.borderClassName,{"univer-w-[278px]":!I,"univer-w-full":I,"univer-shadow":!G&&(y||R||S===D.CELL)}),style:F,onClick:v,onMouseEnter:()=>{T==null||T(),z(!0)},onMouseLeave:()=>{A==null||A(),z(!1)},children:[!G&&y&&(0,c.jsx)(`div`,{className:`univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400`}),(0,c.jsxs)(`div`,{className:`univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5`,children:[(0,c.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden`,children:[(0,c.jsx)(`div`,{className:`univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500`}),(0,c.jsx)(i.Tooltip,{showIfEllipsis:!0,title:Q,children:(0,c.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:Q})})]}),!!H&&(0,c.jsxs)(`div`,{className:`univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row`,children:[(0,c.jsx)(`div`,{className:(0,i.clsx)(`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800`,{"univer-text-green-500":G}),onClick:X,children:G?(0,c.jsx)(a.ResolvedIcon,{}):(0,c.jsx)(a.SolveIcon,{})}),(K==null?void 0:K.userID)===H.root.personId?(0,c.jsx)(`div`,{className:`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800`,onClick:ee,children:(0,c.jsx)(a.DeleteIcon,{})}):null]})]}),(0,c.jsx)(`div`,{ref:Y,className:(0,i.clsx)(`univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden`,i.scrollbarClassName),children:J.map(e=>(0,c.jsx)(k,{unitId:p,subUnitId:m,item:e,isRoot:e.id===(H==null?void 0:H.root.id),editing:B===e.id,resolved:H==null?void 0:H.root.resolved,type:P,threadCommentEditorId:$,onClose:b,onEditingChange:t=>{V(t?e.id:``)},onReply:e=>{e&&requestAnimationFrame(()=>{var t;(t=q.current)==null||t.reply(E([{type:`mention`,content:{id:e.userID,label:`@${e.name}`}},{type:`text`,content:` `}]))})},onAddComment:j,onDeleteComment:M},e.id))}),te&&(0,c.jsx)(`div`,{children:(0,c.jsx)(C,{ref:q,type:P,unitId:p,subUnitId:m,editorId:$,onSave:async({text:t,attachments:n})=>{var i,a;let o={text:t,attachments:n,dT:(0,r.getDT)(),id:(0,e.generateRandomId)(),ref:h,personId:(i=K==null?void 0:K.userID)==null?``:i,parentId:H==null?void 0:H.root.id,unitId:p,subUnitId:m,threadId:(a=H==null?void 0:H.root.threadId)==null?``:a};(j==null?void 0:j(o))!==!1&&(await U.executeCommand(r.AddCommentCommand.id,{unitId:p,subUnitId:m,comment:o}),Y.current&&(Y.current.scrollTop=Y.current.scrollHeight))},autoFocus:w||!H,onCancel:()=>{H||b==null||b()}},`${w}`)})]})},j=n=>{let{unitId:s,subUnitId$:l,type:u,onAdd:d,getSubUnitName:f,onResolve:p,sortComments:m,onItemLeave:_,onItemEnter:v,disableAdd:y,tempComment:b,onAddComment:x,onDeleteComment:S,showComments:C}=n,[w,T]=(0,o.useState)(`all`),[E,O]=(0,o.useState)(`all`),k=(0,t.useDependency)(e.LocaleService),j=(0,t.useDependency)(e.UserManagerService),M=(0,t.useDependency)(r.ThreadCommentModel),[N,P]=(0,o.useState)(()=>M.getUnit(s)),F=(0,t.useObservable)((0,t.useDependency)(h).activeCommentId$),I=(0,t.useObservable)(M.commentUpdate$),L=(0,t.useDependency)(e.ICommandService),R=(0,t.useObservable)(l),z=(0,o.useRef)(!0),B=D.PANEL,V=(0,t.useObservable)(j.currentUser$),H=(0,o.useMemo)(()=>{var e;let t=w===`all`?N:(e=N.filter(e=>e.subUnitId===R))==null?[]:e,n=m==null?(e=>e):m,r=t.map(e=>{var t;return{...e.root,children:(t=e.children)==null?[]:t,users:e.relativeUsers}});if(C){let e=new Map;return r.forEach(t=>{e.set(t.id,t)}),[...C,``].map(t=>e.get(t)).filter(Boolean)}else return n(r)},[C,w,N,m,R]),U=(0,o.useMemo)(()=>[...H.filter(e=>!e.resolved),...H.filter(e=>e.resolved)],[H]),W=(0,o.useMemo)(()=>E===`resolved`?U.filter(e=>e.resolved):E===`unsolved`?U.filter(e=>!e.resolved):E===`concern_me`&&V!=null&&V.userID?U.filter(e=>e==null?void 0:e.users.has(V.userID)):U,[U,V==null?void 0:V.userID,E]),G=b?[b,...W]:W,K=G.filter(e=>!e.resolved),q=G.filter(e=>e.resolved),J=E!==`all`||w!==`all`,Y=()=>{O(`all`),T(`all`)};(0,o.useEffect)(()=>{s&&P(M.getUnit(s))},[s,M,I]),(0,o.useEffect)(()=>{var e;if(!F)return;if(!z.current){z.current=!0;return}let{unitId:t,subUnitId:n,commentId:r}=F,i=`${B}-${t}-${n}-${r}`;(e=document.getElementById(i))==null||e.scrollIntoView({block:`center`})},[F]);let X=e=>(0,c.jsx)(A,{location:B,getSubUnitName:f,id:e.id,unitId:e.unitId,subUnitId:e.subUnitId,refStr:e.ref,type:u,showEdit:(F==null?void 0:F.commentId)===e.id,showHighlight:(F==null?void 0:F.commentId)===e.id,onClick:()=>{z.current=!1,e.resolved?L.executeCommand(g.id):L.executeCommand(g.id,{unitId:e.unitId,subUnitId:e.subUnitId,commentId:e.id,temp:!1})},onMouseEnter:()=>v==null?void 0:v(e),onMouseLeave:()=>_==null?void 0:_(e),onAddComment:x,onDeleteComment:S,onResolve:t=>p==null?void 0:p(e.id,t)},e.id);return(0,c.jsxs)(`div`,{className:`univer-flex univer-min-h-full univer-flex-col univer-pb-3`,children:[(0,c.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-row univer-justify-between`,children:[u===e.UniverInstanceType.UNIVER_SHEET?(0,c.jsx)(i.Select,{borderless:!0,value:w,options:[{value:`current`,label:k.t(`threadCommentUI.filter.sheet.current`)},{value:`all`,label:k.t(`threadCommentUI.filter.sheet.all`)}],onChange:T}):null,(0,c.jsx)(i.Select,{borderless:!0,value:E,options:[{value:`all`,label:k.t(`threadCommentUI.filter.status.all`)},{value:`resolved`,label:k.t(`threadCommentUI.filter.status.resolved`)},{value:`unsolved`,label:k.t(`threadCommentUI.filter.status.unsolved`)},{value:`concern_me`,label:k.t(`threadCommentUI.filter.status.concernMe`)}],onChange:O})]}),G.length===0?(0,c.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[k.t(`threadCommentUI.panel.empty`),J?(0,c.jsx)(`div`,{className:`univer-mt-2 univer-flex univer-flex-row`,children:(0,c.jsx)(i.Button,{onClick:Y,children:k.t(`threadCommentUI.panel.reset`)})}):y?null:(0,c.jsx)(`div`,{className:`univer-mt-2 univer-flex univer-flex-row`,children:(0,c.jsxs)(i.Button,{onClick:d,children:[(0,c.jsx)(a.IncreaseIcon,{className:`univer-mr-1.5`}),k.t(`threadCommentUI.panel.addComment`)]})})]}):(0,c.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-flex-col univer-gap-3`,children:[K.map(X),q.length>0&&(0,c.jsx)(`div`,{className:`univer-text-xs`,children:k.t(`threadCommentUI.panel.solved`)}),q.map(X)]})]})};exports.SetActiveCommentOperation=g,exports.ThreadCommentPanel=j,Object.defineProperty(exports,`ThreadCommentPanelService`,{enumerable:!0,get:function(){return h}}),exports.ThreadCommentTree=A,exports.ThreadCommentTreeLocation=D,Object.defineProperty(exports,`UniverThreadCommentUIPlugin`,{enumerable:!0,get:function(){return x}});
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _univerjs_core = require("@univerjs/core");
3
+ let _univerjs_ui = require("@univerjs/ui");
4
+ let rxjs = require("rxjs");
5
+ let _univerjs_thread_comment = require("@univerjs/thread-comment");
6
+ let _univerjs_design = require("@univerjs/design");
7
+ let _univerjs_icons = require("@univerjs/icons");
8
+ let react = require("react");
9
+ let _univerjs_docs_ui = require("@univerjs/docs-ui");
10
+ let react_jsx_runtime = require("react/jsx-runtime");
11
+
12
+ //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
13
+ function _typeof(o) {
14
+ "@babel/helpers - typeof";
15
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
16
+ return typeof o;
17
+ } : function(o) {
18
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
19
+ }, _typeof(o);
20
+ }
21
+
22
+ //#endregion
23
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
24
+ function toPrimitive(t, r) {
25
+ if ("object" != _typeof(t) || !t) return t;
26
+ var e = t[Symbol.toPrimitive];
27
+ if (void 0 !== e) {
28
+ var i = e.call(t, r || "default");
29
+ if ("object" != _typeof(i)) return i;
30
+ throw new TypeError("@@toPrimitive must return a primitive value.");
31
+ }
32
+ return ("string" === r ? String : Number)(t);
33
+ }
34
+
35
+ //#endregion
36
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
37
+ function toPropertyKey(t) {
38
+ var i = toPrimitive(t, "string");
39
+ return "symbol" == _typeof(i) ? i : i + "";
40
+ }
41
+
42
+ //#endregion
43
+ //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
44
+ function _defineProperty(e, r, t) {
45
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
46
+ value: t,
47
+ enumerable: !0,
48
+ configurable: !0,
49
+ writable: !0
50
+ }) : e[r] = t, e;
51
+ }
52
+
53
+ //#endregion
54
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
55
+ function __decorateParam(paramIndex, decorator) {
56
+ return function(target, key) {
57
+ decorator(target, key, paramIndex);
58
+ };
59
+ }
60
+
61
+ //#endregion
62
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
63
+ function __decorate(decorators, target, key, desc) {
64
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
65
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
66
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
67
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
68
+ }
69
+
70
+ //#endregion
71
+ //#region src/services/thread-comment-panel.service.ts
72
+ let ThreadCommentPanelService = class ThreadCommentPanelService extends _univerjs_core.Disposable {
73
+ constructor(_sidebarService, _univerInstanceService) {
74
+ super();
75
+ this._sidebarService = _sidebarService;
76
+ this._univerInstanceService = _univerInstanceService;
77
+ _defineProperty(this, "_panelVisible", false);
78
+ _defineProperty(this, "_panelVisible$", new rxjs.BehaviorSubject(false));
79
+ _defineProperty(this, "_activeCommentId", void 0);
80
+ _defineProperty(this, "_activeCommentId$", new rxjs.BehaviorSubject(void 0));
81
+ _defineProperty(this, "panelVisible$", this._panelVisible$.asObservable());
82
+ _defineProperty(this, "activeCommentId$", this._activeCommentId$.asObservable());
83
+ this._init();
84
+ this.disposeWithMe(() => {
85
+ this._activeCommentId$.complete();
86
+ this._panelVisible$.complete();
87
+ });
88
+ }
89
+ _init() {
90
+ this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe((opt) => {
91
+ if (!opt.visible) this.setPanelVisible(false);
92
+ }));
93
+ this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.filter)((sheet) => !sheet)).subscribe(() => {
94
+ this._sidebarService.close();
95
+ }));
96
+ }
97
+ get panelVisible() {
98
+ return this._panelVisible;
99
+ }
100
+ get activeCommentId() {
101
+ return this._activeCommentId;
102
+ }
103
+ setPanelVisible(visible) {
104
+ this._panelVisible = visible;
105
+ this._panelVisible$.next(visible);
106
+ }
107
+ setActiveComment(commentInfo) {
108
+ this._activeCommentId = commentInfo;
109
+ this._activeCommentId$.next(commentInfo);
110
+ }
111
+ };
112
+ ThreadCommentPanelService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService)), __decorateParam(1, _univerjs_core.IUniverInstanceService)], ThreadCommentPanelService);
113
+
114
+ //#endregion
115
+ //#region src/commands/operations/comment.operations.ts
116
+ const SetActiveCommentOperation = {
117
+ id: "thread-comment-ui.operation.set-active-comment",
118
+ type: _univerjs_core.CommandType.OPERATION,
119
+ handler(accessor, params) {
120
+ accessor.get(ThreadCommentPanelService).setActiveComment(params);
121
+ return true;
122
+ }
123
+ };
124
+
125
+ //#endregion
126
+ //#region package.json
127
+ var name = "@univerjs/thread-comment-ui";
128
+ var version = "0.21.0-insiders.20260422-d7fcb4d";
129
+
130
+ //#endregion
131
+ //#region src/config/config.ts
132
+ const THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "thread-comment-ui.config";
133
+ const configSymbol = Symbol(THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY);
134
+ const defaultPluginConfig = {};
135
+
136
+ //#endregion
137
+ //#region src/types/const.ts
138
+ /**
139
+ * Copyright 2023-present DreamNum Co., Ltd.
140
+ *
141
+ * Licensed under the Apache License, Version 2.0 (the "License");
142
+ * you may not use this file except in compliance with the License.
143
+ * You may obtain a copy of the License at
144
+ *
145
+ * http://www.apache.org/licenses/LICENSE-2.0
146
+ *
147
+ * Unless required by applicable law or agreed to in writing, software
148
+ * distributed under the License is distributed on an "AS IS" BASIS,
149
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
150
+ * See the License for the specific language governing permissions and
151
+ * limitations under the License.
152
+ */
153
+ const PLUGIN_NAME = "UNIVER_THREAD_COMMENT_UI_PLUGIN";
154
+
155
+ //#endregion
156
+ //#region src/plugin.ts
157
+ let UniverThreadCommentUIPlugin = class UniverThreadCommentUIPlugin extends _univerjs_core.Plugin {
158
+ constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
159
+ super();
160
+ this._config = _config;
161
+ this._injector = _injector;
162
+ this._commandService = _commandService;
163
+ this._configService = _configService;
164
+ const { menu, ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
165
+ if (menu) this._configService.setConfig("menu", menu, { merge: true });
166
+ this._configService.setConfig(THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
167
+ }
168
+ onStarting() {
169
+ var _this$_config;
170
+ (0, _univerjs_core.mergeOverrideWithDependencies)([[ThreadCommentPanelService]], (_this$_config = this._config) === null || _this$_config === void 0 ? void 0 : _this$_config.overrides).forEach((dep) => {
171
+ this._injector.add(dep);
172
+ });
173
+ [SetActiveCommentOperation].forEach((command) => {
174
+ this._commandService.registerCommand(command);
175
+ });
176
+ }
177
+ };
178
+ _defineProperty(UniverThreadCommentUIPlugin, "pluginName", PLUGIN_NAME);
179
+ _defineProperty(UniverThreadCommentUIPlugin, "packageName", name);
180
+ _defineProperty(UniverThreadCommentUIPlugin, "version", version);
181
+ _defineProperty(UniverThreadCommentUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_UNKNOWN);
182
+ UniverThreadCommentUIPlugin = __decorate([
183
+ (0, _univerjs_core.DependentOn)(_univerjs_thread_comment.UniverThreadCommentPlugin),
184
+ __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
185
+ __decorateParam(2, _univerjs_core.ICommandService),
186
+ __decorateParam(3, _univerjs_core.IConfigService)
187
+ ], UniverThreadCommentUIPlugin);
188
+
189
+ //#endregion
190
+ //#region src/views/thread-comment-editor/index.tsx
191
+ function getSnapshot(body) {
192
+ return {
193
+ id: "d",
194
+ body,
195
+ documentStyle: {}
196
+ };
197
+ }
198
+ const ThreadCommentEditor = (0, react.forwardRef)((props, ref) => {
199
+ var _editor$current5;
200
+ const { comment, onSave, id, onCancel, autoFocus, unitId, type, editorId } = props;
201
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
202
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
203
+ const [editing, setEditing] = (0, react.useState)(false);
204
+ const editorService = (0, _univerjs_ui.useDependency)(_univerjs_docs_ui.IEditorService);
205
+ const editor = (0, react.useRef)(null);
206
+ const rootEditorId = type === _univerjs_core.UniverInstanceType.UNIVER_DOC ? _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY : unitId;
207
+ const [canSubmit, setCanSubmit] = (0, react.useState)(() => {
208
+ var _editor$current$getDo, _editor$current;
209
+ return _univerjs_core.BuildTextUtils.transform.getPlainText((_editor$current$getDo = (_editor$current = editor.current) === null || _editor$current === void 0 || (_editor$current = _editor$current.getDocumentData().body) === null || _editor$current === void 0 ? void 0 : _editor$current.dataStream) !== null && _editor$current$getDo !== void 0 ? _editor$current$getDo : "");
210
+ });
211
+ (0, react.useEffect)(() => {
212
+ var _editor$current$getDo2, _editor$current2, _editor$current3;
213
+ setCanSubmit(_univerjs_core.BuildTextUtils.transform.getPlainText((_editor$current$getDo2 = (_editor$current2 = editor.current) === null || _editor$current2 === void 0 || (_editor$current2 = _editor$current2.getDocumentData().body) === null || _editor$current2 === void 0 ? void 0 : _editor$current2.dataStream) !== null && _editor$current$getDo2 !== void 0 ? _editor$current$getDo2 : ""));
214
+ const sub = (_editor$current3 = editor.current) === null || _editor$current3 === void 0 ? void 0 : _editor$current3.selectionChange$.subscribe(() => {
215
+ var _editor$current$getDo3, _editor$current4;
216
+ setCanSubmit(_univerjs_core.BuildTextUtils.transform.getPlainText((_editor$current$getDo3 = (_editor$current4 = editor.current) === null || _editor$current4 === void 0 || (_editor$current4 = _editor$current4.getDocumentData().body) === null || _editor$current4 === void 0 ? void 0 : _editor$current4.dataStream) !== null && _editor$current$getDo3 !== void 0 ? _editor$current$getDo3 : ""));
217
+ });
218
+ return () => sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
219
+ }, [(_editor$current5 = editor.current) === null || _editor$current5 === void 0 ? void 0 : _editor$current5.selectionChange$]);
220
+ const keyboardEventConfig = (0, react.useMemo)(() => ({
221
+ keyCodes: [{ keyCode: _univerjs_ui.KeyCode.ENTER }],
222
+ handler: (keyCode) => {
223
+ if (keyCode === _univerjs_ui.KeyCode.ENTER) commandService.executeCommand(_univerjs_docs_ui.BreakLineCommand.id);
224
+ }
225
+ }), [commandService]);
226
+ (0, react.useImperativeHandle)(ref, () => ({ reply(text) {
227
+ var _getEditorId, _editor$current6;
228
+ if (!editor.current) return;
229
+ editorService.focus((_getEditorId = editor.current.getEditorId()) !== null && _getEditorId !== void 0 ? _getEditorId : "");
230
+ const documentData = getSnapshot(text);
231
+ (_editor$current6 = editor.current) === null || _editor$current6 === void 0 || _editor$current6.setDocumentData(documentData, [{
232
+ startOffset: documentData.body.dataStream.length - 2,
233
+ endOffset: documentData.body.dataStream.length - 2,
234
+ collapsed: true
235
+ }]);
236
+ } }));
237
+ const handleSave = () => {
238
+ if (editor.current) {
239
+ const newText = _univerjs_core.Tools.deepClone(editor.current.getDocumentData().body);
240
+ setEditing(false);
241
+ onSave === null || onSave === void 0 || onSave({
242
+ ...comment,
243
+ text: newText
244
+ });
245
+ editor.current.replaceText("");
246
+ setTimeout(() => {
247
+ var _editor$current7, _editor$current8;
248
+ (_editor$current7 = editor.current) === null || _editor$current7 === void 0 || _editor$current7.setSelectionRanges([]);
249
+ (_editor$current8 = editor.current) === null || _editor$current8 === void 0 || _editor$current8.blur();
250
+ }, 10);
251
+ }
252
+ };
253
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
254
+ onClick: (e) => e.preventDefault(),
255
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_docs_ui.RichTextEditor, {
256
+ className: "univer-w-full",
257
+ editorRef: editor,
258
+ editorId,
259
+ autoFocus,
260
+ keyboardEventConfig,
261
+ placeholder: localeService.t("threadCommentUI.editor.placeholder"),
262
+ initialValue: (comment === null || comment === void 0 ? void 0 : comment.text) && getSnapshot(comment.text),
263
+ onFocusChange: (isFocus) => isFocus && setEditing(isFocus),
264
+ isSingle: false,
265
+ maxHeight: 64,
266
+ onClickOutside: () => {
267
+ setTimeout(() => {
268
+ editorService.focus(rootEditorId);
269
+ }, 30);
270
+ }
271
+ }), editing ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
272
+ className: "univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",
273
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
274
+ onClick: () => {
275
+ var _editor$current9;
276
+ onCancel === null || onCancel === void 0 || onCancel();
277
+ setEditing(false);
278
+ (_editor$current9 = editor.current) === null || _editor$current9 === void 0 || _editor$current9.replaceText("", true);
279
+ commandService.executeCommand(SetActiveCommentOperation.id);
280
+ },
281
+ children: localeService.t("threadCommentUI.editor.cancel")
282
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
283
+ variant: "primary",
284
+ disabled: !canSubmit,
285
+ onClick: handleSave,
286
+ children: localeService.t(id ? "threadCommentUI.editor.save" : "threadCommentUI.editor.reply")
287
+ })]
288
+ }) : null]
289
+ });
290
+ });
291
+
292
+ //#endregion
293
+ //#region src/views/thread-comment-editor/util.ts
294
+ const transformDocument2TextNodesInParagraph = (doc) => {
295
+ const { dataStream, customRanges } = doc;
296
+ const end = dataStream.endsWith("\r\n") ? dataStream.length - 2 : dataStream.length;
297
+ const textNodes = [];
298
+ let lastIndex = 0;
299
+ customRanges === null || customRanges === void 0 || customRanges.forEach((range) => {
300
+ if (lastIndex < range.startIndex) textNodes.push({
301
+ type: "text",
302
+ content: dataStream.slice(lastIndex, range.startIndex)
303
+ });
304
+ textNodes.push({
305
+ type: "mention",
306
+ content: {
307
+ label: dataStream.slice(range.startIndex, range.endIndex + 1),
308
+ id: range.rangeId
309
+ }
310
+ });
311
+ lastIndex = range.endIndex + 1;
312
+ });
313
+ textNodes.push({
314
+ type: "text",
315
+ content: dataStream.slice(lastIndex, end)
316
+ });
317
+ return textNodes;
318
+ };
319
+ const transformDocument2TextNodes = (doc) => {
320
+ if (!doc) return [];
321
+ const { paragraphs = [] } = doc;
322
+ return paragraphs.map((paragraph, index) => {
323
+ return transformDocument2TextNodesInParagraph((0, _univerjs_core.getBodySlice)(doc, index === 0 ? 0 : paragraphs[index - 1].startIndex + 1, paragraph.startIndex));
324
+ });
325
+ };
326
+ const transformTextNodes2Document = (nodes) => {
327
+ let str = "";
328
+ const customRanges = [];
329
+ nodes.forEach((node) => {
330
+ switch (node.type) {
331
+ case "text":
332
+ str += node.content;
333
+ break;
334
+ case "mention": {
335
+ const start = str.length;
336
+ str += node.content.label;
337
+ const end = str.length - 1;
338
+ customRanges.push({
339
+ rangeId: node.content.id,
340
+ rangeType: _univerjs_core.CustomRangeType.MENTION,
341
+ startIndex: start,
342
+ endIndex: end,
343
+ properties: {},
344
+ wholeEntity: true
345
+ });
346
+ break;
347
+ }
348
+ default: break;
349
+ }
350
+ });
351
+ str += "\r\n";
352
+ return {
353
+ textRuns: [],
354
+ paragraphs: [{
355
+ startIndex: str.length - 2,
356
+ paragraphStyle: {}
357
+ }],
358
+ sectionBreaks: [{ startIndex: str.length - 1 }],
359
+ dataStream: str,
360
+ customRanges
361
+ };
362
+ };
363
+
364
+ //#endregion
365
+ //#region src/views/thread-comment-tree/index.tsx
366
+ let ThreadCommentTreeLocation = /* @__PURE__ */ function(ThreadCommentTreeLocation) {
367
+ ThreadCommentTreeLocation["CELL"] = "CELL";
368
+ ThreadCommentTreeLocation["PANEL"] = "PANEL";
369
+ return ThreadCommentTreeLocation;
370
+ }({});
371
+ const MOCK_ID = "__mock__";
372
+ const ThreadCommentItem = (props) => {
373
+ const { item, unitId, subUnitId, editing, onEditingChange, onReply, resolved, isRoot, onClose, onDeleteComment, type, threadCommentEditorId } = props;
374
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
375
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
376
+ const userManagerService = (0, _univerjs_ui.useDependency)(_univerjs_core.UserManagerService);
377
+ const user = userManagerService.getUser(item.personId);
378
+ const currentUser = (0, _univerjs_ui.useObservable)(userManagerService.currentUser$);
379
+ const isCommentBySelf = (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) === item.personId;
380
+ const isMock = item.id === MOCK_ID;
381
+ const [showReply, setShowReply] = (0, react.useState)(false);
382
+ const uiConfig = (0, _univerjs_ui.useConfigValue)(_univerjs_ui.UI_PLUGIN_CONFIG_KEY);
383
+ const avatarFallback = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.avatarFallback;
384
+ const handleDeleteItem = () => {
385
+ if ((onDeleteComment === null || onDeleteComment === void 0 ? void 0 : onDeleteComment(item)) === false) return;
386
+ commandService.executeCommand(isRoot ? _univerjs_thread_comment.DeleteCommentTreeCommand.id : _univerjs_thread_comment.DeleteCommentCommand.id, {
387
+ unitId,
388
+ subUnitId,
389
+ commentId: item.id
390
+ });
391
+ if (isRoot) onClose === null || onClose === void 0 || onClose();
392
+ };
393
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
394
+ className: "univer-relative univer-mb-3 univer-pl-[30px]",
395
+ onMouseLeave: () => setShowReply(false),
396
+ onMouseEnter: () => setShowReply(true),
397
+ children: [
398
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
399
+ className: "univer-absolute univer-left-0 univer-top-0 univer-size-6 univer-rounded-full univer-bg-cover univer-bg-center univer-bg-no-repeat",
400
+ style: { backgroundImage: `url(${(user === null || user === void 0 ? void 0 : user.avatar) || avatarFallback})` }
401
+ }),
402
+ user ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
403
+ className: "univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",
404
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
405
+ className: "univer-text-sm univer-font-medium univer-leading-5",
406
+ children: (user === null || user === void 0 ? void 0 : user.name) || " "
407
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [isMock || resolved ? null : showReply && user ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
408
+ className: "univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",
409
+ onClick: () => onReply(user),
410
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ReplyToCommentIcon, {})
411
+ }) : null, isCommentBySelf && !isMock && !resolved ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
412
+ overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
413
+ className: "univer-rounded-lg",
414
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("ul", {
415
+ className: "univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors",
416
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
417
+ className: "hover:univer-bg-gray-200",
418
+ onClick: () => onEditingChange === null || onEditingChange === void 0 ? void 0 : onEditingChange(true),
419
+ children: localeService.t("threadCommentUI.item.edit")
420
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
421
+ className: "hover:univer-bg-gray-200",
422
+ onClick: handleDeleteItem,
423
+ children: localeService.t("threadCommentUI.item.delete")
424
+ }) })]
425
+ })
426
+ }),
427
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
428
+ className: "univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",
429
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreHorizontalIcon, {})
430
+ })
431
+ }) : null] })]
432
+ }) : null,
433
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("time", {
434
+ className: "univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",
435
+ children: item.dT
436
+ }),
437
+ editing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentEditor, {
438
+ type,
439
+ id: item.id,
440
+ comment: item,
441
+ onCancel: () => onEditingChange === null || onEditingChange === void 0 ? void 0 : onEditingChange(false),
442
+ autoFocus: true,
443
+ unitId,
444
+ subUnitId,
445
+ editorId: threadCommentEditorId,
446
+ onSave: ({ text, attachments }) => {
447
+ onEditingChange === null || onEditingChange === void 0 || onEditingChange(false);
448
+ commandService.executeCommand(_univerjs_thread_comment.UpdateCommentCommand.id, {
449
+ unitId,
450
+ subUnitId,
451
+ payload: {
452
+ commentId: item.id,
453
+ text,
454
+ attachments
455
+ }
456
+ });
457
+ }
458
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
459
+ className: "univer-text-sm univer-text-gray-900 dark:!univer-text-white",
460
+ children: transformDocument2TextNodes(item.text).map((paragraph, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
461
+ className: "univer-break-words",
462
+ children: paragraph.map((item, i) => {
463
+ switch (item.type) {
464
+ case "mention": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
465
+ className: "univer-text-primary-600",
466
+ children: [item.content.label, " "]
467
+ }, i);
468
+ default: return item.content;
469
+ }
470
+ })
471
+ }, i))
472
+ })
473
+ ]
474
+ });
475
+ };
476
+ const ThreadCommentTree = (props) => {
477
+ var _currentUser$userID, _comments$children, _comments$root$subUni;
478
+ const { id, unitId, subUnitId, refStr, showEdit = true, onClick, showHighlight, onClose, getSubUnitName, location, autoFocus, onMouseEnter, onMouseLeave, onAddComment, onDeleteComment, onResolve, type, style, full } = props;
479
+ const threadCommentModel = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment.ThreadCommentModel);
480
+ const [isHover, setIsHover] = (0, react.useState)(false);
481
+ const [editingId, setEditingId] = (0, react.useState)("");
482
+ (0, _univerjs_ui.useObservable)((0, react.useMemo)(() => threadCommentModel.commentUpdate$.pipe((0, rxjs.debounceTime)(16)), [threadCommentModel]));
483
+ const comments = id ? threadCommentModel.getCommentWithChildren(unitId, subUnitId, id) : null;
484
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
485
+ const userManagerService = (0, _univerjs_ui.useDependency)(_univerjs_core.UserManagerService);
486
+ const resolved = comments === null || comments === void 0 ? void 0 : comments.root.resolved;
487
+ const currentUser = (0, _univerjs_ui.useObservable)(userManagerService.currentUser$);
488
+ const editorRef = (0, react.useRef)(null);
489
+ const renderComments = [...comments ? [comments.root] : [{
490
+ id: MOCK_ID,
491
+ text: { dataStream: "\n\r" },
492
+ personId: (_currentUser$userID = currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) !== null && _currentUser$userID !== void 0 ? _currentUser$userID : "",
493
+ ref: refStr !== null && refStr !== void 0 ? refStr : "",
494
+ dT: "",
495
+ unitId,
496
+ subUnitId,
497
+ threadId: ""
498
+ }], ...(_comments$children = comments === null || comments === void 0 ? void 0 : comments.children) !== null && _comments$children !== void 0 ? _comments$children : []];
499
+ const scroller = (0, react.useRef)(null);
500
+ const handleResolve = (e) => {
501
+ e.stopPropagation();
502
+ if (!resolved) commandService.executeCommand(SetActiveCommentOperation.id);
503
+ else commandService.executeCommand(SetActiveCommentOperation.id, {
504
+ unitId,
505
+ subUnitId,
506
+ commentId: id
507
+ });
508
+ commandService.executeCommand(_univerjs_thread_comment.ResolveCommentCommand.id, {
509
+ unitId,
510
+ subUnitId,
511
+ commentId: id,
512
+ resolved: !resolved
513
+ });
514
+ onResolve === null || onResolve === void 0 || onResolve(!resolved);
515
+ };
516
+ const handleDeleteRoot = (e) => {
517
+ e.stopPropagation();
518
+ commandService.executeCommand(SetActiveCommentOperation.id);
519
+ if ((comments === null || comments === void 0 ? void 0 : comments.root) && (onDeleteComment === null || onDeleteComment === void 0 ? void 0 : onDeleteComment(comments.root)) === false) return;
520
+ commandService.executeCommand(_univerjs_thread_comment.DeleteCommentTreeCommand.id, {
521
+ unitId,
522
+ subUnitId,
523
+ commentId: id
524
+ });
525
+ onClose === null || onClose === void 0 || onClose();
526
+ };
527
+ (0, react.useEffect)(() => {
528
+ return onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave();
529
+ }, []);
530
+ const subUnitName = getSubUnitName((_comments$root$subUni = comments === null || comments === void 0 ? void 0 : comments.root.subUnitId) !== null && _comments$root$subUni !== void 0 ? _comments$root$subUni : subUnitId);
531
+ const editorVisible = showEdit && !editingId && !resolved;
532
+ const title = `${refStr || (comments === null || comments === void 0 ? void 0 : comments.root.ref) || ""}${subUnitName ? " · " : ""}${subUnitName}`;
533
+ const threadCommentEditorId = `${_univerjs_core.DOCS_COMMENT_EDITOR_UNIT_ID_KEY}_${location}`;
534
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
535
+ id: `${location}-${unitId}-${subUnitId}-${id}`,
536
+ className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white", _univerjs_design.borderClassName, {
537
+ "univer-w-[278px]": !full,
538
+ "univer-w-full": full,
539
+ "univer-shadow": !resolved && (showHighlight || isHover || location === ThreadCommentTreeLocation.CELL)
540
+ }),
541
+ style,
542
+ onClick,
543
+ onMouseEnter: () => {
544
+ onMouseEnter === null || onMouseEnter === void 0 || onMouseEnter();
545
+ setIsHover(true);
546
+ },
547
+ onMouseLeave: () => {
548
+ onMouseLeave === null || onMouseLeave === void 0 || onMouseLeave();
549
+ setIsHover(false);
550
+ },
551
+ children: [
552
+ !resolved && showHighlight && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400" }),
553
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
554
+ className: "univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5",
555
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
556
+ className: "univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",
557
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
558
+ showIfEllipsis: true,
559
+ title,
560
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
561
+ className: "univer-flex-1 univer-truncate",
562
+ children: title
563
+ })
564
+ })]
565
+ }), !!comments && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
566
+ className: "univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",
567
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
568
+ className: (0, _univerjs_design.clsx)("univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800", { "univer-text-green-500": resolved }),
569
+ onClick: handleResolve,
570
+ children: resolved ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ResolvedIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SolveIcon, {})
571
+ }), (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) === comments.root.personId ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
572
+ className: "univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800",
573
+ onClick: handleDeleteRoot,
574
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, {})
575
+ }) : null]
576
+ })]
577
+ }),
578
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
579
+ ref: scroller,
580
+ className: (0, _univerjs_design.clsx)("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden", _univerjs_design.scrollbarClassName),
581
+ children: renderComments.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentItem, {
582
+ unitId,
583
+ subUnitId,
584
+ item,
585
+ isRoot: item.id === (comments === null || comments === void 0 ? void 0 : comments.root.id),
586
+ editing: editingId === item.id,
587
+ resolved: comments === null || comments === void 0 ? void 0 : comments.root.resolved,
588
+ type,
589
+ threadCommentEditorId,
590
+ onClose,
591
+ onEditingChange: (editing) => {
592
+ if (editing) setEditingId(item.id);
593
+ else setEditingId("");
594
+ },
595
+ onReply: (user) => {
596
+ if (!user) return;
597
+ requestAnimationFrame(() => {
598
+ var _editorRef$current;
599
+ (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || _editorRef$current.reply(transformTextNodes2Document([{
600
+ type: "mention",
601
+ content: {
602
+ id: user.userID,
603
+ label: `@${user.name}`
604
+ }
605
+ }, {
606
+ type: "text",
607
+ content: " "
608
+ }]));
609
+ });
610
+ },
611
+ onAddComment,
612
+ onDeleteComment
613
+ }, item.id))
614
+ }),
615
+ editorVisible && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentEditor, {
616
+ ref: editorRef,
617
+ type,
618
+ unitId,
619
+ subUnitId,
620
+ editorId: threadCommentEditorId,
621
+ onSave: async ({ text, attachments }) => {
622
+ var _currentUser$userID2, _comments$root$thread;
623
+ const comment = {
624
+ text,
625
+ attachments,
626
+ dT: (0, _univerjs_thread_comment.getDT)(),
627
+ id: (0, _univerjs_core.generateRandomId)(),
628
+ ref: refStr,
629
+ personId: (_currentUser$userID2 = currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) !== null && _currentUser$userID2 !== void 0 ? _currentUser$userID2 : "",
630
+ parentId: comments === null || comments === void 0 ? void 0 : comments.root.id,
631
+ unitId,
632
+ subUnitId,
633
+ threadId: (_comments$root$thread = comments === null || comments === void 0 ? void 0 : comments.root.threadId) !== null && _comments$root$thread !== void 0 ? _comments$root$thread : ""
634
+ };
635
+ if ((onAddComment === null || onAddComment === void 0 ? void 0 : onAddComment(comment)) === false) return;
636
+ await commandService.executeCommand(_univerjs_thread_comment.AddCommentCommand.id, {
637
+ unitId,
638
+ subUnitId,
639
+ comment
640
+ });
641
+ if (scroller.current) scroller.current.scrollTop = scroller.current.scrollHeight;
642
+ },
643
+ autoFocus: autoFocus || !comments,
644
+ onCancel: () => {
645
+ if (!comments) onClose === null || onClose === void 0 || onClose();
646
+ }
647
+ }, `${autoFocus}`) })
648
+ ]
649
+ });
650
+ };
651
+
652
+ //#endregion
653
+ //#region src/views/thread-comment-panel/index.tsx
654
+ const ThreadCommentPanel = (props) => {
655
+ const { unitId, subUnitId$, type, onAdd, getSubUnitName, onResolve, sortComments, onItemLeave, onItemEnter, disableAdd, tempComment, onAddComment, onDeleteComment, showComments } = props;
656
+ const [unit, setUnit] = (0, react.useState)("all");
657
+ const [status, setStatus] = (0, react.useState)("all");
658
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
659
+ const userService = (0, _univerjs_ui.useDependency)(_univerjs_core.UserManagerService);
660
+ const threadCommentModel = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment.ThreadCommentModel);
661
+ const [unitComments, setUnitComments] = (0, react.useState)(() => threadCommentModel.getUnit(unitId));
662
+ const activeCommentId = (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(ThreadCommentPanelService).activeCommentId$);
663
+ const update = (0, _univerjs_ui.useObservable)(threadCommentModel.commentUpdate$);
664
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
665
+ const subUnitId = (0, _univerjs_ui.useObservable)(subUnitId$);
666
+ const shouldScroll = (0, react.useRef)(true);
667
+ const location = ThreadCommentTreeLocation.PANEL;
668
+ const currentUser = (0, _univerjs_ui.useObservable)(userService.currentUser$);
669
+ const comments = (0, react.useMemo)(() => {
670
+ var _unitComments$filter;
671
+ const allComments = unit === "all" ? unitComments : (_unitComments$filter = unitComments.filter((i) => i.subUnitId === subUnitId)) !== null && _unitComments$filter !== void 0 ? _unitComments$filter : [];
672
+ const sort = sortComments !== null && sortComments !== void 0 ? sortComments : ((a) => a);
673
+ const res = allComments.map((i) => {
674
+ var _i$children;
675
+ return {
676
+ ...i.root,
677
+ children: (_i$children = i.children) !== null && _i$children !== void 0 ? _i$children : [],
678
+ users: i.relativeUsers
679
+ };
680
+ });
681
+ if (showComments) {
682
+ const map = /* @__PURE__ */ new Map();
683
+ res.forEach((comment) => {
684
+ map.set(comment.id, comment);
685
+ });
686
+ return [...showComments, ""].map((id) => map.get(id)).filter(Boolean);
687
+ } else return sort(res);
688
+ }, [
689
+ showComments,
690
+ unit,
691
+ unitComments,
692
+ sortComments,
693
+ subUnitId
694
+ ]);
695
+ const commentsSorted = (0, react.useMemo)(() => [...comments.filter((comment) => !comment.resolved), ...comments.filter((comment) => comment.resolved)], [comments]);
696
+ const statuedComments = (0, react.useMemo)(() => {
697
+ if (status === "resolved") return commentsSorted.filter((comment) => comment.resolved);
698
+ if (status === "unsolved") return commentsSorted.filter((comment) => !comment.resolved);
699
+ if (status === "concern_me") {
700
+ if (!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID)) return commentsSorted;
701
+ return commentsSorted.filter((comment) => comment === null || comment === void 0 ? void 0 : comment.users.has(currentUser.userID));
702
+ }
703
+ return commentsSorted;
704
+ }, [
705
+ commentsSorted,
706
+ currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID,
707
+ status
708
+ ]);
709
+ const renderComments = tempComment ? [tempComment, ...statuedComments] : statuedComments;
710
+ const unSolvedComments = renderComments.filter((comment) => !comment.resolved);
711
+ const solvedComments = renderComments.filter((comment) => comment.resolved);
712
+ const isFiltering = status !== "all" || unit !== "all";
713
+ const onReset = () => {
714
+ setStatus("all");
715
+ setUnit("all");
716
+ };
717
+ (0, react.useEffect)(() => {
718
+ if (unitId) setUnitComments(threadCommentModel.getUnit(unitId));
719
+ }, [
720
+ unitId,
721
+ threadCommentModel,
722
+ update
723
+ ]);
724
+ (0, react.useEffect)(() => {
725
+ var _document$getElementB;
726
+ if (!activeCommentId) return;
727
+ if (!shouldScroll.current) {
728
+ shouldScroll.current = true;
729
+ return;
730
+ }
731
+ const { unitId, subUnitId, commentId } = activeCommentId;
732
+ const id = `${location}-${unitId}-${subUnitId}-${commentId}`;
733
+ (_document$getElementB = document.getElementById(id)) === null || _document$getElementB === void 0 || _document$getElementB.scrollIntoView({ block: "center" });
734
+ }, [activeCommentId]);
735
+ const renderComment = (comment) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentTree, {
736
+ location,
737
+ getSubUnitName,
738
+ id: comment.id,
739
+ unitId: comment.unitId,
740
+ subUnitId: comment.subUnitId,
741
+ refStr: comment.ref,
742
+ type,
743
+ showEdit: (activeCommentId === null || activeCommentId === void 0 ? void 0 : activeCommentId.commentId) === comment.id,
744
+ showHighlight: (activeCommentId === null || activeCommentId === void 0 ? void 0 : activeCommentId.commentId) === comment.id,
745
+ onClick: () => {
746
+ shouldScroll.current = false;
747
+ if (!comment.resolved) commandService.executeCommand(SetActiveCommentOperation.id, {
748
+ unitId: comment.unitId,
749
+ subUnitId: comment.subUnitId,
750
+ commentId: comment.id,
751
+ temp: false
752
+ });
753
+ else commandService.executeCommand(SetActiveCommentOperation.id);
754
+ },
755
+ onMouseEnter: () => onItemEnter === null || onItemEnter === void 0 ? void 0 : onItemEnter(comment),
756
+ onMouseLeave: () => onItemLeave === null || onItemLeave === void 0 ? void 0 : onItemLeave(comment),
757
+ onAddComment,
758
+ onDeleteComment,
759
+ onResolve: (resolved) => onResolve === null || onResolve === void 0 ? void 0 : onResolve(comment.id, resolved)
760
+ }, comment.id);
761
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
762
+ className: "univer-flex univer-min-h-full univer-flex-col univer-pb-3",
763
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
764
+ className: "univer-mt-3 univer-flex univer-flex-row univer-justify-between",
765
+ children: [type === _univerjs_core.UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
766
+ borderless: true,
767
+ value: unit,
768
+ options: [{
769
+ value: "current",
770
+ label: localeService.t("threadCommentUI.filter.sheet.current")
771
+ }, {
772
+ value: "all",
773
+ label: localeService.t("threadCommentUI.filter.sheet.all")
774
+ }],
775
+ onChange: setUnit
776
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
777
+ borderless: true,
778
+ value: status,
779
+ options: [
780
+ {
781
+ value: "all",
782
+ label: localeService.t("threadCommentUI.filter.status.all")
783
+ },
784
+ {
785
+ value: "resolved",
786
+ label: localeService.t("threadCommentUI.filter.status.resolved")
787
+ },
788
+ {
789
+ value: "unsolved",
790
+ label: localeService.t("threadCommentUI.filter.status.unsolved")
791
+ },
792
+ {
793
+ value: "concern_me",
794
+ label: localeService.t("threadCommentUI.filter.status.concernMe")
795
+ }
796
+ ],
797
+ onChange: setStatus
798
+ })]
799
+ }), renderComments.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
800
+ className: "univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
801
+ children: [localeService.t("threadCommentUI.panel.empty"), isFiltering ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
802
+ className: "univer-mt-2 univer-flex univer-flex-row",
803
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
804
+ onClick: onReset,
805
+ children: localeService.t("threadCommentUI.panel.reset")
806
+ })
807
+ }) : !disableAdd ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
808
+ className: "univer-mt-2 univer-flex univer-flex-row",
809
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
810
+ onClick: onAdd,
811
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.IncreaseIcon, { className: "univer-mr-1.5" }), localeService.t("threadCommentUI.panel.addComment")]
812
+ })
813
+ }) : null]
814
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
815
+ className: "univer-mt-3 univer-flex univer-flex-col univer-gap-3",
816
+ children: [
817
+ unSolvedComments.map(renderComment),
818
+ solvedComments.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
819
+ className: "univer-text-xs",
820
+ children: localeService.t("threadCommentUI.panel.solved")
821
+ }),
822
+ solvedComments.map(renderComment)
823
+ ]
824
+ })]
825
+ });
826
+ };
827
+
828
+ //#endregion
829
+ exports.SetActiveCommentOperation = SetActiveCommentOperation;
830
+ exports.ThreadCommentPanel = ThreadCommentPanel;
831
+ Object.defineProperty(exports, 'ThreadCommentPanelService', {
832
+ enumerable: true,
833
+ get: function () {
834
+ return ThreadCommentPanelService;
835
+ }
836
+ });
837
+ exports.ThreadCommentTree = ThreadCommentTree;
838
+ exports.ThreadCommentTreeLocation = ThreadCommentTreeLocation;
839
+ Object.defineProperty(exports, 'UniverThreadCommentUIPlugin', {
840
+ enumerable: true,
841
+ get: function () {
842
+ return UniverThreadCommentUIPlugin;
843
+ }
844
+ });