@univerjs/thread-comment-ui 0.1.12 → 0.1.13

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 ge=Object.defineProperty;var fe=(n,e,t)=>e in n?ge(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var M=(n,e,t)=>(fe(n,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("@univerjs/thread-comment"),d=require("@univerjs/core"),z=require("@wendellhu/redi"),R=require("@univerjs/ui"),G=require("rxjs"),a=require("react"),b=require("@wendellhu/redi/react-bindings"),x=require("@univerjs/design"),pe=require("dayjs"),Ie=require("clsx"),ne="thread-comment-panel",Se="thread-comment-ui-plugin";var ye=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Ee=(n,e,t,r)=>{for(var o=r>1?void 0:r?be(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&ye(e,t,o),o},ee=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends d.Disposable{constructor(t,r){super();M(this,"_panelVisible",!1);M(this,"_panelVisible$",new G.BehaviorSubject(!1));M(this,"_activeCommentId");M(this,"_activeCommentId$",new G.BehaviorSubject(void 0));M(this,"panelVisible$",this._panelVisible$.asObservable());M(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init()}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(G.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=Ee([ee(0,z.Inject(R.ISidebarService)),ee(1,d.IUniverInstanceService)],exports.ThreadCommentPanelService);const re={id:"thread-comment-ui.operation.toggle-panel",type:d.CommandType.OPERATION,handler(n){const e=n.get(R.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:ne},width:320}),t.setPanelVisible(!0)),!0}},J={id:"thread-comment-ui.operation.set-active-comment",type:d.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}},Te={threadCommentUI:{panel:{title:"评论管理",empty:"暂无评论",filterEmpty:"没有匹配的结果",reset:"重置",addComment:"新建评论"},editor:{placeholder:"回复",reply:"回复",cancel:"取消",save:"保存"},item:{edit:"编辑",delete:"删除"},filter:{sheet:{all:"所有表格",current:"当前表格"},status:{all:"所有评论",resolved:"已解决",unsolved:"未解决",concernMe:"与我有关"}}}};var _e=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Me=(n,e,t,r)=>{for(var o=r>1?void 0:r?xe(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&_e(e,t,o),o},Ne=(n,e)=>(t,r)=>e(t,r,n);let Y=class extends d.Disposable{constructor(n){super(),this._localeService=n,this._initLocales()}_initLocales(){this._localeService.load({zhCN:Te})}};Y=Me([d.OnLifecycle(d.LifecycleStages.Starting,Y),Ne(0,z.Inject(d.LocaleService))],Y);class Ue{constructor(){M(this,"trigger","@")}async getMentions(e){return[]}}const Q=z.createIdentifier("thread-comment.mention-data.service");var Pe=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,$e=(n,e,t,r)=>{for(var o=r>1?void 0:r?Oe(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&Pe(e,t,o),o},te=(n,e)=>(t,r)=>e(t,r,n),Z;exports.UniverThreadCommentUIPlugin=(Z=class extends $.UniverThreadCommentPlugin{constructor(t,r,o){super(t,r,o);M(this,"_config1");this._injector=r,this._commandService=o,this._config1=t}onStarting(t){super.onStarting(t),d.mergeOverrideWithDependencies([[Y],[exports.ThreadCommentPanelService],[Q,{useClass:Ue}]],this._config1.overrides).forEach(r=>{t.add(r)}),[re,J].forEach(r=>{this._commandService.registerCommand(r)})}},M(Z,"pluginName",Se),M(Z,"type",d.UniverInstanceType.UNIVER_UNKNOWN),Z);exports.UniverThreadCommentUIPlugin=$e([te(1,z.Inject(z.Injector)),te(2,d.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)},De=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},k=a.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,i=n.extend,s=De(n,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),c=a.useRef("_".concat(He()));return ae(t,"".concat(r),{defIds:t.defIds,idSuffix:c.current},_({ref:e,className:u},s),i)});function ae(n,e,t,r,o){return a.createElement(n.tag,_(_({key:e},we(n,t,o)),r),(Re(n,t).children||[]).map(function(i,s){return ae(i,"".concat(e,"-").concat(n.tag,"-").concat(s),t,void 0,o)}))}function we(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(i){var s=i[0],u=i[1];typeof u=="string"&&(r[s]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Re(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 He(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},oe=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"delete-single",ref:e,icon:Le}))});oe.displayName="DeleteSingle";const je=oe;var ke={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=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"increase-single",ref:e,icon:ke}))});ie.displayName="IncreaseSingle";const Ae=ie;var Ve={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"}}]},le=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Ve}))});le.displayName="MoreHorizontalSingle";const Be=le;var ze={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(k,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:ze}))});se.displayName="ReplyToCommentSingle";const We=se;var qe={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"}}]},me=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"resolved-single",ref:e,icon:qe}))});me.displayName="ResolvedSingle";const Fe=me;var Ze={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}}]},ce=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"solve-single",ref:e,icon:Ze}))});ce.displayName="SolveSingle";const Ye=ce,Ke="univer-thread-comment-editor-buttons",Ge="univer-thread-comment-editor-suggestion",Je="univer-thread-comment-editor-suggestionActive",Qe="univer-thread-comment-editor-suggestion-icon",K={threadCommentEditorButtons:Ke,threadCommentEditorSuggestion:Ge,threadCommentEditorSuggestionActive:Je,threadCommentEditorSuggestionIcon:Qe},Xe=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},et=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),de=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let i=0;return t==null||t.forEach(s=>{i<s.startIndex&&o.push({type:"text",content:e.slice(i,s.startIndex)}),o.push({type:"mention",content:{label:e.slice(s.startIndex,s.endIndex).slice(1,-1),id:s.rangeId}}),i=s.endIndex}),o.push({type:"text",content:e.slice(i,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 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}},tt=n=>({display:n.label,id:`${n.id}`,raw:n}),nt=(n,e,t,r,o)=>{var s,u;const i=(s=n.raw)==null?void 0:s.icon;return a.createElement("div",{className:K.threadCommentEditorSuggestion},i?a.createElement("img",{className:K.threadCommentEditorSuggestionIcon,src:i}):null,a.createElement("div",null,(u=n.display)!=null?u:n.id))},he=a.forwardRef((n,e)=>{var h;const{comment:t,onSave:r,id:o,onCancel:i,autoFocus:s}=n,u=b.useDependency(Q),c=b.useDependency(d.LocaleService),[f,p]=a.useState({...t}),[N,I]=a.useState(!1),S=a.useRef(null);return a.useImperativeHandle(e,()=>({reply(y){var v;p({...t,text:y,attachments:[]}),(v=S.current)==null||v.inputElement.focus()}})),a.createElement("div",{className:K.threadCommentEditor,onClick:y=>y.preventDefault()},a.createElement(x.Mentions,{ref:S,autoFocus:s,style:{width:"100%"},placeholder:c.t("threadCommentUI.editor.placeholder"),value:f!=null&&f.text?et(de(f.text)):"",onChange:y=>{y.target.value||p({...t,text:void 0}),p==null||p({...t,text:ue(Xe(y.target.value))})},onFocus:()=>{I(!0)}},a.createElement(x.Mention,{key:u.trigger,trigger:u.trigger,data:(y,v)=>u.getMentions(y).then(U=>U.map(tt)).then(v),displayTransform:(y,v)=>`@${v} `,renderSuggestion:(h=u.renderSuggestion)!=null?h:nt})),N?a.createElement("div",{className:K.threadCommentEditorButtons},a.createElement(x.Button,{style:{marginRight:12},onClick:()=>{i==null||i(),I(!1),p({text:void 0})}},c.t("threadCommentUI.editor.cancel")),a.createElement(x.Button,{type:"primary",disabled:!f.text,onClick:()=>{f.text&&(r==null||r({...f,text:f.text}),I(!1),p({text:void 0}))}},c.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),rt="univer-thread-comment",at="univer-thread-comment-active",ot="univer-thread-comment-content",it="univer-thread-comment-highlight",lt="univer-thread-comment-icon-container",st="univer-thread-comment-icon",mt="univer-thread-comment-title",ct="univer-thread-comment-title-position",dt="univer-thread-comment-title-highlight",ut="univer-thread-comment-username",ht="univer-thread-comment-item",vt="univer-thread-comment-item-head",Ct="univer-thread-comment-item-title",gt="univer-thread-comment-item-title-position",ft="univer-thread-comment-item-title-highlight",pt="univer-thread-comment-item-time",It="univer-thread-comment-item-content",St="univer-thread-comment-item-at",g={threadComment:rt,threadCommentActive:at,threadCommentContent:ot,threadCommentHighlight:it,threadCommentIconContainer:lt,threadCommentIcon:st,threadCommentTitle:mt,threadCommentTitlePosition:ct,threadCommentTitleHighlight:dt,threadCommentUsername:ut,threadCommentItem:ht,threadCommentItemHead:vt,threadCommentItemTitle:Ct,threadCommentItemTitlePosition:gt,threadCommentItemTitleHighlight:ft,threadCommentItemTime:pt,threadCommentItemContent:It,threadCommentItemAt:St},ve="__mock__",yt=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:i,onReply:s,resolved:u,isRoot:c,onClose:f}=n,p=b.useDependency(d.ICommandService),N=b.useDependency(d.LocaleService),I=b.useDependency(d.UserManagerService),S=I.getUser(e.personId),h=R.useObservable(I.currentUser$),y=(h==null?void 0:h.userID)===e.personId,v=e.id===ve,[U,H]=a.useState(!1),m=()=>{p.executeCommand(c?$.DeleteCommentTreeCommand.id:$.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),c&&(f==null||f())};return a.createElement("div",{className:g.threadCommentItem,onMouseLeave:()=>H(!1),onMouseEnter:()=>H(!0)},a.createElement("img",{className:g.threadCommentItemHead,src:S==null?void 0:S.avatar}),a.createElement("div",{className:g.threadCommentItemTitle},a.createElement("div",{className:g.threadCommentUsername},(S==null?void 0:S.name)||" "),a.createElement("div",null,v||u?null:U?a.createElement("div",{className:g.threadCommentIcon,onClick:()=>s(S)},a.createElement(We,null)):null,y&&!v&&!u?a.createElement(x.Dropdown,{overlay:a.createElement(x.Menu,null,a.createElement(x.MenuItem,{key:"edit",onClick:()=>i==null?void 0:i(!0)},N.t("threadCommentUI.item.edit")),a.createElement(x.MenuItem,{key:"delete",onClick:m},N.t("threadCommentUI.item.delete")))},a.createElement("div",{className:g.threadCommentIcon},a.createElement(Be,null))):null)),a.createElement("div",{className:g.threadCommentItemTime},e.dT),o?a.createElement(he,{id:e.id,comment:e,onCancel:()=>i==null?void 0:i(!1),autoFocus:!0,onSave:({text:C,attachments:L})=>{i==null||i(!1),p.executeCommand($.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:C,attachments:L}})}}):a.createElement("div",{className:g.threadCommentItemContent},de(e.text).map((C,L)=>{switch(C.type){case"mention":return a.createElement("a",{className:g.threadCommentItemAt,key:L},"@",C.content.label," ");default:return C.content}})))},Ce=n=>{var j,V,q;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:i=!0,onClick:s,showHighlight:u,onClose:c,getSubUnitName:f,prefix:p,autoFocus:N,onMouseEnter:I,onMouseLeave:S}=n,h=b.useDependency($.ThreadCommentModel),[y,v]=a.useState(!1),[U,H]=a.useState("");R.useObservable(h.commentMap$);const m=e?h.getCommentWithChildren(t,r,e):null,C=b.useDependency(d.ICommandService),L=b.useDependency(d.UserManagerService),D=m==null?void 0:m.root.resolved,E=R.useObservable(L.currentUser$),P=a.useRef(null),A=[...m?[m.root]:[{id:ve,text:{dataStream:`
3
- \r`},personId:(j=E==null?void 0:E.userID)!=null?j:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r}],...(V=m==null?void 0:m.children)!=null?V:[]],W=()=>{C.executeCommand($.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!D}),c==null||c()},w=()=>{C.executeCommand($.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),c==null||c()};return a.createElement("div",{className:Ie(g.threadComment,{[g.threadCommentActive]:!D&&(u||y||p==="cell")}),onClick:s,id:`${p}-${t}-${r}-${e}`,onMouseEnter:()=>{I==null||I(),v(!0)},onMouseLeave:()=>{S==null||S(),v(!1)}},!D&&u?a.createElement("div",{className:g.threadCommentHighlight}):null,a.createElement("div",{className:g.threadCommentTitle},a.createElement("div",{className:g.threadCommentTitlePosition},a.createElement("div",{className:g.threadCommentTitleHighlight}),o||(m==null?void 0:m.root.ref)," · ",f((q=m==null?void 0:m.root.subUnitId)!=null?q:r)),m?a.createElement("div",{className:g.threadCommentIconContainer},a.createElement("div",{onClick:W,className:g.threadCommentIcon,style:{color:D?"rgb(var(--green-500))":""}},D?a.createElement(Fe,null):a.createElement(Ye,null)),(E==null?void 0:E.userID)===m.root.personId?a.createElement("div",{className:g.threadCommentIcon,onClick:w},a.createElement(je,null)):null):null),a.createElement("div",{className:g.threadCommentContent},A.map(l=>a.createElement(yt,{onClose:c,unitId:t,subUnitId:r,item:l,key:l.id,isRoot:l.id===(m==null?void 0:m.root.id),editing:U===l.id,resolved:m==null?void 0:m.root.resolved,onEditingChange:T=>{H(T?l.id:"")},onReply:T=>{var O;T&&((O=P.current)==null||O.reply(ue([{type:"mention",content:{id:T.userID,label:T.name}}])))}}))),i&&!U&&!D?a.createElement("div",null,a.createElement(he,{key:`${N}`,ref:P,onSave:({text:l,attachments:T})=>{C.executeCommand($.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:{text:l,attachments:T,dT:pe().format("YYYY/MM/DD HH:mm"),id:d.Tools.generateRandomId(),ref:o,personId:E==null?void 0:E.userID,parentId:m==null?void 0:m.root.id,unitId:t,subUnitId:r}})},autoFocus:N||!m,onCancel:()=>{m||c==null||c()}})):null)},bt="univer-thread-comment-panel",Et="univer-thread-comment",Tt="univer-thread-comment-panel-forms",_t="univer-select",xt="univer-thread-comment-panel-empty",Mt="univer-thread-comment-panel-add",F={threadCommentPanel:bt,threadComment:Et,threadCommentPanelForms:Tt,select:_t,threadCommentPanelEmpty:xt,threadCommentPanelAdd:Mt},Nt=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:i,onResolve:s,sortComments:u,onItemLeave:c,onItemEnter:f}=n,[p,N]=a.useState("all"),[I,S]=a.useState("all"),h=b.useDependency(d.LocaleService),y=b.useDependency(d.UserManagerService),v=b.useDependency($.ThreadCommentModel),[U,H]=a.useState(()=>v.getUnit(e)),m=b.useDependency(exports.ThreadCommentPanelService),C=R.useObservable(m.activeCommentId$),L=R.useObservable(v.commentUpdate$),D=b.useDependency(d.ICommandService),E=R.useObservable(t),P=y.getCurrentUser(),A=a.useRef(!0),W="panel",w=a.useMemo(()=>{var l,T;if(p==="all"){const O=U.map(B=>B[1]).flat().filter(B=>!B.parentId);return u?u(O):O}else return(T=(l=U.find(O=>O[0]===E))==null?void 0:l[1])!=null?T:[]},[p,U,E,u]),j=a.useMemo(()=>I==="resolved"?w.filter(l=>l.resolved):I==="unsolved"?w.filter(l=>!l.resolved):I==="concern_me"&&P!=null&&P.userID?w.map(l=>v.getCommentWithChildren(l.unitId,l.subUnitId,l.id)).map(l=>l!=null&&l.relativeUsers.has(P.userID)?l.root:null).filter(Boolean):w,[w,P==null?void 0:P.userID,I,v]),V=I!=="all"||p!=="all",q=()=>{S("all"),N("all")};return a.useEffect(()=>{e&&H(v.getUnit(e))},[e,v,L]),a.useEffect(()=>{var X;if(!C)return;if(!A.current){A.current=!0;return}const{unitId:l,subUnitId:T,commentId:O}=C,B=`${W}-${l}-${T}-${O}`;(X=document.getElementById(B))==null||X.scrollIntoView({block:"center"})},[C]),a.createElement("div",{className:F.threadCommentPanel},a.createElement("div",{className:F.threadCommentPanelForms},a.createElement(x.Select,{borderless:!0,value:p,onChange:l=>N(l),options:[{value:"current",label:h.t("threadCommentUI.filter.sheet.current")},{value:"all",label:h.t("threadCommentUI.filter.sheet.all")}]}),a.createElement(x.Select,{borderless:!0,value:I,onChange:l=>S(l),options:[{value:"all",label:h.t("threadCommentUI.filter.status.all")},{value:"resolved",label:h.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:h.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:h.t("threadCommentUI.filter.status.concernMe")}]})),j==null?void 0:j.map(l=>a.createElement(Ce,{prefix:W,getSubUnitName:i,key:l.id,id:l.id,unitId:l.unitId,subUnitId:l.subUnitId,type:r,showEdit:(C==null?void 0:C.commentId)===l.id,showHighlight:(C==null?void 0:C.commentId)===l.id,onClick:()=>{A.current=!1,D.executeCommand(J.id,{unitId:l.unitId,subUnitId:l.subUnitId,commentId:l.id,temp:!0})},onClose:()=>s==null?void 0:s(l.id),onMouseEnter:()=>f==null?void 0:f(l),onMouseLeave:()=>c==null?void 0:c(l)})),j.length?null:a.createElement("div",{className:F.threadCommentPanelEmpty},V?h.t("threadCommentUI.panel.filterEmpty"):h.t("threadCommentUI.panel.empty"),V?a.createElement(x.Button,{onClick:q,type:"link"},h.t("threadCommentUI.panel.reset")):a.createElement(x.Button,{id:"thread-comment-add",className:F.threadCommentPanelAdd,type:"primary",onClick:o},a.createElement(Ae,null),h.t("threadCommentUI.panel.addComment"))))};exports.IThreadCommentMentionDataService=Q;exports.SetActiveCommentOperation=J;exports.THREAD_COMMENT_PANEL=ne;exports.ThreadCommentPanel=Nt;exports.ThreadCommentTree=Ce;exports.ToggleSheetCommentPanelOperation=re;
1
+ "use strict";var ge=Object.defineProperty;var fe=(n,e,t)=>e in n?ge(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var M=(n,e,t)=>(fe(n,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("@univerjs/thread-comment"),d=require("@univerjs/core"),W=require("@wendellhu/redi"),R=require("@univerjs/ui"),G=require("rxjs"),a=require("react"),b=require("@wendellhu/redi/react-bindings"),_=require("@univerjs/design"),pe=require("dayjs"),Ie=require("clsx"),ne="thread-comment-panel",Se="thread-comment-ui-plugin";var ye=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Ee=(n,e,t,r)=>{for(var o=r>1?void 0:r?be(e,t):e,i=n.length-1,l;i>=0;i--)(l=n[i])&&(o=(r?l(e,t,o):l(o))||o);return r&&o&&ye(e,t,o),o},ee=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends d.Disposable{constructor(t,r){super();M(this,"_panelVisible",!1);M(this,"_panelVisible$",new G.BehaviorSubject(!1));M(this,"_activeCommentId");M(this,"_activeCommentId$",new G.BehaviorSubject(void 0));M(this,"panelVisible$",this._panelVisible$.asObservable());M(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init()}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(G.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=Ee([ee(0,W.Inject(R.ISidebarService)),ee(1,d.IUniverInstanceService)],exports.ThreadCommentPanelService);const re={id:"thread-comment-ui.operation.toggle-panel",type:d.CommandType.OPERATION,handler(n){const e=n.get(R.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:ne},width:320}),t.setPanelVisible(!0)),!0}},J={id:"thread-comment-ui.operation.set-active-comment",type:d.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}};var Te=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,_e=(n,e,t,r)=>{for(var o=r>1?void 0:r?xe(e,t):e,i=n.length-1,l;i>=0;i--)(l=n[i])&&(o=(r?l(e,t,o):l(o))||o);return r&&o&&Te(e,t,o),o},Me=(n,e)=>(t,r)=>e(t,r,n);let Y=class extends d.Disposable{constructor(n){super(),this._localeService=n}};Y=_e([d.OnLifecycle(d.LifecycleStages.Starting,Y),Me(0,W.Inject(d.LocaleService))],Y);class Ne{constructor(){M(this,"trigger","@")}async getMentions(e){return[]}}const Q=W.createIdentifier("thread-comment.mention-data.service");var Pe=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Oe=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ue(e,t):e,i=n.length-1,l;i>=0;i--)(l=n[i])&&(o=(r?l(e,t,o):l(o))||o);return r&&o&&Pe(e,t,o),o},te=(n,e)=>(t,r)=>e(t,r,n),Z;exports.UniverThreadCommentUIPlugin=(Z=class extends $.UniverThreadCommentPlugin{constructor(t,r,o){super(t,r,o);M(this,"_config1");this._injector=r,this._commandService=o,this._config1=t}onStarting(t){super.onStarting(t),d.mergeOverrideWithDependencies([[Y],[exports.ThreadCommentPanelService],[Q,{useClass:Ne}]],this._config1.overrides).forEach(r=>{t.add(r)}),[re,J].forEach(r=>{this._commandService.registerCommand(r)})}},M(Z,"pluginName",Se),M(Z,"type",d.UniverInstanceType.UNIVER_UNKNOWN),Z);exports.UniverThreadCommentUIPlugin=Oe([te(1,W.Inject(W.Injector)),te(2,d.ICommandService)],exports.UniverThreadCommentUIPlugin);var x=function(){return x=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},x.apply(this,arguments)},$e=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},k=a.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,i=n.extend,l=$e(n,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),c=a.useRef("_".concat(Re()));return ae(t,"".concat(r),{defIds:t.defIds,idSuffix:c.current},x({ref:e,className:u},l),i)});function ae(n,e,t,r,o){return a.createElement(n.tag,x(x({key:e},De(n,t,o)),r),(we(n,t).children||[]).map(function(i,l){return ae(i,"".concat(e,"-").concat(n.tag,"-").concat(l),t,void 0,o)}))}function De(n,e,t){var r=x({},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 l=i[0],u=i[1];typeof u=="string"&&(r[l]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function we(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)?x(x({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?x(x({},o),{attrs:x(x({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function Re(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var He={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"}}]},oe=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"delete-single",ref:e,icon:He}))});oe.displayName="DeleteSingle";const Le=oe;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=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"increase-single",ref:e,icon:je}))});ie.displayName="IncreaseSingle";const ke=ie;var Ae={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=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Ae}))});se.displayName="MoreHorizontalSingle";const Ve=se;var Be={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}}]},le=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Be}))});le.displayName="ReplyToCommentSingle";const We=le;var qe={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"}}]},me=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"resolved-single",ref:e,icon:qe}))});me.displayName="ResolvedSingle";const ze=me;var Fe={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}}]},ce=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"solve-single",ref:e,icon:Fe}))});ce.displayName="SolveSingle";const Ze=ce,Ye="univer-thread-comment-editor-buttons",Ke="univer-thread-comment-editor-suggestion",Ge="univer-thread-comment-editor-suggestionActive",Je="univer-thread-comment-editor-suggestion-icon",K={threadCommentEditorButtons:Ye,threadCommentEditorSuggestion:Ke,threadCommentEditorSuggestionActive:Ge,threadCommentEditorSuggestionIcon:Je},Qe=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},Xe=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),de=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let i=0;return t==null||t.forEach(l=>{i<l.startIndex&&o.push({type:"text",content:e.slice(i,l.startIndex)}),o.push({type:"mention",content:{label:e.slice(l.startIndex,l.endIndex).slice(1,-1),id:l.rangeId}}),i=l.endIndex}),o.push({type:"text",content:e.slice(i,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 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}},et=n=>({display:n.label,id:`${n.id}`,raw:n}),tt=(n,e,t,r,o)=>{var l,u;const i=(l=n.raw)==null?void 0:l.icon;return a.createElement("div",{className:K.threadCommentEditorSuggestion},i?a.createElement("img",{className:K.threadCommentEditorSuggestionIcon,src:i}):null,a.createElement("div",null,(u=n.display)!=null?u:n.id))},he=a.forwardRef((n,e)=>{var h;const{comment:t,onSave:r,id:o,onCancel:i,autoFocus:l}=n,u=b.useDependency(Q),c=b.useDependency(d.LocaleService),[f,p]=a.useState({...t}),[N,I]=a.useState(!1),S=a.useRef(null);return a.useImperativeHandle(e,()=>({reply(y){var v;p({...t,text:y,attachments:[]}),(v=S.current)==null||v.inputElement.focus()}})),a.createElement("div",{className:K.threadCommentEditor,onClick:y=>y.preventDefault()},a.createElement(_.Mentions,{ref:S,autoFocus:l,style:{width:"100%"},placeholder:c.t("threadCommentUI.editor.placeholder"),value:f!=null&&f.text?Xe(de(f.text)):"",onChange:y=>{y.target.value||p({...t,text:void 0}),p==null||p({...t,text:ue(Qe(y.target.value))})},onFocus:()=>{I(!0)}},a.createElement(_.Mention,{key:u.trigger,trigger:u.trigger,data:(y,v)=>u.getMentions(y).then(P=>P.map(et)).then(v),displayTransform:(y,v)=>`@${v} `,renderSuggestion:(h=u.renderSuggestion)!=null?h:tt})),N?a.createElement("div",{className:K.threadCommentEditorButtons},a.createElement(_.Button,{style:{marginRight:12},onClick:()=>{i==null||i(),I(!1),p({text:void 0})}},c.t("threadCommentUI.editor.cancel")),a.createElement(_.Button,{type:"primary",disabled:!f.text,onClick:()=>{f.text&&(r==null||r({...f,text:f.text}),I(!1),p({text:void 0}))}},c.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),nt="univer-thread-comment",rt="univer-thread-comment-active",at="univer-thread-comment-content",ot="univer-thread-comment-highlight",it="univer-thread-comment-icon-container",st="univer-thread-comment-icon",lt="univer-thread-comment-title",mt="univer-thread-comment-title-position",ct="univer-thread-comment-title-highlight",dt="univer-thread-comment-username",ut="univer-thread-comment-item",ht="univer-thread-comment-item-head",vt="univer-thread-comment-item-title",Ct="univer-thread-comment-item-title-position",gt="univer-thread-comment-item-title-highlight",ft="univer-thread-comment-item-time",pt="univer-thread-comment-item-content",It="univer-thread-comment-item-at",g={threadComment:nt,threadCommentActive:rt,threadCommentContent:at,threadCommentHighlight:ot,threadCommentIconContainer:it,threadCommentIcon:st,threadCommentTitle:lt,threadCommentTitlePosition:mt,threadCommentTitleHighlight:ct,threadCommentUsername:dt,threadCommentItem:ut,threadCommentItemHead:ht,threadCommentItemTitle:vt,threadCommentItemTitlePosition:Ct,threadCommentItemTitleHighlight:gt,threadCommentItemTime:ft,threadCommentItemContent:pt,threadCommentItemAt:It},ve="__mock__",St=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:i,onReply:l,resolved:u,isRoot:c,onClose:f}=n,p=b.useDependency(d.ICommandService),N=b.useDependency(d.LocaleService),I=b.useDependency(d.UserManagerService),S=I.getUser(e.personId),h=R.useObservable(I.currentUser$),y=(h==null?void 0:h.userID)===e.personId,v=e.id===ve,[P,H]=a.useState(!1),m=()=>{p.executeCommand(c?$.DeleteCommentTreeCommand.id:$.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),c&&(f==null||f())};return a.createElement("div",{className:g.threadCommentItem,onMouseLeave:()=>H(!1),onMouseEnter:()=>H(!0)},a.createElement("img",{className:g.threadCommentItemHead,src:S==null?void 0:S.avatar}),a.createElement("div",{className:g.threadCommentItemTitle},a.createElement("div",{className:g.threadCommentUsername},(S==null?void 0:S.name)||" "),a.createElement("div",null,v||u?null:P?a.createElement("div",{className:g.threadCommentIcon,onClick:()=>l(S)},a.createElement(We,null)):null,y&&!v&&!u?a.createElement(_.Dropdown,{overlay:a.createElement(_.Menu,null,a.createElement(_.MenuItem,{key:"edit",onClick:()=>i==null?void 0:i(!0)},N.t("threadCommentUI.item.edit")),a.createElement(_.MenuItem,{key:"delete",onClick:m},N.t("threadCommentUI.item.delete")))},a.createElement("div",{className:g.threadCommentIcon},a.createElement(Ve,null))):null)),a.createElement("div",{className:g.threadCommentItemTime},e.dT),o?a.createElement(he,{id:e.id,comment:e,onCancel:()=>i==null?void 0:i(!1),autoFocus:!0,onSave:({text:C,attachments:L})=>{i==null||i(!1),p.executeCommand($.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:C,attachments:L}})}}):a.createElement("div",{className:g.threadCommentItemContent},de(e.text).map((C,L)=>{switch(C.type){case"mention":return a.createElement("a",{className:g.threadCommentItemAt,key:L},"@",C.content.label," ");default:return C.content}})))},Ce=n=>{var j,V,z;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:i=!0,onClick:l,showHighlight:u,onClose:c,getSubUnitName:f,prefix:p,autoFocus:N,onMouseEnter:I,onMouseLeave:S}=n,h=b.useDependency($.ThreadCommentModel),[y,v]=a.useState(!1),[P,H]=a.useState("");R.useObservable(h.commentMap$);const m=e?h.getCommentWithChildren(t,r,e):null,C=b.useDependency(d.ICommandService),L=b.useDependency(d.UserManagerService),D=m==null?void 0:m.root.resolved,E=R.useObservable(L.currentUser$),U=a.useRef(null),A=[...m?[m.root]:[{id:ve,text:{dataStream:`
3
+ \r`},personId:(j=E==null?void 0:E.userID)!=null?j:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r}],...(V=m==null?void 0:m.children)!=null?V:[]],q=()=>{C.executeCommand($.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!D}),c==null||c()},w=()=>{C.executeCommand($.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),c==null||c()};return a.createElement("div",{className:Ie(g.threadComment,{[g.threadCommentActive]:!D&&(u||y||p==="cell")}),onClick:l,id:`${p}-${t}-${r}-${e}`,onMouseEnter:()=>{I==null||I(),v(!0)},onMouseLeave:()=>{S==null||S(),v(!1)}},!D&&u?a.createElement("div",{className:g.threadCommentHighlight}):null,a.createElement("div",{className:g.threadCommentTitle},a.createElement("div",{className:g.threadCommentTitlePosition},a.createElement("div",{className:g.threadCommentTitleHighlight}),o||(m==null?void 0:m.root.ref)," · ",f((z=m==null?void 0:m.root.subUnitId)!=null?z:r)),m?a.createElement("div",{className:g.threadCommentIconContainer},a.createElement("div",{onClick:q,className:g.threadCommentIcon,style:{color:D?"rgb(var(--green-500))":""}},D?a.createElement(ze,null):a.createElement(Ze,null)),(E==null?void 0:E.userID)===m.root.personId?a.createElement("div",{className:g.threadCommentIcon,onClick:w},a.createElement(Le,null)):null):null),a.createElement("div",{className:g.threadCommentContent},A.map(s=>a.createElement(St,{onClose:c,unitId:t,subUnitId:r,item:s,key:s.id,isRoot:s.id===(m==null?void 0:m.root.id),editing:P===s.id,resolved:m==null?void 0:m.root.resolved,onEditingChange:T=>{H(T?s.id:"")},onReply:T=>{var O;T&&((O=U.current)==null||O.reply(ue([{type:"mention",content:{id:T.userID,label:T.name}}])))}}))),i&&!P&&!D?a.createElement("div",null,a.createElement(he,{key:`${N}`,ref:U,onSave:({text:s,attachments:T})=>{C.executeCommand($.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:{text:s,attachments:T,dT:pe().format("YYYY/MM/DD HH:mm"),id:d.Tools.generateRandomId(),ref:o,personId:E==null?void 0:E.userID,parentId:m==null?void 0:m.root.id,unitId:t,subUnitId:r}})},autoFocus:N||!m,onCancel:()=>{m||c==null||c()}})):null)},yt="univer-thread-comment-panel",bt="univer-thread-comment",Et="univer-thread-comment-panel-forms",Tt="univer-select",xt="univer-thread-comment-panel-empty",_t="univer-thread-comment-panel-add",F={threadCommentPanel:yt,threadComment:bt,threadCommentPanelForms:Et,select:Tt,threadCommentPanelEmpty:xt,threadCommentPanelAdd:_t},Mt=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:i,onResolve:l,sortComments:u,onItemLeave:c,onItemEnter:f}=n,[p,N]=a.useState("all"),[I,S]=a.useState("all"),h=b.useDependency(d.LocaleService),y=b.useDependency(d.UserManagerService),v=b.useDependency($.ThreadCommentModel),[P,H]=a.useState(()=>v.getUnit(e)),m=b.useDependency(exports.ThreadCommentPanelService),C=R.useObservable(m.activeCommentId$),L=R.useObservable(v.commentUpdate$),D=b.useDependency(d.ICommandService),E=R.useObservable(t),U=y.currentUser,A=a.useRef(!0),q="panel",w=a.useMemo(()=>{var s,T;if(p==="all"){const O=P.map(B=>B[1]).flat().filter(B=>!B.parentId);return u?u(O):O}else return(T=(s=P.find(O=>O[0]===E))==null?void 0:s[1])!=null?T:[]},[p,P,E,u]),j=a.useMemo(()=>I==="resolved"?w.filter(s=>s.resolved):I==="unsolved"?w.filter(s=>!s.resolved):I==="concern_me"&&U!=null&&U.userID?w.map(s=>v.getCommentWithChildren(s.unitId,s.subUnitId,s.id)).map(s=>s!=null&&s.relativeUsers.has(U.userID)?s.root:null).filter(Boolean):w,[w,U==null?void 0:U.userID,I,v]),V=I!=="all"||p!=="all",z=()=>{S("all"),N("all")};return a.useEffect(()=>{e&&H(v.getUnit(e))},[e,v,L]),a.useEffect(()=>{var X;if(!C)return;if(!A.current){A.current=!0;return}const{unitId:s,subUnitId:T,commentId:O}=C,B=`${q}-${s}-${T}-${O}`;(X=document.getElementById(B))==null||X.scrollIntoView({block:"center"})},[C]),a.createElement("div",{className:F.threadCommentPanel},a.createElement("div",{className:F.threadCommentPanelForms},a.createElement(_.Select,{borderless:!0,value:p,onChange:s=>N(s),options:[{value:"current",label:h.t("threadCommentUI.filter.sheet.current")},{value:"all",label:h.t("threadCommentUI.filter.sheet.all")}]}),a.createElement(_.Select,{borderless:!0,value:I,onChange:s=>S(s),options:[{value:"all",label:h.t("threadCommentUI.filter.status.all")},{value:"resolved",label:h.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:h.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:h.t("threadCommentUI.filter.status.concernMe")}]})),j==null?void 0:j.map(s=>a.createElement(Ce,{prefix:q,getSubUnitName:i,key:s.id,id:s.id,unitId:s.unitId,subUnitId:s.subUnitId,type:r,showEdit:(C==null?void 0:C.commentId)===s.id,showHighlight:(C==null?void 0:C.commentId)===s.id,onClick:()=>{A.current=!1,D.executeCommand(J.id,{unitId:s.unitId,subUnitId:s.subUnitId,commentId:s.id,temp:!0})},onClose:()=>l==null?void 0:l(s.id),onMouseEnter:()=>f==null?void 0:f(s),onMouseLeave:()=>c==null?void 0:c(s)})),j.length?null:a.createElement("div",{className:F.threadCommentPanelEmpty},V?h.t("threadCommentUI.panel.filterEmpty"):h.t("threadCommentUI.panel.empty"),V?a.createElement(_.Button,{onClick:z,type:"link"},h.t("threadCommentUI.panel.reset")):a.createElement(_.Button,{id:"thread-comment-add",className:F.threadCommentPanelAdd,type:"primary",onClick:o},a.createElement(ke,null),h.t("threadCommentUI.panel.addComment"))))};exports.IThreadCommentMentionDataService=Q;exports.SetActiveCommentOperation=J;exports.THREAD_COMMENT_PANEL=ne;exports.ThreadCommentPanel=Mt;exports.ThreadCommentTree=Ce;exports.ToggleSheetCommentPanelOperation=re;
package/lib/es/index.js CHANGED
@@ -3,11 +3,11 @@ var Oe = (t, e, n) => e in t ? Ue(t, e, { enumerable: !0, configurable: !0, writ
3
3
  var _ = (t, e, n) => (Oe(t, typeof e != "symbol" ? e + "" : e, n), n);
4
4
  import { UniverThreadCommentPlugin as Pe, ThreadCommentModel as ce, AddCommentCommand as He, UpdateCommentCommand as we, ResolveCommentCommand as De, DeleteCommentTreeCommand as ue, DeleteCommentCommand as Re } from "@univerjs/thread-comment";
5
5
  import { Disposable as he, UniverInstanceType as ve, IUniverInstanceService as ke, CommandType as Ce, OnLifecycle as Le, LifecycleStages as je, LocaleService as J, mergeOverrideWithDependencies as Ae, ICommandService as Q, CustomRangeType as Ve, UserManagerService as ee, Tools as Be } from "@univerjs/core";
6
- import { Inject as te, createIdentifier as ze, Injector as We } from "@wendellhu/redi";
7
- import { ISidebarService as fe, useObservable as j } from "@univerjs/ui";
6
+ import { Inject as te, createIdentifier as We, Injector as ze } from "@wendellhu/redi";
7
+ import { ISidebarService as ge, useObservable as j } from "@univerjs/ui";
8
8
  import { BehaviorSubject as re, filter as Fe } from "rxjs";
9
9
  import a, { forwardRef as H, useRef as X, createElement as k, useState as P, useImperativeHandle as Ze, useMemo as oe, useEffect as ae } from "react";
10
- import { useDependency as S } from "@wendellhu/redi/react-bindings";
10
+ import { useDependency as b } from "@wendellhu/redi/react-bindings";
11
11
  import { Mentions as Ye, Mention as Ke, Button as G, Dropdown as Ge, Menu as qe, MenuItem as ie, Select as le } from "@univerjs/design";
12
12
  import Je from "dayjs";
13
13
  import Qe from "clsx";
@@ -53,77 +53,42 @@ let A = class extends he {
53
53
  }
54
54
  };
55
55
  A = rt([
56
- se(0, te(fe)),
56
+ se(0, te(ge)),
57
57
  se(1, ke)
58
58
  ], A);
59
59
  const ot = {
60
60
  id: "thread-comment-ui.operation.toggle-panel",
61
61
  type: Ce.OPERATION,
62
62
  handler(t) {
63
- const e = t.get(fe), n = t.get(A);
63
+ const e = t.get(ge), n = t.get(A);
64
64
  return n.panelVisible ? (e.close(), n.setPanelVisible(!1)) : (e.open({
65
65
  header: { title: "threadCommentUI.panel.title" },
66
66
  children: { label: Xe },
67
67
  width: 320
68
68
  }), n.setPanelVisible(!0)), !0;
69
69
  }
70
- }, ge = {
70
+ }, fe = {
71
71
  id: "thread-comment-ui.operation.set-active-comment",
72
72
  type: Ce.OPERATION,
73
73
  handler(t, e) {
74
74
  return t.get(A).setActiveComment(e), !0;
75
75
  }
76
- }, at = {
77
- threadCommentUI: {
78
- panel: {
79
- title: "评论管理",
80
- empty: "暂无评论",
81
- filterEmpty: "没有匹配的结果",
82
- reset: "重置",
83
- addComment: "新建评论"
84
- },
85
- editor: {
86
- placeholder: "回复",
87
- reply: "回复",
88
- cancel: "取消",
89
- save: "保存"
90
- },
91
- item: {
92
- edit: "编辑",
93
- delete: "删除"
94
- },
95
- filter: {
96
- sheet: {
97
- all: "所有表格",
98
- current: "当前表格"
99
- },
100
- status: {
101
- all: "所有评论",
102
- resolved: "已解决",
103
- unsolved: "未解决",
104
- concernMe: "与我有关"
105
- }
106
- }
107
- }
108
76
  };
109
- var it = Object.defineProperty, lt = Object.getOwnPropertyDescriptor, st = (t, e, n, r) => {
110
- for (var o = r > 1 ? void 0 : r ? lt(e, n) : e, i = t.length - 1, s; i >= 0; i--)
77
+ var at = Object.defineProperty, it = Object.getOwnPropertyDescriptor, lt = (t, e, n, r) => {
78
+ for (var o = r > 1 ? void 0 : r ? it(e, n) : e, i = t.length - 1, s; i >= 0; i--)
111
79
  (s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
112
- return r && o && it(e, n, o), o;
113
- }, mt = (t, e) => (n, r) => e(n, r, t);
80
+ return r && o && at(e, n, o), o;
81
+ }, st = (t, e) => (n, r) => e(n, r, t);
114
82
  let K = class extends he {
115
83
  constructor(t) {
116
- super(), this._localeService = t, this._initLocales();
117
- }
118
- _initLocales() {
119
- this._localeService.load({ zhCN: at });
84
+ super(), this._localeService = t;
120
85
  }
121
86
  };
122
- K = st([
87
+ K = lt([
123
88
  Le(je.Starting, K),
124
- mt(0, te(J))
89
+ st(0, te(J))
125
90
  ], K);
126
- class dt {
91
+ class mt {
127
92
  constructor() {
128
93
  _(this, "trigger", "@");
129
94
  }
@@ -131,11 +96,11 @@ class dt {
131
96
  return [];
132
97
  }
133
98
  }
134
- const pe = ze("thread-comment.mention-data.service");
135
- var ct = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, ht = (t, e, n, r) => {
136
- for (var o = r > 1 ? void 0 : r ? ut(e, n) : e, i = t.length - 1, s; i >= 0; i--)
99
+ const pe = We("thread-comment.mention-data.service");
100
+ var dt = Object.defineProperty, ct = Object.getOwnPropertyDescriptor, ut = (t, e, n, r) => {
101
+ for (var o = r > 1 ? void 0 : r ? ct(e, n) : e, i = t.length - 1, s; i >= 0; i--)
137
102
  (s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
138
- return r && o && ct(e, n, o), o;
103
+ return r && o && dt(e, n, o), o;
139
104
  }, me = (t, e) => (n, r) => e(n, r, t), Y;
140
105
  let de = (Y = class extends Pe {
141
106
  constructor(e, n, r) {
@@ -151,16 +116,16 @@ let de = (Y = class extends Pe {
151
116
  super.onStarting(e), Ae([
152
117
  [K],
153
118
  [A],
154
- [pe, { useClass: dt }]
119
+ [pe, { useClass: mt }]
155
120
  ], this._config1.overrides).forEach((n) => {
156
121
  e.add(n);
157
- }), [ot, ge].forEach((n) => {
122
+ }), [ot, fe].forEach((n) => {
158
123
  this._commandService.registerCommand(n);
159
124
  });
160
125
  }
161
126
  }, _(Y, "pluginName", et), _(Y, "type", ve.UNIVER_UNKNOWN), Y);
162
- de = ht([
163
- me(1, te(We)),
127
+ de = ut([
128
+ me(1, te(ze)),
164
129
  me(2, Q)
165
130
  ], de);
166
131
  var x = function() {
@@ -172,7 +137,7 @@ var x = function() {
172
137
  }
173
138
  return t;
174
139
  }, x.apply(this, arguments);
175
- }, vt = function(t, e) {
140
+ }, ht = function(t, e) {
176
141
  var n = {};
177
142
  for (var r in t)
178
143
  Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
@@ -181,15 +146,15 @@ var x = function() {
181
146
  e.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[o]) && (n[r[o]] = t[r[o]]);
182
147
  return n;
183
148
  }, L = H(function(t, e) {
184
- var n = t.icon, r = t.id, o = t.className, i = t.extend, s = vt(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(r, " ").concat(o || "").trim(), d = X("_".concat(gt()));
149
+ var n = t.icon, r = t.id, o = t.className, i = t.extend, s = ht(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(r, " ").concat(o || "").trim(), d = X("_".concat(gt()));
185
150
  return Ie(n, "".concat(r), { defIds: n.defIds, idSuffix: d.current }, x({ ref: e, className: c }, s), i);
186
151
  });
187
152
  function Ie(t, e, n, r, o) {
188
- return k(t.tag, x(x({ key: e }, Ct(t, n, o)), r), (ft(t, n).children || []).map(function(i, s) {
153
+ return k(t.tag, x(x({ key: e }, vt(t, n, o)), r), (Ct(t, n).children || []).map(function(i, s) {
189
154
  return Ie(i, "".concat(e, "-").concat(t.tag, "-").concat(s), n, void 0, o);
190
155
  }));
191
156
  }
192
- function Ct(t, e, n) {
157
+ function vt(t, e, n) {
193
158
  var r = x({}, t.attrs);
194
159
  n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1);
195
160
  var o = e.defIds;
@@ -198,7 +163,7 @@ function Ct(t, e, n) {
198
163
  typeof c == "string" && (r[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
199
164
  })), r;
200
165
  }
201
- function ft(t, e) {
166
+ function Ct(t, e) {
202
167
  var n, r = e.defIds;
203
168
  return !r || r.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? x(x({}, t), { children: t.children.map(function(o) {
204
169
  return typeof o.attrs.id == "string" && r && r.indexOf(o.attrs.id) > -1 ? x(x({}, o), { attrs: x(x({}, o.attrs), { id: o.attrs.id + e.idSuffix }) }) : o;
@@ -208,65 +173,65 @@ function gt() {
208
173
  return Math.random().toString(36).substring(2, 8);
209
174
  }
210
175
  L.displayName = "UniverIcon";
211
- var pt = { 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" } }] }, ye = H(function(t, e) {
176
+ var ft = { 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" } }] }, ye = H(function(t, e) {
212
177
  return k(L, Object.assign({}, t, {
213
178
  id: "delete-single",
214
179
  ref: e,
215
- icon: pt
180
+ icon: ft
216
181
  }));
217
182
  });
218
183
  ye.displayName = "DeleteSingle";
219
- const It = ye;
220
- var yt = { 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 = H(function(t, e) {
184
+ const pt = ye;
185
+ var It = { 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" } }] }, be = H(function(t, e) {
221
186
  return k(L, Object.assign({}, t, {
222
187
  id: "increase-single",
223
188
  ref: e,
224
- icon: yt
189
+ icon: It
225
190
  }));
226
191
  });
227
- Se.displayName = "IncreaseSingle";
228
- const St = Se;
229
- var bt = { 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 = H(function(t, e) {
192
+ be.displayName = "IncreaseSingle";
193
+ const yt = be;
194
+ var bt = { 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 = H(function(t, e) {
230
195
  return k(L, Object.assign({}, t, {
231
196
  id: "more-horizontal-single",
232
197
  ref: e,
233
198
  icon: bt
234
199
  }));
235
200
  });
236
- be.displayName = "MoreHorizontalSingle";
237
- const Et = be;
238
- var xt = { 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 } }] }, Ee = H(function(t, e) {
201
+ Se.displayName = "MoreHorizontalSingle";
202
+ const St = Se;
203
+ 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 } }] }, Ee = H(function(t, e) {
239
204
  return k(L, Object.assign({}, t, {
240
205
  id: "reply-to-comment-single",
241
206
  ref: e,
242
- icon: xt
207
+ icon: Et
243
208
  }));
244
209
  });
245
210
  Ee.displayName = "ReplyToCommentSingle";
246
- const _t = Ee;
247
- 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" } }] }, xe = H(function(t, e) {
211
+ const xt = Ee;
212
+ var _t = { 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" } }] }, xe = H(function(t, e) {
248
213
  return k(L, Object.assign({}, t, {
249
214
  id: "resolved-single",
250
215
  ref: e,
251
- icon: Nt
216
+ icon: _t
252
217
  }));
253
218
  });
254
219
  xe.displayName = "ResolvedSingle";
255
- const Tt = xe;
256
- var Mt = { 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 = H(function(t, e) {
220
+ const Nt = xe;
221
+ 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 } }] }, _e = H(function(t, e) {
257
222
  return k(L, Object.assign({}, t, {
258
223
  id: "solve-single",
259
224
  ref: e,
260
- icon: Mt
225
+ icon: Tt
261
226
  }));
262
227
  });
263
228
  _e.displayName = "SolveSingle";
264
- const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-comment-editor-suggestion", Pt = "univer-thread-comment-editor-suggestionActive", Ht = "univer-thread-comment-editor-suggestion-icon", q = {
265
- threadCommentEditorButtons: Ut,
266
- threadCommentEditorSuggestion: Ot,
267
- threadCommentEditorSuggestionActive: Pt,
268
- threadCommentEditorSuggestionIcon: Ht
269
- }, wt = (t) => {
229
+ const Mt = _e, $t = "univer-thread-comment-editor-buttons", Ut = "univer-thread-comment-editor-suggestion", Ot = "univer-thread-comment-editor-suggestionActive", Pt = "univer-thread-comment-editor-suggestion-icon", q = {
230
+ threadCommentEditorButtons: $t,
231
+ threadCommentEditorSuggestion: Ut,
232
+ threadCommentEditorSuggestionActive: Ot,
233
+ threadCommentEditorSuggestionIcon: Pt
234
+ }, Ht = (t) => {
270
235
  const e = /@\[(.*?)\]\((.*?)\)|(\w+)/g;
271
236
  let n, r = 0;
272
237
  const o = [];
@@ -288,7 +253,7 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
288
253
  type: "text",
289
254
  content: t.substring(r)
290
255
  }), o;
291
- }, Dt = (t) => t.map((e) => {
256
+ }, wt = (t) => t.map((e) => {
292
257
  switch (e.type) {
293
258
  case "mention":
294
259
  return `@[${e.content.label}](${e.content.id})`;
@@ -351,21 +316,21 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
351
316
  dataStream: e,
352
317
  customRanges: n
353
318
  };
354
- }, Rt = (t) => ({
319
+ }, Dt = (t) => ({
355
320
  display: t.label,
356
321
  id: `${t.id}`,
357
322
  raw: t
358
- }), kt = (t, e, n, r, o) => {
323
+ }), Rt = (t, e, n, r, o) => {
359
324
  var s, c;
360
325
  const i = (s = t.raw) == null ? void 0 : s.icon;
361
326
  return /* @__PURE__ */ a.createElement("div", { className: q.threadCommentEditorSuggestion }, i ? /* @__PURE__ */ a.createElement("img", { className: q.threadCommentEditorSuggestionIcon, src: i }) : null, /* @__PURE__ */ a.createElement("div", null, (c = t.display) != null ? c : t.id));
362
327
  }, Me = H((t, e) => {
363
328
  var u;
364
- const { comment: n, onSave: r, id: o, onCancel: i, autoFocus: s } = t, c = S(pe), d = S(J), [f, g] = P({ ...n }), [N, p] = P(!1), I = X(null);
329
+ const { comment: n, onSave: r, id: o, onCancel: i, autoFocus: s } = t, c = b(pe), d = b(J), [g, f] = P({ ...n }), [N, p] = P(!1), I = X(null);
365
330
  return Ze(e, () => ({
366
331
  reply(y) {
367
332
  var h;
368
- g({
333
+ f({
369
334
  ...n,
370
335
  text: y,
371
336
  attachments: []
@@ -378,9 +343,9 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
378
343
  autoFocus: s,
379
344
  style: { width: "100%" },
380
345
  placeholder: d.t("threadCommentUI.editor.placeholder"),
381
- value: f != null && f.text ? Dt(Ne(f.text)) : "",
346
+ value: g != null && g.text ? wt(Ne(g.text)) : "",
382
347
  onChange: (y) => {
383
- y.target.value || g({ ...n, text: void 0 }), g == null || g({ ...n, text: Te(wt(y.target.value)) });
348
+ y.target.value || f({ ...n, text: void 0 }), f == null || f({ ...n, text: Te(Ht(y.target.value)) });
384
349
  },
385
350
  onFocus: () => {
386
351
  p(!0);
@@ -391,9 +356,9 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
391
356
  {
392
357
  key: c.trigger,
393
358
  trigger: c.trigger,
394
- data: (y, h) => c.getMentions(y).then((T) => T.map(Rt)).then(h),
359
+ data: (y, h) => c.getMentions(y).then((T) => T.map(Dt)).then(h),
395
360
  displayTransform: (y, h) => `@${h} `,
396
- renderSuggestion: (u = c.renderSuggestion) != null ? u : kt
361
+ renderSuggestion: (u = c.renderSuggestion) != null ? u : Rt
397
362
  }
398
363
  )
399
364
  ), N ? /* @__PURE__ */ a.createElement("div", { className: q.threadCommentEditorButtons }, /* @__PURE__ */ a.createElement(
@@ -401,7 +366,7 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
401
366
  {
402
367
  style: { marginRight: 12 },
403
368
  onClick: () => {
404
- i == null || i(), p(!1), g({ text: void 0 });
369
+ i == null || i(), p(!1), f({ text: void 0 });
405
370
  }
406
371
  },
407
372
  d.t("threadCommentUI.editor.cancel")
@@ -409,52 +374,52 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
409
374
  G,
410
375
  {
411
376
  type: "primary",
412
- disabled: !f.text,
377
+ disabled: !g.text,
413
378
  onClick: () => {
414
- f.text && (r == null || r({
415
- ...f,
416
- text: f.text
417
- }), p(!1), g({ text: void 0 }));
379
+ g.text && (r == null || r({
380
+ ...g,
381
+ text: g.text
382
+ }), p(!1), f({ text: void 0 }));
418
383
  }
419
384
  },
420
385
  d.t(o ? "threadCommentUI.editor.save" : "threadCommentUI.editor.reply")
421
386
  )) : null);
422
- }), Lt = "univer-thread-comment", jt = "univer-thread-comment-active", At = "univer-thread-comment-content", Vt = "univer-thread-comment-highlight", Bt = "univer-thread-comment-icon-container", zt = "univer-thread-comment-icon", Wt = "univer-thread-comment-title", Ft = "univer-thread-comment-title-position", Zt = "univer-thread-comment-title-highlight", Yt = "univer-thread-comment-username", Kt = "univer-thread-comment-item", Gt = "univer-thread-comment-item-head", qt = "univer-thread-comment-item-title", Jt = "univer-thread-comment-item-title-position", Qt = "univer-thread-comment-item-title-highlight", Xt = "univer-thread-comment-item-time", en = "univer-thread-comment-item-content", tn = "univer-thread-comment-item-at", C = {
423
- threadComment: Lt,
424
- threadCommentActive: jt,
425
- threadCommentContent: At,
426
- threadCommentHighlight: Vt,
427
- threadCommentIconContainer: Bt,
428
- threadCommentIcon: zt,
387
+ }), kt = "univer-thread-comment", Lt = "univer-thread-comment-active", jt = "univer-thread-comment-content", At = "univer-thread-comment-highlight", Vt = "univer-thread-comment-icon-container", Bt = "univer-thread-comment-icon", Wt = "univer-thread-comment-title", zt = "univer-thread-comment-title-position", Ft = "univer-thread-comment-title-highlight", Zt = "univer-thread-comment-username", Yt = "univer-thread-comment-item", Kt = "univer-thread-comment-item-head", Gt = "univer-thread-comment-item-title", qt = "univer-thread-comment-item-title-position", Jt = "univer-thread-comment-item-title-highlight", Qt = "univer-thread-comment-item-time", Xt = "univer-thread-comment-item-content", en = "univer-thread-comment-item-at", C = {
388
+ threadComment: kt,
389
+ threadCommentActive: Lt,
390
+ threadCommentContent: jt,
391
+ threadCommentHighlight: At,
392
+ threadCommentIconContainer: Vt,
393
+ threadCommentIcon: Bt,
429
394
  threadCommentTitle: Wt,
430
- threadCommentTitlePosition: Ft,
431
- threadCommentTitleHighlight: Zt,
432
- threadCommentUsername: Yt,
433
- threadCommentItem: Kt,
434
- threadCommentItemHead: Gt,
435
- threadCommentItemTitle: qt,
436
- threadCommentItemTitlePosition: Jt,
437
- threadCommentItemTitleHighlight: Qt,
438
- threadCommentItemTime: Xt,
439
- threadCommentItemContent: en,
440
- threadCommentItemAt: tn
441
- }, $e = "__mock__", nn = (t) => {
442
- const { item: e, unitId: n, subUnitId: r, editing: o, onEditingChange: i, onReply: s, resolved: c, isRoot: d, onClose: f } = t, g = S(Q), N = S(J), p = S(ee), I = p.getUser(e.personId), u = j(p.currentUser$), y = (u == null ? void 0 : u.userID) === e.personId, h = e.id === $e, [T, w] = P(!1), m = () => {
443
- g.executeCommand(
395
+ threadCommentTitlePosition: zt,
396
+ threadCommentTitleHighlight: Ft,
397
+ threadCommentUsername: Zt,
398
+ threadCommentItem: Yt,
399
+ threadCommentItemHead: Kt,
400
+ threadCommentItemTitle: Gt,
401
+ threadCommentItemTitlePosition: qt,
402
+ threadCommentItemTitleHighlight: Jt,
403
+ threadCommentItemTime: Qt,
404
+ threadCommentItemContent: Xt,
405
+ threadCommentItemAt: en
406
+ }, $e = "__mock__", tn = (t) => {
407
+ const { item: e, unitId: n, subUnitId: r, editing: o, onEditingChange: i, onReply: s, resolved: c, isRoot: d, onClose: g } = t, f = b(Q), N = b(J), p = b(ee), I = p.getUser(e.personId), u = j(p.currentUser$), y = (u == null ? void 0 : u.userID) === e.personId, h = e.id === $e, [T, w] = P(!1), m = () => {
408
+ f.executeCommand(
444
409
  d ? ue.id : Re.id,
445
410
  {
446
411
  unitId: n,
447
412
  subUnitId: r,
448
413
  commentId: e.id
449
414
  }
450
- ), d && (f == null || f());
415
+ ), d && (g == null || g());
451
416
  };
452
- return /* @__PURE__ */ a.createElement("div", { className: C.threadCommentItem, onMouseLeave: () => w(!1), onMouseEnter: () => w(!0) }, /* @__PURE__ */ a.createElement("img", { className: C.threadCommentItemHead, src: I == null ? void 0 : I.avatar }), /* @__PURE__ */ a.createElement("div", { className: C.threadCommentItemTitle }, /* @__PURE__ */ a.createElement("div", { className: C.threadCommentUsername }, (I == null ? void 0 : I.name) || " "), /* @__PURE__ */ a.createElement("div", null, h || c ? null : T ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIcon, onClick: () => s(I) }, /* @__PURE__ */ a.createElement(_t, null)) : null, y && !h && !c ? /* @__PURE__ */ a.createElement(
417
+ return /* @__PURE__ */ a.createElement("div", { className: C.threadCommentItem, onMouseLeave: () => w(!1), onMouseEnter: () => w(!0) }, /* @__PURE__ */ a.createElement("img", { className: C.threadCommentItemHead, src: I == null ? void 0 : I.avatar }), /* @__PURE__ */ a.createElement("div", { className: C.threadCommentItemTitle }, /* @__PURE__ */ a.createElement("div", { className: C.threadCommentUsername }, (I == null ? void 0 : I.name) || " "), /* @__PURE__ */ a.createElement("div", null, h || c ? null : T ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIcon, onClick: () => s(I) }, /* @__PURE__ */ a.createElement(xt, null)) : null, y && !h && !c ? /* @__PURE__ */ a.createElement(
453
418
  Ge,
454
419
  {
455
420
  overlay: /* @__PURE__ */ a.createElement(qe, null, /* @__PURE__ */ a.createElement(ie, { key: "edit", onClick: () => i == null ? void 0 : i(!0) }, N.t("threadCommentUI.item.edit")), /* @__PURE__ */ a.createElement(ie, { key: "delete", onClick: m }, N.t("threadCommentUI.item.delete")))
456
421
  },
457
- /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIcon }, /* @__PURE__ */ a.createElement(Et, null))
422
+ /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIcon }, /* @__PURE__ */ a.createElement(St, null))
458
423
  ) : null)), /* @__PURE__ */ a.createElement("div", { className: C.threadCommentItemTime }, e.dT), o ? /* @__PURE__ */ a.createElement(
459
424
  Me,
460
425
  {
@@ -463,7 +428,7 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
463
428
  onCancel: () => i == null ? void 0 : i(!1),
464
429
  autoFocus: !0,
465
430
  onSave: ({ text: v, attachments: D }) => {
466
- i == null || i(!1), g.executeCommand(
431
+ i == null || i(!1), f.executeCommand(
467
432
  we.id,
468
433
  {
469
434
  unitId: n,
@@ -485,7 +450,7 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
485
450
  return v.content;
486
451
  }
487
452
  })));
488
- }, rn = (t) => {
453
+ }, nn = (t) => {
489
454
  var R, B, F;
490
455
  const {
491
456
  id: e,
@@ -496,14 +461,14 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
496
461
  onClick: s,
497
462
  showHighlight: c,
498
463
  onClose: d,
499
- getSubUnitName: f,
500
- prefix: g,
464
+ getSubUnitName: g,
465
+ prefix: f,
501
466
  autoFocus: N,
502
467
  onMouseEnter: p,
503
468
  onMouseLeave: I
504
- } = t, u = S(ce), [y, h] = P(!1), [T, w] = P("");
469
+ } = t, u = b(ce), [y, h] = P(!1), [T, w] = P("");
505
470
  j(u.commentMap$);
506
- const m = e ? u.getCommentWithChildren(n, r, e) : null, v = S(Q), D = S(ee), U = m == null ? void 0 : m.root.resolved, b = j(D.currentUser$), M = X(null), V = [
471
+ const m = e ? u.getCommentWithChildren(n, r, e) : null, v = b(Q), D = b(ee), U = m == null ? void 0 : m.root.resolved, S = j(D.currentUser$), M = X(null), V = [
507
472
  ...m ? [m.root] : (
508
473
  // mock empty comment
509
474
  [{
@@ -512,7 +477,7 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
512
477
  dataStream: `
513
478
  \r`
514
479
  },
515
- personId: (R = b == null ? void 0 : b.userID) != null ? R : "",
480
+ personId: (R = S == null ? void 0 : S.userID) != null ? R : "",
516
481
  ref: o != null ? o : "",
517
482
  dT: "",
518
483
  unitId: n,
@@ -520,7 +485,7 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
520
485
  }]
521
486
  ),
522
487
  ...(B = m == null ? void 0 : m.children) != null ? B : []
523
- ], W = () => {
488
+ ], z = () => {
524
489
  v.executeCommand(De.id, {
525
490
  unitId: n,
526
491
  subUnitId: r,
@@ -541,10 +506,10 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
541
506
  "div",
542
507
  {
543
508
  className: Qe(C.threadComment, {
544
- [C.threadCommentActive]: !U && (c || y || g === "cell")
509
+ [C.threadCommentActive]: !U && (c || y || f === "cell")
545
510
  }),
546
511
  onClick: s,
547
- id: `${g}-${n}-${r}-${e}`,
512
+ id: `${f}-${n}-${r}-${e}`,
548
513
  onMouseEnter: () => {
549
514
  p == null || p(), h(!0);
550
515
  },
@@ -553,18 +518,18 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
553
518
  }
554
519
  },
555
520
  !U && c ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentHighlight }) : null,
556
- /* @__PURE__ */ a.createElement("div", { className: C.threadCommentTitle }, /* @__PURE__ */ a.createElement("div", { className: C.threadCommentTitlePosition }, /* @__PURE__ */ a.createElement("div", { className: C.threadCommentTitleHighlight }), o || (m == null ? void 0 : m.root.ref), " · ", f((F = m == null ? void 0 : m.root.subUnitId) != null ? F : r)), m ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIconContainer }, /* @__PURE__ */ a.createElement(
521
+ /* @__PURE__ */ a.createElement("div", { className: C.threadCommentTitle }, /* @__PURE__ */ a.createElement("div", { className: C.threadCommentTitlePosition }, /* @__PURE__ */ a.createElement("div", { className: C.threadCommentTitleHighlight }), o || (m == null ? void 0 : m.root.ref), " · ", g((F = m == null ? void 0 : m.root.subUnitId) != null ? F : r)), m ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIconContainer }, /* @__PURE__ */ a.createElement(
557
522
  "div",
558
523
  {
559
- onClick: W,
524
+ onClick: z,
560
525
  className: C.threadCommentIcon,
561
526
  style: { color: U ? "rgb(var(--green-500))" : "" }
562
527
  },
563
- U ? /* @__PURE__ */ a.createElement(Tt, null) : /* @__PURE__ */ a.createElement($t, null)
564
- ), (b == null ? void 0 : b.userID) === m.root.personId ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIcon, onClick: O }, /* @__PURE__ */ a.createElement(It, null)) : null) : null),
528
+ U ? /* @__PURE__ */ a.createElement(Nt, null) : /* @__PURE__ */ a.createElement(Mt, null)
529
+ ), (S == null ? void 0 : S.userID) === m.root.personId ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIcon, onClick: O }, /* @__PURE__ */ a.createElement(pt, null)) : null) : null),
565
530
  /* @__PURE__ */ a.createElement("div", { className: C.threadCommentContent }, V.map(
566
531
  (l) => /* @__PURE__ */ a.createElement(
567
- nn,
532
+ tn,
568
533
  {
569
534
  onClose: d,
570
535
  unitId: n,
@@ -607,7 +572,7 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
607
572
  dT: Je().format("YYYY/MM/DD HH:mm"),
608
573
  id: Be.generateRandomId(),
609
574
  ref: o,
610
- personId: b == null ? void 0 : b.userID,
575
+ personId: S == null ? void 0 : S.userID,
611
576
  parentId: m == null ? void 0 : m.root.id,
612
577
  unitId: n,
613
578
  subUnitId: r
@@ -622,22 +587,22 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
622
587
  }
623
588
  )) : null
624
589
  );
625
- }, on = "univer-thread-comment-panel", an = "univer-thread-comment", ln = "univer-thread-comment-panel-forms", sn = "univer-select", mn = "univer-thread-comment-panel-empty", dn = "univer-thread-comment-panel-add", Z = {
626
- threadCommentPanel: on,
627
- threadComment: an,
628
- threadCommentPanelForms: ln,
629
- select: sn,
630
- threadCommentPanelEmpty: mn,
631
- threadCommentPanelAdd: dn
590
+ }, rn = "univer-thread-comment-panel", on = "univer-thread-comment", an = "univer-thread-comment-panel-forms", ln = "univer-select", sn = "univer-thread-comment-panel-empty", mn = "univer-thread-comment-panel-add", Z = {
591
+ threadCommentPanel: rn,
592
+ threadComment: on,
593
+ threadCommentPanelForms: an,
594
+ select: ln,
595
+ threadCommentPanelEmpty: sn,
596
+ threadCommentPanelAdd: mn
632
597
  }, bn = (t) => {
633
- const { unitId: e, subUnitId$: n, type: r, onAdd: o, getSubUnitName: i, onResolve: s, sortComments: c, onItemLeave: d, onItemEnter: f } = t, [g, N] = P("all"), [p, I] = P("all"), u = S(J), y = S(ee), h = S(ce), [T, w] = P(() => h.getUnit(e)), m = S(A), v = j(m.activeCommentId$), D = j(h.commentUpdate$), U = S(Q), b = j(n), M = y.getCurrentUser(), V = X(!0), W = "panel", O = oe(() => {
598
+ const { unitId: e, subUnitId$: n, type: r, onAdd: o, getSubUnitName: i, onResolve: s, sortComments: c, onItemLeave: d, onItemEnter: g } = t, [f, N] = P("all"), [p, I] = P("all"), u = b(J), y = b(ee), h = b(ce), [T, w] = P(() => h.getUnit(e)), m = b(A), v = j(m.activeCommentId$), D = j(h.commentUpdate$), U = b(Q), S = j(n), M = y.currentUser, V = X(!0), z = "panel", O = oe(() => {
634
599
  var l, E;
635
- if (g === "all") {
636
- const $ = T.map((z) => z[1]).flat().filter((z) => !z.parentId);
600
+ if (f === "all") {
601
+ const $ = T.map((W) => W[1]).flat().filter((W) => !W.parentId);
637
602
  return c ? c($) : $;
638
603
  } else
639
- return (E = (l = T.find(($) => $[0] === b)) == null ? void 0 : l[1]) != null ? E : [];
640
- }, [g, T, b, c]), R = oe(() => p === "resolved" ? O.filter((l) => l.resolved) : p === "unsolved" ? O.filter((l) => !l.resolved) : p === "concern_me" && M != null && M.userID ? O.map((l) => h.getCommentWithChildren(l.unitId, l.subUnitId, l.id)).map((l) => l != null && l.relativeUsers.has(M.userID) ? l.root : null).filter(Boolean) : O, [O, M == null ? void 0 : M.userID, p, h]), B = p !== "all" || g !== "all", F = () => {
604
+ return (E = (l = T.find(($) => $[0] === S)) == null ? void 0 : l[1]) != null ? E : [];
605
+ }, [f, T, S, c]), R = oe(() => p === "resolved" ? O.filter((l) => l.resolved) : p === "unsolved" ? O.filter((l) => !l.resolved) : p === "concern_me" && M != null && M.userID ? O.map((l) => h.getCommentWithChildren(l.unitId, l.subUnitId, l.id)).map((l) => l != null && l.relativeUsers.has(M.userID) ? l.root : null).filter(Boolean) : O, [O, M == null ? void 0 : M.userID, p, h]), B = p !== "all" || f !== "all", F = () => {
641
606
  I("all"), N("all");
642
607
  };
643
608
  return ae(() => {
@@ -652,13 +617,13 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
652
617
  V.current = !0;
653
618
  return;
654
619
  }
655
- const { unitId: l, subUnitId: E, commentId: $ } = v, z = `${W}-${l}-${E}-${$}`;
656
- (ne = document.getElementById(z)) == null || ne.scrollIntoView({ block: "center" });
620
+ const { unitId: l, subUnitId: E, commentId: $ } = v, W = `${z}-${l}-${E}-${$}`;
621
+ (ne = document.getElementById(W)) == null || ne.scrollIntoView({ block: "center" });
657
622
  }, [v]), /* @__PURE__ */ a.createElement("div", { className: Z.threadCommentPanel }, /* @__PURE__ */ a.createElement("div", { className: Z.threadCommentPanelForms }, /* @__PURE__ */ a.createElement(
658
623
  le,
659
624
  {
660
625
  borderless: !0,
661
- value: g,
626
+ value: f,
662
627
  onChange: (l) => N(l),
663
628
  options: [
664
629
  {
@@ -697,9 +662,9 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
697
662
  ]
698
663
  }
699
664
  )), R == null ? void 0 : R.map((l) => /* @__PURE__ */ a.createElement(
700
- rn,
665
+ nn,
701
666
  {
702
- prefix: W,
667
+ prefix: z,
703
668
  getSubUnitName: i,
704
669
  key: l.id,
705
670
  id: l.id,
@@ -709,7 +674,7 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
709
674
  showEdit: (v == null ? void 0 : v.commentId) === l.id,
710
675
  showHighlight: (v == null ? void 0 : v.commentId) === l.id,
711
676
  onClick: () => {
712
- V.current = !1, U.executeCommand(ge.id, {
677
+ V.current = !1, U.executeCommand(fe.id, {
713
678
  unitId: l.unitId,
714
679
  subUnitId: l.subUnitId,
715
680
  commentId: l.id,
@@ -717,7 +682,7 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
717
682
  });
718
683
  },
719
684
  onClose: () => s == null ? void 0 : s(l.id),
720
- onMouseEnter: () => f == null ? void 0 : f(l),
685
+ onMouseEnter: () => g == null ? void 0 : g(l),
721
686
  onMouseLeave: () => d == null ? void 0 : d(l)
722
687
  }
723
688
  )), R.length ? null : /* @__PURE__ */ a.createElement("div", { className: Z.threadCommentPanelEmpty }, B ? u.t("threadCommentUI.panel.filterEmpty") : u.t("threadCommentUI.panel.empty"), B ? /* @__PURE__ */ a.createElement(
@@ -735,17 +700,17 @@ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-
735
700
  type: "primary",
736
701
  onClick: o
737
702
  },
738
- /* @__PURE__ */ a.createElement(St, null),
703
+ /* @__PURE__ */ a.createElement(yt, null),
739
704
  u.t("threadCommentUI.panel.addComment")
740
705
  )));
741
706
  };
742
707
  export {
743
708
  pe as IThreadCommentMentionDataService,
744
- ge as SetActiveCommentOperation,
709
+ fe as SetActiveCommentOperation,
745
710
  Xe as THREAD_COMMENT_PANEL,
746
711
  bn as ThreadCommentPanel,
747
712
  A as ThreadCommentPanelService,
748
- rn as ThreadCommentTree,
713
+ nn as ThreadCommentTree,
749
714
  ot as ToggleSheetCommentPanelOperation,
750
715
  de as UniverThreadCommentUIPlugin
751
716
  };
@@ -0,0 +1,33 @@
1
+ {
2
+ "threadCommentUI": {
3
+ "panel": {
4
+ "title": "Comment Management",
5
+ "empty": "No comments yet",
6
+ "filterEmpty": "No match result",
7
+ "reset": "Reset Filter",
8
+ "addComment": "Add Comment"
9
+ },
10
+ "editor": {
11
+ "placeholder": "Reply or add others with @",
12
+ "reply": "Comment",
13
+ "cancel": "Cancel",
14
+ "save": "Save"
15
+ },
16
+ "item": {
17
+ "edit": "Edit",
18
+ "delete": "Delete This Comment"
19
+ },
20
+ "filter": {
21
+ "sheet": {
22
+ "all": "All sheet",
23
+ "current": "Current sheet"
24
+ },
25
+ "status": {
26
+ "all": "All comments",
27
+ "resolved": "Resolved",
28
+ "unsolved": "Not resolved",
29
+ "concernMe": "Concern me"
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "threadCommentUI": {
3
+ "panel": {
4
+ "title": "Comment Management",
5
+ "empty": "No comments yet",
6
+ "filterEmpty": "No match result",
7
+ "reset": "Reset Filter",
8
+ "addComment": "Add Comment"
9
+ },
10
+ "editor": {
11
+ "placeholder": "Reply or add others with @",
12
+ "reply": "Comment",
13
+ "cancel": "Cancel",
14
+ "save": "Save"
15
+ },
16
+ "item": {
17
+ "edit": "Edit",
18
+ "delete": "Delete This Comment"
19
+ },
20
+ "filter": {
21
+ "sheet": {
22
+ "all": "All sheet",
23
+ "current": "Current sheet"
24
+ },
25
+ "status": {
26
+ "all": "All comments",
27
+ "resolved": "Resolved",
28
+ "unsolved": "Not resolved",
29
+ "concernMe": "Concern me"
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "threadCommentUI": {
3
+ "panel": {
4
+ "title": "评论管理",
5
+ "empty": "暂无评论",
6
+ "filterEmpty": "没有匹配的结果",
7
+ "reset": "重置",
8
+ "addComment": "新建评论"
9
+ },
10
+ "editor": {
11
+ "placeholder": "回复",
12
+ "reply": "回复",
13
+ "cancel": "取消",
14
+ "save": "保存"
15
+ },
16
+ "item": {
17
+ "edit": "编辑",
18
+ "delete": "删除"
19
+ },
20
+ "filter": {
21
+ "sheet": {
22
+ "all": "所有表格",
23
+ "current": "当前表格"
24
+ },
25
+ "status": {
26
+ "all": "所有评论",
27
+ "resolved": "已解决",
28
+ "unsolved": "未解决",
29
+ "concernMe": "与我有关"
30
+ }
31
+ }
32
+ }
33
+ }
@@ -3,5 +3,4 @@ import { Disposable, LocaleService } from '@univerjs/core';
3
3
  export declare class ThreadCommentUIController extends Disposable {
4
4
  private readonly _localeService;
5
5
  constructor(_localeService: LocaleService);
6
- private _initLocales;
7
6
  }
package/lib/umd/index.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(m,C){typeof exports=="object"&&typeof module<"u"?C(exports,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("dayjs"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/thread-comment","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@wendellhu/redi/react-bindings","@univerjs/design","dayjs","clsx"],C):(m=typeof globalThis<"u"?globalThis:m||self,C(m.UniverThreadCommentUi={},m.UniverThreadComment,m.UniverCore,m["@wendellhu/redi"],m.UniverUi,m.rxjs,m.React,m["@wendellhu/redi/react-bindings"],m.UniverDesign,m.dayjs,m.clsx))})(this,function(m,C,c,z,H,Q,i,T,_,ge,pe){"use strict";var et=Object.defineProperty;var tt=(m,C,c)=>C in m?et(m,C,{enumerable:!0,configurable:!0,writable:!0,value:c}):m[C]=c;var x=(m,C,c)=>(tt(m,typeof C!="symbol"?C+"":C,c),c);var K;const ee="thread-comment-panel",Ie="thread-comment-ui-plugin";var Se=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Ee=(n,e,t,r)=>{for(var o=r>1?void 0:r?ye(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&Se(e,t,o),o},te=(n,e)=>(t,r)=>e(t,r,n);m.ThreadCommentPanelService=class extends c.Disposable{constructor(t,r){super();x(this,"_panelVisible",!1);x(this,"_panelVisible$",new Q.BehaviorSubject(!1));x(this,"_activeCommentId");x(this,"_activeCommentId$",new Q.BehaviorSubject(void 0));x(this,"panelVisible$",this._panelVisible$.asObservable());x(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init()}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).pipe(Q.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)}},m.ThreadCommentPanelService=Ee([te(0,z.Inject(H.ISidebarService)),te(1,c.IUniverInstanceService)],m.ThreadCommentPanelService);const ne={id:"thread-comment-ui.operation.toggle-panel",type:c.CommandType.OPERATION,handler(n){const e=n.get(H.ISidebarService),t=n.get(m.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:ee},width:320}),t.setPanelVisible(!0)),!0}},X={id:"thread-comment-ui.operation.set-active-comment",type:c.CommandType.OPERATION,handler(n,e){return n.get(m.ThreadCommentPanelService).setActiveComment(e),!0}},be={threadCommentUI:{panel:{title:"评论管理",empty:"暂无评论",filterEmpty:"没有匹配的结果",reset:"重置",addComment:"新建评论"},editor:{placeholder:"回复",reply:"回复",cancel:"取消",save:"保存"},item:{edit:"编辑",delete:"删除"},filter:{sheet:{all:"所有表格",current:"当前表格"},status:{all:"所有评论",resolved:"已解决",unsolved:"未解决",concernMe:"与我有关"}}}};var Te=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ue=(n,e,t,r)=>{for(var o=r>1?void 0:r?_e(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&Te(e,t,o),o},Pe=(n,e)=>(t,r)=>e(t,r,n);let B=class extends c.Disposable{constructor(n){super(),this._localeService=n,this._initLocales()}_initLocales(){this._localeService.load({zhCN:be})}};B=Ue([c.OnLifecycle(c.LifecycleStages.Starting,B),Pe(0,z.Inject(c.LocaleService))],B);class Me{constructor(){x(this,"trigger","@")}async getMentions(e){return[]}}const R=z.createIdentifier("thread-comment.mention-data.service");var xe=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Oe=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ne(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&xe(e,t,o),o},re=(n,e)=>(t,r)=>e(t,r,n);m.UniverThreadCommentUIPlugin=(K=class extends C.UniverThreadCommentPlugin{constructor(t,r,o){super(t,r,o);x(this,"_config1");this._injector=r,this._commandService=o,this._config1=t}onStarting(t){super.onStarting(t),c.mergeOverrideWithDependencies([[B],[m.ThreadCommentPanelService],[R,{useClass:Me}]],this._config1.overrides).forEach(r=>{t.add(r)}),[ne,X].forEach(r=>{this._commandService.registerCommand(r)})}},x(K,"pluginName",Ie),x(K,"type",c.UniverInstanceType.UNIVER_UNKNOWN),K),m.UniverThreadCommentUIPlugin=Oe([re(1,z.Inject(z.Injector)),re(2,c.ICommandService)],m.UniverThreadCommentUIPlugin);var U=function(){return U=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},U.apply(this,arguments)},we=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},L=i.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,a=n.extend,s=we(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),u=i.useRef("_".concat($e()));return ie(t,"".concat(r),{defIds:t.defIds,idSuffix:u.current},U({ref:e,className:h},s),a)});function ie(n,e,t,r,o){return i.createElement(n.tag,U(U({key:e},De(n,t,o)),r),(He(n,t).children||[]).map(function(a,s){return ie(a,"".concat(e,"-").concat(n.tag,"-").concat(s),t,void 0,o)}))}function De(n,e,t){var r=U({},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 s=a[0],h=a[1];typeof h=="string"&&(r[s]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function He(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)?U(U({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?U(U({},o),{attrs:U(U({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function $e(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var je={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"}}]},oe=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"delete-single",ref:e,icon:je}))});oe.displayName="DeleteSingle";const Le=oe;var ke={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"}}]},ae=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"increase-single",ref:e,icon:ke}))});ae.displayName="IncreaseSingle";const Ae=ae;var Ve={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"}}]},le=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Ve}))});le.displayName="MoreHorizontalSingle";const ze=le;var We={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}}]},me=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:We}))});me.displayName="ReplyToCommentSingle";const qe=me;var Fe={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"}}]},se=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"resolved-single",ref:e,icon:Fe}))});se.displayName="ResolvedSingle";const Be=se;var Ze={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}}]},de=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"solve-single",ref:e,icon:Ze}))});de.displayName="SolveSingle";const Ye=de,Z={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"},Ke=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},Ge=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),ce=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let a=0;return t==null||t.forEach(s=>{a<s.startIndex&&o.push({type:"text",content:e.slice(a,s.startIndex)}),o.push({type:"mention",content:{label:e.slice(s.startIndex,s.endIndex).slice(1,-1),id:s.rangeId}}),a=s.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}},Je=n=>({display:n.label,id:`${n.id}`,raw:n}),Qe=(n,e,t,r,o)=>{var s,h;const a=(s=n.raw)==null?void 0:s.icon;return i.createElement("div",{className:Z.threadCommentEditorSuggestion},a?i.createElement("img",{className:Z.threadCommentEditorSuggestionIcon,src:a}):null,i.createElement("div",null,(h=n.display)!=null?h:n.id))},he=i.forwardRef((n,e)=>{var v;const{comment:t,onSave:r,id:o,onCancel:a,autoFocus:s}=n,h=T.useDependency(R),u=T.useDependency(c.LocaleService),[I,S]=i.useState({...t}),[N,y]=i.useState(!1),E=i.useRef(null);return i.useImperativeHandle(e,()=>({reply(b){var f;S({...t,text:b,attachments:[]}),(f=E.current)==null||f.inputElement.focus()}})),i.createElement("div",{className:Z.threadCommentEditor,onClick:b=>b.preventDefault()},i.createElement(_.Mentions,{ref:E,autoFocus:s,style:{width:"100%"},placeholder:u.t("threadCommentUI.editor.placeholder"),value:I!=null&&I.text?Ge(ce(I.text)):"",onChange:b=>{b.target.value||S({...t,text:void 0}),S==null||S({...t,text:ue(Ke(b.target.value))})},onFocus:()=>{y(!0)}},i.createElement(_.Mention,{key:h.trigger,trigger:h.trigger,data:(b,f)=>h.getMentions(b).then(O=>O.map(Je)).then(f),displayTransform:(b,f)=>`@${f} `,renderSuggestion:(v=h.renderSuggestion)!=null?v:Qe})),N?i.createElement("div",{className:Z.threadCommentEditorButtons},i.createElement(_.Button,{style:{marginRight:12},onClick:()=>{a==null||a(),y(!1),S({text:void 0})}},u.t("threadCommentUI.editor.cancel")),i.createElement(_.Button,{type:"primary",disabled:!I.text,onClick:()=>{I.text&&(r==null||r({...I,text:I.text}),y(!1),S({text:void 0}))}},u.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),g={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",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"},Ce="__mock__",Xe=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:a,onReply:s,resolved:h,isRoot:u,onClose:I}=n,S=T.useDependency(c.ICommandService),N=T.useDependency(c.LocaleService),y=T.useDependency(c.UserManagerService),E=y.getUser(e.personId),v=H.useObservable(y.currentUser$),b=(v==null?void 0:v.userID)===e.personId,f=e.id===Ce,[O,k]=i.useState(!1),d=()=>{S.executeCommand(u?C.DeleteCommentTreeCommand.id:C.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),u&&(I==null||I())};return i.createElement("div",{className:g.threadCommentItem,onMouseLeave:()=>k(!1),onMouseEnter:()=>k(!0)},i.createElement("img",{className:g.threadCommentItemHead,src:E==null?void 0:E.avatar}),i.createElement("div",{className:g.threadCommentItemTitle},i.createElement("div",{className:g.threadCommentUsername},(E==null?void 0:E.name)||" "),i.createElement("div",null,f||h?null:O?i.createElement("div",{className:g.threadCommentIcon,onClick:()=>s(E)},i.createElement(qe,null)):null,b&&!f&&!h?i.createElement(_.Dropdown,{overlay:i.createElement(_.Menu,null,i.createElement(_.MenuItem,{key:"edit",onClick:()=>a==null?void 0:a(!0)},N.t("threadCommentUI.item.edit")),i.createElement(_.MenuItem,{key:"delete",onClick:d},N.t("threadCommentUI.item.delete")))},i.createElement("div",{className:g.threadCommentIcon},i.createElement(ze,null))):null)),i.createElement("div",{className:g.threadCommentItemTime},e.dT),o?i.createElement(he,{id:e.id,comment:e,onCancel:()=>a==null?void 0:a(!1),autoFocus:!0,onSave:({text:p,attachments:A})=>{a==null||a(!1),S.executeCommand(C.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:p,attachments:A}})}}):i.createElement("div",{className:g.threadCommentItemContent},ce(e.text).map((p,A)=>{switch(p.type){case"mention":return i.createElement("a",{className:g.threadCommentItemAt,key:A},"@",p.content.label," ");default:return p.content}})))},ve=n=>{var V,q,J;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:a=!0,onClick:s,showHighlight:h,onClose:u,getSubUnitName:I,prefix:S,autoFocus:N,onMouseEnter:y,onMouseLeave:E}=n,v=T.useDependency(C.ThreadCommentModel),[b,f]=i.useState(!1),[O,k]=i.useState("");H.useObservable(v.commentMap$);const d=e?v.getCommentWithChildren(t,r,e):null,p=T.useDependency(c.ICommandService),A=T.useDependency(c.UserManagerService),$=d==null?void 0:d.root.resolved,P=H.useObservable(A.currentUser$),w=i.useRef(null),W=[...d?[d.root]:[{id:Ce,text:{dataStream:`
3
- \r`},personId:(V=P==null?void 0:P.userID)!=null?V:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r}],...(q=d==null?void 0:d.children)!=null?q:[]],G=()=>{p.executeCommand(C.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!$}),u==null||u()},j=()=>{p.executeCommand(C.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),u==null||u()};return i.createElement("div",{className:pe(g.threadComment,{[g.threadCommentActive]:!$&&(h||b||S==="cell")}),onClick:s,id:`${S}-${t}-${r}-${e}`,onMouseEnter:()=>{y==null||y(),f(!0)},onMouseLeave:()=>{E==null||E(),f(!1)}},!$&&h?i.createElement("div",{className:g.threadCommentHighlight}):null,i.createElement("div",{className:g.threadCommentTitle},i.createElement("div",{className:g.threadCommentTitlePosition},i.createElement("div",{className:g.threadCommentTitleHighlight}),o||(d==null?void 0:d.root.ref)," · ",I((J=d==null?void 0:d.root.subUnitId)!=null?J:r)),d?i.createElement("div",{className:g.threadCommentIconContainer},i.createElement("div",{onClick:G,className:g.threadCommentIcon,style:{color:$?"rgb(var(--green-500))":""}},$?i.createElement(Be,null):i.createElement(Ye,null)),(P==null?void 0:P.userID)===d.root.personId?i.createElement("div",{className:g.threadCommentIcon,onClick:j},i.createElement(Le,null)):null):null),i.createElement("div",{className:g.threadCommentContent},W.map(l=>i.createElement(Xe,{onClose:u,unitId:t,subUnitId:r,item:l,key:l.id,isRoot:l.id===(d==null?void 0:d.root.id),editing:O===l.id,resolved:d==null?void 0:d.root.resolved,onEditingChange:M=>{k(M?l.id:"")},onReply:M=>{var D;M&&((D=w.current)==null||D.reply(ue([{type:"mention",content:{id:M.userID,label:M.name}}])))}}))),a&&!O&&!$?i.createElement("div",null,i.createElement(he,{key:`${N}`,ref:w,onSave:({text:l,attachments:M})=>{p.executeCommand(C.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:{text:l,attachments:M,dT:ge().format("YYYY/MM/DD HH:mm"),id:c.Tools.generateRandomId(),ref:o,personId:P==null?void 0:P.userID,parentId:d==null?void 0:d.root.id,unitId:t,subUnitId:r}})},autoFocus:N||!d,onCancel:()=>{d||u==null||u()}})):null)},Y={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"},Re=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:a,onResolve:s,sortComments:h,onItemLeave:u,onItemEnter:I}=n,[S,N]=i.useState("all"),[y,E]=i.useState("all"),v=T.useDependency(c.LocaleService),b=T.useDependency(c.UserManagerService),f=T.useDependency(C.ThreadCommentModel),[O,k]=i.useState(()=>f.getUnit(e)),d=T.useDependency(m.ThreadCommentPanelService),p=H.useObservable(d.activeCommentId$),A=H.useObservable(f.commentUpdate$),$=T.useDependency(c.ICommandService),P=H.useObservable(t),w=b.getCurrentUser(),W=i.useRef(!0),G="panel",j=i.useMemo(()=>{var l,M;if(S==="all"){const D=O.map(F=>F[1]).flat().filter(F=>!F.parentId);return h?h(D):D}else return(M=(l=O.find(D=>D[0]===P))==null?void 0:l[1])!=null?M:[]},[S,O,P,h]),V=i.useMemo(()=>y==="resolved"?j.filter(l=>l.resolved):y==="unsolved"?j.filter(l=>!l.resolved):y==="concern_me"&&w!=null&&w.userID?j.map(l=>f.getCommentWithChildren(l.unitId,l.subUnitId,l.id)).map(l=>l!=null&&l.relativeUsers.has(w.userID)?l.root:null).filter(Boolean):j,[j,w==null?void 0:w.userID,y,f]),q=y!=="all"||S!=="all",J=()=>{E("all"),N("all")};return i.useEffect(()=>{e&&k(f.getUnit(e))},[e,f,A]),i.useEffect(()=>{var fe;if(!p)return;if(!W.current){W.current=!0;return}const{unitId:l,subUnitId:M,commentId:D}=p,F=`${G}-${l}-${M}-${D}`;(fe=document.getElementById(F))==null||fe.scrollIntoView({block:"center"})},[p]),i.createElement("div",{className:Y.threadCommentPanel},i.createElement("div",{className:Y.threadCommentPanelForms},i.createElement(_.Select,{borderless:!0,value:S,onChange:l=>N(l),options:[{value:"current",label:v.t("threadCommentUI.filter.sheet.current")},{value:"all",label:v.t("threadCommentUI.filter.sheet.all")}]}),i.createElement(_.Select,{borderless:!0,value:y,onChange:l=>E(l),options:[{value:"all",label:v.t("threadCommentUI.filter.status.all")},{value:"resolved",label:v.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:v.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:v.t("threadCommentUI.filter.status.concernMe")}]})),V==null?void 0:V.map(l=>i.createElement(ve,{prefix:G,getSubUnitName:a,key:l.id,id:l.id,unitId:l.unitId,subUnitId:l.subUnitId,type:r,showEdit:(p==null?void 0:p.commentId)===l.id,showHighlight:(p==null?void 0:p.commentId)===l.id,onClick:()=>{W.current=!1,$.executeCommand(X.id,{unitId:l.unitId,subUnitId:l.subUnitId,commentId:l.id,temp:!0})},onClose:()=>s==null?void 0:s(l.id),onMouseEnter:()=>I==null?void 0:I(l),onMouseLeave:()=>u==null?void 0:u(l)})),V.length?null:i.createElement("div",{className:Y.threadCommentPanelEmpty},q?v.t("threadCommentUI.panel.filterEmpty"):v.t("threadCommentUI.panel.empty"),q?i.createElement(_.Button,{onClick:J,type:"link"},v.t("threadCommentUI.panel.reset")):i.createElement(_.Button,{id:"thread-comment-add",className:Y.threadCommentPanelAdd,type:"primary",onClick:o},i.createElement(Ae,null),v.t("threadCommentUI.panel.addComment"))))};m.IThreadCommentMentionDataService=R,m.SetActiveCommentOperation=X,m.THREAD_COMMENT_PANEL=ee,m.ThreadCommentPanel=Re,m.ThreadCommentTree=ve,m.ToggleSheetCommentPanelOperation=ne,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
1
+ (function(m,C){typeof exports=="object"&&typeof module<"u"?C(exports,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("dayjs"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/thread-comment","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@wendellhu/redi/react-bindings","@univerjs/design","dayjs","clsx"],C):(m=typeof globalThis<"u"?globalThis:m||self,C(m.UniverThreadCommentUi={},m.UniverThreadComment,m.UniverCore,m["@wendellhu/redi"],m.UniverUi,m.rxjs,m.React,m["@wendellhu/redi/react-bindings"],m.UniverDesign,m.dayjs,m.clsx))})(this,function(m,C,c,W,H,Q,i,T,_,ge,pe){"use strict";var Re=Object.defineProperty;var et=(m,C,c)=>C in m?Re(m,C,{enumerable:!0,configurable:!0,writable:!0,value:c}):m[C]=c;var x=(m,C,c)=>(et(m,typeof C!="symbol"?C+"":C,c),c);var K;const ee="thread-comment-panel",Ie="thread-comment-ui-plugin";var Se=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Ee=(n,e,t,r)=>{for(var o=r>1?void 0:r?ye(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&Se(e,t,o),o},te=(n,e)=>(t,r)=>e(t,r,n);m.ThreadCommentPanelService=class extends c.Disposable{constructor(t,r){super();x(this,"_panelVisible",!1);x(this,"_panelVisible$",new Q.BehaviorSubject(!1));x(this,"_activeCommentId");x(this,"_activeCommentId$",new Q.BehaviorSubject(void 0));x(this,"panelVisible$",this._panelVisible$.asObservable());x(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init()}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).pipe(Q.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)}},m.ThreadCommentPanelService=Ee([te(0,W.Inject(H.ISidebarService)),te(1,c.IUniverInstanceService)],m.ThreadCommentPanelService);const ne={id:"thread-comment-ui.operation.toggle-panel",type:c.CommandType.OPERATION,handler(n){const e=n.get(H.ISidebarService),t=n.get(m.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:ee},width:320}),t.setPanelVisible(!0)),!0}},X={id:"thread-comment-ui.operation.set-active-comment",type:c.CommandType.OPERATION,handler(n,e){return n.get(m.ThreadCommentPanelService).setActiveComment(e),!0}};var be=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,_e=(n,e,t,r)=>{for(var o=r>1?void 0:r?Te(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&be(e,t,o),o},Ue=(n,e)=>(t,r)=>e(t,r,n);let B=class extends c.Disposable{constructor(n){super(),this._localeService=n}};B=_e([c.OnLifecycle(c.LifecycleStages.Starting,B),Ue(0,W.Inject(c.LocaleService))],B);class Pe{constructor(){x(this,"trigger","@")}async getMentions(e){return[]}}const R=W.createIdentifier("thread-comment.mention-data.service");var Me=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Ne=(n,e,t,r)=>{for(var o=r>1?void 0:r?xe(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&Me(e,t,o),o},re=(n,e)=>(t,r)=>e(t,r,n);m.UniverThreadCommentUIPlugin=(K=class extends C.UniverThreadCommentPlugin{constructor(t,r,o){super(t,r,o);x(this,"_config1");this._injector=r,this._commandService=o,this._config1=t}onStarting(t){super.onStarting(t),c.mergeOverrideWithDependencies([[B],[m.ThreadCommentPanelService],[R,{useClass:Pe}]],this._config1.overrides).forEach(r=>{t.add(r)}),[ne,X].forEach(r=>{this._commandService.registerCommand(r)})}},x(K,"pluginName",Ie),x(K,"type",c.UniverInstanceType.UNIVER_UNKNOWN),K),m.UniverThreadCommentUIPlugin=Ne([re(1,W.Inject(W.Injector)),re(2,c.ICommandService)],m.UniverThreadCommentUIPlugin);var U=function(){return U=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},U.apply(this,arguments)},Oe=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},L=i.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,a=n.extend,s=Oe(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),u=i.useRef("_".concat(He()));return ie(t,"".concat(r),{defIds:t.defIds,idSuffix:u.current},U({ref:e,className:h},s),a)});function ie(n,e,t,r,o){return i.createElement(n.tag,U(U({key:e},we(n,t,o)),r),(De(n,t).children||[]).map(function(a,s){return ie(a,"".concat(e,"-").concat(n.tag,"-").concat(s),t,void 0,o)}))}function we(n,e,t){var r=U({},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 s=a[0],h=a[1];typeof h=="string"&&(r[s]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function De(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)?U(U({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?U(U({},o),{attrs:U(U({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function He(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var $e={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"}}]},oe=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"delete-single",ref:e,icon:$e}))});oe.displayName="DeleteSingle";const je=oe;var Le={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"}}]},ae=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"increase-single",ref:e,icon:Le}))});ae.displayName="IncreaseSingle";const ke=ae;var Ae={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"}}]},le=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Ae}))});le.displayName="MoreHorizontalSingle";const Ve=le;var We={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}}]},me=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:We}))});me.displayName="ReplyToCommentSingle";const qe=me;var ze={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"}}]},se=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"resolved-single",ref:e,icon:ze}))});se.displayName="ResolvedSingle";const Fe=se;var Be={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}}]},de=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"solve-single",ref:e,icon:Be}))});de.displayName="SolveSingle";const Ze=de,Z={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"},Ye=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},Ke=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),ce=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let a=0;return t==null||t.forEach(s=>{a<s.startIndex&&o.push({type:"text",content:e.slice(a,s.startIndex)}),o.push({type:"mention",content:{label:e.slice(s.startIndex,s.endIndex).slice(1,-1),id:s.rangeId}}),a=s.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}},Ge=n=>({display:n.label,id:`${n.id}`,raw:n}),Je=(n,e,t,r,o)=>{var s,h;const a=(s=n.raw)==null?void 0:s.icon;return i.createElement("div",{className:Z.threadCommentEditorSuggestion},a?i.createElement("img",{className:Z.threadCommentEditorSuggestionIcon,src:a}):null,i.createElement("div",null,(h=n.display)!=null?h:n.id))},he=i.forwardRef((n,e)=>{var v;const{comment:t,onSave:r,id:o,onCancel:a,autoFocus:s}=n,h=T.useDependency(R),u=T.useDependency(c.LocaleService),[I,S]=i.useState({...t}),[N,y]=i.useState(!1),E=i.useRef(null);return i.useImperativeHandle(e,()=>({reply(b){var f;S({...t,text:b,attachments:[]}),(f=E.current)==null||f.inputElement.focus()}})),i.createElement("div",{className:Z.threadCommentEditor,onClick:b=>b.preventDefault()},i.createElement(_.Mentions,{ref:E,autoFocus:s,style:{width:"100%"},placeholder:u.t("threadCommentUI.editor.placeholder"),value:I!=null&&I.text?Ke(ce(I.text)):"",onChange:b=>{b.target.value||S({...t,text:void 0}),S==null||S({...t,text:ue(Ye(b.target.value))})},onFocus:()=>{y(!0)}},i.createElement(_.Mention,{key:h.trigger,trigger:h.trigger,data:(b,f)=>h.getMentions(b).then(O=>O.map(Ge)).then(f),displayTransform:(b,f)=>`@${f} `,renderSuggestion:(v=h.renderSuggestion)!=null?v:Je})),N?i.createElement("div",{className:Z.threadCommentEditorButtons},i.createElement(_.Button,{style:{marginRight:12},onClick:()=>{a==null||a(),y(!1),S({text:void 0})}},u.t("threadCommentUI.editor.cancel")),i.createElement(_.Button,{type:"primary",disabled:!I.text,onClick:()=>{I.text&&(r==null||r({...I,text:I.text}),y(!1),S({text:void 0}))}},u.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),g={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",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"},Ce="__mock__",Qe=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:a,onReply:s,resolved:h,isRoot:u,onClose:I}=n,S=T.useDependency(c.ICommandService),N=T.useDependency(c.LocaleService),y=T.useDependency(c.UserManagerService),E=y.getUser(e.personId),v=H.useObservable(y.currentUser$),b=(v==null?void 0:v.userID)===e.personId,f=e.id===Ce,[O,k]=i.useState(!1),d=()=>{S.executeCommand(u?C.DeleteCommentTreeCommand.id:C.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),u&&(I==null||I())};return i.createElement("div",{className:g.threadCommentItem,onMouseLeave:()=>k(!1),onMouseEnter:()=>k(!0)},i.createElement("img",{className:g.threadCommentItemHead,src:E==null?void 0:E.avatar}),i.createElement("div",{className:g.threadCommentItemTitle},i.createElement("div",{className:g.threadCommentUsername},(E==null?void 0:E.name)||" "),i.createElement("div",null,f||h?null:O?i.createElement("div",{className:g.threadCommentIcon,onClick:()=>s(E)},i.createElement(qe,null)):null,b&&!f&&!h?i.createElement(_.Dropdown,{overlay:i.createElement(_.Menu,null,i.createElement(_.MenuItem,{key:"edit",onClick:()=>a==null?void 0:a(!0)},N.t("threadCommentUI.item.edit")),i.createElement(_.MenuItem,{key:"delete",onClick:d},N.t("threadCommentUI.item.delete")))},i.createElement("div",{className:g.threadCommentIcon},i.createElement(Ve,null))):null)),i.createElement("div",{className:g.threadCommentItemTime},e.dT),o?i.createElement(he,{id:e.id,comment:e,onCancel:()=>a==null?void 0:a(!1),autoFocus:!0,onSave:({text:p,attachments:A})=>{a==null||a(!1),S.executeCommand(C.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:p,attachments:A}})}}):i.createElement("div",{className:g.threadCommentItemContent},ce(e.text).map((p,A)=>{switch(p.type){case"mention":return i.createElement("a",{className:g.threadCommentItemAt,key:A},"@",p.content.label," ");default:return p.content}})))},ve=n=>{var V,z,J;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:a=!0,onClick:s,showHighlight:h,onClose:u,getSubUnitName:I,prefix:S,autoFocus:N,onMouseEnter:y,onMouseLeave:E}=n,v=T.useDependency(C.ThreadCommentModel),[b,f]=i.useState(!1),[O,k]=i.useState("");H.useObservable(v.commentMap$);const d=e?v.getCommentWithChildren(t,r,e):null,p=T.useDependency(c.ICommandService),A=T.useDependency(c.UserManagerService),$=d==null?void 0:d.root.resolved,P=H.useObservable(A.currentUser$),w=i.useRef(null),q=[...d?[d.root]:[{id:Ce,text:{dataStream:`
3
+ \r`},personId:(V=P==null?void 0:P.userID)!=null?V:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r}],...(z=d==null?void 0:d.children)!=null?z:[]],G=()=>{p.executeCommand(C.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!$}),u==null||u()},j=()=>{p.executeCommand(C.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),u==null||u()};return i.createElement("div",{className:pe(g.threadComment,{[g.threadCommentActive]:!$&&(h||b||S==="cell")}),onClick:s,id:`${S}-${t}-${r}-${e}`,onMouseEnter:()=>{y==null||y(),f(!0)},onMouseLeave:()=>{E==null||E(),f(!1)}},!$&&h?i.createElement("div",{className:g.threadCommentHighlight}):null,i.createElement("div",{className:g.threadCommentTitle},i.createElement("div",{className:g.threadCommentTitlePosition},i.createElement("div",{className:g.threadCommentTitleHighlight}),o||(d==null?void 0:d.root.ref)," · ",I((J=d==null?void 0:d.root.subUnitId)!=null?J:r)),d?i.createElement("div",{className:g.threadCommentIconContainer},i.createElement("div",{onClick:G,className:g.threadCommentIcon,style:{color:$?"rgb(var(--green-500))":""}},$?i.createElement(Fe,null):i.createElement(Ze,null)),(P==null?void 0:P.userID)===d.root.personId?i.createElement("div",{className:g.threadCommentIcon,onClick:j},i.createElement(je,null)):null):null),i.createElement("div",{className:g.threadCommentContent},q.map(l=>i.createElement(Qe,{onClose:u,unitId:t,subUnitId:r,item:l,key:l.id,isRoot:l.id===(d==null?void 0:d.root.id),editing:O===l.id,resolved:d==null?void 0:d.root.resolved,onEditingChange:M=>{k(M?l.id:"")},onReply:M=>{var D;M&&((D=w.current)==null||D.reply(ue([{type:"mention",content:{id:M.userID,label:M.name}}])))}}))),a&&!O&&!$?i.createElement("div",null,i.createElement(he,{key:`${N}`,ref:w,onSave:({text:l,attachments:M})=>{p.executeCommand(C.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:{text:l,attachments:M,dT:ge().format("YYYY/MM/DD HH:mm"),id:c.Tools.generateRandomId(),ref:o,personId:P==null?void 0:P.userID,parentId:d==null?void 0:d.root.id,unitId:t,subUnitId:r}})},autoFocus:N||!d,onCancel:()=>{d||u==null||u()}})):null)},Y={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"},Xe=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:a,onResolve:s,sortComments:h,onItemLeave:u,onItemEnter:I}=n,[S,N]=i.useState("all"),[y,E]=i.useState("all"),v=T.useDependency(c.LocaleService),b=T.useDependency(c.UserManagerService),f=T.useDependency(C.ThreadCommentModel),[O,k]=i.useState(()=>f.getUnit(e)),d=T.useDependency(m.ThreadCommentPanelService),p=H.useObservable(d.activeCommentId$),A=H.useObservable(f.commentUpdate$),$=T.useDependency(c.ICommandService),P=H.useObservable(t),w=b.currentUser,q=i.useRef(!0),G="panel",j=i.useMemo(()=>{var l,M;if(S==="all"){const D=O.map(F=>F[1]).flat().filter(F=>!F.parentId);return h?h(D):D}else return(M=(l=O.find(D=>D[0]===P))==null?void 0:l[1])!=null?M:[]},[S,O,P,h]),V=i.useMemo(()=>y==="resolved"?j.filter(l=>l.resolved):y==="unsolved"?j.filter(l=>!l.resolved):y==="concern_me"&&w!=null&&w.userID?j.map(l=>f.getCommentWithChildren(l.unitId,l.subUnitId,l.id)).map(l=>l!=null&&l.relativeUsers.has(w.userID)?l.root:null).filter(Boolean):j,[j,w==null?void 0:w.userID,y,f]),z=y!=="all"||S!=="all",J=()=>{E("all"),N("all")};return i.useEffect(()=>{e&&k(f.getUnit(e))},[e,f,A]),i.useEffect(()=>{var fe;if(!p)return;if(!q.current){q.current=!0;return}const{unitId:l,subUnitId:M,commentId:D}=p,F=`${G}-${l}-${M}-${D}`;(fe=document.getElementById(F))==null||fe.scrollIntoView({block:"center"})},[p]),i.createElement("div",{className:Y.threadCommentPanel},i.createElement("div",{className:Y.threadCommentPanelForms},i.createElement(_.Select,{borderless:!0,value:S,onChange:l=>N(l),options:[{value:"current",label:v.t("threadCommentUI.filter.sheet.current")},{value:"all",label:v.t("threadCommentUI.filter.sheet.all")}]}),i.createElement(_.Select,{borderless:!0,value:y,onChange:l=>E(l),options:[{value:"all",label:v.t("threadCommentUI.filter.status.all")},{value:"resolved",label:v.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:v.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:v.t("threadCommentUI.filter.status.concernMe")}]})),V==null?void 0:V.map(l=>i.createElement(ve,{prefix:G,getSubUnitName:a,key:l.id,id:l.id,unitId:l.unitId,subUnitId:l.subUnitId,type:r,showEdit:(p==null?void 0:p.commentId)===l.id,showHighlight:(p==null?void 0:p.commentId)===l.id,onClick:()=>{q.current=!1,$.executeCommand(X.id,{unitId:l.unitId,subUnitId:l.subUnitId,commentId:l.id,temp:!0})},onClose:()=>s==null?void 0:s(l.id),onMouseEnter:()=>I==null?void 0:I(l),onMouseLeave:()=>u==null?void 0:u(l)})),V.length?null:i.createElement("div",{className:Y.threadCommentPanelEmpty},z?v.t("threadCommentUI.panel.filterEmpty"):v.t("threadCommentUI.panel.empty"),z?i.createElement(_.Button,{onClick:J,type:"link"},v.t("threadCommentUI.panel.reset")):i.createElement(_.Button,{id:"thread-comment-add",className:Y.threadCommentPanelAdd,type:"primary",onClick:o},i.createElement(ke,null),v.t("threadCommentUI.panel.addComment"))))};m.IThreadCommentMentionDataService=R,m.SetActiveCommentOperation=X,m.THREAD_COMMENT_PANEL=ee,m.ThreadCommentPanel=Xe,m.ThreadCommentTree=ve,m.ToggleSheetCommentPanelOperation=ne,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/thread-comment-ui",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "private": false,
5
5
  "description": "Univer common thread comment UI plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -32,6 +32,7 @@
32
32
  "require": "./lib/cjs/*",
33
33
  "types": "./lib/types/index.d.ts"
34
34
  },
35
+ "./locale/*": "./lib/locale/*.json",
35
36
  "./lib/*": "./lib/*"
36
37
  },
37
38
  "main": "./lib/cjs/index.js",
@@ -52,15 +53,15 @@
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/core": "0.1.12",
56
- "@univerjs/design": "0.1.12",
57
- "@univerjs/thread-comment": "0.1.12",
58
- "@univerjs/ui": "0.1.12"
56
+ "@univerjs/core": "0.1.13",
57
+ "@univerjs/design": "0.1.13",
58
+ "@univerjs/thread-comment": "0.1.13",
59
+ "@univerjs/ui": "0.1.13"
59
60
  },
60
61
  "dependencies": {
61
- "@univerjs/icons": "^0.1.52",
62
- "@univerjs/protocol": "^0.1.32",
63
- "@univerjs/thread-comment": "0.1.12"
62
+ "@univerjs/icons": "^0.1.55",
63
+ "@univerjs/protocol": "^0.1.34",
64
+ "@univerjs/thread-comment": "0.1.13"
64
65
  },
65
66
  "devDependencies": {
66
67
  "@wendellhu/redi": "0.15.2",
@@ -70,12 +71,12 @@
70
71
  "react": "18.2.0",
71
72
  "rxjs": "^7.8.1",
72
73
  "typescript": "^5.4.5",
73
- "vite": "^5.2.11",
74
+ "vite": "^5.2.12",
74
75
  "vitest": "^1.6.0",
75
- "@univerjs/core": "0.1.12",
76
- "@univerjs/design": "0.1.12",
77
- "@univerjs/ui": "0.1.12",
78
- "@univerjs/shared": "0.1.12"
76
+ "@univerjs/core": "0.1.13",
77
+ "@univerjs/design": "0.1.13",
78
+ "@univerjs/ui": "0.1.13",
79
+ "@univerjs/shared": "0.1.13"
79
80
  },
80
81
  "scripts": {
81
82
  "test": "vitest run",
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright 2023-present DreamNum Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export { default as enUS } from './en-US';
17
- export { default as zhCN } from './zh-CN';
18
- export { default as ruRU } from './ru-RU';