@univerjs/thread-comment-ui 0.2.4-alpha.0 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var Me=Object.defineProperty;var Ue=(n,e,t)=>e in n?Me(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var R=(n,e,t)=>Ue(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ne=require("dayjs"),w=require("@univerjs/thread-comment"),i=require("@univerjs/core"),H=require("@univerjs/ui"),ie=require("rxjs"),a=require("react"),P=require("@univerjs/design"),Oe=require("clsx"),De=require("@univerjs/engine-render"),$e=require("@univerjs/docs");function ce(){return Ne().format("YYYY/MM/DD HH:mm")}const ue="thread-comment-panel",Re="THREAD_COMMENT_UI_PLUGIN";var we=Object.defineProperty,He=Object.getOwnPropertyDescriptor,je=(n,e,t,r)=>{for(var o=r>1?void 0:r?He(e,t):e,s=n.length-1,d;s>=0;s--)(d=n[s])&&(o=(r?d(e,t,o):d(o))||o);return r&&o&&we(e,t,o),o},me=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends i.Disposable{constructor(t,r){super();R(this,"_panelVisible",!1);R(this,"_panelVisible$",new ie.BehaviorSubject(!1));R(this,"_activeCommentId");R(this,"_activeCommentId$",new ie.BehaviorSubject(void 0));R(this,"panelVisible$",this._panelVisible$.asObservable());R(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$(i.UniverInstanceType.UNIVER_SHEET).pipe(ie.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)}};exports.ThreadCommentPanelService=je([me(0,i.Inject(H.ISidebarService)),me(1,i.IUniverInstanceService)],exports.ThreadCommentPanelService);const he={id:"thread-comment-ui.operation.toggle-panel",type:i.CommandType.OPERATION,handler(n){const e=n.get(H.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:ue},width:320}),t.setPanelVisible(!0)),!0}},k={id:"thread-comment-ui.operation.set-active-comment",type:i.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}};var Le=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,ke=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ae(e,t):e,s=n.length-1,d;s>=0;s--)(d=n[s])&&(o=(r?d(e,t,o):d(o))||o);return r&&o&&Le(e,t,o),o},Ve=(n,e)=>(t,r)=>e(t,r,n);let re=class extends i.Disposable{constructor(n){super(),this._localeService=n}};re=ke([i.OnLifecycle(i.LifecycleStages.Starting,re),Ve(0,i.Inject(i.LocaleService))],re);class Be{constructor(){R(this,"dataSource");R(this,"renderSuggestion");R(this,"trigger","@")}async getMentions(e,t,r){return this.dataSource?this.dataSource.getMentions(e,t,r):[]}}const se=i.createIdentifier("thread-comment.mention-data.service");var ve=Object.defineProperty,We=Object.getOwnPropertyDescriptor,qe=(n,e,t)=>e in n?ve(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Fe=(n,e,t,r)=>{for(var o=r>1?void 0:r?We(e,t):e,s=n.length-1,d;s>=0;s--)(d=n[s])&&(o=(r?d(e,t,o):d(o))||o);return r&&o&&ve(e,t,o),o},de=(n,e)=>(t,r)=>e(t,r,n),Ce=(n,e,t)=>qe(n,typeof e!="symbol"?e+"":e,t);exports.UniverThreadCommentUIPlugin=class extends i.Plugin{constructor(e,t,r){super(),this._config=e,this._injector=t,this._commandService=r}onStarting(e){var t;i.mergeOverrideWithDependencies([[re],[exports.ThreadCommentPanelService],[se,{useClass:Be}]],(t=this._config)==null?void 0:t.overrides).forEach(r=>{e.add(r)}),[he,k].forEach(r=>{this._commandService.registerCommand(r)})}};Ce(exports.UniverThreadCommentUIPlugin,"pluginName",Re);Ce(exports.UniverThreadCommentUIPlugin,"type",i.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=Fe([i.DependentOn(w.UniverThreadCommentPlugin),de(1,i.Inject(i.Injector)),de(2,i.ICommandService)],exports.UniverThreadCommentUIPlugin);var _=function(){return _=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},_.apply(this,arguments)},ze=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 o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]]);return t},B=a.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,s=n.extend,d=ze(n,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),g=a.useRef("_".concat(Ge()));return fe(t,"".concat(r),{defIds:t.defIds,idSuffix:g.current},_({ref:e,className:u},d),s)});function fe(n,e,t,r,o){return a.createElement(n.tag,_(_({key:e},Ze(n,t,o)),r),(Ye(n,t).children||[]).map(function(s,d){return fe(s,"".concat(e,"-").concat(n.tag,"-").concat(d),t,void 0,o)}))}function Ze(n,e,t){var r=_({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(s){var d=s[0],u=s[1];typeof u=="string"&&(r[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Ye(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)?_(_({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?_(_({},o),{attrs:_(_({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function Ge(){return Math.random().toString(36).substring(2,8)}B.displayName="UniverIcon";var Ke={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"}}]},ge=a.forwardRef(function(n,e){return a.createElement(B,Object.assign({},n,{id:"delete-single",ref:e,icon:Ke}))});ge.displayName="DeleteSingle";var Je={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"}}]},pe=a.forwardRef(function(n,e){return a.createElement(B,Object.assign({},n,{id:"increase-single",ref:e,icon:Je}))});pe.displayName="IncreaseSingle";var Qe={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"}}]},Ie=a.forwardRef(function(n,e){return a.createElement(B,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Qe}))});Ie.displayName="MoreHorizontalSingle";var Xe={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}}]},Se=a.forwardRef(function(n,e){return a.createElement(B,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Xe}))});Se.displayName="ReplyToCommentSingle";var et={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"}}]},be=a.forwardRef(function(n,e){return a.createElement(B,Object.assign({},n,{id:"resolved-single",ref:e,icon:et}))});be.displayName="ResolvedSingle";var tt={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}}]},ye=a.forwardRef(function(n,e){return a.createElement(B,Object.assign({},n,{id:"solve-single",ref:e,icon:tt}))});ye.displayName="SolveSingle";const nt="univer-thread-comment-editor-buttons",rt="univer-thread-comment-editor-suggestion",at="univer-thread-comment-editor-suggestionActive",ot="univer-thread-comment-editor-suggestion-icon",ae={threadCommentEditorButtons:nt,threadCommentEditorSuggestion:rt,threadCommentEditorSuggestionActive:at,threadCommentEditorSuggestionIcon:ot},it=n=>{const e=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let t,r=0;const o=[];for(;(t=e.exec(n))!==null;)t.index>r&&o.push({type:"text",content:n.substring(r,t.index)}),t[1]&&t[2]?o.push({type:"mention",content:{label:t[1],id:t[2]}}):t[3]&&o.push({type:"text",content:t[3]}),r=e.lastIndex;return r<n.length&&o.push({type:"text",content:n.substring(r)}),o},st=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),Ee=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let s=0;return t==null||t.forEach(d=>{s<d.startIndex&&o.push({type:"text",content:e.slice(s,d.startIndex)}),o.push({type:"mention",content:{label:e.slice(d.startIndex,d.endIndex).slice(1,-1),id:d.rangeId}}),s=d.endIndex}),o.push({type:"text",content:e.slice(s,r)}),o},Te=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const o=e.length;e+=`${r.content.label}`;const s=e.length;t.push({rangeId:r.content.id,rangeType:i.CustomRangeType.MENTION,startIndex:o,endIndex:s});break}}}),e+=`
2
- \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},lt=n=>({display:n.label,id:`${n.id}`,raw:n}),mt=(n,e,t,r,o)=>{var d,u;const s=(d=n.raw)==null?void 0:d.icon;return a.createElement("div",{className:ae.threadCommentEditorSuggestion},s?a.createElement("img",{className:ae.threadCommentEditorSuggestionIcon,src:s}):null,a.createElement("div",null,(u=n.display)!=null?u:n.id))},xe=a.forwardRef((n,e)=>{var C;const{comment:t,onSave:r,id:o,onCancel:s,autoFocus:d,unitId:u,subUnitId:g}=n,E=i.useDependency(se),N=i.useDependency(i.ICommandService),x=i.useDependency(i.LocaleService),[S,v]=a.useState({...t}),[p,b]=a.useState(!1),M=a.useRef(null),y=i.useDependency(De.ITextSelectionRenderManager),j=i.useDependency($e.TextSelectionManagerService);return a.useImperativeHandle(e,()=>({reply(f){var c;v({...t,text:f,attachments:[]}),(c=M.current)==null||c.inputElement.focus()}})),a.createElement("div",{className:ae.threadCommentEditor,onClick:f=>f.preventDefault()},a.createElement(P.Mentions,{ref:M,autoFocus:d,style:{width:"100%"},placeholder:x.t("threadCommentUI.editor.placeholder"),value:S!=null&&S.text?st(Ee(S.text)):"",onChange:f=>{f.target.value||v({...t,text:void 0}),v==null||v({...t,text:Te(it(f.target.value))})},onFocus:()=>{const f=j.getActiveRange();f&&f.collapsed&&y.removeAllTextRanges(),y.blur(),b(!0)}},a.createElement(P.Mention,{key:E.trigger,trigger:E.trigger,data:(f,c)=>E.getMentions(f,u,g).then(l=>l.map(lt)).then(c),displayTransform:(f,c)=>`@${c} `,renderSuggestion:(C=E.renderSuggestion)!=null?C:mt})),p?a.createElement("div",{className:ae.threadCommentEditorButtons},a.createElement(P.Button,{style:{marginRight:12},onClick:()=>{s==null||s(),b(!1),v({text:void 0}),N.executeCommand(k.id)}},x.t("threadCommentUI.editor.cancel")),a.createElement(P.Button,{type:"primary",disabled:!S.text,onClick:()=>{S.text&&(r==null||r({...S,text:S.text}),b(!1),v({text:void 0}))}},x.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),dt="univer-thread-comment",ct="univer-thread-comment-active",ut="univer-thread-comment-content",ht="univer-thread-comment-highlight",vt="univer-thread-comment-icon-container",Ct="univer-thread-comment-icon",ft="univer-thread-comment-title",gt="univer-thread-comment-title-position",pt="univer-thread-comment-title-highlight",It="univer-thread-comment-title-position-text",St="univer-thread-comment-username",bt="univer-thread-comment-item",yt="univer-thread-comment-item-head",Et="univer-thread-comment-item-title",Tt="univer-thread-comment-item-title-position",xt="univer-thread-comment-item-title-highlight",_t="univer-thread-comment-item-time",Pt="univer-thread-comment-item-content",Mt="univer-thread-comment-item-at",h={threadComment:dt,threadCommentActive:ct,threadCommentContent:ut,threadCommentHighlight:ht,threadCommentIconContainer:vt,threadCommentIcon:Ct,threadCommentTitle:ft,threadCommentTitlePosition:gt,threadCommentTitleHighlight:pt,threadCommentTitlePositionText:It,threadCommentUsername:St,threadCommentItem:bt,threadCommentItemHead:yt,threadCommentItemTitle:Et,threadCommentItemTitlePosition:Tt,threadCommentItemTitleHighlight:xt,threadCommentItemTime:_t,threadCommentItemContent:Pt,threadCommentItemAt:Mt},_e="__mock__",Ut=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:s,onReply:d,resolved:u,isRoot:g,onClose:E,onDeleteComment:N}=n,x=i.useDependency(i.ICommandService),S=i.useDependency(i.LocaleService),v=i.useDependency(i.UserManagerService),p=v.getUser(e.personId),b=H.useObservable(v.currentUser$),M=(b==null?void 0:b.userID)===e.personId,y=e.id===_e,[j,C]=a.useState(!1),f=()=>{(N==null?void 0:N(e))!==!1&&(x.executeCommand(g?w.DeleteCommentTreeCommand.id:w.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),g&&(E==null||E()))};return a.createElement("div",{className:h.threadCommentItem,onMouseLeave:()=>C(!1),onMouseEnter:()=>C(!0)},a.createElement("img",{className:h.threadCommentItemHead,src:p==null?void 0:p.avatar}),a.createElement("div",{className:h.threadCommentItemTitle},a.createElement("div",{className:h.threadCommentUsername},(p==null?void 0:p.name)||" "),a.createElement("div",null,y||u?null:j?a.createElement("div",{className:h.threadCommentIcon,onClick:()=>d(p)},a.createElement(Se,null)):null,M&&!y&&!u?a.createElement(P.Dropdown,{overlay:a.createElement(P.Menu,null,a.createElement(P.MenuItem,{key:"edit",onClick:()=>s==null?void 0:s(!0)},S.t("threadCommentUI.item.edit")),a.createElement(P.MenuItem,{key:"delete",onClick:f},S.t("threadCommentUI.item.delete")))},a.createElement("div",{className:h.threadCommentIcon},a.createElement(Ie,null))):null)),a.createElement("div",{className:h.threadCommentItemTime},e.dT),o?a.createElement(xe,{id:e.id,comment:e,onCancel:()=>s==null?void 0:s(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:c,attachments:l})=>{s==null||s(!1),x.executeCommand(w.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:c,attachments:l}})}}):a.createElement("div",{className:h.threadCommentItemContent},Ee(e.text).map((c,l)=>{switch(c.type){case"mention":return a.createElement("a",{className:h.threadCommentItemAt,key:l},"@",c.content.label," ");default:return c.content}})))},Pe=n=>{var Z,W,X;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:s=!0,onClick:d,showHighlight:u,onClose:g,getSubUnitName:E,prefix:N,autoFocus:x,onMouseEnter:S,onMouseLeave:v,onAddComment:p,onDeleteComment:b,onResolve:M}=n,y=i.useDependency(w.ThreadCommentModel),[j,C]=a.useState(!1),[f,c]=a.useState("");H.useObservable(y.commentMap$);const l=e?y.getCommentWithChildren(t,r,e):null,L=i.useDependency(i.ICommandService),oe=i.useDependency(i.UserManagerService),I=l==null?void 0:l.root.resolved,U=H.useObservable(oe.currentUser$),q=a.useRef(null),J=[...l?[l.root]:[{id:_e,text:{dataStream:`
3
- \r`},personId:(Z=U==null?void 0:U.userID)!=null?Z:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(W=l==null?void 0:l.children)!=null?W:[]],F=T=>{T.stopPropagation(),I?L.executeCommand(k.id,{unitId:t,subUnitId:r,commentId:e}):L.executeCommand(k.id),L.executeCommand(w.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!I}),M==null||M(!I)},Q=T=>{T.stopPropagation(),L.executeCommand(k.id),!(l!=null&&l.root&&(b==null?void 0:b(l.root))===!1)&&(L.executeCommand(w.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),g==null||g())};a.useEffect(()=>v==null?void 0:v(),[]);const O=E((X=l==null?void 0:l.root.subUnitId)!=null?X:r),z=s&&!f&&!I,A=`${o||(l==null?void 0:l.root.ref)||""}${O?" · ":""}${O}`;return a.createElement("div",{className:Oe(h.threadComment,{[h.threadCommentActive]:!I&&(u||j||N==="cell")}),onClick:d,id:`${N}-${t}-${r}-${e}`,onMouseEnter:()=>{S==null||S(),C(!0)},onMouseLeave:()=>{v==null||v(),C(!1)}},!I&&u?a.createElement("div",{className:h.threadCommentHighlight}):null,a.createElement("div",{className:h.threadCommentTitle},a.createElement("div",{className:h.threadCommentTitlePosition},a.createElement("div",{className:h.threadCommentTitleHighlight}),a.createElement("div",{className:h.threadCommentTitlePositionText},A)),l?a.createElement("div",{className:h.threadCommentIconContainer},a.createElement("div",{onClick:F,className:h.threadCommentIcon,style:{color:I?"rgb(var(--green-500))":""}},I?a.createElement(be,null):a.createElement(ye,null)),(U==null?void 0:U.userID)===l.root.personId?a.createElement("div",{className:h.threadCommentIcon,onClick:Q},a.createElement(ge,null)):null):null),a.createElement("div",{className:h.threadCommentContent},J.map(T=>a.createElement(Ut,{onClose:g,unitId:t,subUnitId:r,item:T,key:T.id,isRoot:T.id===(l==null?void 0:l.root.id),editing:f===T.id,resolved:l==null?void 0:l.root.resolved,onEditingChange:D=>{c(D?T.id:"")},onReply:D=>{D&&requestAnimationFrame(()=>{var V;(V=q.current)==null||V.reply(Te([{type:"mention",content:{id:D.userID,label:D.name}}]))})},onAddComment:p,onDeleteComment:b}))),z?a.createElement("div",null,a.createElement(xe,{key:`${x}`,ref:q,unitId:t,subUnitId:r,onSave:({text:T,attachments:D})=>{const V={text:T,attachments:D,dT:ce(),id:i.Tools.generateRandomId(),ref:o,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};(p==null?void 0:p(V))!==!1&&L.executeCommand(w.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:V})},autoFocus:x||!l,onCancel:()=>{l||g==null||g()}})):null)},Nt="univer-thread-comment-panel",Ot="univer-thread-comment",Dt="univer-thread-comment-panel-forms",$t="univer-select",Rt="univer-thread-comment-panel-empty",wt="univer-thread-comment-panel-add",Ht="univer-thread-comment-panel-solved",K={threadCommentPanel:Nt,threadComment:Ot,threadCommentPanelForms:Dt,select:$t,threadCommentPanelEmpty:Rt,threadCommentPanelAdd:wt,threadCommentPanelSolved:Ht},jt=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:s,onResolve:d,sortComments:u,onItemLeave:g,onItemEnter:E,disableAdd:N,tempComment:x,onAddComment:S,onDeleteComment:v,showComments:p}=n,[b,M]=a.useState("all"),[y,j]=a.useState("all"),C=i.useDependency(i.LocaleService),f=i.useDependency(i.UserManagerService),c=i.useDependency(w.ThreadCommentModel),[l,L]=a.useState(()=>c.getUnit(e)),oe=i.useDependency(exports.ThreadCommentPanelService),I=H.useObservable(oe.activeCommentId$),U=H.useObservable(c.commentUpdate$),q=i.useDependency(i.ICommandService),J=H.useObservable(t),F=a.useRef(!0),Q="panel",O=H.useObservable(f.currentUser$),z=a.useMemo(()=>{var te,G;const m=(b==="all"?l.map($=>$[1]).flat():(G=(te=l.find($=>$[0]===J))==null?void 0:te[1])!=null?G:[]).filter($=>!$.parentId),Y=u!=null?u:$=>$,ee=m;if(p){const $=new Map;return ee.forEach(ne=>{$.set(ne.id,ne)}),[...p,""].map(ne=>$.get(ne)).filter(Boolean)}else return Y(ee)},[p,b,l,u,J]),A=a.useMemo(()=>[...z.filter(m=>!m.resolved),...z.filter(m=>m.resolved)],[z]),Z=a.useMemo(()=>y==="resolved"?A.filter(m=>m.resolved):y==="unsolved"?A.filter(m=>!m.resolved):y==="concern_me"&&O!=null&&O.userID?A.map(m=>c.getCommentWithChildren(m.unitId,m.subUnitId,m.id)).map(m=>m!=null&&m.relativeUsers.has(O.userID)?m.root:null).filter(Boolean):A,[A,O==null?void 0:O.userID,y,c]),W=x?[x,...Z]:Z,X=W.filter(m=>!m.resolved),T=W.filter(m=>m.resolved),D=y!=="all"||b!=="all",V=()=>{j("all"),M("all")};a.useEffect(()=>{e&&L(c.getUnit(e))},[e,c,U]),a.useEffect(()=>{var G;if(!I)return;if(!F.current){F.current=!0;return}const{unitId:m,subUnitId:Y,commentId:ee}=I,te=`${Q}-${m}-${Y}-${ee}`;(G=document.getElementById(te))==null||G.scrollIntoView({block:"center"})},[I]);const le=m=>a.createElement(Pe,{prefix:Q,getSubUnitName:s,key:m.id,id:m.id,unitId:m.unitId,subUnitId:m.subUnitId,refStr:m.ref,type:r,showEdit:(I==null?void 0:I.commentId)===m.id,showHighlight:(I==null?void 0:I.commentId)===m.id,onClick:()=>{F.current=!1,m.resolved?q.executeCommand(k.id):q.executeCommand(k.id,{unitId:m.unitId,subUnitId:m.subUnitId,commentId:m.id,temp:!1})},onMouseEnter:()=>E==null?void 0:E(m),onMouseLeave:()=>g==null?void 0:g(m),onAddComment:S,onDeleteComment:v,onResolve:Y=>d==null?void 0:d(m.id,Y)});return a.createElement("div",{className:K.threadCommentPanel},a.createElement("div",{className:K.threadCommentPanelForms},r===i.UniverInstanceType.UNIVER_SHEET?a.createElement(P.Select,{borderless:!0,value:b,onChange:m=>M(m),options:[{value:"current",label:C.t("threadCommentUI.filter.sheet.current")},{value:"all",label:C.t("threadCommentUI.filter.sheet.all")}]}):null,a.createElement(P.Select,{borderless:!0,value:y,onChange:m=>j(m),options:[{value:"all",label:C.t("threadCommentUI.filter.status.all")},{value:"resolved",label:C.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:C.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:C.t("threadCommentUI.filter.status.concernMe")}]})),X.map(le),T.length?a.createElement("div",{className:K.threadCommentPanelSolved},"已解决"):null,T.map(le),W.length?null:a.createElement("div",{className:K.threadCommentPanelEmpty},D?C.t("threadCommentUI.panel.filterEmpty"):C.t("threadCommentUI.panel.empty"),D?a.createElement(P.Button,{onClick:V,type:"link"},C.t("threadCommentUI.panel.reset")):a.createElement(P.Button,{id:"thread-comment-add",className:K.threadCommentPanelAdd,type:"primary",onClick:o,disabled:N},a.createElement(pe,null),C.t("threadCommentUI.panel.addComment"))))};exports.IThreadCommentMentionDataService=se;exports.SetActiveCommentOperation=k;exports.THREAD_COMMENT_PANEL=ue;exports.ThreadCommentPanel=jt;exports.ThreadCommentTree=Pe;exports.ToggleSheetCommentPanelOperation=he;exports.getDT=ce;
1
+ "use strict";var Ne=Object.defineProperty;var Oe=(n,e,t)=>e in n?Ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var w=(n,e,t)=>Oe(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const De=require("dayjs"),H=require("@univerjs/thread-comment"),d=require("@univerjs/core"),Q=require("@wendellhu/redi"),j=require("@univerjs/ui"),le=require("rxjs"),a=require("react"),y=require("@wendellhu/redi/react-bindings"),M=require("@univerjs/design"),$e=require("clsx"),Re=require("@univerjs/engine-render"),we=require("@univerjs/docs");function he(){return De().format("YYYY/MM/DD HH:mm")}const ve="thread-comment-panel",He="THREAD_COMMENT_UI_PLUGIN";var je=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,Ae=(n,e,t,r)=>{for(var o=r>1?void 0:r?Le(e,t):e,i=n.length-1,m;i>=0;i--)(m=n[i])&&(o=(r?m(e,t,o):m(o))||o);return r&&o&&je(e,t,o),o},ce=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends d.Disposable{constructor(t,r){super();w(this,"_panelVisible",!1);w(this,"_panelVisible$",new le.BehaviorSubject(!1));w(this,"_activeCommentId");w(this,"_activeCommentId$",new le.BehaviorSubject(void 0));w(this,"panelVisible$",this._panelVisible$.asObservable());w(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$(d.UniverInstanceType.UNIVER_SHEET).pipe(le.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)}};exports.ThreadCommentPanelService=Ae([ce(0,Q.Inject(j.ISidebarService)),ce(1,d.IUniverInstanceService)],exports.ThreadCommentPanelService);const Ce={id:"thread-comment-ui.operation.toggle-panel",type:d.CommandType.OPERATION,handler(n){const e=n.get(j.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:ve},width:320}),t.setPanelVisible(!0)),!0}},V={id:"thread-comment-ui.operation.set-active-comment",type:d.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}};var ke=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,Be=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ve(e,t):e,i=n.length-1,m;i>=0;i--)(m=n[i])&&(o=(r?m(e,t,o):m(o))||o);return r&&o&&ke(e,t,o),o},qe=(n,e)=>(t,r)=>e(t,r,n);let oe=class extends d.Disposable{constructor(n){super(),this._localeService=n}};oe=Be([d.OnLifecycle(d.LifecycleStages.Starting,oe),qe(0,Q.Inject(d.LocaleService))],oe);class We{constructor(){w(this,"dataSource");w(this,"renderSuggestion");w(this,"trigger","@")}async getMentions(e,t,r){return this.dataSource?this.dataSource.getMentions(e,t,r):[]}}const me=Q.createIdentifier("thread-comment.mention-data.service");var fe=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,ze=(n,e,t)=>e in n?fe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ze=(n,e,t,r)=>{for(var o=r>1?void 0:r?Fe(e,t):e,i=n.length-1,m;i>=0;i--)(m=n[i])&&(o=(r?m(e,t,o):m(o))||o);return r&&o&&fe(e,t,o),o},ue=(n,e)=>(t,r)=>e(t,r,n),ge=(n,e,t)=>ze(n,typeof e!="symbol"?e+"":e,t);exports.UniverThreadCommentUIPlugin=class extends d.Plugin{constructor(e,t,r){super(),this._config=e,this._injector=t,this._commandService=r}onStarting(e){var t;d.mergeOverrideWithDependencies([[oe],[exports.ThreadCommentPanelService],[me,{useClass:We}]],(t=this._config)==null?void 0:t.overrides).forEach(r=>{e.add(r)}),[Ce,V].forEach(r=>{this._commandService.registerCommand(r)})}};ge(exports.UniverThreadCommentUIPlugin,"pluginName",He);ge(exports.UniverThreadCommentUIPlugin,"type",d.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=Ze([d.DependentOn(H.UniverThreadCommentPlugin),ue(1,Q.Inject(Q.Injector)),ue(2,d.ICommandService)],exports.UniverThreadCommentUIPlugin);var P=function(){return P=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},P.apply(this,arguments)},Ye=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 o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]]);return t},q=a.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,i=n.extend,m=Ye(n,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),g=a.useRef("_".concat(Je()));return pe(t,"".concat(r),{defIds:t.defIds,idSuffix:g.current},P({ref:e,className:u},m),i)});function pe(n,e,t,r,o){return a.createElement(n.tag,P(P({key:e},Ge(n,t,o)),r),(Ke(n,t).children||[]).map(function(i,m){return pe(i,"".concat(e,"-").concat(n.tag,"-").concat(m),t,void 0,o)}))}function Ge(n,e,t){var r=P({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(i){var m=i[0],u=i[1];typeof u=="string"&&(r[m]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Ke(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)?P(P({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?P(P({},o),{attrs:P(P({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function Je(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var Qe={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"}}]},Ie=a.forwardRef(function(n,e){return a.createElement(q,Object.assign({},n,{id:"delete-single",ref:e,icon:Qe}))});Ie.displayName="DeleteSingle";var Xe={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"}}]},Se=a.forwardRef(function(n,e){return a.createElement(q,Object.assign({},n,{id:"increase-single",ref:e,icon:Xe}))});Se.displayName="IncreaseSingle";var et={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"}}]},be=a.forwardRef(function(n,e){return a.createElement(q,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:et}))});be.displayName="MoreHorizontalSingle";var tt={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}}]},ye=a.forwardRef(function(n,e){return a.createElement(q,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:tt}))});ye.displayName="ReplyToCommentSingle";var nt={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"}}]},Ee=a.forwardRef(function(n,e){return a.createElement(q,Object.assign({},n,{id:"resolved-single",ref:e,icon:nt}))});Ee.displayName="ResolvedSingle";var rt={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}}]},Te=a.forwardRef(function(n,e){return a.createElement(q,Object.assign({},n,{id:"solve-single",ref:e,icon:rt}))});Te.displayName="SolveSingle";const at="univer-thread-comment-editor-buttons",ot="univer-thread-comment-editor-suggestion",it="univer-thread-comment-editor-suggestionActive",st="univer-thread-comment-editor-suggestion-icon",ie={threadCommentEditorButtons:at,threadCommentEditorSuggestion:ot,threadCommentEditorSuggestionActive:it,threadCommentEditorSuggestionIcon:st},lt=n=>{const e=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let t,r=0;const o=[];for(;(t=e.exec(n))!==null;)t.index>r&&o.push({type:"text",content:n.substring(r,t.index)}),t[1]&&t[2]?o.push({type:"mention",content:{label:t[1],id:t[2]}}):t[3]&&o.push({type:"text",content:t[3]}),r=e.lastIndex;return r<n.length&&o.push({type:"text",content:n.substring(r)}),o},mt=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),xe=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let i=0;return t==null||t.forEach(m=>{i<m.startIndex&&o.push({type:"text",content:e.slice(i,m.startIndex)}),o.push({type:"mention",content:{label:e.slice(m.startIndex,m.endIndex).slice(1,-1),id:m.rangeId}}),i=m.endIndex}),o.push({type:"text",content:e.slice(i,r)}),o},_e=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const o=e.length;e+=`${r.content.label}`;const i=e.length;t.push({rangeId:r.content.id,rangeType:d.CustomRangeType.MENTION,startIndex:o,endIndex:i});break}}}),e+=`
2
+ \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},dt=n=>({display:n.label,id:`${n.id}`,raw:n}),ct=(n,e,t,r,o)=>{var m,u;const i=(m=n.raw)==null?void 0:m.icon;return a.createElement("div",{className:ie.threadCommentEditorSuggestion},i?a.createElement("img",{className:ie.threadCommentEditorSuggestionIcon,src:i}):null,a.createElement("div",null,(u=n.display)!=null?u:n.id))},Pe=a.forwardRef((n,e)=>{var C;const{comment:t,onSave:r,id:o,onCancel:i,autoFocus:m,unitId:u,subUnitId:g}=n,T=y.useDependency(me),O=y.useDependency(d.ICommandService),_=y.useDependency(d.LocaleService),[S,v]=a.useState({...t}),[p,b]=a.useState(!1),U=a.useRef(null),E=y.useDependency(Re.ITextSelectionRenderManager),L=y.useDependency(we.TextSelectionManagerService);return a.useImperativeHandle(e,()=>({reply(f){var c;v({...t,text:f,attachments:[]}),(c=U.current)==null||c.inputElement.focus()}})),a.createElement("div",{className:ie.threadCommentEditor,onClick:f=>f.preventDefault()},a.createElement(M.Mentions,{ref:U,autoFocus:m,style:{width:"100%"},placeholder:_.t("threadCommentUI.editor.placeholder"),value:S!=null&&S.text?mt(xe(S.text)):"",onChange:f=>{f.target.value||v({...t,text:void 0}),v==null||v({...t,text:_e(lt(f.target.value))})},onFocus:()=>{const f=L.getActiveRange();f&&f.collapsed&&E.removeAllTextRanges(),E.blur(),b(!0)}},a.createElement(M.Mention,{key:T.trigger,trigger:T.trigger,data:(f,c)=>T.getMentions(f,u,g).then(s=>s.map(dt)).then(c),displayTransform:(f,c)=>`@${c} `,renderSuggestion:(C=T.renderSuggestion)!=null?C:ct})),p?a.createElement("div",{className:ie.threadCommentEditorButtons},a.createElement(M.Button,{style:{marginRight:12},onClick:()=>{i==null||i(),b(!1),v({text:void 0}),O.executeCommand(V.id)}},_.t("threadCommentUI.editor.cancel")),a.createElement(M.Button,{type:"primary",disabled:!S.text,onClick:()=>{S.text&&(r==null||r({...S,text:S.text}),b(!1),v({text:void 0}))}},_.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),ut="univer-thread-comment",ht="univer-thread-comment-active",vt="univer-thread-comment-content",Ct="univer-thread-comment-highlight",ft="univer-thread-comment-icon-container",gt="univer-thread-comment-icon",pt="univer-thread-comment-title",It="univer-thread-comment-title-position",St="univer-thread-comment-title-highlight",bt="univer-thread-comment-title-position-text",yt="univer-thread-comment-username",Et="univer-thread-comment-item",Tt="univer-thread-comment-item-head",xt="univer-thread-comment-item-title",_t="univer-thread-comment-item-title-position",Pt="univer-thread-comment-item-title-highlight",Mt="univer-thread-comment-item-time",Ut="univer-thread-comment-item-content",Nt="univer-thread-comment-item-at",h={threadComment:ut,threadCommentActive:ht,threadCommentContent:vt,threadCommentHighlight:Ct,threadCommentIconContainer:ft,threadCommentIcon:gt,threadCommentTitle:pt,threadCommentTitlePosition:It,threadCommentTitleHighlight:St,threadCommentTitlePositionText:bt,threadCommentUsername:yt,threadCommentItem:Et,threadCommentItemHead:Tt,threadCommentItemTitle:xt,threadCommentItemTitlePosition:_t,threadCommentItemTitleHighlight:Pt,threadCommentItemTime:Mt,threadCommentItemContent:Ut,threadCommentItemAt:Nt},Me="__mock__",Ot=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:i,onReply:m,resolved:u,isRoot:g,onClose:T,onDeleteComment:O}=n,_=y.useDependency(d.ICommandService),S=y.useDependency(d.LocaleService),v=y.useDependency(d.UserManagerService),p=v.getUser(e.personId),b=j.useObservable(v.currentUser$),U=(b==null?void 0:b.userID)===e.personId,E=e.id===Me,[L,C]=a.useState(!1),f=()=>{(O==null?void 0:O(e))!==!1&&(_.executeCommand(g?H.DeleteCommentTreeCommand.id:H.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),g&&(T==null||T()))};return a.createElement("div",{className:h.threadCommentItem,onMouseLeave:()=>C(!1),onMouseEnter:()=>C(!0)},a.createElement("img",{className:h.threadCommentItemHead,src:p==null?void 0:p.avatar}),a.createElement("div",{className:h.threadCommentItemTitle},a.createElement("div",{className:h.threadCommentUsername},(p==null?void 0:p.name)||" "),a.createElement("div",null,E||u?null:L?a.createElement("div",{className:h.threadCommentIcon,onClick:()=>m(p)},a.createElement(ye,null)):null,U&&!E&&!u?a.createElement(M.Dropdown,{overlay:a.createElement(M.Menu,null,a.createElement(M.MenuItem,{key:"edit",onClick:()=>i==null?void 0:i(!0)},S.t("threadCommentUI.item.edit")),a.createElement(M.MenuItem,{key:"delete",onClick:f},S.t("threadCommentUI.item.delete")))},a.createElement("div",{className:h.threadCommentIcon},a.createElement(be,null))):null)),a.createElement("div",{className:h.threadCommentItemTime},e.dT),o?a.createElement(Pe,{id:e.id,comment:e,onCancel:()=>i==null?void 0:i(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:c,attachments:s})=>{i==null||i(!1),_.executeCommand(H.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:c,attachments:s}})}}):a.createElement("div",{className:h.threadCommentItemContent},xe(e.text).map((c,s)=>{switch(c.type){case"mention":return a.createElement("a",{className:h.threadCommentItemAt,key:s},"@",c.content.label," ");default:return c.content}})))},Ue=n=>{var Y,W,te;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:i=!0,onClick:m,showHighlight:u,onClose:g,getSubUnitName:T,prefix:O,autoFocus:_,onMouseEnter:S,onMouseLeave:v,onAddComment:p,onDeleteComment:b,onResolve:U}=n,E=y.useDependency(H.ThreadCommentModel),[L,C]=a.useState(!1),[f,c]=a.useState("");j.useObservable(E.commentMap$);const s=e?E.getCommentWithChildren(t,r,e):null,A=y.useDependency(d.ICommandService),se=y.useDependency(d.UserManagerService),I=s==null?void 0:s.root.resolved,N=j.useObservable(se.currentUser$),F=a.useRef(null),X=[...s?[s.root]:[{id:Me,text:{dataStream:`
3
+ \r`},personId:(Y=N==null?void 0:N.userID)!=null?Y:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(W=s==null?void 0:s.children)!=null?W:[]],z=x=>{x.stopPropagation(),I?A.executeCommand(V.id,{unitId:t,subUnitId:r,commentId:e}):A.executeCommand(V.id),A.executeCommand(H.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!I}),U==null||U(!I)},ee=x=>{x.stopPropagation(),A.executeCommand(V.id),!(s!=null&&s.root&&(b==null?void 0:b(s.root))===!1)&&(A.executeCommand(H.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),g==null||g())};a.useEffect(()=>v==null?void 0:v(),[]);const D=T((te=s==null?void 0:s.root.subUnitId)!=null?te:r),Z=i&&!f&&!I,k=`${o||(s==null?void 0:s.root.ref)||""}${D?" · ":""}${D}`;return a.createElement("div",{className:$e(h.threadComment,{[h.threadCommentActive]:!I&&(u||L||O==="cell")}),onClick:m,id:`${O}-${t}-${r}-${e}`,onMouseEnter:()=>{S==null||S(),C(!0)},onMouseLeave:()=>{v==null||v(),C(!1)}},!I&&u?a.createElement("div",{className:h.threadCommentHighlight}):null,a.createElement("div",{className:h.threadCommentTitle},a.createElement("div",{className:h.threadCommentTitlePosition},a.createElement("div",{className:h.threadCommentTitleHighlight}),a.createElement("div",{className:h.threadCommentTitlePositionText},k)),s?a.createElement("div",{className:h.threadCommentIconContainer},a.createElement("div",{onClick:z,className:h.threadCommentIcon,style:{color:I?"rgb(var(--green-500))":""}},I?a.createElement(Ee,null):a.createElement(Te,null)),(N==null?void 0:N.userID)===s.root.personId?a.createElement("div",{className:h.threadCommentIcon,onClick:ee},a.createElement(Ie,null)):null):null),a.createElement("div",{className:h.threadCommentContent},X.map(x=>a.createElement(Ot,{onClose:g,unitId:t,subUnitId:r,item:x,key:x.id,isRoot:x.id===(s==null?void 0:s.root.id),editing:f===x.id,resolved:s==null?void 0:s.root.resolved,onEditingChange:$=>{c($?x.id:"")},onReply:$=>{$&&requestAnimationFrame(()=>{var B;(B=F.current)==null||B.reply(_e([{type:"mention",content:{id:$.userID,label:$.name}}]))})},onAddComment:p,onDeleteComment:b}))),Z?a.createElement("div",null,a.createElement(Pe,{key:`${_}`,ref:F,unitId:t,subUnitId:r,onSave:({text:x,attachments:$})=>{const B={text:x,attachments:$,dT:he(),id:d.Tools.generateRandomId(),ref:o,personId:N==null?void 0:N.userID,parentId:s==null?void 0:s.root.id,unitId:t,subUnitId:r,threadId:s==null?void 0:s.root.threadId};(p==null?void 0:p(B))!==!1&&A.executeCommand(H.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:B})},autoFocus:_||!s,onCancel:()=>{s||g==null||g()}})):null)},Dt="univer-thread-comment-panel",$t="univer-thread-comment",Rt="univer-thread-comment-panel-forms",wt="univer-select",Ht="univer-thread-comment-panel-empty",jt="univer-thread-comment-panel-add",Lt="univer-thread-comment-panel-solved",J={threadCommentPanel:Dt,threadComment:$t,threadCommentPanelForms:Rt,select:wt,threadCommentPanelEmpty:Ht,threadCommentPanelAdd:jt,threadCommentPanelSolved:Lt},At=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:i,onResolve:m,sortComments:u,onItemLeave:g,onItemEnter:T,disableAdd:O,tempComment:_,onAddComment:S,onDeleteComment:v,showComments:p}=n,[b,U]=a.useState("all"),[E,L]=a.useState("all"),C=y.useDependency(d.LocaleService),f=y.useDependency(d.UserManagerService),c=y.useDependency(H.ThreadCommentModel),[s,A]=a.useState(()=>c.getUnit(e)),se=y.useDependency(exports.ThreadCommentPanelService),I=j.useObservable(se.activeCommentId$),N=j.useObservable(c.commentUpdate$),F=y.useDependency(d.ICommandService),X=j.useObservable(t),z=a.useRef(!0),ee="panel",D=j.useObservable(f.currentUser$),Z=a.useMemo(()=>{var re,K;const l=(b==="all"?s.map(R=>R[1]).flat():(K=(re=s.find(R=>R[0]===X))==null?void 0:re[1])!=null?K:[]).filter(R=>!R.parentId),G=u!=null?u:R=>R,ne=l;if(p){const R=new Map;return ne.forEach(ae=>{R.set(ae.id,ae)}),[...p,""].map(ae=>R.get(ae)).filter(Boolean)}else return G(ne)},[p,b,s,u,X]),k=a.useMemo(()=>[...Z.filter(l=>!l.resolved),...Z.filter(l=>l.resolved)],[Z]),Y=a.useMemo(()=>E==="resolved"?k.filter(l=>l.resolved):E==="unsolved"?k.filter(l=>!l.resolved):E==="concern_me"&&D!=null&&D.userID?k.map(l=>c.getCommentWithChildren(l.unitId,l.subUnitId,l.id)).map(l=>l!=null&&l.relativeUsers.has(D.userID)?l.root:null).filter(Boolean):k,[k,D==null?void 0:D.userID,E,c]),W=_?[_,...Y]:Y,te=W.filter(l=>!l.resolved),x=W.filter(l=>l.resolved),$=E!=="all"||b!=="all",B=()=>{L("all"),U("all")};a.useEffect(()=>{e&&A(c.getUnit(e))},[e,c,N]),a.useEffect(()=>{var K;if(!I)return;if(!z.current){z.current=!0;return}const{unitId:l,subUnitId:G,commentId:ne}=I,re=`${ee}-${l}-${G}-${ne}`;(K=document.getElementById(re))==null||K.scrollIntoView({block:"center"})},[I]);const de=l=>a.createElement(Ue,{prefix:ee,getSubUnitName:i,key:l.id,id:l.id,unitId:l.unitId,subUnitId:l.subUnitId,refStr:l.ref,type:r,showEdit:(I==null?void 0:I.commentId)===l.id,showHighlight:(I==null?void 0:I.commentId)===l.id,onClick:()=>{z.current=!1,l.resolved?F.executeCommand(V.id):F.executeCommand(V.id,{unitId:l.unitId,subUnitId:l.subUnitId,commentId:l.id,temp:!1})},onMouseEnter:()=>T==null?void 0:T(l),onMouseLeave:()=>g==null?void 0:g(l),onAddComment:S,onDeleteComment:v,onResolve:G=>m==null?void 0:m(l.id,G)});return a.createElement("div",{className:J.threadCommentPanel},a.createElement("div",{className:J.threadCommentPanelForms},r===d.UniverInstanceType.UNIVER_SHEET?a.createElement(M.Select,{borderless:!0,value:b,onChange:l=>U(l),options:[{value:"current",label:C.t("threadCommentUI.filter.sheet.current")},{value:"all",label:C.t("threadCommentUI.filter.sheet.all")}]}):null,a.createElement(M.Select,{borderless:!0,value:E,onChange:l=>L(l),options:[{value:"all",label:C.t("threadCommentUI.filter.status.all")},{value:"resolved",label:C.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:C.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:C.t("threadCommentUI.filter.status.concernMe")}]})),te.map(de),x.length?a.createElement("div",{className:J.threadCommentPanelSolved},"已解决"):null,x.map(de),W.length?null:a.createElement("div",{className:J.threadCommentPanelEmpty},$?C.t("threadCommentUI.panel.filterEmpty"):C.t("threadCommentUI.panel.empty"),$?a.createElement(M.Button,{onClick:B,type:"link"},C.t("threadCommentUI.panel.reset")):a.createElement(M.Button,{id:"thread-comment-add",className:J.threadCommentPanelAdd,type:"primary",onClick:o,disabled:O},a.createElement(Se,null),C.t("threadCommentUI.panel.addComment"))))};exports.IThreadCommentMentionDataService=me;exports.SetActiveCommentOperation=V;exports.THREAD_COMMENT_PANEL=ve;exports.ThreadCommentPanel=At;exports.ThreadCommentTree=Ue;exports.ToggleSheetCommentPanelOperation=Ce;exports.getDT=he;
package/lib/es/index.js CHANGED
@@ -3,10 +3,12 @@ var Fe = (t, e, n) => e in t ? We(t, e, { enumerable: !0, configurable: !0, writ
3
3
  var w = (t, e, n) => Fe(t, typeof e != "symbol" ? e + "" : e, n);
4
4
  import ze from "dayjs";
5
5
  import { UniverThreadCommentPlugin as Ze, ThreadCommentModel as xe, AddCommentCommand as Ye, UpdateCommentCommand as Ge, ResolveCommentCommand as Ke, DeleteCommentTreeCommand as _e, DeleteCommentCommand as qe } from "@univerjs/thread-comment";
6
- import { Disposable as Te, UniverInstanceType as Ce, Inject as fe, IUniverInstanceService as Je, CommandType as Ne, OnLifecycle as Qe, LifecycleStages as Xe, LocaleService as de, createIdentifier as et, Plugin as tt, mergeOverrideWithDependencies as nt, DependentOn as rt, Injector as ot, ICommandService as X, CustomRangeType as at, useDependency as b, UserManagerService as ge, Tools as it } from "@univerjs/core";
6
+ import { Disposable as Te, UniverInstanceType as Ce, IUniverInstanceService as Je, CommandType as Ne, OnLifecycle as Qe, LifecycleStages as Xe, LocaleService as de, Plugin as et, mergeOverrideWithDependencies as tt, DependentOn as nt, ICommandService as X, CustomRangeType as rt, UserManagerService as fe, Tools as ot } from "@univerjs/core";
7
+ import { Inject as ge, createIdentifier as at, Injector as it } from "@wendellhu/redi";
7
8
  import { ISidebarService as Me, useObservable as j } from "@univerjs/ui";
8
9
  import { BehaviorSubject as Ie, filter as lt } from "rxjs";
9
10
  import a, { forwardRef as A, useRef as ce, createElement as B, useState as k, useImperativeHandle as st, useEffect as ve, useMemo as he } from "react";
11
+ import { useDependency as b } from "@wendellhu/redi/react-bindings";
10
12
  import { Mentions as mt, Mention as dt, Button as le, Dropdown as ct, Menu as ut, MenuItem as Se, Select as be } from "@univerjs/design";
11
13
  import ht from "clsx";
12
14
  import { ITextSelectionRenderManager as vt } from "@univerjs/engine-render";
@@ -58,7 +60,7 @@ let z = class extends Te {
58
60
  }
59
61
  };
60
62
  z = bt([
61
- Ee(0, fe(Me)),
63
+ Ee(0, ge(Me)),
62
64
  Ee(1, Je)
63
65
  ], z);
64
66
  const Et = {
@@ -91,7 +93,7 @@ let ie = class extends Te {
91
93
  };
92
94
  ie = _t([
93
95
  Qe(Xe.Starting, ie),
94
- Tt(0, fe(de))
96
+ Tt(0, ge(de))
95
97
  ], ie);
96
98
  class Nt {
97
99
  constructor() {
@@ -103,19 +105,19 @@ class Nt {
103
105
  return this.dataSource ? this.dataSource.getMentions(e, n, r) : [];
104
106
  }
105
107
  }
106
- const Pe = et("thread-comment.mention-data.service");
108
+ const Pe = at("thread-comment.mention-data.service");
107
109
  var Ue = Object.defineProperty, Mt = Object.getOwnPropertyDescriptor, Pt = (t, e, n) => e in t ? Ue(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Ut = (t, e, n, r) => {
108
110
  for (var o = r > 1 ? void 0 : r ? Mt(e, n) : e, i = t.length - 1, m; i >= 0; i--)
109
111
  (m = t[i]) && (o = (r ? m(e, n, o) : m(o)) || o);
110
112
  return r && o && Ue(e, n, o), o;
111
113
  }, ye = (t, e) => (n, r) => e(n, r, t), $e = (t, e, n) => Pt(t, typeof e != "symbol" ? e + "" : e, n);
112
- let se = class extends tt {
114
+ let se = class extends et {
113
115
  constructor(t, e, n) {
114
116
  super(), this._config = t, this._injector = e, this._commandService = n;
115
117
  }
116
118
  onStarting(t) {
117
119
  var e;
118
- nt([
120
+ tt([
119
121
  [ie],
120
122
  [z],
121
123
  [Pe, { useClass: Nt }]
@@ -129,8 +131,8 @@ let se = class extends tt {
129
131
  $e(se, "pluginName", pt);
130
132
  $e(se, "type", Ce.UNIVER_UNKNOWN);
131
133
  se = Ut([
132
- rt(Ze),
133
- ye(1, fe(ot)),
134
+ nt(Ze),
135
+ ye(1, ge(it)),
134
136
  ye(2, X)
135
137
  ], se);
136
138
  var T = function() {
@@ -290,7 +292,7 @@ const Vt = "univer-thread-comment-editor-buttons", Bt = "univer-thread-comment-e
290
292
  const i = e.length;
291
293
  n.push({
292
294
  rangeId: r.content.id,
293
- rangeType: at.MENTION,
295
+ rangeType: rt.MENTION,
294
296
  startIndex: o,
295
297
  endIndex: i
296
298
  });
@@ -404,7 +406,7 @@ const Vt = "univer-thread-comment-editor-buttons", Bt = "univer-thread-comment-e
404
406
  threadCommentItemContent: hn,
405
407
  threadCommentItemAt: vn
406
408
  }, Be = "__mock__", Cn = (t) => {
407
- const { item: e, unitId: n, subUnitId: r, editing: o, onEditingChange: i, onReply: m, resolved: c, isRoot: f, onClose: y, onDeleteComment: P } = t, _ = b(X), I = b(de), h = b(ge), g = h.getUser(e.personId), S = j(h.currentUser$), N = (S == null ? void 0 : S.userID) === e.personId, E = e.id === Be, [H, v] = k(!1), C = () => {
409
+ const { item: e, unitId: n, subUnitId: r, editing: o, onEditingChange: i, onReply: m, resolved: c, isRoot: f, onClose: y, onDeleteComment: P } = t, _ = b(X), I = b(de), h = b(fe), g = h.getUser(e.personId), S = j(h.currentUser$), N = (S == null ? void 0 : S.userID) === e.personId, E = e.id === Be, [H, v] = k(!1), C = () => {
408
410
  (P == null ? void 0 : P(e)) !== !1 && (_.executeCommand(
409
411
  f ? _e.id : qe.id,
410
412
  {
@@ -473,7 +475,7 @@ const Vt = "univer-thread-comment-editor-buttons", Bt = "univer-thread-comment-e
473
475
  onResolve: N
474
476
  } = t, E = b(xe), [H, v] = k(!1), [C, d] = k("");
475
477
  j(E.commentMap$);
476
- const l = e ? E.getCommentWithChildren(n, r, e) : null, R = b(X), ue = b(ge), p = l == null ? void 0 : l.root.resolved, M = j(ue.currentUser$), Z = ce(null), ee = [
478
+ const l = e ? E.getCommentWithChildren(n, r, e) : null, R = b(X), ue = b(fe), p = l == null ? void 0 : l.root.resolved, M = j(ue.currentUser$), Z = ce(null), ee = [
477
479
  ...l ? [l.root] : (
478
480
  // mock empty comment
479
481
  [{
@@ -583,7 +585,7 @@ const Vt = "univer-thread-comment-editor-buttons", Bt = "univer-thread-comment-e
583
585
  text: x,
584
586
  attachments: $,
585
587
  dT: ft(),
586
- id: it.generateRandomId(),
588
+ id: ot.generateRandomId(),
587
589
  ref: o,
588
590
  personId: M == null ? void 0 : M.userID,
589
591
  parentId: l == null ? void 0 : l.root.id,
@@ -615,7 +617,7 @@ const Vt = "univer-thread-comment-editor-buttons", Bt = "univer-thread-comment-e
615
617
  threadCommentPanelEmpty: bn,
616
618
  threadCommentPanelAdd: En,
617
619
  threadCommentPanelSolved: yn
618
- }, Rn = (t) => {
620
+ }, kn = (t) => {
619
621
  const {
620
622
  unitId: e,
621
623
  subUnitId$: n,
@@ -631,7 +633,7 @@ const Vt = "univer-thread-comment-editor-buttons", Bt = "univer-thread-comment-e
631
633
  onAddComment: I,
632
634
  onDeleteComment: h,
633
635
  showComments: g
634
- } = t, [S, N] = k("all"), [E, H] = k("all"), v = b(de), C = b(ge), d = b(xe), [l, R] = k(() => d.getUnit(e)), ue = b(z), p = j(ue.activeCommentId$), M = j(d.commentUpdate$), Z = b(X), ee = j(n), Y = ce(!0), te = "panel", U = j(C.currentUser$), G = he(() => {
636
+ } = t, [S, N] = k("all"), [E, H] = k("all"), v = b(de), C = b(fe), d = b(xe), [l, R] = k(() => d.getUnit(e)), ue = b(z), p = j(ue.activeCommentId$), M = j(d.commentUpdate$), Z = b(X), ee = j(n), Y = ce(!0), te = "panel", U = j(C.currentUser$), G = he(() => {
635
637
  var oe, J;
636
638
  const s = (S === "all" ? l.map((O) => O[1]).flat() : (J = (oe = l.find((O) => O[0] === ee)) == null ? void 0 : oe[1]) != null ? J : []).filter((O) => !O.parentId), q = c != null ? c : (O) => O, re = s;
637
639
  if (g) {
@@ -759,7 +761,7 @@ export {
759
761
  Pe as IThreadCommentMentionDataService,
760
762
  V as SetActiveCommentOperation,
761
763
  gt as THREAD_COMMENT_PANEL,
762
- Rn as ThreadCommentPanel,
764
+ kn as ThreadCommentPanel,
763
765
  z as ThreadCommentPanelService,
764
766
  fn as ThreadCommentTree,
765
767
  Et as ToggleSheetCommentPanelOperation,
@@ -1,4 +1,5 @@
1
- import { DependencyOverride, ICommandService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { DependencyOverride, ICommandService, Plugin, UniverInstanceType } from '@univerjs/core';
2
+ import { Injector } from '@wendellhu/redi';
2
3
 
3
4
  export interface IUniverThreadCommentUIConfig {
4
5
  overrides?: DependencyOverride;
@@ -17,4 +17,4 @@ export declare class ThreadCommentMentionDataService implements IThreadCommentMe
17
17
  getMentions(search: string, unitId: string, subUnitId: string): Promise<IThreadCommentMention[]>;
18
18
  trigger: string;
19
19
  }
20
- export declare const IThreadCommentMentionDataService: import('@univerjs/core').IdentifierDecorator<IThreadCommentMentionDataService>;
20
+ export declare const IThreadCommentMentionDataService: import('@wendellhu/redi').IdentifierDecorator<IThreadCommentMentionDataService>;
@@ -1,6 +1,6 @@
1
1
  import { default as React } from 'react';
2
- import { UniverInstanceType, Nullable } from '@univerjs/core';
3
2
  import { IThreadComment } from '@univerjs/thread-comment';
3
+ import { Nullable, UniverInstanceType } from '@univerjs/core';
4
4
  import { Observable } from 'rxjs';
5
5
  import { IThreadCommentTreeProps } from '../thread-comment-tree';
6
6
 
package/lib/umd/index.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(d,U){typeof exports=="object"&&typeof module<"u"?U(exports,require("dayjs"),require("@univerjs/thread-comment"),require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("clsx"),require("@univerjs/engine-render"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/thread-comment","@univerjs/core","@univerjs/ui","rxjs","react","@univerjs/design","clsx","@univerjs/engine-render","@univerjs/docs"],U):(d=typeof globalThis<"u"?globalThis:d||self,U(d.UniverThreadCommentUi={},d.dayjs,d.UniverThreadComment,d.UniverCore,d.UniverUi,d.rxjs,d.React,d.UniverDesign,d.clsx,d.UniverEngineRender,d.UniverDocs))})(this,function(d,U,T,a,L,me,i,x,Ne,Oe,De){"use strict";var mt=Object.defineProperty;var st=(d,U,T)=>U in d?mt(d,U,{enumerable:!0,configurable:!0,writable:!0,value:T}):d[U]=T;var A=(d,U,T)=>st(d,typeof U!="symbol"?U+"":U,T);function de(){return U().format("YYYY/MM/DD HH:mm")}const ce="thread-comment-panel",we="THREAD_COMMENT_UI_PLUGIN";var He=Object.defineProperty,je=Object.getOwnPropertyDescriptor,$e=(n,e,t,r)=>{for(var o=r>1?void 0:r?je(e,t):e,m=n.length-1,c;m>=0;m--)(c=n[m])&&(o=(r?c(e,t,o):c(o))||o);return r&&o&&He(e,t,o),o},ue=(n,e)=>(t,r)=>e(t,r,n);d.ThreadCommentPanelService=class extends a.Disposable{constructor(t,r){super();A(this,"_panelVisible",!1);A(this,"_panelVisible$",new me.BehaviorSubject(!1));A(this,"_activeCommentId");A(this,"_activeCommentId$",new me.BehaviorSubject(void 0));A(this,"panelVisible$",this._panelVisible$.asObservable());A(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(me.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)}},d.ThreadCommentPanelService=$e([ue(0,a.Inject(L.ISidebarService)),ue(1,a.IUniverInstanceService)],d.ThreadCommentPanelService);const he={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(L.ISidebarService),t=n.get(d.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:ce},width:320}),t.setPanelVisible(!0)),!0}},k={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(d.ThreadCommentPanelService).setActiveComment(e),!0}};var Ae=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,ke=(n,e,t,r)=>{for(var o=r>1?void 0:r?Le(e,t):e,m=n.length-1,c;m>=0;m--)(c=n[m])&&(o=(r?c(e,t,o):c(o))||o);return r&&o&&Ae(e,t,o),o},Ve=(n,e)=>(t,r)=>e(t,r,n);let R=class extends a.Disposable{constructor(n){super(),this._localeService=n}};R=ke([a.OnLifecycle(a.LifecycleStages.Starting,R),Ve(0,a.Inject(a.LocaleService))],R);class Be{constructor(){A(this,"dataSource");A(this,"renderSuggestion");A(this,"trigger","@")}async getMentions(e,t,r){return this.dataSource?this.dataSource.getMentions(e,t,r):[]}}const se=a.createIdentifier("thread-comment.mention-data.service");var ve=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,We=(n,e,t)=>e in n?ve(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,qe=(n,e,t,r)=>{for(var o=r>1?void 0:r?Fe(e,t):e,m=n.length-1,c;m>=0;m--)(c=n[m])&&(o=(r?c(e,t,o):c(o))||o);return r&&o&&ve(e,t,o),o},Ce=(n,e)=>(t,r)=>e(t,r,n),fe=(n,e,t)=>We(n,typeof e!="symbol"?e+"":e,t);d.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e,t,r){super(),this._config=e,this._injector=t,this._commandService=r}onStarting(e){var t;a.mergeOverrideWithDependencies([[R],[d.ThreadCommentPanelService],[se,{useClass:Be}]],(t=this._config)==null?void 0:t.overrides).forEach(r=>{e.add(r)}),[he,k].forEach(r=>{this._commandService.registerCommand(r)})}},fe(d.UniverThreadCommentUIPlugin,"pluginName",we),fe(d.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),d.UniverThreadCommentUIPlugin=qe([a.DependentOn(T.UniverThreadCommentPlugin),Ce(1,a.Inject(a.Injector)),Ce(2,a.ICommandService)],d.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 o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},M.apply(this,arguments)},ze=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 o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]]);return t},W=i.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,m=n.extend,c=ze(n,["icon","id","className","extend"]),v="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),p=i.useRef("_".concat(Ge()));return ge(t,"".concat(r),{defIds:t.defIds,idSuffix:p.current},M({ref:e,className:v},c),m)});function ge(n,e,t,r,o){return i.createElement(n.tag,M(M({key:e},Ze(n,t,o)),r),(Ye(n,t).children||[]).map(function(m,c){return ge(m,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,o)}))}function Ze(n,e,t){var r=M({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(m){var c=m[0],v=m[1];typeof v=="string"&&(r[c]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Ye(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(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?M(M({},o),{attrs:M(M({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function Ge(){return Math.random().toString(36).substring(2,8)}W.displayName="UniverIcon";var Ke={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"}}]},pe=i.forwardRef(function(n,e){return i.createElement(W,Object.assign({},n,{id:"delete-single",ref:e,icon:Ke}))});pe.displayName="DeleteSingle";var Je={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"}}]},Ie=i.forwardRef(function(n,e){return i.createElement(W,Object.assign({},n,{id:"increase-single",ref:e,icon:Je}))});Ie.displayName="IncreaseSingle";var Qe={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"}}]},Se=i.forwardRef(function(n,e){return i.createElement(W,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Qe}))});Se.displayName="MoreHorizontalSingle";var Xe={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}}]},ye=i.forwardRef(function(n,e){return i.createElement(W,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Xe}))});ye.displayName="ReplyToCommentSingle";var Re={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"}}]},Ee=i.forwardRef(function(n,e){return i.createElement(W,Object.assign({},n,{id:"resolved-single",ref:e,icon:Re}))});Ee.displayName="ResolvedSingle";var et={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}}]},be=i.forwardRef(function(n,e){return i.createElement(W,Object.assign({},n,{id:"solve-single",ref:e,icon:et}))});be.displayName="SolveSingle";const ee={threadCommentEditorButtons:"univer-thread-comment-editor-buttons",threadCommentEditorSuggestion:"univer-thread-comment-editor-suggestion",threadCommentEditorSuggestionActive:"univer-thread-comment-editor-suggestionActive",threadCommentEditorSuggestionIcon:"univer-thread-comment-editor-suggestion-icon"},tt=n=>{const e=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let t,r=0;const o=[];for(;(t=e.exec(n))!==null;)t.index>r&&o.push({type:"text",content:n.substring(r,t.index)}),t[1]&&t[2]?o.push({type:"mention",content:{label:t[1],id:t[2]}}):t[3]&&o.push({type:"text",content:t[3]}),r=e.lastIndex;return r<n.length&&o.push({type:"text",content:n.substring(r)}),o},nt=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),Te=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let m=0;return t==null||t.forEach(c=>{m<c.startIndex&&o.push({type:"text",content:e.slice(m,c.startIndex)}),o.push({type:"mention",content:{label:e.slice(c.startIndex,c.endIndex).slice(1,-1),id:c.rangeId}}),m=c.endIndex}),o.push({type:"text",content:e.slice(m,r)}),o},_e=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const o=e.length;e+=`${r.content.label}`;const m=e.length;t.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:o,endIndex:m});break}}}),e+=`
2
- \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},rt=n=>({display:n.label,id:`${n.id}`,raw:n}),it=(n,e,t,r,o)=>{var c,v;const m=(c=n.raw)==null?void 0:c.icon;return i.createElement("div",{className:ee.threadCommentEditorSuggestion},m?i.createElement("img",{className:ee.threadCommentEditorSuggestionIcon,src:m}):null,i.createElement("div",null,(v=n.display)!=null?v:n.id))},Pe=i.forwardRef((n,e)=>{var f;const{comment:t,onSave:r,id:o,onCancel:m,autoFocus:c,unitId:v,subUnitId:p}=n,_=a.useDependency(se),w=a.useDependency(a.ICommandService),N=a.useDependency(a.LocaleService),[y,C]=i.useState({...t}),[I,E]=i.useState(!1),O=i.useRef(null),b=a.useDependency(Oe.ITextSelectionRenderManager),V=a.useDependency(De.TextSelectionManagerService);return i.useImperativeHandle(e,()=>({reply(g){var u;C({...t,text:g,attachments:[]}),(u=O.current)==null||u.inputElement.focus()}})),i.createElement("div",{className:ee.threadCommentEditor,onClick:g=>g.preventDefault()},i.createElement(x.Mentions,{ref:O,autoFocus:c,style:{width:"100%"},placeholder:N.t("threadCommentUI.editor.placeholder"),value:y!=null&&y.text?nt(Te(y.text)):"",onChange:g=>{g.target.value||C({...t,text:void 0}),C==null||C({...t,text:_e(tt(g.target.value))})},onFocus:()=>{const g=V.getActiveRange();g&&g.collapsed&&b.removeAllTextRanges(),b.blur(),E(!0)}},i.createElement(x.Mention,{key:_.trigger,trigger:_.trigger,data:(g,u)=>_.getMentions(g,v,p).then(s=>s.map(rt)).then(u),displayTransform:(g,u)=>`@${u} `,renderSuggestion:(f=_.renderSuggestion)!=null?f:it})),I?i.createElement("div",{className:ee.threadCommentEditorButtons},i.createElement(x.Button,{style:{marginRight:12},onClick:()=>{m==null||m(),E(!1),C({text:void 0}),w.executeCommand(k.id)}},N.t("threadCommentUI.editor.cancel")),i.createElement(x.Button,{type:"primary",disabled:!y.text,onClick:()=>{y.text&&(r==null||r({...y,text:y.text}),E(!1),C({text:void 0}))}},N.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),h={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",threadCommentItemTitlePosition:"univer-thread-comment-item-title-position",threadCommentItemTitleHighlight:"univer-thread-comment-item-title-highlight",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},Ue="__mock__",ot=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:m,onReply:c,resolved:v,isRoot:p,onClose:_,onDeleteComment:w}=n,N=a.useDependency(a.ICommandService),y=a.useDependency(a.LocaleService),C=a.useDependency(a.UserManagerService),I=C.getUser(e.personId),E=L.useObservable(C.currentUser$),O=(E==null?void 0:E.userID)===e.personId,b=e.id===Ue,[V,f]=i.useState(!1),g=()=>{(w==null?void 0:w(e))!==!1&&(N.executeCommand(p?T.DeleteCommentTreeCommand.id:T.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),p&&(_==null||_()))};return i.createElement("div",{className:h.threadCommentItem,onMouseLeave:()=>f(!1),onMouseEnter:()=>f(!0)},i.createElement("img",{className:h.threadCommentItemHead,src:I==null?void 0:I.avatar}),i.createElement("div",{className:h.threadCommentItemTitle},i.createElement("div",{className:h.threadCommentUsername},(I==null?void 0:I.name)||" "),i.createElement("div",null,b||v?null:V?i.createElement("div",{className:h.threadCommentIcon,onClick:()=>c(I)},i.createElement(ye,null)):null,O&&!b&&!v?i.createElement(x.Dropdown,{overlay:i.createElement(x.Menu,null,i.createElement(x.MenuItem,{key:"edit",onClick:()=>m==null?void 0:m(!0)},y.t("threadCommentUI.item.edit")),i.createElement(x.MenuItem,{key:"delete",onClick:g},y.t("threadCommentUI.item.delete")))},i.createElement("div",{className:h.threadCommentIcon},i.createElement(Se,null))):null)),i.createElement("div",{className:h.threadCommentItemTime},e.dT),o?i.createElement(Pe,{id:e.id,comment:e,onCancel:()=>m==null?void 0:m(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:u,attachments:s})=>{m==null||m(!1),N.executeCommand(T.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:u,attachments:s}})}}):i.createElement("div",{className:h.threadCommentItemContent},Te(e.text).map((u,s)=>{switch(u.type){case"mention":return i.createElement("a",{className:h.threadCommentItemAt,key:s},"@",u.content.label," ");default:return u.content}})))},xe=n=>{var J,z,re;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:m=!0,onClick:c,showHighlight:v,onClose:p,getSubUnitName:_,prefix:w,autoFocus:N,onMouseEnter:y,onMouseLeave:C,onAddComment:I,onDeleteComment:E,onResolve:O}=n,b=a.useDependency(T.ThreadCommentModel),[V,f]=i.useState(!1),[g,u]=i.useState("");L.useObservable(b.commentMap$);const s=e?b.getCommentWithChildren(t,r,e):null,B=a.useDependency(a.ICommandService),le=a.useDependency(a.UserManagerService),S=s==null?void 0:s.root.resolved,D=L.useObservable(le.currentUser$),Y=i.useRef(null),te=[...s?[s.root]:[{id:Ue,text:{dataStream:`
3
- \r`},personId:(J=D==null?void 0:D.userID)!=null?J:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(z=s==null?void 0:s.children)!=null?z:[]],G=P=>{P.stopPropagation(),S?B.executeCommand(k.id,{unitId:t,subUnitId:r,commentId:e}):B.executeCommand(k.id),B.executeCommand(T.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!S}),O==null||O(!S)},ne=P=>{P.stopPropagation(),B.executeCommand(k.id),!(s!=null&&s.root&&(E==null?void 0:E(s.root))===!1)&&(B.executeCommand(T.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),p==null||p())};i.useEffect(()=>C==null?void 0:C(),[]);const H=_((re=s==null?void 0:s.root.subUnitId)!=null?re:r),K=m&&!g&&!S,F=`${o||(s==null?void 0:s.root.ref)||""}${H?" · ":""}${H}`;return i.createElement("div",{className:Ne(h.threadComment,{[h.threadCommentActive]:!S&&(v||V||w==="cell")}),onClick:c,id:`${w}-${t}-${r}-${e}`,onMouseEnter:()=>{y==null||y(),f(!0)},onMouseLeave:()=>{C==null||C(),f(!1)}},!S&&v?i.createElement("div",{className:h.threadCommentHighlight}):null,i.createElement("div",{className:h.threadCommentTitle},i.createElement("div",{className:h.threadCommentTitlePosition},i.createElement("div",{className:h.threadCommentTitleHighlight}),i.createElement("div",{className:h.threadCommentTitlePositionText},F)),s?i.createElement("div",{className:h.threadCommentIconContainer},i.createElement("div",{onClick:G,className:h.threadCommentIcon,style:{color:S?"rgb(var(--green-500))":""}},S?i.createElement(Ee,null):i.createElement(be,null)),(D==null?void 0:D.userID)===s.root.personId?i.createElement("div",{className:h.threadCommentIcon,onClick:ne},i.createElement(pe,null)):null):null),i.createElement("div",{className:h.threadCommentContent},te.map(P=>i.createElement(ot,{onClose:p,unitId:t,subUnitId:r,item:P,key:P.id,isRoot:P.id===(s==null?void 0:s.root.id),editing:g===P.id,resolved:s==null?void 0:s.root.resolved,onEditingChange:j=>{u(j?P.id:"")},onReply:j=>{j&&requestAnimationFrame(()=>{var q;(q=Y.current)==null||q.reply(_e([{type:"mention",content:{id:j.userID,label:j.name}}]))})},onAddComment:I,onDeleteComment:E}))),K?i.createElement("div",null,i.createElement(Pe,{key:`${N}`,ref:Y,unitId:t,subUnitId:r,onSave:({text:P,attachments:j})=>{const q={text:P,attachments:j,dT:de(),id:a.Tools.generateRandomId(),ref:o,personId:D==null?void 0:D.userID,parentId:s==null?void 0:s.root.id,unitId:t,subUnitId:r,threadId:s==null?void 0:s.root.threadId};(I==null?void 0:I(q))!==!1&&B.executeCommand(T.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:q})},autoFocus:N||!s,onCancel:()=>{s||p==null||p()}})):null)},Z={threadCommentPanel:"univer-thread-comment-panel",threadComment:"univer-thread-comment",threadCommentPanelForms:"univer-thread-comment-panel-forms",select:"univer-select",threadCommentPanelEmpty:"univer-thread-comment-panel-empty",threadCommentPanelAdd:"univer-thread-comment-panel-add",threadCommentPanelSolved:"univer-thread-comment-panel-solved"},at=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:m,onResolve:c,sortComments:v,onItemLeave:p,onItemEnter:_,disableAdd:w,tempComment:N,onAddComment:y,onDeleteComment:C,showComments:I}=n,[E,O]=i.useState("all"),[b,V]=i.useState("all"),f=a.useDependency(a.LocaleService),g=a.useDependency(a.UserManagerService),u=a.useDependency(T.ThreadCommentModel),[s,B]=i.useState(()=>u.getUnit(e)),le=a.useDependency(d.ThreadCommentPanelService),S=L.useObservable(le.activeCommentId$),D=L.useObservable(u.commentUpdate$),Y=a.useDependency(a.ICommandService),te=L.useObservable(t),G=i.useRef(!0),ne="panel",H=L.useObservable(g.currentUser$),K=i.useMemo(()=>{var oe,X;const l=(E==="all"?s.map($=>$[1]).flat():(X=(oe=s.find($=>$[0]===te))==null?void 0:oe[1])!=null?X:[]).filter($=>!$.parentId),Q=v!=null?v:$=>$,ie=l;if(I){const $=new Map;return ie.forEach(ae=>{$.set(ae.id,ae)}),[...I,""].map(ae=>$.get(ae)).filter(Boolean)}else return Q(ie)},[I,E,s,v,te]),F=i.useMemo(()=>[...K.filter(l=>!l.resolved),...K.filter(l=>l.resolved)],[K]),J=i.useMemo(()=>b==="resolved"?F.filter(l=>l.resolved):b==="unsolved"?F.filter(l=>!l.resolved):b==="concern_me"&&H!=null&&H.userID?F.map(l=>u.getCommentWithChildren(l.unitId,l.subUnitId,l.id)).map(l=>l!=null&&l.relativeUsers.has(H.userID)?l.root:null).filter(Boolean):F,[F,H==null?void 0:H.userID,b,u]),z=N?[N,...J]:J,re=z.filter(l=>!l.resolved),P=z.filter(l=>l.resolved),j=b!=="all"||E!=="all",q=()=>{V("all"),O("all")};i.useEffect(()=>{e&&B(u.getUnit(e))},[e,u,D]),i.useEffect(()=>{var X;if(!S)return;if(!G.current){G.current=!0;return}const{unitId:l,subUnitId:Q,commentId:ie}=S,oe=`${ne}-${l}-${Q}-${ie}`;(X=document.getElementById(oe))==null||X.scrollIntoView({block:"center"})},[S]);const Me=l=>i.createElement(xe,{prefix:ne,getSubUnitName:m,key:l.id,id:l.id,unitId:l.unitId,subUnitId:l.subUnitId,refStr:l.ref,type:r,showEdit:(S==null?void 0:S.commentId)===l.id,showHighlight:(S==null?void 0:S.commentId)===l.id,onClick:()=>{G.current=!1,l.resolved?Y.executeCommand(k.id):Y.executeCommand(k.id,{unitId:l.unitId,subUnitId:l.subUnitId,commentId:l.id,temp:!1})},onMouseEnter:()=>_==null?void 0:_(l),onMouseLeave:()=>p==null?void 0:p(l),onAddComment:y,onDeleteComment:C,onResolve:Q=>c==null?void 0:c(l.id,Q)});return i.createElement("div",{className:Z.threadCommentPanel},i.createElement("div",{className:Z.threadCommentPanelForms},r===a.UniverInstanceType.UNIVER_SHEET?i.createElement(x.Select,{borderless:!0,value:E,onChange:l=>O(l),options:[{value:"current",label:f.t("threadCommentUI.filter.sheet.current")},{value:"all",label:f.t("threadCommentUI.filter.sheet.all")}]}):null,i.createElement(x.Select,{borderless:!0,value:b,onChange:l=>V(l),options:[{value:"all",label:f.t("threadCommentUI.filter.status.all")},{value:"resolved",label:f.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:f.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:f.t("threadCommentUI.filter.status.concernMe")}]})),re.map(Me),P.length?i.createElement("div",{className:Z.threadCommentPanelSolved},"已解决"):null,P.map(Me),z.length?null:i.createElement("div",{className:Z.threadCommentPanelEmpty},j?f.t("threadCommentUI.panel.filterEmpty"):f.t("threadCommentUI.panel.empty"),j?i.createElement(x.Button,{onClick:q,type:"link"},f.t("threadCommentUI.panel.reset")):i.createElement(x.Button,{id:"thread-comment-add",className:Z.threadCommentPanelAdd,type:"primary",onClick:o,disabled:w},i.createElement(Ie,null),f.t("threadCommentUI.panel.addComment"))))};d.IThreadCommentMentionDataService=se,d.SetActiveCommentOperation=k,d.THREAD_COMMENT_PANEL=ce,d.ThreadCommentPanel=at,d.ThreadCommentTree=xe,d.ToggleSheetCommentPanelOperation=he,d.getDT=de,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("dayjs"),require("@univerjs/thread-comment"),require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@wendellhu/redi/react-bindings"),require("@univerjs/design"),require("clsx"),require("@univerjs/engine-render"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/thread-comment","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@wendellhu/redi/react-bindings","@univerjs/design","clsx","@univerjs/engine-render","@univerjs/docs"],x):(s=typeof globalThis<"u"?globalThis:s||self,x(s.UniverThreadCommentUi={},s.dayjs,s.UniverThreadComment,s.UniverCore,s["@wendellhu/redi"],s.UniverUi,s.rxjs,s.React,s["@wendellhu/redi/react-bindings"],s.UniverDesign,s.clsx,s.UniverEngineRender,s.UniverDocs))})(this,function(s,x,_,c,Y,k,se,i,b,M,De,we,He){"use strict";var st=Object.defineProperty;var dt=(s,x,_)=>x in s?st(s,x,{enumerable:!0,configurable:!0,writable:!0,value:_}):s[x]=_;var L=(s,x,_)=>dt(s,typeof x!="symbol"?x+"":x,_);function ue(){return x().format("YYYY/MM/DD HH:mm")}const he="thread-comment-panel",je="THREAD_COMMENT_UI_PLUGIN";var $e=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Le=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ae(e,t):e,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(e,t,o):d(o))||o);return r&&o&&$e(e,t,o),o},ve=(n,e)=>(t,r)=>e(t,r,n);s.ThreadCommentPanelService=class extends c.Disposable{constructor(t,r){super();L(this,"_panelVisible",!1);L(this,"_panelVisible$",new se.BehaviorSubject(!1));L(this,"_activeCommentId");L(this,"_activeCommentId$",new se.BehaviorSubject(void 0));L(this,"panelVisible$",this._panelVisible$.asObservable());L(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$(c.UniverInstanceType.UNIVER_SHEET).pipe(se.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)}},s.ThreadCommentPanelService=Le([ve(0,Y.Inject(k.ISidebarService)),ve(1,c.IUniverInstanceService)],s.ThreadCommentPanelService);const Ce={id:"thread-comment-ui.operation.toggle-panel",type:c.CommandType.OPERATION,handler(n){const e=n.get(k.ISidebarService),t=n.get(s.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:he},width:320}),t.setPanelVisible(!0)),!0}},V={id:"thread-comment-ui.operation.set-active-comment",type:c.CommandType.OPERATION,handler(n,e){return n.get(s.ThreadCommentPanelService).setActiveComment(e),!0}};var ke=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,qe=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ve(e,t):e,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(e,t,o):d(o))||o);return r&&o&&ke(e,t,o),o},Fe=(n,e)=>(t,r)=>e(t,r,n);let te=class extends c.Disposable{constructor(n){super(),this._localeService=n}};te=qe([c.OnLifecycle(c.LifecycleStages.Starting,te),Fe(0,Y.Inject(c.LocaleService))],te);class We{constructor(){L(this,"dataSource");L(this,"renderSuggestion");L(this,"trigger","@")}async getMentions(e,t,r){return this.dataSource?this.dataSource.getMentions(e,t,r):[]}}const de=Y.createIdentifier("thread-comment.mention-data.service");var fe=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Be=(n,e,t)=>e in n?fe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ze=(n,e,t,r)=>{for(var o=r>1?void 0:r?ze(e,t):e,a=n.length-1,d;a>=0;a--)(d=n[a])&&(o=(r?d(e,t,o):d(o))||o);return r&&o&&fe(e,t,o),o},pe=(n,e)=>(t,r)=>e(t,r,n),ge=(n,e,t)=>Be(n,typeof e!="symbol"?e+"":e,t);s.UniverThreadCommentUIPlugin=class extends c.Plugin{constructor(e,t,r){super(),this._config=e,this._injector=t,this._commandService=r}onStarting(e){var t;c.mergeOverrideWithDependencies([[te],[s.ThreadCommentPanelService],[de,{useClass:We}]],(t=this._config)==null?void 0:t.overrides).forEach(r=>{e.add(r)}),[Ce,V].forEach(r=>{this._commandService.registerCommand(r)})}},ge(s.UniverThreadCommentUIPlugin,"pluginName",je),ge(s.UniverThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_UNKNOWN),s.UniverThreadCommentUIPlugin=Ze([c.DependentOn(_.UniverThreadCommentPlugin),pe(1,Y.Inject(Y.Injector)),pe(2,c.ICommandService)],s.UniverThreadCommentUIPlugin);var N=function(){return N=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},N.apply(this,arguments)},Ye=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 o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]]);return t},z=i.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,a=n.extend,d=Ye(n,["icon","id","className","extend"]),v="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),g=i.useRef("_".concat(Je()));return Ie(t,"".concat(r),{defIds:t.defIds,idSuffix:g.current},N({ref:e,className:v},d),a)});function Ie(n,e,t,r,o){return i.createElement(n.tag,N(N({key:e},Ge(n,t,o)),r),(Ke(n,t).children||[]).map(function(a,d){return Ie(a,"".concat(e,"-").concat(n.tag,"-").concat(d),t,void 0,o)}))}function Ge(n,e,t){var r=N({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(a){var d=a[0],v=a[1];typeof v=="string"&&(r[d]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Ke(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)?N(N({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?N(N({},o),{attrs:N(N({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function Je(){return Math.random().toString(36).substring(2,8)}z.displayName="UniverIcon";var Qe={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"}}]},Se=i.forwardRef(function(n,e){return i.createElement(z,Object.assign({},n,{id:"delete-single",ref:e,icon:Qe}))});Se.displayName="DeleteSingle";var Xe={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"}}]},ye=i.forwardRef(function(n,e){return i.createElement(z,Object.assign({},n,{id:"increase-single",ref:e,icon:Xe}))});ye.displayName="IncreaseSingle";var Re={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"}}]},Ee=i.forwardRef(function(n,e){return i.createElement(z,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Re}))});Ee.displayName="MoreHorizontalSingle";var et={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}}]},be=i.forwardRef(function(n,e){return i.createElement(z,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:et}))});be.displayName="ReplyToCommentSingle";var tt={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"}}]},Te=i.forwardRef(function(n,e){return i.createElement(z,Object.assign({},n,{id:"resolved-single",ref:e,icon:tt}))});Te.displayName="ResolvedSingle";var nt={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}}]},_e=i.forwardRef(function(n,e){return i.createElement(z,Object.assign({},n,{id:"solve-single",ref:e,icon:nt}))});_e.displayName="SolveSingle";const ne={threadCommentEditorButtons:"univer-thread-comment-editor-buttons",threadCommentEditorSuggestion:"univer-thread-comment-editor-suggestion",threadCommentEditorSuggestionActive:"univer-thread-comment-editor-suggestionActive",threadCommentEditorSuggestionIcon:"univer-thread-comment-editor-suggestion-icon"},rt=n=>{const e=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let t,r=0;const o=[];for(;(t=e.exec(n))!==null;)t.index>r&&o.push({type:"text",content:n.substring(r,t.index)}),t[1]&&t[2]?o.push({type:"mention",content:{label:t[1],id:t[2]}}):t[3]&&o.push({type:"text",content:t[3]}),r=e.lastIndex;return r<n.length&&o.push({type:"text",content:n.substring(r)}),o},it=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),Pe=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let a=0;return t==null||t.forEach(d=>{a<d.startIndex&&o.push({type:"text",content:e.slice(a,d.startIndex)}),o.push({type:"mention",content:{label:e.slice(d.startIndex,d.endIndex).slice(1,-1),id:d.rangeId}}),a=d.endIndex}),o.push({type:"text",content:e.slice(a,r)}),o},Ue=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const o=e.length;e+=`${r.content.label}`;const a=e.length;t.push({rangeId:r.content.id,rangeType:c.CustomRangeType.MENTION,startIndex:o,endIndex:a});break}}}),e+=`
2
+ \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},ot=n=>({display:n.label,id:`${n.id}`,raw:n}),at=(n,e,t,r,o)=>{var d,v;const a=(d=n.raw)==null?void 0:d.icon;return i.createElement("div",{className:ne.threadCommentEditorSuggestion},a?i.createElement("img",{className:ne.threadCommentEditorSuggestionIcon,src:a}):null,i.createElement("div",null,(v=n.display)!=null?v:n.id))},xe=i.forwardRef((n,e)=>{var f;const{comment:t,onSave:r,id:o,onCancel:a,autoFocus:d,unitId:v,subUnitId:g}=n,P=b.useDependency(de),H=b.useDependency(c.ICommandService),O=b.useDependency(c.LocaleService),[y,C]=i.useState({...t}),[I,E]=i.useState(!1),D=i.useRef(null),T=b.useDependency(we.ITextSelectionRenderManager),q=b.useDependency(He.TextSelectionManagerService);return i.useImperativeHandle(e,()=>({reply(p){var u;C({...t,text:p,attachments:[]}),(u=D.current)==null||u.inputElement.focus()}})),i.createElement("div",{className:ne.threadCommentEditor,onClick:p=>p.preventDefault()},i.createElement(M.Mentions,{ref:D,autoFocus:d,style:{width:"100%"},placeholder:O.t("threadCommentUI.editor.placeholder"),value:y!=null&&y.text?it(Pe(y.text)):"",onChange:p=>{p.target.value||C({...t,text:void 0}),C==null||C({...t,text:Ue(rt(p.target.value))})},onFocus:()=>{const p=q.getActiveRange();p&&p.collapsed&&T.removeAllTextRanges(),T.blur(),E(!0)}},i.createElement(M.Mention,{key:P.trigger,trigger:P.trigger,data:(p,u)=>P.getMentions(p,v,g).then(m=>m.map(ot)).then(u),displayTransform:(p,u)=>`@${u} `,renderSuggestion:(f=P.renderSuggestion)!=null?f:at})),I?i.createElement("div",{className:ne.threadCommentEditorButtons},i.createElement(M.Button,{style:{marginRight:12},onClick:()=>{a==null||a(),E(!1),C({text:void 0}),H.executeCommand(V.id)}},O.t("threadCommentUI.editor.cancel")),i.createElement(M.Button,{type:"primary",disabled:!y.text,onClick:()=>{y.text&&(r==null||r({...y,text:y.text}),E(!1),C({text:void 0}))}},O.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),h={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",threadCommentItemTitlePosition:"univer-thread-comment-item-title-position",threadCommentItemTitleHighlight:"univer-thread-comment-item-title-highlight",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},Me="__mock__",mt=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:a,onReply:d,resolved:v,isRoot:g,onClose:P,onDeleteComment:H}=n,O=b.useDependency(c.ICommandService),y=b.useDependency(c.LocaleService),C=b.useDependency(c.UserManagerService),I=C.getUser(e.personId),E=k.useObservable(C.currentUser$),D=(E==null?void 0:E.userID)===e.personId,T=e.id===Me,[q,f]=i.useState(!1),p=()=>{(H==null?void 0:H(e))!==!1&&(O.executeCommand(g?_.DeleteCommentTreeCommand.id:_.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),g&&(P==null||P()))};return i.createElement("div",{className:h.threadCommentItem,onMouseLeave:()=>f(!1),onMouseEnter:()=>f(!0)},i.createElement("img",{className:h.threadCommentItemHead,src:I==null?void 0:I.avatar}),i.createElement("div",{className:h.threadCommentItemTitle},i.createElement("div",{className:h.threadCommentUsername},(I==null?void 0:I.name)||" "),i.createElement("div",null,T||v?null:q?i.createElement("div",{className:h.threadCommentIcon,onClick:()=>d(I)},i.createElement(be,null)):null,D&&!T&&!v?i.createElement(M.Dropdown,{overlay:i.createElement(M.Menu,null,i.createElement(M.MenuItem,{key:"edit",onClick:()=>a==null?void 0:a(!0)},y.t("threadCommentUI.item.edit")),i.createElement(M.MenuItem,{key:"delete",onClick:p},y.t("threadCommentUI.item.delete")))},i.createElement("div",{className:h.threadCommentIcon},i.createElement(Ee,null))):null)),i.createElement("div",{className:h.threadCommentItemTime},e.dT),o?i.createElement(xe,{id:e.id,comment:e,onCancel:()=>a==null?void 0:a(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:u,attachments:m})=>{a==null||a(!1),O.executeCommand(_.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:u,attachments:m}})}}):i.createElement("div",{className:h.threadCommentItemContent},Pe(e.text).map((u,m)=>{switch(u.type){case"mention":return i.createElement("a",{className:h.threadCommentItemAt,key:m},"@",u.content.label," ");default:return u.content}})))},Ne=n=>{var X,Z,oe;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:a=!0,onClick:d,showHighlight:v,onClose:g,getSubUnitName:P,prefix:H,autoFocus:O,onMouseEnter:y,onMouseLeave:C,onAddComment:I,onDeleteComment:E,onResolve:D}=n,T=b.useDependency(_.ThreadCommentModel),[q,f]=i.useState(!1),[p,u]=i.useState("");k.useObservable(T.commentMap$);const m=e?T.getCommentWithChildren(t,r,e):null,F=b.useDependency(c.ICommandService),ce=b.useDependency(c.UserManagerService),S=m==null?void 0:m.root.resolved,w=k.useObservable(ce.currentUser$),K=i.useRef(null),re=[...m?[m.root]:[{id:Me,text:{dataStream:`
3
+ \r`},personId:(X=w==null?void 0:w.userID)!=null?X:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(Z=m==null?void 0:m.children)!=null?Z:[]],J=U=>{U.stopPropagation(),S?F.executeCommand(V.id,{unitId:t,subUnitId:r,commentId:e}):F.executeCommand(V.id),F.executeCommand(_.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!S}),D==null||D(!S)},ie=U=>{U.stopPropagation(),F.executeCommand(V.id),!(m!=null&&m.root&&(E==null?void 0:E(m.root))===!1)&&(F.executeCommand(_.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),g==null||g())};i.useEffect(()=>C==null?void 0:C(),[]);const j=P((oe=m==null?void 0:m.root.subUnitId)!=null?oe:r),Q=a&&!p&&!S,W=`${o||(m==null?void 0:m.root.ref)||""}${j?" · ":""}${j}`;return i.createElement("div",{className:De(h.threadComment,{[h.threadCommentActive]:!S&&(v||q||H==="cell")}),onClick:d,id:`${H}-${t}-${r}-${e}`,onMouseEnter:()=>{y==null||y(),f(!0)},onMouseLeave:()=>{C==null||C(),f(!1)}},!S&&v?i.createElement("div",{className:h.threadCommentHighlight}):null,i.createElement("div",{className:h.threadCommentTitle},i.createElement("div",{className:h.threadCommentTitlePosition},i.createElement("div",{className:h.threadCommentTitleHighlight}),i.createElement("div",{className:h.threadCommentTitlePositionText},W)),m?i.createElement("div",{className:h.threadCommentIconContainer},i.createElement("div",{onClick:J,className:h.threadCommentIcon,style:{color:S?"rgb(var(--green-500))":""}},S?i.createElement(Te,null):i.createElement(_e,null)),(w==null?void 0:w.userID)===m.root.personId?i.createElement("div",{className:h.threadCommentIcon,onClick:ie},i.createElement(Se,null)):null):null),i.createElement("div",{className:h.threadCommentContent},re.map(U=>i.createElement(mt,{onClose:g,unitId:t,subUnitId:r,item:U,key:U.id,isRoot:U.id===(m==null?void 0:m.root.id),editing:p===U.id,resolved:m==null?void 0:m.root.resolved,onEditingChange:$=>{u($?U.id:"")},onReply:$=>{$&&requestAnimationFrame(()=>{var B;(B=K.current)==null||B.reply(Ue([{type:"mention",content:{id:$.userID,label:$.name}}]))})},onAddComment:I,onDeleteComment:E}))),Q?i.createElement("div",null,i.createElement(xe,{key:`${O}`,ref:K,unitId:t,subUnitId:r,onSave:({text:U,attachments:$})=>{const B={text:U,attachments:$,dT:ue(),id:c.Tools.generateRandomId(),ref:o,personId:w==null?void 0:w.userID,parentId:m==null?void 0:m.root.id,unitId:t,subUnitId:r,threadId:m==null?void 0:m.root.threadId};(I==null?void 0:I(B))!==!1&&F.executeCommand(_.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:B})},autoFocus:O||!m,onCancel:()=>{m||g==null||g()}})):null)},G={threadCommentPanel:"univer-thread-comment-panel",threadComment:"univer-thread-comment",threadCommentPanelForms:"univer-thread-comment-panel-forms",select:"univer-select",threadCommentPanelEmpty:"univer-thread-comment-panel-empty",threadCommentPanelAdd:"univer-thread-comment-panel-add",threadCommentPanelSolved:"univer-thread-comment-panel-solved"},lt=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:a,onResolve:d,sortComments:v,onItemLeave:g,onItemEnter:P,disableAdd:H,tempComment:O,onAddComment:y,onDeleteComment:C,showComments:I}=n,[E,D]=i.useState("all"),[T,q]=i.useState("all"),f=b.useDependency(c.LocaleService),p=b.useDependency(c.UserManagerService),u=b.useDependency(_.ThreadCommentModel),[m,F]=i.useState(()=>u.getUnit(e)),ce=b.useDependency(s.ThreadCommentPanelService),S=k.useObservable(ce.activeCommentId$),w=k.useObservable(u.commentUpdate$),K=b.useDependency(c.ICommandService),re=k.useObservable(t),J=i.useRef(!0),ie="panel",j=k.useObservable(p.currentUser$),Q=i.useMemo(()=>{var me,ee;const l=(E==="all"?m.map(A=>A[1]).flat():(ee=(me=m.find(A=>A[0]===re))==null?void 0:me[1])!=null?ee:[]).filter(A=>!A.parentId),R=v!=null?v:A=>A,ae=l;if(I){const A=new Map;return ae.forEach(le=>{A.set(le.id,le)}),[...I,""].map(le=>A.get(le)).filter(Boolean)}else return R(ae)},[I,E,m,v,re]),W=i.useMemo(()=>[...Q.filter(l=>!l.resolved),...Q.filter(l=>l.resolved)],[Q]),X=i.useMemo(()=>T==="resolved"?W.filter(l=>l.resolved):T==="unsolved"?W.filter(l=>!l.resolved):T==="concern_me"&&j!=null&&j.userID?W.map(l=>u.getCommentWithChildren(l.unitId,l.subUnitId,l.id)).map(l=>l!=null&&l.relativeUsers.has(j.userID)?l.root:null).filter(Boolean):W,[W,j==null?void 0:j.userID,T,u]),Z=O?[O,...X]:X,oe=Z.filter(l=>!l.resolved),U=Z.filter(l=>l.resolved),$=T!=="all"||E!=="all",B=()=>{q("all"),D("all")};i.useEffect(()=>{e&&F(u.getUnit(e))},[e,u,w]),i.useEffect(()=>{var ee;if(!S)return;if(!J.current){J.current=!0;return}const{unitId:l,subUnitId:R,commentId:ae}=S,me=`${ie}-${l}-${R}-${ae}`;(ee=document.getElementById(me))==null||ee.scrollIntoView({block:"center"})},[S]);const Oe=l=>i.createElement(Ne,{prefix:ie,getSubUnitName:a,key:l.id,id:l.id,unitId:l.unitId,subUnitId:l.subUnitId,refStr:l.ref,type:r,showEdit:(S==null?void 0:S.commentId)===l.id,showHighlight:(S==null?void 0:S.commentId)===l.id,onClick:()=>{J.current=!1,l.resolved?K.executeCommand(V.id):K.executeCommand(V.id,{unitId:l.unitId,subUnitId:l.subUnitId,commentId:l.id,temp:!1})},onMouseEnter:()=>P==null?void 0:P(l),onMouseLeave:()=>g==null?void 0:g(l),onAddComment:y,onDeleteComment:C,onResolve:R=>d==null?void 0:d(l.id,R)});return i.createElement("div",{className:G.threadCommentPanel},i.createElement("div",{className:G.threadCommentPanelForms},r===c.UniverInstanceType.UNIVER_SHEET?i.createElement(M.Select,{borderless:!0,value:E,onChange:l=>D(l),options:[{value:"current",label:f.t("threadCommentUI.filter.sheet.current")},{value:"all",label:f.t("threadCommentUI.filter.sheet.all")}]}):null,i.createElement(M.Select,{borderless:!0,value:T,onChange:l=>q(l),options:[{value:"all",label:f.t("threadCommentUI.filter.status.all")},{value:"resolved",label:f.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:f.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:f.t("threadCommentUI.filter.status.concernMe")}]})),oe.map(Oe),U.length?i.createElement("div",{className:G.threadCommentPanelSolved},"已解决"):null,U.map(Oe),Z.length?null:i.createElement("div",{className:G.threadCommentPanelEmpty},$?f.t("threadCommentUI.panel.filterEmpty"):f.t("threadCommentUI.panel.empty"),$?i.createElement(M.Button,{onClick:B,type:"link"},f.t("threadCommentUI.panel.reset")):i.createElement(M.Button,{id:"thread-comment-add",className:G.threadCommentPanelAdd,type:"primary",onClick:o,disabled:H},i.createElement(ye,null),f.t("threadCommentUI.panel.addComment"))))};s.IThreadCommentMentionDataService=de,s.SetActiveCommentOperation=V,s.THREAD_COMMENT_PANEL=he,s.ThreadCommentPanel=lt,s.ThreadCommentTree=Ne,s.ToggleSheetCommentPanelOperation=Ce,s.getDT=ue,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/thread-comment-ui",
3
- "version": "0.2.4-alpha.0",
3
+ "version": "0.2.4",
4
4
  "private": false,
5
5
  "description": "Univer common thread comment UI plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -48,22 +48,24 @@
48
48
  "lib"
49
49
  ],
50
50
  "peerDependencies": {
51
+ "@wendellhu/redi": "0.16.0",
51
52
  "clsx": ">=2.0.0",
52
53
  "dayjs": ">=1.11.0",
53
54
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
54
55
  "rxjs": ">=7.0.0",
55
- "@univerjs/design": "0.2.4-alpha.0",
56
- "@univerjs/core": "0.2.4-alpha.0",
57
- "@univerjs/docs": "0.2.4-alpha.0",
58
- "@univerjs/engine-render": "0.2.4-alpha.0",
59
- "@univerjs/thread-comment": "0.2.4-alpha.0",
60
- "@univerjs/ui": "0.2.4-alpha.0"
56
+ "@univerjs/core": "0.2.4",
57
+ "@univerjs/design": "0.2.4",
58
+ "@univerjs/engine-render": "0.2.4",
59
+ "@univerjs/thread-comment": "0.2.4",
60
+ "@univerjs/docs": "0.2.4",
61
+ "@univerjs/ui": "0.2.4"
61
62
  },
62
63
  "dependencies": {
63
- "@univerjs/icons": "^0.1.64",
64
+ "@univerjs/icons": "^0.1.65",
64
65
  "@univerjs/protocol": "0.1.38-alpha.23"
65
66
  },
66
67
  "devDependencies": {
68
+ "@wendellhu/redi": "0.16.0",
67
69
  "clsx": "^2.1.1",
68
70
  "dayjs": "^1.11.11",
69
71
  "less": "^4.2.0",
@@ -72,13 +74,13 @@
72
74
  "typescript": "^5.5.3",
73
75
  "vite": "^5.3.4",
74
76
  "vitest": "^2.0.3",
75
- "@univerjs/design": "0.2.4-alpha.0",
76
- "@univerjs/core": "0.2.4-alpha.0",
77
- "@univerjs/docs": "0.2.4-alpha.0",
78
- "@univerjs/engine-render": "0.2.4-alpha.0",
79
- "@univerjs/shared": "0.2.4-alpha.0",
80
- "@univerjs/thread-comment": "0.2.4-alpha.0",
81
- "@univerjs/ui": "0.2.4-alpha.0"
77
+ "@univerjs/design": "0.2.4",
78
+ "@univerjs/docs": "0.2.4",
79
+ "@univerjs/core": "0.2.4",
80
+ "@univerjs/engine-render": "0.2.4",
81
+ "@univerjs/shared": "0.2.4",
82
+ "@univerjs/thread-comment": "0.2.4",
83
+ "@univerjs/ui": "0.2.4"
82
84
  },
83
85
  "univerSpace": {
84
86
  ".": {