@univerjs/thread-comment-ui 0.10.12 → 0.10.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 +4 -4
- package/lib/es/index.js +603 -410
- package/lib/index.js +603 -410
- package/lib/umd/index.js +4 -4
- package/package.json +8 -8
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/thread-comment"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/thread-comment","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverThreadCommentUi={},u.UniverCore,u.UniverUi,u.rxjs,u.UniverThreadComment,u.React,u.UniverDesign,u.React,u.UniverDocsUi))})(this,(function(u,a,m,X,B,s,U,d,se){"use strict";var Ke=Object.defineProperty;var Ge=(u,a,m)=>a in u?Ke(u,a,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[a]=m;var Y=(u,a,m)=>Ge(u,typeof a!="symbol"?a+"":a,m);var Se=Object.getOwnPropertyDescriptor,we=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,o=n.length-1,v;o>=0;o--)(v=n[o])&&(i=v(i)||i);return i},oe=(n,e)=>(t,r)=>e(t,r,n);u.ThreadCommentPanelService=class extends a.Disposable{constructor(t,r){super();Y(this,"_panelVisible",!1);Y(this,"_panelVisible$",new X.BehaviorSubject(!1));Y(this,"_activeCommentId");Y(this,"_activeCommentId$",new X.BehaviorSubject(void 0));Y(this,"panelVisible$",this._panelVisible$.asObservable());Y(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(X.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)}},u.ThreadCommentPanelService=we([oe(0,a.Inject(m.ISidebarService)),oe(1,a.IUniverInstanceService)],u.ThreadCommentPanelService);const le="thread-comment-panel",_e="UNIVER_THREAD_COMMENT_UI_PLUGIN",de={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(m.ISidebarService),t=n.get(u.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:le},width:330}),t.setPanelVisible(!0)),!0}},q={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(u.ThreadCommentPanelService).setActiveComment(e),!0}},Te="thread-comment-ui.config",ce={};var Ne=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Oe=(n,e,t)=>e in n?Ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,De=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ue(e,t):e,o=n.length-1,v;o>=0;o--)(v=n[o])&&(i=v(i)||i);return i},ae=(n,e)=>(t,r)=>e(t,r,n),ue=(n,e,t)=>Oe(n,typeof e!="symbol"?e+"":e,t);u.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ce,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:o,...v}=a.merge({},ce,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Te,v)}onStarting(){var e;a.mergeOverrideWithDependencies([[u.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[de,q].forEach(t=>{this._commandService.registerCommand(t)})}},ue(u.UniverThreadCommentUIPlugin,"pluginName",_e),ue(u.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),u.UniverThreadCommentUIPlugin=De([a.DependentOn(B.UniverThreadCommentPlugin),ae(1,a.Inject(a.Injector)),ae(2,a.ICommandService),ae(3,a.IConfigService)],u.UniverThreadCommentUIPlugin);var E=function(){return E=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},E.apply(this,arguments)},Ee=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},K=d.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,o=n.extend,v=Ee(n,["icon","id","className","extend"]),g="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),I=d.useRef("_".concat(je()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:I.current},E({ref:e,className:g},v),o)});function ve(n,e,t,r,i){return d.createElement(n.tag,E(E({key:e},ke(n,t,i)),r),(Me(n,t).children||[]).map(function(o,v){return ve(o,"".concat(e,"-").concat(n.tag,"-").concat(v),t,void 0,i)}))}function ke(n,e,t){var r=E({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(o){var v=o[0],g=o[1];v==="mask"&&typeof g=="string"&&(r[v]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(o){var v=o[0],g=o[1];typeof g=="string"&&(r[v]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Me(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)?E(E({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?E(E({},i),{attrs:E(E({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function je(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.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.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.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"}}]},me=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"delete-icon",ref:e,icon:Pe}))});me.displayName="DeleteIcon";var $e={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"increase-icon",ref:e,icon:$e}))});fe.displayName="IncreaseIcon";var Le={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z"}}]},he=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"more-horizontal-icon",ref:e,icon:Le}))});he.displayName="MoreHorizontalIcon";var He={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.76813",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M8.91626 6.1311H9.27424",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},pe=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"reply-to-comment-icon",ref:e,icon:He}))});pe.displayName="ReplyToCommentIcon";var Ve={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},Ce=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"resolved-icon",ref:e,icon:Ve}))});Ce.displayName="ResolvedIcon";var Be={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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}}]},ge=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"solve-icon",ref:e,icon:Be}))});ge.displayName="SolveIcon";function Ie(n){return{id:"d",body:n,documentStyle:{}}}const be=d.forwardRef((n,e)=>{var H;const{comment:t,onSave:r,id:i,onCancel:o,autoFocus:v,unitId:g,type:I}=n,O=m.useDependency(a.ICommandService),k=m.useDependency(a.LocaleService),[Z,M]=d.useState(!1),w=m.useDependency(se.IEditorService),h=d.useRef(null),p=I===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:g,[j,_]=d.useState(()=>{var f,C,b;return a.BuildTextUtils.transform.getPlainText((b=(C=(f=h.current)==null?void 0:f.getDocumentData().body)==null?void 0:C.dataStream)!=null?b:"")});d.useEffect(()=>{var C,b,T,x;_(a.BuildTextUtils.transform.getPlainText((T=(b=(C=h.current)==null?void 0:C.getDocumentData().body)==null?void 0:b.dataStream)!=null?T:""));const f=(x=h.current)==null?void 0:x.selectionChange$.subscribe(()=>{var l,N,G;_(a.BuildTextUtils.transform.getPlainText((G=(N=(l=h.current)==null?void 0:l.getDocumentData().body)==null?void 0:N.dataStream)!=null?G:""))});return()=>f==null?void 0:f.unsubscribe()},[(H=h.current)==null?void 0:H.selectionChange$]);const F=d.useMemo(()=>({keyCodes:[{keyCode:m.KeyCode.ENTER}],handler:f=>{f===m.KeyCode.ENTER&&O.executeCommand(se.BreakLineCommand.id)}}),[O]);d.useImperativeHandle(e,()=>({reply(f){var b,T;if(!h.current)return;w.focus((b=h.current.getEditorId())!=null?b:"");const C=Ie(f);(T=h.current)==null||T.setDocumentData(C,[{startOffset:C.body.dataStream.length-2,endOffset:C.body.dataStream.length-2,collapsed:!0}])}}));const y=()=>{if(h.current){const f=a.Tools.deepClone(h.current.getDocumentData().body);M(!1),r==null||r({...t,text:f}),h.current.replaceText(""),setTimeout(()=>{var C,b;(C=h.current)==null||C.setSelectionRanges([]),(b=h.current)==null||b.blur()},10)}};return s.jsxs("div",{onClick:f=>f.preventDefault(),children:[s.jsx(se.RichTextEditor,{className:"univer-w-full",editorRef:h,autoFocus:v,keyboardEventConfig:F,placeholder:k.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&Ie(t.text),onFocusChange:f=>f&&M(f),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{w.focus(p)},30)}}),Z?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[s.jsx(U.Button,{onClick:()=>{var f;o==null||o(),M(!1),(f=h.current)==null||f.replaceText("",!0),O.executeCommand(q.id)},children:k.t("threadCommentUI.editor.cancel")}),s.jsx(U.Button,{variant:"primary",disabled:!j,onClick:y,children:k.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
|
|
2
|
-
`)?e.length-2:e.length,
|
|
3
|
-
`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},
|
|
4
|
-
\r`},personId:(
|
|
1
|
+
(function(u,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/thread-comment"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/thread-comment","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u.UniverThreadCommentUi={},u.UniverCore,u.UniverUi,u.rxjs,u.UniverThreadComment,u.React,u.UniverDesign,u.React,u.UniverDocsUi))})(this,(function(u,s,m,Q,V,i,U,d,ie){"use strict";var Fe=Object.defineProperty;var qe=(u,s,m)=>s in u?Fe(u,s,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[s]=m;var z=(u,s,m)=>qe(u,typeof s!="symbol"?s+"":s,m);var ye=Object.getOwnPropertyDescriptor,Se=(r,e,t,n)=>{for(var o=n>1?void 0:n?ye(e,t):e,l=r.length-1,v;l>=0;l--)(v=r[l])&&(o=v(o)||o);return o},oe=(r,e)=>(t,n)=>e(t,n,r);u.ThreadCommentPanelService=class extends s.Disposable{constructor(t,n){super();z(this,"_panelVisible",!1);z(this,"_panelVisible$",new Q.BehaviorSubject(!1));z(this,"_activeCommentId");z(this,"_activeCommentId$",new Q.BehaviorSubject(void 0));z(this,"panelVisible$",this._panelVisible$.asObservable());z(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=n,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.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)}},u.ThreadCommentPanelService=Se([oe(0,s.Inject(m.ISidebarService)),oe(1,s.IUniverInstanceService)],u.ThreadCommentPanelService);const le="thread-comment-panel",we="UNIVER_THREAD_COMMENT_UI_PLUGIN",ae={id:"thread-comment-ui.operation.toggle-panel",type:s.CommandType.OPERATION,handler(r){const e=r.get(m.ISidebarService),t=r.get(u.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:le},width:330}),t.setPanelVisible(!0)),!0}},F={id:"thread-comment-ui.operation.set-active-comment",type:s.CommandType.OPERATION,handler(r,e){return r.get(u.ThreadCommentPanelService).setActiveComment(e),!0}},_e="thread-comment-ui.config",de={};var Te=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Ue=(r,e,t)=>e in r?Te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,De=(r,e,t,n)=>{for(var o=n>1?void 0:n?Ne(e,t):e,l=r.length-1,v;l>=0;l--)(v=r[l])&&(o=v(o)||o);return o},se=(r,e)=>(t,n)=>e(t,n,r),ce=(r,e,t)=>Ue(r,typeof e!="symbol"?e+"":e,t);u.UniverThreadCommentUIPlugin=class extends s.Plugin{constructor(e=de,t,n,o){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=o;const{menu:l,...v}=s.merge({},de,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(_e,v)}onStarting(){var e;s.mergeOverrideWithDependencies([[u.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[ae,F].forEach(t=>{this._commandService.registerCommand(t)})}},ce(u.UniverThreadCommentUIPlugin,"pluginName",we),ce(u.UniverThreadCommentUIPlugin,"type",s.UniverInstanceType.UNIVER_UNKNOWN),u.UniverThreadCommentUIPlugin=De([s.DependentOn(V.UniverThreadCommentPlugin),se(1,s.Inject(s.Injector)),se(2,s.ICommandService),se(3,s.IConfigService)],u.UniverThreadCommentUIPlugin);function q({ref:r,...e}){const{icon:t,id:n,className:o,extend:l,...v}=e,S=`univerjs-icon univerjs-icon-${n} ${o||""}`.trim(),g=d.useRef(`_${ke()}`);return ue(t,`${n}`,{defIds:t.defIds,idSuffix:g.current},{ref:r,className:S,...v},l)}function ue(r,e,t,n,o){return d.createElement(r.tag,{key:e,...$e(r,t,o),...n},(Ee(r,t).children||[]).map((l,v)=>ue(l,`${e}-${r.tag}-${v}`,t,void 0,o)))}function $e(r,e,t){const n={...r.attrs};t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(([l,v])=>{l==="mask"&&typeof v=="string"&&(n[l]=v.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(([l,v])=>{typeof v=="string"&&(n[l]=v.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),n}function Ee(r,e){var n;const{defIds:t}=e;return!t||t.length===0?r:r.tag==="defs"&&((n=r.children)!=null&&n.length)?{...r,children:r.children.map(o=>typeof o.attrs.id=="string"&&t&&t.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:r}function ke(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";const Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.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.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.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"}}]},ve=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"delete-icon",ref:t,icon:Me}))});ve.displayName="DeleteIcon";const Oe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},me=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"increase-icon",ref:t,icon:Oe}))});me.displayName="IncreaseIcon";const je={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z"}}]},he=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"more-horizontal-icon",ref:t,icon:je}))});he.displayName="MoreHorizontalIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.76813",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M8.91626 6.1311H9.27424",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},fe=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"reply-to-comment-icon",ref:t,icon:Pe}))});fe.displayName="ReplyToCommentIcon";const Le={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},pe=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"resolved-icon",ref:t,icon:Le}))});pe.displayName="ResolvedIcon";const He={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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=d.forwardRef(function(e,t){return d.createElement(q,Object.assign({},e,{id:"solve-icon",ref:t,icon:He}))});Ce.displayName="SolveIcon";function ge(r){return{id:"d",body:r,documentStyle:{}}}const Ie=d.forwardRef((r,e)=>{var L;const{comment:t,onSave:n,id:o,onCancel:l,autoFocus:v,unitId:S,type:g}=r,D=m.useDependency(s.ICommandService),E=m.useDependency(s.LocaleService),[W,k]=d.useState(!1),w=m.useDependency(ie.IEditorService),f=d.useRef(null),p=g===s.UniverInstanceType.UNIVER_DOC?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:S,[M,_]=d.useState(()=>{var h,C,I;return s.BuildTextUtils.transform.getPlainText((I=(C=(h=f.current)==null?void 0:h.getDocumentData().body)==null?void 0:C.dataStream)!=null?I:"")});d.useEffect(()=>{var C,I,T,b;_(s.BuildTextUtils.transform.getPlainText((T=(I=(C=f.current)==null?void 0:C.getDocumentData().body)==null?void 0:I.dataStream)!=null?T:""));const h=(b=f.current)==null?void 0:b.selectionChange$.subscribe(()=>{var a,N,K;_(s.BuildTextUtils.transform.getPlainText((K=(N=(a=f.current)==null?void 0:a.getDocumentData().body)==null?void 0:N.dataStream)!=null?K:""))});return()=>h==null?void 0:h.unsubscribe()},[(L=f.current)==null?void 0:L.selectionChange$]);const Z=d.useMemo(()=>({keyCodes:[{keyCode:m.KeyCode.ENTER}],handler:h=>{h===m.KeyCode.ENTER&&D.executeCommand(ie.BreakLineCommand.id)}}),[D]);d.useImperativeHandle(e,()=>({reply(h){var I,T;if(!f.current)return;w.focus((I=f.current.getEditorId())!=null?I:"");const C=ge(h);(T=f.current)==null||T.setDocumentData(C,[{startOffset:C.body.dataStream.length-2,endOffset:C.body.dataStream.length-2,collapsed:!0}])}}));const x=()=>{if(f.current){const h=s.Tools.deepClone(f.current.getDocumentData().body);k(!1),n==null||n({...t,text:h}),f.current.replaceText(""),setTimeout(()=>{var C,I;(C=f.current)==null||C.setSelectionRanges([]),(I=f.current)==null||I.blur()},10)}};return i.jsxs("div",{onClick:h=>h.preventDefault(),children:[i.jsx(ie.RichTextEditor,{className:"univer-w-full",editorRef:f,autoFocus:v,keyboardEventConfig:Z,placeholder:E.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&ge(t.text),onFocusChange:h=>h&&k(h),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{w.focus(p)},30)}}),W?i.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[i.jsx(U.Button,{onClick:()=>{var h;l==null||l(),k(!1),(h=f.current)==null||h.replaceText("",!0),D.executeCommand(F.id)},children:E.t("threadCommentUI.editor.cancel")}),i.jsx(U.Button,{variant:"primary",disabled:!M,onClick:x,children:E.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ve=r=>{const{dataStream:e,customRanges:t}=r,n=e.endsWith(`\r
|
|
2
|
+
`)?e.length-2:e.length,o=[];let l=0;return t==null||t.forEach(v=>{l<v.startIndex&&o.push({type:"text",content:e.slice(l,v.startIndex)}),o.push({type:"mention",content:{label:e.slice(v.startIndex,v.endIndex+1),id:v.rangeId}}),l=v.endIndex+1}),o.push({type:"text",content:e.slice(l,n)}),o},Be=r=>{const{paragraphs:e=[]}=r;let t=0;return e.map(n=>{const o=s.getBodySlice(r,t,n.startIndex);return t=n.startIndex+1,Ve(o)})},Ae=r=>{let e="";const t=[];return r.forEach(n=>{switch(n.type){case"text":e+=n.content;break;case"mention":{const o=e.length;e+=n.content.label;const l=e.length-1;t.push({rangeId:n.content.id,rangeType:s.CustomRangeType.MENTION,startIndex:o,endIndex:l,properties:{},wholeEntity:!0});break}}}),e+=`\r
|
|
3
|
+
`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},be="__mock__",We=r=>{const{item:e,unitId:t,subUnitId:n,editing:o,onEditingChange:l,onReply:v,resolved:S,isRoot:g,onClose:D,onDeleteComment:E,type:W}=r,k=m.useDependency(s.ICommandService),w=m.useDependency(s.LocaleService),f=m.useDependency(s.UserManagerService),p=f.getUser(e.personId),M=m.useObservable(f.currentUser$),_=(M==null?void 0:M.userID)===e.personId,Z=e.id===be,[x,L]=d.useState(!1),h=m.useConfigValue(m.UI_PLUGIN_CONFIG_KEY),C=h==null?void 0:h.avatarFallback,I=()=>{(E==null?void 0:E(e))!==!1&&(k.executeCommand(g?V.DeleteCommentTreeCommand.id:V.DeleteCommentCommand.id,{unitId:t,subUnitId:n,commentId:e.id}),g&&(D==null||D()))};return i.jsxs("div",{className:"univer-relative univer-mb-3 univer-pl-[30px]",onMouseLeave:()=>L(!1),onMouseEnter:()=>L(!0),children:[i.jsx("div",{className:"univer-absolute univer-left-0 univer-top-0 univer-h-6 univer-w-6 univer-rounded-full univer-bg-cover univer-bg-center univer-bg-no-repeat",style:{backgroundImage:`url(${(p==null?void 0:p.avatar)||C})`}}),p?i.jsxs("div",{className:"univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",children:[i.jsx("div",{className:"univer-text-sm univer-font-medium univer-leading-5",children:(p==null?void 0:p.name)||" "}),i.jsxs("div",{children:[Z||S?null:x&&p?i.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",onClick:()=>v(p),children:i.jsx(fe,{})}):null,_&&!Z&&!S?i.jsx(U.Dropdown,{overlay:i.jsx("div",{className:"univer-rounded-lg",children:i.jsxs("ul",{className:"univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors",children:[i.jsx("li",{children:i.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>l==null?void 0:l(!0),children:w.t("threadCommentUI.item.edit")})}),i.jsx("li",{children:i.jsx("a",{className:"hover:univer-bg-gray-200",onClick:I,children:w.t("threadCommentUI.item.delete")})})]})}),children:i.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",children:i.jsx(he,{})})}):null]})]}):null,i.jsx("time",{className:"univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",children:e.dT}),o?i.jsx(Ie,{type:W,id:e.id,comment:e,onCancel:()=>l==null?void 0:l(!1),autoFocus:!0,unitId:t,subUnitId:n,onSave:({text:T,attachments:b})=>{l==null||l(!1),k.executeCommand(V.UpdateCommentCommand.id,{unitId:t,subUnitId:n,payload:{commentId:e.id,text:T,attachments:b}})}}):i.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:Be(e.text).map((T,b)=>i.jsx("div",{className:"univer-break-words",children:T.map((a,N)=>{switch(a.type){case"mention":return i.jsxs("a",{className:"univer-text-primary-600",children:[a.content.label," "]},N);default:return a.content}})},b))})]})},xe=r=>{var re,J,c;const{id:e,unitId:t,subUnitId:n,refStr:o,showEdit:l=!0,onClick:v,showHighlight:S,onClose:g,getSubUnitName:D,prefix:E,autoFocus:W,onMouseEnter:k,onMouseLeave:w,onAddComment:f,onDeleteComment:p,onResolve:M,type:_,style:Z,full:x}=r,L=m.useDependency(V.ThreadCommentModel),[h,C]=d.useState(!1),[I,T]=d.useState(""),b=d.useMemo(()=>L.commentUpdate$.pipe(Q.debounceTime(16)),[L]);m.useObservable(b);const a=e?L.getCommentWithChildren(t,n,e):null,N=m.useDependency(s.ICommandService),K=m.useDependency(s.UserManagerService),O=a==null?void 0:a.root.resolved,j=m.useObservable(K.currentUser$),B=d.useRef(null),Y=[...a?[a.root]:[{id:be,text:{dataStream:`
|
|
4
|
+
\r`},personId:(re=j==null?void 0:j.userID)!=null?re:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:n,threadId:""}],...(J=a==null?void 0:a.children)!=null?J:[]],H=d.useRef(null),X=y=>{y.stopPropagation(),O?N.executeCommand(F.id,{unitId:t,subUnitId:n,commentId:e}):N.executeCommand(F.id),N.executeCommand(V.ResolveCommentCommand.id,{unitId:t,subUnitId:n,commentId:e,resolved:!O}),M==null||M(!O)},R=y=>{y.stopPropagation(),N.executeCommand(F.id),!(a!=null&&a.root&&(p==null?void 0:p(a.root))===!1)&&(N.executeCommand(V.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:n,commentId:e}),g==null||g())};d.useEffect(()=>w==null?void 0:w(),[]);const ee=D((c=a==null?void 0:a.root.subUnitId)!=null?c:n),te=l&&!I&&!O,ne=`${o||(a==null?void 0:a.root.ref)||""}${ee?" · ":""}${ee}`;return i.jsxs("div",{id:`${E}-${t}-${n}-${e}`,className:U.clsx("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white",U.borderClassName,{"univer-w-[278px]":!x,"univer-w-full":x,"univer-shadow":!O&&(S||h||E==="cell")}),style:Z,onClick:v,onMouseEnter:()=>{k==null||k(),C(!0)},onMouseLeave:()=>{w==null||w(),C(!1)},children:[!O&&S&&i.jsx("div",{className:"univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400"}),i.jsxs("div",{className:"univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5",children:[i.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",children:[i.jsx("div",{className:"univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500"}),i.jsx(U.Tooltip,{showIfEllipsis:!0,title:ne,children:i.jsx("div",{className:"univer-flex-1 univer-truncate",children:ne})})]}),!!a&&i.jsxs("div",{className:"univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",children:[i.jsx("div",{className:U.clsx("univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800",{"univer-text-green-500":O}),onClick:X,children:O?i.jsx(pe,{}):i.jsx(Ce,{})}),(j==null?void 0:j.userID)===a.root.personId?i.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800",onClick:R,children:i.jsx(ve,{})}):null]})]}),i.jsx("div",{ref:H,className:U.clsx("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",U.scrollbarClassName),children:Y.map(y=>i.jsx(We,{unitId:t,subUnitId:n,item:y,isRoot:y.id===(a==null?void 0:a.root.id),editing:I===y.id,resolved:a==null?void 0:a.root.resolved,type:_,onClose:g,onEditingChange:P=>{T(P?y.id:"")},onReply:P=>{P&&requestAnimationFrame(()=>{var A;(A=B.current)==null||A.reply(Ae([{type:"mention",content:{id:P.userID,label:`@${P.name}`}},{type:"text",content:" "}]))})},onAddComment:f,onDeleteComment:p},y.id))}),te&&i.jsx("div",{children:i.jsx(Ie,{ref:B,type:_,unitId:t,subUnitId:n,onSave:async({text:y,attachments:P})=>{const A={text:y,attachments:P,dT:V.getDT(),id:s.generateRandomId(),ref:o,personId:j==null?void 0:j.userID,parentId:a==null?void 0:a.root.id,unitId:t,subUnitId:n,threadId:a==null?void 0:a.root.threadId};(f==null?void 0:f(A))!==!1&&(await N.executeCommand(V.AddCommentCommand.id,{unitId:t,subUnitId:n,comment:A}),H.current&&(H.current.scrollTop=H.current.scrollHeight))},autoFocus:W||!a,onCancel:()=>{a||g==null||g()}},`${W}`)})]})},Ze=r=>{const{unitId:e,subUnitId$:t,type:n,onAdd:o,getSubUnitName:l,onResolve:v,sortComments:S,onItemLeave:g,onItemEnter:D,disableAdd:E,tempComment:W,onAddComment:k,onDeleteComment:w,showComments:f}=r,[p,M]=d.useState("all"),[_,Z]=d.useState("all"),x=m.useDependency(s.LocaleService),L=m.useDependency(s.UserManagerService),h=m.useDependency(V.ThreadCommentModel),[C,I]=d.useState(()=>h.getUnit(e)),T=m.useDependency(u.ThreadCommentPanelService),b=m.useObservable(T.activeCommentId$),a=m.useObservable(h.commentUpdate$),N=m.useDependency(s.ICommandService),K=m.useObservable(t),O=d.useRef(!0),j="panel",B=m.useObservable(L.currentUser$),Y=d.useMemo(()=>{var A;const c=p==="all"?C:(A=C.filter($=>$.subUnitId===K))!=null?A:[],y=S!=null?S:($=>$),P=c.map($=>{var G;return{...$.root,children:(G=$.children)!=null?G:[],users:$.relativeUsers}});if(f){const $=new Map;return P.forEach(G=>{$.set(G.id,G)}),[...f,""].map(G=>$.get(G)).filter(Boolean)}else return y(P)},[f,p,C,S,K]),H=d.useMemo(()=>[...Y.filter(c=>!c.resolved),...Y.filter(c=>c.resolved)],[Y]),X=d.useMemo(()=>_==="resolved"?H.filter(c=>c.resolved):_==="unsolved"?H.filter(c=>!c.resolved):_==="concern_me"&&B!=null&&B.userID?H.filter(c=>c==null?void 0:c.users.has(B.userID)):H,[H,B==null?void 0:B.userID,_]),R=W?[W,...X]:X,ee=R.filter(c=>!c.resolved),te=R.filter(c=>c.resolved),ne=_!=="all"||p!=="all",re=()=>{Z("all"),M("all")};d.useEffect(()=>{e&&I(h.getUnit(e))},[e,h,a]),d.useEffect(()=>{var $;if(!b)return;if(!O.current){O.current=!0;return}const{unitId:c,subUnitId:y,commentId:P}=b,A=`${j}-${c}-${y}-${P}`;($=document.getElementById(A))==null||$.scrollIntoView({block:"center"})},[b]);const J=c=>i.jsx(xe,{full:!0,prefix:j,getSubUnitName:l,id:c.id,unitId:c.unitId,subUnitId:c.subUnitId,refStr:c.ref,type:n,showEdit:(b==null?void 0:b.commentId)===c.id,showHighlight:(b==null?void 0:b.commentId)===c.id,onClick:()=>{O.current=!1,c.resolved?N.executeCommand(F.id):N.executeCommand(F.id,{unitId:c.unitId,subUnitId:c.subUnitId,commentId:c.id,temp:!1})},onMouseEnter:()=>D==null?void 0:D(c),onMouseLeave:()=>g==null?void 0:g(c),onAddComment:k,onDeleteComment:w,onResolve:y=>v==null?void 0:v(c.id,y)},c.id);return i.jsxs("div",{className:"univer-flex univer-min-h-full univer-flex-col univer-pb-3",children:[i.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-between",children:[n===s.UniverInstanceType.UNIVER_SHEET?i.jsx(U.Select,{borderless:!0,value:p,options:[{value:"current",label:x.t("threadCommentUI.filter.sheet.current")},{value:"all",label:x.t("threadCommentUI.filter.sheet.all")}],onChange:M}):null,i.jsx(U.Select,{borderless:!0,value:_,options:[{value:"all",label:x.t("threadCommentUI.filter.status.all")},{value:"resolved",label:x.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:x.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:x.t("threadCommentUI.filter.status.concernMe")}],onChange:Z})]}),R.length===0?i.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[x.t("threadCommentUI.panel.empty"),ne?i.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:i.jsx(U.Button,{onClick:re,children:x.t("threadCommentUI.panel.reset")})}):E?null:i.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:i.jsxs(U.Button,{onClick:o,children:[i.jsx(me,{className:"univer-mr-1.5"}),x.t("threadCommentUI.panel.addComment")]})})]}):i.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[ee.map(J),te.length>0&&i.jsx("div",{className:"univer-text-xs",children:x.t("threadCommentUI.panel.solved")}),te.map(J)]})]})};u.SetActiveCommentOperation=F,u.THREAD_COMMENT_PANEL=le,u.ThreadCommentPanel=Ze,u.ThreadCommentTree=xe,u.ToggleSheetCommentPanelOperation=ae,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/thread-comment-ui",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer common thread comment UI plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"rxjs": ">=7.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@univerjs/icons": "^0.
|
|
56
|
-
"@univerjs/
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/docs-ui": "0.10.
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
55
|
+
"@univerjs/icons": "^1.0.2",
|
|
56
|
+
"@univerjs/design": "0.10.13",
|
|
57
|
+
"@univerjs/core": "0.10.13",
|
|
58
|
+
"@univerjs/docs-ui": "0.10.13",
|
|
59
|
+
"@univerjs/thread-comment": "0.10.13",
|
|
60
|
+
"@univerjs/ui": "0.10.13"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"postcss": "^8.5.6",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"typescript": "^5.9.3",
|
|
68
68
|
"vite": "^7.1.10",
|
|
69
69
|
"vitest": "^3.2.4",
|
|
70
|
-
"@univerjs-infra/shared": "0.10.
|
|
70
|
+
"@univerjs-infra/shared": "0.10.13"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"test": "vitest run",
|