@univerjs/preset-docs-thread-comment 0.6.1-nightly.202502241606 → 0.6.1-nightly.202502251606

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 (2) hide show
  1. package/lib/umd/index.js +5 -5
  2. package/package.json +4 -4
package/lib/umd/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // @univerjs/thread-comment-ui/index
2
- (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverThreadCommentUi={},c.UniverCore,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.UniverDesign,c.React,c.UniverDocsUi))})(this,function(c,a,_,C,te,o,B,m,se){"use strict";var Je=Object.defineProperty;var Qe=(c,a,_)=>a in c?Je(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var K=(c,a,_)=>Qe(c,typeof a!="symbol"?a+"":a,_);var Pe=Object.getOwnPropertyDescriptor,xe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Pe(e,t):e,d=n.length-1,h;d>=0;d--)(h=n[d])&&(i=h(i)||i);return i},le=(n,e)=>(t,r)=>e(t,r,n);c.ThreadCommentPanelService=class extends a.Disposable{constructor(t,r){super();K(this,"_panelVisible",!1);K(this,"_panelVisible$",new te.BehaviorSubject(!1));K(this,"_activeCommentId");K(this,"_activeCommentId$",new te.BehaviorSubject(void 0));K(this,"panelVisible$",this._panelVisible$.asObservable());K(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(te.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}},c.ThreadCommentPanelService=xe([le(0,a.Inject(C.ISidebarService)),le(1,a.IUniverInstanceService)],c.ThreadCommentPanelService);const me="thread-comment-panel",Ee="UNIVER_THREAD_COMMENT_UI_PLUGIN",ce={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(C.ISidebarService),t=n.get(c.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:me},width:330}),t.setPanelVisible(!0)),!0}},F={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(c.ThreadCommentPanelService).setActiveComment(e),!0}},De="thread-comment-ui.config",he={};var Oe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,He=(n,e,t)=>e in n?Oe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,we=(n,e,t,r)=>{for(var i=r>1?void 0:r?Me(e,t):e,d=n.length-1,h;d>=0;d--)(h=n[d])&&(i=h(i)||i);return i},de=(n,e)=>(t,r)=>e(t,r,n),ue=(n,e,t)=>He(n,typeof e!="symbol"?e+"":e,t);c.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=he,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:d,...h}=a.merge({},he,this._config);d&&this._configService.setConfig("menu",d,{merge:!0}),this._configService.setConfig(De,h)}onStarting(){var e;a.mergeOverrideWithDependencies([[c.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[ce,F].forEach(t=>{this._commandService.registerCommand(t)})}},ue(c.UniverThreadCommentUIPlugin,"pluginName",Ee),ue(c.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),c.UniverThreadCommentUIPlugin=we([a.DependentOn(_.UniverThreadCommentPlugin),de(1,a.Inject(a.Injector)),de(2,a.ICommandService),de(3,a.IConfigService)],c.UniverThreadCommentUIPlugin);var M=function(){return M=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},M.apply(this,arguments)},je=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},q=m.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,d=n.extend,h=je(n,["icon","id","className","extend"]),I="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),b=m.useRef("_".concat(Ae()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:b.current},M({ref:e,className:I},h),d)});function ve(n,e,t,r,i){return m.createElement(n.tag,M(M({key:e},ke(n,t,i)),r),($e(n,t).children||[]).map(function(d,h){return ve(d,"".concat(e,"-").concat(n.tag,"-").concat(h),t,void 0,i)}))}function ke(n,e,t){var r=M({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(d){var h=d[0],I=d[1];h==="mask"&&typeof I=="string"&&(r[h]=I.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(d){var h=d[0],I=d[1];typeof I=="string"&&(r[h]=I.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function $e(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?M(M({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?M(M({},i),{attrs:M(M({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Ae(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ce=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"delete-single",ref:e,icon:Le}))});Ce.displayName="DeleteSingle";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"increase-single",ref:e,icon:Ve}))});fe.displayName="IncreaseSingle";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},pe=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Be}))});pe.displayName="MoreHorizontalSingle";var Fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},ge=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Fe}))});ge.displayName="ReplyToCommentSingle";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ie=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"resolved-single",ref:e,icon:We}))});Ie.displayName="ResolvedSingle";var qe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},Se=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"solve-single",ref:e,icon:qe}))});Se.displayName="SolveSingle";function ye(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=ye(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ze(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=ye(n))&&(r&&(r+=" "),r+=e);return r}const be={threadCommentEditorButtons:"univer-thread-comment-editor-buttons"};function Te(n){return{id:"d",body:n,documentStyle:{}}}const _e=m.forwardRef((n,e)=>{var L;const{comment:t,onSave:r,id:i,onCancel:d,autoFocus:h,unitId:I,type:b}=n,E=C.useDependency(a.ICommandService),H=C.useDependency(a.LocaleService),[V,w]=m.useState(!1),D=C.useDependency(se.IEditorService),v=m.useRef(null),S=b===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:I,[j,N]=m.useState(()=>{var u,f,y;return a.BuildTextUtils.transform.getPlainText((y=(f=(u=v.current)==null?void 0:u.getDocumentData().body)==null?void 0:f.dataStream)!=null?y:"")});m.useEffect(()=>{var f,y,l,p;N(a.BuildTextUtils.transform.getPlainText((l=(y=(f=v.current)==null?void 0:f.getDocumentData().body)==null?void 0:y.dataStream)!=null?l:""));const u=(p=v.current)==null?void 0:p.selectionChange$.subscribe(()=>{var Z,P,U;N(a.BuildTextUtils.transform.getPlainText((U=(P=(Z=v.current)==null?void 0:Z.getDocumentData().body)==null?void 0:P.dataStream)!=null?U:""))});return()=>u==null?void 0:u.unsubscribe()},[(L=v.current)==null?void 0:L.selectionChange$]);const $=m.useMemo(()=>({keyCodes:[{keyCode:C.KeyCode.ENTER}],handler:u=>{u===C.KeyCode.ENTER&&E.executeCommand(se.BreakLineCommand.id)}}),[E]);m.useImperativeHandle(e,()=>({reply(u){var f,y;(f=v.current)==null||f.focus(),(y=v.current)==null||y.setDocumentData(Te(u))}}));const T=()=>{if(v.current){const u=a.Tools.deepClone(v.current.getDocumentData().body);w(!1),r==null||r({...t,text:u}),v.current.replaceText(""),setTimeout(()=>{var f,y;(f=v.current)==null||f.setSelectionRanges([]),(y=v.current)==null||y.blur()},10)}};return o.jsxs("div",{className:be.threadCommentEditor,onClick:u=>u.preventDefault(),children:[o.jsx(se.RichTextEditor,{ref:v,autoFocus:h,style:{width:"100%"},keyboardEventConfig:$,placeholder:H.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&Te(t.text),onFocusChange:u=>u&&w(u),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{D.focus(S)},30)}}),V?o.jsxs("div",{className:be.threadCommentEditorButtons,children:[o.jsx(B.Button,{style:{marginRight:12},onClick:()=>{var u;d==null||d(),w(!1),(u=v.current)==null||u.replaceText("",!0),E.executeCommand(F.id)},children:H.t("threadCommentUI.editor.cancel")}),o.jsx(B.Button,{type:"primary",disabled:!j,onClick:T,children:H.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ke=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
3
- `)?e.length-2:e.length,i=[];let d=0;return t==null||t.forEach(h=>{d<h.startIndex&&i.push({type:"text",content:e.slice(d,h.startIndex)}),i.push({type:"mention",content:{label:e.slice(h.startIndex,h.endIndex+1),id:h.rangeId}}),d=h.endIndex+1}),i.push({type:"text",content:e.slice(d,r)}),i},Ze=n=>{const{paragraphs:e=[]}=n;let t=0;return e.map(r=>{const i=a.getBodySlice(n,t,r.startIndex);return t=r.startIndex+1,Ke(i)})},Ge=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const d=e.length-1;t.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:i,endIndex:d,properties:{}});break}}}),e+=`
4
- \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},g={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",threadCommentTitlePositionText:"univer-thread-comment-title-position-text",threadCommentUsername:"univer-thread-comment-username",threadCommentItem:"univer-thread-comment-item",threadCommentItemHead:"univer-thread-comment-item-head",threadCommentItemTitle:"univer-thread-comment-item-title",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},Ue="__mock__",Re=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:d,onReply:h,resolved:I,isRoot:b,onClose:E,onDeleteComment:H,type:V}=n,w=C.useDependency(a.ICommandService),D=C.useDependency(a.LocaleService),v=C.useDependency(a.UserManagerService),S=v.getUser(e.personId),j=C.useObservable(v.currentUser$),N=(j==null?void 0:j.userID)===e.personId,$=e.id===Ue,[T,L]=m.useState(!1),u=()=>{(H==null?void 0:H(e))!==!1&&(w.executeCommand(b?_.DeleteCommentTreeCommand.id:_.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),b&&(E==null||E()))};return o.jsxs("div",{className:g.threadCommentItem,onMouseLeave:()=>L(!1),onMouseEnter:()=>L(!0),children:[o.jsx("img",{className:g.threadCommentItemHead,src:S==null?void 0:S.avatar}),o.jsxs("div",{className:g.threadCommentItemTitle,children:[o.jsx("div",{className:g.threadCommentUsername,children:(S==null?void 0:S.name)||" "}),o.jsxs("div",{children:[$||I?null:T?o.jsx("div",{className:g.threadCommentIcon,onClick:()=>h(S),children:o.jsx(ge,{})}):null,N&&!$&&!I?o.jsx(B.Dropdown,{overlay:o.jsx("div",{className:"univer-rounded-lg univer-p-4 univer-theme",children:o.jsxs("ul",{className:`
2
+ (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverThreadCommentUi={},c.UniverCore,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.UniverDesign,c.React,c.UniverDocsUi))})(this,function(c,a,_,C,te,o,B,m,se){"use strict";var Je=Object.defineProperty;var Qe=(c,a,_)=>a in c?Je(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var K=(c,a,_)=>Qe(c,typeof a!="symbol"?a+"":a,_);var Pe=Object.getOwnPropertyDescriptor,xe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Pe(e,t):e,d=n.length-1,h;d>=0;d--)(h=n[d])&&(i=h(i)||i);return i},le=(n,e)=>(t,r)=>e(t,r,n);c.ThreadCommentPanelService=class extends a.Disposable{constructor(t,r){super();K(this,"_panelVisible",!1);K(this,"_panelVisible$",new te.BehaviorSubject(!1));K(this,"_activeCommentId");K(this,"_activeCommentId$",new te.BehaviorSubject(void 0));K(this,"panelVisible$",this._panelVisible$.asObservable());K(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(te.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}},c.ThreadCommentPanelService=xe([le(0,a.Inject(C.ISidebarService)),le(1,a.IUniverInstanceService)],c.ThreadCommentPanelService);const me="thread-comment-panel",Ee="UNIVER_THREAD_COMMENT_UI_PLUGIN",ce={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(C.ISidebarService),t=n.get(c.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:me},width:330}),t.setPanelVisible(!0)),!0}},F={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(c.ThreadCommentPanelService).setActiveComment(e),!0}},De="thread-comment-ui.config",he={};var Oe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,He=(n,e,t)=>e in n?Oe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,we=(n,e,t,r)=>{for(var i=r>1?void 0:r?Me(e,t):e,d=n.length-1,h;d>=0;d--)(h=n[d])&&(i=h(i)||i);return i},de=(n,e)=>(t,r)=>e(t,r,n),ue=(n,e,t)=>He(n,typeof e!="symbol"?e+"":e,t);c.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=he,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:d,...h}=a.merge({},he,this._config);d&&this._configService.setConfig("menu",d,{merge:!0}),this._configService.setConfig(De,h)}onStarting(){var e;a.mergeOverrideWithDependencies([[c.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[ce,F].forEach(t=>{this._commandService.registerCommand(t)})}},ue(c.UniverThreadCommentUIPlugin,"pluginName",Ee),ue(c.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),c.UniverThreadCommentUIPlugin=we([a.DependentOn(_.UniverThreadCommentPlugin),de(1,a.Inject(a.Injector)),de(2,a.ICommandService),de(3,a.IConfigService)],c.UniverThreadCommentUIPlugin);var M=function(){return M=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},M.apply(this,arguments)},je=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},q=m.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,d=n.extend,h=je(n,["icon","id","className","extend"]),I="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),b=m.useRef("_".concat(Ae()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:b.current},M({ref:e,className:I},h),d)});function ve(n,e,t,r,i){return m.createElement(n.tag,M(M({key:e},ke(n,t,i)),r),($e(n,t).children||[]).map(function(d,h){return ve(d,"".concat(e,"-").concat(n.tag,"-").concat(h),t,void 0,i)}))}function ke(n,e,t){var r=M({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(d){var h=d[0],I=d[1];h==="mask"&&typeof I=="string"&&(r[h]=I.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(d){var h=d[0],I=d[1];typeof I=="string"&&(r[h]=I.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function $e(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?M(M({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?M(M({},i),{attrs:M(M({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Ae(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ce=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"delete-single",ref:e,icon:Le}))});Ce.displayName="DeleteSingle";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"increase-single",ref:e,icon:Ve}))});fe.displayName="IncreaseSingle";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},pe=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Be}))});pe.displayName="MoreHorizontalSingle";var Fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},ge=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Fe}))});ge.displayName="ReplyToCommentSingle";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ie=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"resolved-single",ref:e,icon:We}))});Ie.displayName="ResolvedSingle";var qe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},Se=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"solve-single",ref:e,icon:qe}))});Se.displayName="SolveSingle";function ye(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=ye(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ze(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=ye(n))&&(r&&(r+=" "),r+=e);return r}const be={threadCommentEditorButtons:"univer-thread-comment-editor-buttons"};function Te(n){return{id:"d",body:n,documentStyle:{}}}const _e=m.forwardRef((n,e)=>{var L;const{comment:t,onSave:r,id:i,onCancel:d,autoFocus:h,unitId:I,type:b}=n,E=C.useDependency(a.ICommandService),H=C.useDependency(a.LocaleService),[V,w]=m.useState(!1),D=C.useDependency(se.IEditorService),v=m.useRef(null),S=b===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:I,[j,N]=m.useState(()=>{var u,f,y;return a.BuildTextUtils.transform.getPlainText((y=(f=(u=v.current)==null?void 0:u.getDocumentData().body)==null?void 0:f.dataStream)!=null?y:"")});m.useEffect(()=>{var f,y,l,p;N(a.BuildTextUtils.transform.getPlainText((l=(y=(f=v.current)==null?void 0:f.getDocumentData().body)==null?void 0:y.dataStream)!=null?l:""));const u=(p=v.current)==null?void 0:p.selectionChange$.subscribe(()=>{var Z,P,U;N(a.BuildTextUtils.transform.getPlainText((U=(P=(Z=v.current)==null?void 0:Z.getDocumentData().body)==null?void 0:P.dataStream)!=null?U:""))});return()=>u==null?void 0:u.unsubscribe()},[(L=v.current)==null?void 0:L.selectionChange$]);const $=m.useMemo(()=>({keyCodes:[{keyCode:C.KeyCode.ENTER}],handler:u=>{u===C.KeyCode.ENTER&&E.executeCommand(se.BreakLineCommand.id)}}),[E]);m.useImperativeHandle(e,()=>({reply(u){var f,y;(f=v.current)==null||f.focus(),(y=v.current)==null||y.setDocumentData(Te(u))}}));const T=()=>{if(v.current){const u=a.Tools.deepClone(v.current.getDocumentData().body);w(!1),r==null||r({...t,text:u}),v.current.replaceText(""),setTimeout(()=>{var f,y;(f=v.current)==null||f.setSelectionRanges([]),(y=v.current)==null||y.blur()},10)}};return o.jsxs("div",{className:be.threadCommentEditor,onClick:u=>u.preventDefault(),children:[o.jsx(se.RichTextEditor,{editorRef:v,autoFocus:h,style:{width:"100%"},keyboardEventConfig:$,placeholder:H.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&Te(t.text),onFocusChange:u=>u&&w(u),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{D.focus(S)},30)}}),V?o.jsxs("div",{className:be.threadCommentEditorButtons,children:[o.jsx(B.Button,{style:{marginRight:12},onClick:()=>{var u;d==null||d(),w(!1),(u=v.current)==null||u.replaceText("",!0),E.executeCommand(F.id)},children:H.t("threadCommentUI.editor.cancel")}),o.jsx(B.Button,{type:"primary",disabled:!j,onClick:T,children:H.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ke=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
3
+ `)?e.length-2:e.length,i=[];let d=0;return t==null||t.forEach(h=>{d<h.startIndex&&i.push({type:"text",content:e.slice(d,h.startIndex)}),i.push({type:"mention",content:{label:e.slice(h.startIndex,h.endIndex+1),id:h.rangeId}}),d=h.endIndex+1}),i.push({type:"text",content:e.slice(d,r)}),i},Ze=n=>{const{paragraphs:e=[]}=n;let t=0;return e.map(r=>{const i=a.getBodySlice(n,t,r.startIndex);return t=r.startIndex+1,Ke(i)})},Re=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const d=e.length-1;t.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:i,endIndex:d,properties:{}});break}}}),e+=`
4
+ \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},g={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",threadCommentTitlePositionText:"univer-thread-comment-title-position-text",threadCommentUsername:"univer-thread-comment-username",threadCommentItem:"univer-thread-comment-item",threadCommentItemHead:"univer-thread-comment-item-head",threadCommentItemTitle:"univer-thread-comment-item-title",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},Ue="__mock__",Ge=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:d,onReply:h,resolved:I,isRoot:b,onClose:E,onDeleteComment:H,type:V}=n,w=C.useDependency(a.ICommandService),D=C.useDependency(a.LocaleService),v=C.useDependency(a.UserManagerService),S=v.getUser(e.personId),j=C.useObservable(v.currentUser$),N=(j==null?void 0:j.userID)===e.personId,$=e.id===Ue,[T,L]=m.useState(!1),u=()=>{(H==null?void 0:H(e))!==!1&&(w.executeCommand(b?_.DeleteCommentTreeCommand.id:_.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),b&&(E==null||E()))};return o.jsxs("div",{className:g.threadCommentItem,onMouseLeave:()=>L(!1),onMouseEnter:()=>L(!0),children:[o.jsx("img",{className:g.threadCommentItemHead,src:S==null?void 0:S.avatar}),o.jsxs("div",{className:g.threadCommentItemTitle,children:[o.jsx("div",{className:g.threadCommentUsername,children:(S==null?void 0:S.name)||" "}),o.jsxs("div",{children:[$||I?null:T?o.jsx("div",{className:g.threadCommentIcon,onClick:()=>h(S),children:o.jsx(ge,{})}):null,N&&!$&&!I?o.jsx(B.Dropdown,{overlay:o.jsx("div",{className:"univer-rounded-lg univer-p-4 univer-theme",children:o.jsxs("ul",{className:`
5
5
  univer-m-0 univer-grid univer-list-none univer-gap-2 univer-p-0
6
6
  univer-text-sm
7
7
  [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-p-1
8
- `,children:[o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>d==null?void 0:d(!0),children:D.t("threadCommentUI.item.edit")})}),o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:u,children:D.t("threadCommentUI.item.delete")})})]})}),children:o.jsx("div",{className:g.threadCommentIcon,children:o.jsx(pe,{})})}):null]})]}),o.jsx("div",{className:g.threadCommentItemTime,children:e.dT}),i?o.jsx(_e,{type:V,id:e.id,comment:e,onCancel:()=>d==null?void 0:d(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:f,attachments:y})=>{d==null||d(!1),w.executeCommand(_.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:f,attachments:y}})}}):o.jsx("div",{className:g.threadCommentItemContent,children:Ze(e.text).map((f,y)=>o.jsx("div",{children:f.map((l,p)=>{switch(l.type){case"mention":return o.jsxs("a",{className:g.threadCommentItemAt,children:[l.content.label," "]},p);default:return l.content}})},y))})]})},Ne=n=>{var X,ee,ie;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:d=!0,onClick:h,showHighlight:I,onClose:b,getSubUnitName:E,prefix:H,autoFocus:V,onMouseEnter:w,onMouseLeave:D,onAddComment:v,onDeleteComment:S,onResolve:j,type:N}=n,$=C.useDependency(_.ThreadCommentModel),[T,L]=m.useState(!1),[u,f]=m.useState(""),y=m.useMemo(()=>$.commentUpdate$.pipe(te.debounceTime(16)),[$]);C.useObservable(y);const l=e?$.getCommentWithChildren(t,r,e):null,p=C.useDependency(a.ICommandService),Z=C.useDependency(a.UserManagerService),P=l==null?void 0:l.root.resolved,U=C.useObservable(Z.currentUser$),G=m.useRef(null),ne=[...l?[l.root]:[{id:Ue,text:{dataStream:`
9
- \r`},personId:(X=U==null?void 0:U.userID)!=null?X:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(ee=l==null?void 0:l.children)!=null?ee:[]],k=m.useRef(null),Y=x=>{x.stopPropagation(),P?p.executeCommand(F.id,{unitId:t,subUnitId:r,commentId:e}):p.executeCommand(F.id),p.executeCommand(_.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!P}),j==null||j(!P)},W=x=>{x.stopPropagation(),p.executeCommand(F.id),!(l!=null&&l.root&&(S==null?void 0:S(l.root))===!1)&&(p.executeCommand(_.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),b==null||b())};m.useEffect(()=>D==null?void 0:D(),[]);const J=E((ie=l==null?void 0:l.root.subUnitId)!=null?ie:r),Q=d&&!u&&!P,re=`${i||(l==null?void 0:l.root.ref)||""}${J?" · ":""}${J}`;return o.jsxs("div",{className:ze(g.threadComment,{[g.threadCommentActive]:!P&&(I||T||H==="cell")}),onClick:h,id:`${H}-${t}-${r}-${e}`,onMouseEnter:()=>{w==null||w(),L(!0)},onMouseLeave:()=>{D==null||D(),L(!1)},children:[!P&&I?o.jsx("div",{className:g.threadCommentHighlight}):null,o.jsxs("div",{className:g.threadCommentTitle,children:[o.jsxs("div",{className:g.threadCommentTitlePosition,children:[o.jsx("div",{className:g.threadCommentTitleHighlight}),o.jsx(B.Tooltip,{showIfEllipsis:!0,title:re,children:o.jsx("div",{className:g.threadCommentTitlePositionText,children:re})})]}),l?o.jsxs("div",{className:g.threadCommentIconContainer,children:[o.jsx("div",{onClick:Y,className:g.threadCommentIcon,style:{color:P?"rgb(var(--green-500))":""},children:P?o.jsx(Ie,{}):o.jsx(Se,{})}),(U==null?void 0:U.userID)===l.root.personId?o.jsx("div",{className:g.threadCommentIcon,onClick:W,children:o.jsx(Ce,{})}):null]}):null]}),o.jsx("div",{className:g.threadCommentContent,ref:k,children:ne.map(x=>o.jsx(Re,{onClose:b,unitId:t,subUnitId:r,item:x,isRoot:x.id===(l==null?void 0:l.root.id),editing:u===x.id,resolved:l==null?void 0:l.root.resolved,type:N,onEditingChange:s=>{f(s?x.id:"")},onReply:s=>{s&&requestAnimationFrame(()=>{var A;(A=G.current)==null||A.reply(Ge([{type:"mention",content:{id:s.userID,label:s.name}}]))})},onAddComment:v,onDeleteComment:S},x.id))}),Q?o.jsx("div",{children:o.jsx(_e,{ref:G,type:N,unitId:t,subUnitId:r,onSave:async({text:x,attachments:s})=>{const A={text:x,attachments:s,dT:_.getDT(),id:a.generateRandomId(),ref:i,personId:U==null?void 0:U.userID,parentId:l==null?void 0:l.root.id,unitId:t,subUnitId:r,threadId:l==null?void 0:l.root.threadId};(v==null?void 0:v(A))!==!1&&(await p.executeCommand(_.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:A}),k.current&&(k.current.scrollTop=k.current.scrollHeight))},autoFocus:V||!l,onCancel:()=>{l||b==null||b()}},`${V}`)}):null]})},R={threadCommentPanel:"univer-thread-comment-panel",threadCommentPanelForms:"univer-thread-comment-panel-forms",threadCommentPanelEmpty:"univer-thread-comment-panel-empty",threadCommentPanelAdd:"univer-thread-comment-panel-add",threadCommentPanelSolved:"univer-thread-comment-panel-solved"},Ye=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:d,onResolve:h,sortComments:I,onItemLeave:b,onItemEnter:E,disableAdd:H,tempComment:V,onAddComment:w,onDeleteComment:D,showComments:v}=n,[S,j]=m.useState("all"),[N,$]=m.useState("all"),T=C.useDependency(a.LocaleService),L=C.useDependency(a.UserManagerService),u=C.useDependency(_.ThreadCommentModel),[f,y]=m.useState(()=>u.getUnit(e)),l=C.useDependency(c.ThreadCommentPanelService),p=C.useObservable(l.activeCommentId$),Z=C.useObservable(u.commentUpdate$),P=C.useDependency(a.ICommandService),U=C.useObservable(t),G=m.useRef(!0),ne="panel",k=C.useObservable(L.currentUser$),Y=m.useMemo(()=>{var ae;const s=S==="all"?f:(ae=f.filter(O=>O.subUnitId===U))!=null?ae:[],A=I!=null?I:O=>O,oe=s.map(O=>{var z;return{...O.root,children:(z=O.children)!=null?z:[],users:O.relativeUsers}});if(v){const O=new Map;return oe.forEach(z=>{O.set(z.id,z)}),[...v,""].map(z=>O.get(z)).filter(Boolean)}else return A(oe)},[v,S,f,I,U]),W=m.useMemo(()=>[...Y.filter(s=>!s.resolved),...Y.filter(s=>s.resolved)],[Y]),J=m.useMemo(()=>N==="resolved"?W.filter(s=>s.resolved):N==="unsolved"?W.filter(s=>!s.resolved):N==="concern_me"&&k!=null&&k.userID?W.filter(s=>s==null?void 0:s.users.has(k.userID)):W,[W,k==null?void 0:k.userID,N]),Q=V?[V,...J]:J,re=Q.filter(s=>!s.resolved),X=Q.filter(s=>s.resolved),ee=N!=="all"||S!=="all",ie=()=>{$("all"),j("all")};m.useEffect(()=>{e&&y(u.getUnit(e))},[e,u,Z]),m.useEffect(()=>{var O;if(!p)return;if(!G.current){G.current=!0;return}const{unitId:s,subUnitId:A,commentId:oe}=p,ae=`${ne}-${s}-${A}-${oe}`;(O=document.getElementById(ae))==null||O.scrollIntoView({block:"center"})},[p]);const x=s=>o.jsx(Ne,{prefix:ne,getSubUnitName:d,id:s.id,unitId:s.unitId,subUnitId:s.subUnitId,refStr:s.ref,type:r,showEdit:(p==null?void 0:p.commentId)===s.id,showHighlight:(p==null?void 0:p.commentId)===s.id,onClick:()=>{G.current=!1,s.resolved?P.executeCommand(F.id):P.executeCommand(F.id,{unitId:s.unitId,subUnitId:s.subUnitId,commentId:s.id,temp:!1})},onMouseEnter:()=>E==null?void 0:E(s),onMouseLeave:()=>b==null?void 0:b(s),onAddComment:w,onDeleteComment:D,onResolve:A=>h==null?void 0:h(s.id,A)},s.id);return o.jsxs("div",{className:R.threadCommentPanel,children:[o.jsxs("div",{className:R.threadCommentPanelForms,children:[r===a.UniverInstanceType.UNIVER_SHEET?o.jsx(B.Select,{borderless:!0,value:S,onChange:s=>j(s),options:[{value:"current",label:T.t("threadCommentUI.filter.sheet.current")},{value:"all",label:T.t("threadCommentUI.filter.sheet.all")}]}):null,o.jsx(B.Select,{borderless:!0,value:N,onChange:s=>$(s),options:[{value:"all",label:T.t("threadCommentUI.filter.status.all")},{value:"resolved",label:T.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:T.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:T.t("threadCommentUI.filter.status.concernMe")}]})]}),re.map(x),X.length?o.jsx("div",{className:R.threadCommentPanelSolved,children:"已解决"}):null,X.map(x),Q.length?null:o.jsxs("div",{className:R.threadCommentPanelEmpty,children:[ee?T.t("threadCommentUI.panel.filterEmpty"):T.t("threadCommentUI.panel.empty"),ee?o.jsx(B.Button,{onClick:ie,type:"link",children:T.t("threadCommentUI.panel.reset")}):o.jsxs(B.Button,{id:"thread-comment-add",className:R.threadCommentPanelAdd,type:"primary",onClick:i,disabled:H,children:[o.jsx(fe,{}),T.t("threadCommentUI.panel.addComment")]})]})]})};c.SetActiveCommentOperation=F,c.THREAD_COMMENT_PANEL=me,c.ThreadCommentPanel=Ye,c.ThreadCommentTree=Ne,c.ToggleSheetCommentPanelOperation=ce,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
8
+ `,children:[o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>d==null?void 0:d(!0),children:D.t("threadCommentUI.item.edit")})}),o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:u,children:D.t("threadCommentUI.item.delete")})})]})}),children:o.jsx("div",{className:g.threadCommentIcon,children:o.jsx(pe,{})})}):null]})]}),o.jsx("div",{className:g.threadCommentItemTime,children:e.dT}),i?o.jsx(_e,{type:V,id:e.id,comment:e,onCancel:()=>d==null?void 0:d(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:f,attachments:y})=>{d==null||d(!1),w.executeCommand(_.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:f,attachments:y}})}}):o.jsx("div",{className:g.threadCommentItemContent,children:Ze(e.text).map((f,y)=>o.jsx("div",{children:f.map((l,p)=>{switch(l.type){case"mention":return o.jsxs("a",{className:g.threadCommentItemAt,children:[l.content.label," "]},p);default:return l.content}})},y))})]})},Ne=n=>{var X,ee,ie;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:d=!0,onClick:h,showHighlight:I,onClose:b,getSubUnitName:E,prefix:H,autoFocus:V,onMouseEnter:w,onMouseLeave:D,onAddComment:v,onDeleteComment:S,onResolve:j,type:N}=n,$=C.useDependency(_.ThreadCommentModel),[T,L]=m.useState(!1),[u,f]=m.useState(""),y=m.useMemo(()=>$.commentUpdate$.pipe(te.debounceTime(16)),[$]);C.useObservable(y);const l=e?$.getCommentWithChildren(t,r,e):null,p=C.useDependency(a.ICommandService),Z=C.useDependency(a.UserManagerService),P=l==null?void 0:l.root.resolved,U=C.useObservable(Z.currentUser$),R=m.useRef(null),ne=[...l?[l.root]:[{id:Ue,text:{dataStream:`
9
+ \r`},personId:(X=U==null?void 0:U.userID)!=null?X:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(ee=l==null?void 0:l.children)!=null?ee:[]],k=m.useRef(null),Y=x=>{x.stopPropagation(),P?p.executeCommand(F.id,{unitId:t,subUnitId:r,commentId:e}):p.executeCommand(F.id),p.executeCommand(_.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!P}),j==null||j(!P)},W=x=>{x.stopPropagation(),p.executeCommand(F.id),!(l!=null&&l.root&&(S==null?void 0:S(l.root))===!1)&&(p.executeCommand(_.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),b==null||b())};m.useEffect(()=>D==null?void 0:D(),[]);const J=E((ie=l==null?void 0:l.root.subUnitId)!=null?ie:r),Q=d&&!u&&!P,re=`${i||(l==null?void 0:l.root.ref)||""}${J?" · ":""}${J}`;return o.jsxs("div",{className:ze(g.threadComment,{[g.threadCommentActive]:!P&&(I||T||H==="cell")}),onClick:h,id:`${H}-${t}-${r}-${e}`,onMouseEnter:()=>{w==null||w(),L(!0)},onMouseLeave:()=>{D==null||D(),L(!1)},children:[!P&&I?o.jsx("div",{className:g.threadCommentHighlight}):null,o.jsxs("div",{className:g.threadCommentTitle,children:[o.jsxs("div",{className:g.threadCommentTitlePosition,children:[o.jsx("div",{className:g.threadCommentTitleHighlight}),o.jsx(B.Tooltip,{showIfEllipsis:!0,title:re,children:o.jsx("div",{className:g.threadCommentTitlePositionText,children:re})})]}),l?o.jsxs("div",{className:g.threadCommentIconContainer,children:[o.jsx("div",{onClick:Y,className:g.threadCommentIcon,style:{color:P?"rgb(var(--green-500))":""},children:P?o.jsx(Ie,{}):o.jsx(Se,{})}),(U==null?void 0:U.userID)===l.root.personId?o.jsx("div",{className:g.threadCommentIcon,onClick:W,children:o.jsx(Ce,{})}):null]}):null]}),o.jsx("div",{className:g.threadCommentContent,ref:k,children:ne.map(x=>o.jsx(Ge,{onClose:b,unitId:t,subUnitId:r,item:x,isRoot:x.id===(l==null?void 0:l.root.id),editing:u===x.id,resolved:l==null?void 0:l.root.resolved,type:N,onEditingChange:s=>{f(s?x.id:"")},onReply:s=>{s&&requestAnimationFrame(()=>{var A;(A=R.current)==null||A.reply(Re([{type:"mention",content:{id:s.userID,label:s.name}}]))})},onAddComment:v,onDeleteComment:S},x.id))}),Q?o.jsx("div",{children:o.jsx(_e,{ref:R,type:N,unitId:t,subUnitId:r,onSave:async({text:x,attachments:s})=>{const A={text:x,attachments:s,dT:_.getDT(),id:a.generateRandomId(),ref:i,personId:U==null?void 0:U.userID,parentId:l==null?void 0:l.root.id,unitId:t,subUnitId:r,threadId:l==null?void 0:l.root.threadId};(v==null?void 0:v(A))!==!1&&(await p.executeCommand(_.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:A}),k.current&&(k.current.scrollTop=k.current.scrollHeight))},autoFocus:V||!l,onCancel:()=>{l||b==null||b()}},`${V}`)}):null]})},G={threadCommentPanel:"univer-thread-comment-panel",threadCommentPanelForms:"univer-thread-comment-panel-forms",threadCommentPanelEmpty:"univer-thread-comment-panel-empty",threadCommentPanelAdd:"univer-thread-comment-panel-add",threadCommentPanelSolved:"univer-thread-comment-panel-solved"},Ye=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:d,onResolve:h,sortComments:I,onItemLeave:b,onItemEnter:E,disableAdd:H,tempComment:V,onAddComment:w,onDeleteComment:D,showComments:v}=n,[S,j]=m.useState("all"),[N,$]=m.useState("all"),T=C.useDependency(a.LocaleService),L=C.useDependency(a.UserManagerService),u=C.useDependency(_.ThreadCommentModel),[f,y]=m.useState(()=>u.getUnit(e)),l=C.useDependency(c.ThreadCommentPanelService),p=C.useObservable(l.activeCommentId$),Z=C.useObservable(u.commentUpdate$),P=C.useDependency(a.ICommandService),U=C.useObservable(t),R=m.useRef(!0),ne="panel",k=C.useObservable(L.currentUser$),Y=m.useMemo(()=>{var ae;const s=S==="all"?f:(ae=f.filter(O=>O.subUnitId===U))!=null?ae:[],A=I!=null?I:O=>O,oe=s.map(O=>{var z;return{...O.root,children:(z=O.children)!=null?z:[],users:O.relativeUsers}});if(v){const O=new Map;return oe.forEach(z=>{O.set(z.id,z)}),[...v,""].map(z=>O.get(z)).filter(Boolean)}else return A(oe)},[v,S,f,I,U]),W=m.useMemo(()=>[...Y.filter(s=>!s.resolved),...Y.filter(s=>s.resolved)],[Y]),J=m.useMemo(()=>N==="resolved"?W.filter(s=>s.resolved):N==="unsolved"?W.filter(s=>!s.resolved):N==="concern_me"&&k!=null&&k.userID?W.filter(s=>s==null?void 0:s.users.has(k.userID)):W,[W,k==null?void 0:k.userID,N]),Q=V?[V,...J]:J,re=Q.filter(s=>!s.resolved),X=Q.filter(s=>s.resolved),ee=N!=="all"||S!=="all",ie=()=>{$("all"),j("all")};m.useEffect(()=>{e&&y(u.getUnit(e))},[e,u,Z]),m.useEffect(()=>{var O;if(!p)return;if(!R.current){R.current=!0;return}const{unitId:s,subUnitId:A,commentId:oe}=p,ae=`${ne}-${s}-${A}-${oe}`;(O=document.getElementById(ae))==null||O.scrollIntoView({block:"center"})},[p]);const x=s=>o.jsx(Ne,{prefix:ne,getSubUnitName:d,id:s.id,unitId:s.unitId,subUnitId:s.subUnitId,refStr:s.ref,type:r,showEdit:(p==null?void 0:p.commentId)===s.id,showHighlight:(p==null?void 0:p.commentId)===s.id,onClick:()=>{R.current=!1,s.resolved?P.executeCommand(F.id):P.executeCommand(F.id,{unitId:s.unitId,subUnitId:s.subUnitId,commentId:s.id,temp:!1})},onMouseEnter:()=>E==null?void 0:E(s),onMouseLeave:()=>b==null?void 0:b(s),onAddComment:w,onDeleteComment:D,onResolve:A=>h==null?void 0:h(s.id,A)},s.id);return o.jsxs("div",{className:G.threadCommentPanel,children:[o.jsxs("div",{className:G.threadCommentPanelForms,children:[r===a.UniverInstanceType.UNIVER_SHEET?o.jsx(B.Select,{borderless:!0,value:S,onChange:s=>j(s),options:[{value:"current",label:T.t("threadCommentUI.filter.sheet.current")},{value:"all",label:T.t("threadCommentUI.filter.sheet.all")}]}):null,o.jsx(B.Select,{borderless:!0,value:N,onChange:s=>$(s),options:[{value:"all",label:T.t("threadCommentUI.filter.status.all")},{value:"resolved",label:T.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:T.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:T.t("threadCommentUI.filter.status.concernMe")}]})]}),re.map(x),X.length?o.jsx("div",{className:G.threadCommentPanelSolved,children:"已解决"}):null,X.map(x),Q.length?null:o.jsxs("div",{className:G.threadCommentPanelEmpty,children:[ee?T.t("threadCommentUI.panel.filterEmpty"):T.t("threadCommentUI.panel.empty"),ee?o.jsx(B.Button,{onClick:ie,type:"link",children:T.t("threadCommentUI.panel.reset")}):o.jsxs(B.Button,{id:"thread-comment-add",className:G.threadCommentPanelAdd,type:"primary",onClick:i,disabled:H,children:[o.jsx(fe,{}),T.t("threadCommentUI.panel.addComment")]})]})]})};c.SetActiveCommentOperation=F,c.THREAD_COMMENT_PANEL=me,c.ThreadCommentPanel=Ye,c.ThreadCommentTree=Ne,c.ToggleSheetCommentPanelOperation=ce,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
10
10
 
11
11
 
12
12
  // @univerjs/docs-thread-comment-ui/index
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-docs-thread-comment",
3
- "version": "0.6.1-nightly.202502241606",
3
+ "version": "0.6.1-nightly.202502251606",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,11 +57,11 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/docs-thread-comment-ui": "0.6.1-nightly.202502241606",
61
- "@univerjs/thread-comment-ui": "0.6.1-nightly.202502241606"
60
+ "@univerjs/docs-thread-comment-ui": "0.6.1-nightly.202502251606",
61
+ "@univerjs/thread-comment-ui": "0.6.1-nightly.202502251606"
62
62
  },
63
63
  "devDependencies": {
64
- "@univerjs/core": "0.6.1-nightly.202502241606",
64
+ "@univerjs/core": "0.6.1-nightly.202502251606",
65
65
  "typescript": "^5.7.2",
66
66
  "@univerjs-infra/shared": "0.6.1"
67
67
  },