| 123456789101112 |
- "use strict";var Oe=Object.defineProperty;var Re=(n,e,t)=>e in n?Oe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var F=(n,e,t)=>Re(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),A=require("@univerjs/thread-comment"),H=require("@univerjs/ui"),ae=require("rxjs"),m=require("react"),L=require("@univerjs/design"),se=require("@univerjs/docs-ui");var De=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,we=(n,e,t,r)=>{for(var o=r>1?void 0:r?Me(e,t):e,d=n.length-1,c;d>=0;d--)(c=n[d])&&(o=(r?c(e,t,o):c(o))||o);return r&&o&&De(e,t,o),o},me=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends a.Disposable{constructor(t,r){super();F(this,"_panelVisible",!1);F(this,"_panelVisible$",new ae.BehaviorSubject(!1));F(this,"_activeCommentId");F(this,"_activeCommentId$",new ae.BehaviorSubject(void 0));F(this,"panelVisible$",this._panelVisible$.asObservable());F(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(ae.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=we([me(0,a.Inject(H.ISidebarService)),me(1,a.IUniverInstanceService)],exports.ThreadCommentPanelService);const ve="thread-comment-panel",$e="UNIVER_THREAD_COMMENT_UI_PLUGIN",pe={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(H.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:ve},width:330}),t.setPanelVisible(!0)),!0}},B={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}},He="thread-comment-ui.config",ce={};var ge=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,ke=(n,e,t)=>e in n?ge(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ae=(n,e,t,r)=>{for(var o=r>1?void 0:r?Le(e,t):e,d=n.length-1,c;d>=0;d--)(c=n[d])&&(o=(r?c(e,t,o):c(o))||o);return r&&o&&ge(e,t,o),o},de=(n,e)=>(t,r)=>e(t,r,n),Ie=(n,e,t)=>ke(n,typeof e!="symbol"?e+"":e,t);exports.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ce,t,r,o){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=o;const{menu:d,...c}=a.merge({},ce,this._config);d&&this._configService.setConfig("menu",d,{merge:!0}),this._configService.setConfig(He,c)}onStarting(){var e;a.mergeOverrideWithDependencies([[exports.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[pe,B].forEach(t=>{this._commandService.registerCommand(t)})}};Ie(exports.UniverThreadCommentUIPlugin,"pluginName",$e);Ie(exports.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=Ae([a.DependentOn(A.UniverThreadCommentPlugin),de(1,a.Inject(a.Injector)),de(2,a.ICommandService),de(3,a.IConfigService)],exports.UniverThreadCommentUIPlugin);var le={exports:{}},X={};/**
- * @license React
- * react-jsx-runtime.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */var ue;function Ve(){if(ue)return X;ue=1;var n=m,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function c(f,h,b){var v,E={},y=null,_=null;b!==void 0&&(y=""+b),h.key!==void 0&&(y=""+h.key),h.ref!==void 0&&(_=h.ref);for(v in h)r.call(h,v)&&!d.hasOwnProperty(v)&&(E[v]=h[v]);if(f&&f.defaultProps)for(v in h=f.defaultProps,h)E[v]===void 0&&(E[v]=h[v]);return{$$typeof:e,type:f,key:y,ref:_,props:E,_owner:o.current}}return X.Fragment=t,X.jsx=c,X.jsxs=c,X}var he;function Be(){return he||(he=1,le.exports=Ve()),le.exports}var i=Be(),M=function(){return M=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},M.apply(this,arguments)},qe=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]]);return t},W=m.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,d=n.extend,c=qe(n,["icon","id","className","extend"]),f="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),h=m.useRef("_".concat(ze()));return xe(t,"".concat(r),{defIds:t.defIds,idSuffix:h.current},M({ref:e,className:f},c),d)});function xe(n,e,t,r,o){return m.createElement(n.tag,M(M({key:e},Fe(n,t,o)),r),(We(n,t).children||[]).map(function(d,c){return xe(d,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,o)}))}function Fe(n,e,t){var r=M({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(d){var c=d[0],f=d[1];typeof f=="string"&&(r[c]=f.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)?M(M({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?M(M({},o),{attrs:M(M({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function ze(){return Math.random().toString(36).substring(2,8)}W.displayName="UniverIcon";var Ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Se=m.forwardRef(function(n,e){return m.createElement(W,Object.assign({},n,{id:"delete-single",ref:e,icon:Ke}))});Se.displayName="DeleteSingle";var Ze={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=m.forwardRef(function(n,e){return m.createElement(W,Object.assign({},n,{id:"increase-single",ref:e,icon:Ze}))});be.displayName="IncreaseSingle";var Je={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"}}]},ye=m.forwardRef(function(n,e){return m.createElement(W,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Je}))});ye.displayName="MoreHorizontalSingle";var Ge={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}}]},_e=m.forwardRef(function(n,e){return m.createElement(W,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Ge}))});_e.displayName="ReplyToCommentSingle";var Ye={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Te=m.forwardRef(function(n,e){return m.createElement(W,Object.assign({},n,{id:"resolved-single",ref:e,icon:Ye}))});Te.displayName="ResolvedSingle";var Qe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},je=m.forwardRef(function(n,e){return m.createElement(W,Object.assign({},n,{id:"solve-single",ref:e,icon:Qe}))});je.displayName="SolveSingle";function Ee(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(t=Ee(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function Xe(){for(var n,e,t=0,r="",o=arguments.length;t<o;t++)(n=arguments[t])&&(e=Ee(n))&&(r&&(r+=" "),r+=e);return r}const et="univer-thread-comment-editor-buttons",tt="univer-thread-comment-editor-suggestion",nt="univer-thread-comment-editor-suggestionActive",rt="univer-thread-comment-editor-suggestion-icon",Ce={threadCommentEditorButtons:et,threadCommentEditorSuggestion:tt,threadCommentEditorSuggestionActive:nt,threadCommentEditorSuggestionIcon:rt};function fe(n){return{id:"d",body:n,documentStyle:{}}}const Ue=m.forwardRef((n,e)=>{var k;const{comment:t,onSave:r,id:o,onCancel:d,autoFocus:c,unitId:f,type:h}=n,b=a.useDependency(a.ICommandService),v=a.useDependency(a.LocaleService),[E,y]=m.useState(!1),_=a.useDependency(se.IEditorService),C=m.useRef(null),x=h===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:f,[R,U]=m.useState(()=>{var u,p,S;return a.BuildTextUtils.transform.getPlainText((S=(p=(u=C.current)==null?void 0:u.getDocumentData().body)==null?void 0:p.dataStream)!=null?S:"")});m.useEffect(()=>{var p,S,l,g;U(a.BuildTextUtils.transform.getPlainText((l=(S=(p=C.current)==null?void 0:p.getDocumentData().body)==null?void 0:S.dataStream)!=null?l:""));const u=(g=C.current)==null?void 0:g.selectionChange$.subscribe(()=>{var z,P,j;U(a.BuildTextUtils.transform.getPlainText((j=(P=(z=C.current)==null?void 0:z.getDocumentData().body)==null?void 0:P.dataStream)!=null?j:""))});return()=>u==null?void 0:u.unsubscribe()},[(k=C.current)==null?void 0:k.selectionChange$]);const w=m.useMemo(()=>({keyCodes:[{keyCode:H.KeyCode.ENTER}],handler:u=>{u===H.KeyCode.ENTER&&b.executeCommand(se.BreakLineCommand.id)}}),[b]);m.useImperativeHandle(e,()=>({reply(u){var p,S;(p=C.current)==null||p.focus(),(S=C.current)==null||S.setDocumentData(fe(u))}}));const T=()=>{if(C.current){const u=a.Tools.deepClone(C.current.getDocumentData().body);y(!1),r==null||r({...t,text:u}),C.current.replaceText(""),setTimeout(()=>{var p,S;(p=C.current)==null||p.setSelectionRanges([]),(S=C.current)==null||S.blur()},10)}};return i.jsxs("div",{className:Ce.threadCommentEditor,onClick:u=>u.preventDefault(),children:[i.jsx(se.RichTextEditor,{ref:C,autoFocus:c,style:{width:"100%"},keyboardEventConfig:w,placeholder:v.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&fe(t.text),onFocusChange:u=>u&&y(u),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{_.focus(x)},30)}}),E?i.jsxs("div",{className:Ce.threadCommentEditorButtons,children:[i.jsx(L.Button,{style:{marginRight:12},onClick:()=>{var u;d==null||d(),y(!1),(u=C.current)==null||u.replaceText("",!0),b.executeCommand(B.id)},children:v.t("threadCommentUI.editor.cancel")}),i.jsx(L.Button,{type:"primary",disabled:!R,onClick:T,children:v.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),ot=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
- `)?e.length-2:e.length,o=[];let d=0;return t==null||t.forEach(c=>{d<c.startIndex&&o.push({type:"text",content:e.slice(d,c.startIndex)}),o.push({type:"mention",content:{label:e.slice(c.startIndex,c.endIndex+1),id:c.rangeId}}),d=c.endIndex+1}),o.push({type:"text",content:e.slice(d,r)}),o},it=n=>{const{paragraphs:e=[]}=n;let t=0;return e.map(r=>{const o=a.getBodySlice(n,t,r.startIndex);return t=r.startIndex+1,ot(o)})},at=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 d=e.length-1;t.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:o,endIndex:d,properties:{}});break}}}),e+=`
- \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},st="univer-thread-comment",dt="univer-thread-comment-active",lt="univer-thread-comment-content",mt="univer-thread-comment-highlight",ct="univer-thread-comment-icon-container",ut="univer-thread-comment-icon",ht="univer-thread-comment-title",Ct="univer-thread-comment-title-position",ft="univer-thread-comment-title-highlight",vt="univer-thread-comment-title-position-text",pt="univer-thread-comment-username",gt="univer-thread-comment-item",It="univer-thread-comment-item-head",xt="univer-thread-comment-item-title",St="univer-thread-comment-item-title-position",bt="univer-thread-comment-item-title-highlight",yt="univer-thread-comment-item-time",_t="univer-thread-comment-item-content",Tt="univer-thread-comment-item-at",I={threadComment:st,threadCommentActive:dt,threadCommentContent:lt,threadCommentHighlight:mt,threadCommentIconContainer:ct,threadCommentIcon:ut,threadCommentTitle:ht,threadCommentTitlePosition:Ct,threadCommentTitleHighlight:ft,threadCommentTitlePositionText:vt,threadCommentUsername:pt,threadCommentItem:gt,threadCommentItemHead:It,threadCommentItemTitle:xt,threadCommentItemTitlePosition:St,threadCommentItemTitleHighlight:bt,threadCommentItemTime:yt,threadCommentItemContent:_t,threadCommentItemAt:Tt},Pe="__mock__",jt=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:d,onReply:c,resolved:f,isRoot:h,onClose:b,onDeleteComment:v,type:E}=n,y=a.useDependency(a.ICommandService),_=a.useDependency(a.LocaleService),C=a.useDependency(a.UserManagerService),x=C.getUser(e.personId),R=H.useObservable(C.currentUser$),U=(R==null?void 0:R.userID)===e.personId,w=e.id===Pe,[T,k]=m.useState(!1),u=()=>{(v==null?void 0:v(e))!==!1&&(y.executeCommand(h?A.DeleteCommentTreeCommand.id:A.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),h&&(b==null||b()))};return i.jsxs("div",{className:I.threadCommentItem,onMouseLeave:()=>k(!1),onMouseEnter:()=>k(!0),children:[i.jsx("img",{className:I.threadCommentItemHead,src:x==null?void 0:x.avatar}),i.jsxs("div",{className:I.threadCommentItemTitle,children:[i.jsx("div",{className:I.threadCommentUsername,children:(x==null?void 0:x.name)||" "}),i.jsxs("div",{children:[w||f?null:T?i.jsx("div",{className:I.threadCommentIcon,onClick:()=>c(x),children:i.jsx(_e,{})}):null,U&&!w&&!f?i.jsx(L.DropdownLegacy,{overlay:i.jsxs(L.Menu,{children:[i.jsx(L.MenuItem,{onClick:()=>d==null?void 0:d(!0),children:_.t("threadCommentUI.item.edit")},"edit"),i.jsx(L.MenuItem,{onClick:u,children:_.t("threadCommentUI.item.delete")},"delete")]}),children:i.jsx("div",{className:I.threadCommentIcon,children:i.jsx(ye,{})})}):null]})]}),i.jsx("div",{className:I.threadCommentItemTime,children:e.dT}),o?i.jsx(Ue,{type:E,id:e.id,comment:e,onCancel:()=>d==null?void 0:d(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:p,attachments:S})=>{d==null||d(!1),y.executeCommand(A.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:p,attachments:S}})}}):i.jsx("div",{className:I.threadCommentItemContent,children:it(e.text).map((p,S)=>i.jsx("div",{children:p.map((l,g)=>{switch(l.type){case"mention":return i.jsxs("a",{className:I.threadCommentItemAt,children:[l.content.label," "]},g);default:return l.content}})},S))})]})},Ne=n=>{var Y,Q,re;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:d=!0,onClick:c,showHighlight:f,onClose:h,getSubUnitName:b,prefix:v,autoFocus:E,onMouseEnter:y,onMouseLeave:_,onAddComment:C,onDeleteComment:x,onResolve:R,type:U}=n,w=a.useDependency(A.ThreadCommentModel),[T,k]=m.useState(!1),[u,p]=m.useState(""),S=m.useMemo(()=>w.commentUpdate$.pipe(ae.debounceTime(16)),[w]);H.useObservable(S);const l=e?w.getCommentWithChildren(t,r,e):null,g=a.useDependency(a.ICommandService),z=a.useDependency(a.UserManagerService),P=l==null?void 0:l.root.resolved,j=H.useObservable(z.currentUser$),K=m.useRef(null),te=[...l?[l.root]:[{id:Pe,text:{dataStream:`
- \r`},personId:(Y=j==null?void 0:j.userID)!=null?Y:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(Q=l==null?void 0:l.children)!=null?Q:[]],D=m.useRef(null),Z=N=>{N.stopPropagation(),P?g.executeCommand(B.id,{unitId:t,subUnitId:r,commentId:e}):g.executeCommand(B.id),g.executeCommand(A.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!P}),R==null||R(!P)},V=N=>{N.stopPropagation(),g.executeCommand(B.id),!(l!=null&&l.root&&(x==null?void 0:x(l.root))===!1)&&(g.executeCommand(A.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),h==null||h())};m.useEffect(()=>_==null?void 0:_(),[]);const J=b((re=l==null?void 0:l.root.subUnitId)!=null?re:r),G=d&&!u&&!P,ne=`${o||(l==null?void 0:l.root.ref)||""}${J?" · ":""}${J}`;return i.jsxs("div",{className:Xe(I.threadComment,{[I.threadCommentActive]:!P&&(f||T||v==="cell")}),onClick:c,id:`${v}-${t}-${r}-${e}`,onMouseEnter:()=>{y==null||y(),k(!0)},onMouseLeave:()=>{_==null||_(),k(!1)},children:[!P&&f?i.jsx("div",{className:I.threadCommentHighlight}):null,i.jsxs("div",{className:I.threadCommentTitle,children:[i.jsxs("div",{className:I.threadCommentTitlePosition,children:[i.jsx("div",{className:I.threadCommentTitleHighlight}),i.jsx(L.Tooltip,{showIfEllipsis:!0,title:ne,children:i.jsx("div",{className:I.threadCommentTitlePositionText,children:ne})})]}),l?i.jsxs("div",{className:I.threadCommentIconContainer,children:[i.jsx("div",{onClick:Z,className:I.threadCommentIcon,style:{color:P?"rgb(var(--green-500))":""},children:P?i.jsx(Te,{}):i.jsx(je,{})}),(j==null?void 0:j.userID)===l.root.personId?i.jsx("div",{className:I.threadCommentIcon,onClick:V,children:i.jsx(Se,{})}):null]}):null]}),i.jsx("div",{className:I.threadCommentContent,ref:D,children:te.map(N=>i.jsx(jt,{onClose:h,unitId:t,subUnitId:r,item:N,isRoot:N.id===(l==null?void 0:l.root.id),editing:u===N.id,resolved:l==null?void 0:l.root.resolved,type:U,onEditingChange:s=>{p(s?N.id:"")},onReply:s=>{s&&requestAnimationFrame(()=>{var $;($=K.current)==null||$.reply(at([{type:"mention",content:{id:s.userID,label:s.name}}]))})},onAddComment:C,onDeleteComment:x},N.id))}),G?i.jsx("div",{children:i.jsx(Ue,{ref:K,type:U,unitId:t,subUnitId:r,onSave:async({text:N,attachments:s})=>{const $={text:N,attachments:s,dT:A.getDT(),id:a.generateRandomId(),ref:o,personId:j==null?void 0:j.userID,parentId:l==null?void 0:l.root.id,unitId:t,subUnitId:r,threadId:l==null?void 0:l.root.threadId};(C==null?void 0:C($))!==!1&&(await g.executeCommand(A.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:$}),D.current&&(D.current.scrollTop=D.current.scrollHeight))},autoFocus:E||!l,onCancel:()=>{l||h==null||h()}},`${E}`)}):null]})},Et="univer-thread-comment-panel",Ut="univer-thread-comment",Pt="univer-thread-comment-panel-forms",Nt="univer-select",Ot="univer-thread-comment-panel-empty",Rt="univer-thread-comment-panel-add",Dt="univer-thread-comment-panel-solved",ee={threadCommentPanel:Et,threadComment:Ut,threadCommentPanelForms:Pt,select:Nt,threadCommentPanelEmpty:Ot,threadCommentPanelAdd:Rt,threadCommentPanelSolved:Dt},Mt=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:d,onResolve:c,sortComments:f,onItemLeave:h,onItemEnter:b,disableAdd:v,tempComment:E,onAddComment:y,onDeleteComment:_,showComments:C}=n,[x,R]=m.useState("all"),[U,w]=m.useState("all"),T=a.useDependency(a.LocaleService),k=a.useDependency(a.UserManagerService),u=a.useDependency(A.ThreadCommentModel),[p,S]=m.useState(()=>u.getUnit(e)),l=a.useDependency(exports.ThreadCommentPanelService),g=H.useObservable(l.activeCommentId$),z=H.useObservable(u.commentUpdate$),P=a.useDependency(a.ICommandService),j=H.useObservable(t),K=m.useRef(!0),te="panel",D=H.useObservable(k.currentUser$),Z=m.useMemo(()=>{var ie;const s=x==="all"?p:(ie=p.filter(O=>O.subUnitId===j))!=null?ie:[],$=f!=null?f:O=>O,oe=s.map(O=>{var q;return{...O.root,children:(q=O.children)!=null?q:[],users:O.relativeUsers}});if(C){const O=new Map;return oe.forEach(q=>{O.set(q.id,q)}),[...C,""].map(q=>O.get(q)).filter(Boolean)}else return $(oe)},[C,x,p,f,j]),V=m.useMemo(()=>[...Z.filter(s=>!s.resolved),...Z.filter(s=>s.resolved)],[Z]),J=m.useMemo(()=>U==="resolved"?V.filter(s=>s.resolved):U==="unsolved"?V.filter(s=>!s.resolved):U==="concern_me"&&D!=null&&D.userID?V.filter(s=>s==null?void 0:s.users.has(D.userID)):V,[V,D==null?void 0:D.userID,U]),G=E?[E,...J]:J,ne=G.filter(s=>!s.resolved),Y=G.filter(s=>s.resolved),Q=U!=="all"||x!=="all",re=()=>{w("all"),R("all")};m.useEffect(()=>{e&&S(u.getUnit(e))},[e,u,z]),m.useEffect(()=>{var O;if(!g)return;if(!K.current){K.current=!0;return}const{unitId:s,subUnitId:$,commentId:oe}=g,ie=`${te}-${s}-${$}-${oe}`;(O=document.getElementById(ie))==null||O.scrollIntoView({block:"center"})},[g]);const N=s=>i.jsx(Ne,{prefix:te,getSubUnitName:d,id:s.id,unitId:s.unitId,subUnitId:s.subUnitId,refStr:s.ref,type:r,showEdit:(g==null?void 0:g.commentId)===s.id,showHighlight:(g==null?void 0:g.commentId)===s.id,onClick:()=>{K.current=!1,s.resolved?P.executeCommand(B.id):P.executeCommand(B.id,{unitId:s.unitId,subUnitId:s.subUnitId,commentId:s.id,temp:!1})},onMouseEnter:()=>b==null?void 0:b(s),onMouseLeave:()=>h==null?void 0:h(s),onAddComment:y,onDeleteComment:_,onResolve:$=>c==null?void 0:c(s.id,$)},s.id);return i.jsxs("div",{className:ee.threadCommentPanel,children:[i.jsxs("div",{className:ee.threadCommentPanelForms,children:[r===a.UniverInstanceType.UNIVER_SHEET?i.jsx(L.Select,{borderless:!0,value:x,onChange:s=>R(s),options:[{value:"current",label:T.t("threadCommentUI.filter.sheet.current")},{value:"all",label:T.t("threadCommentUI.filter.sheet.all")}]}):null,i.jsx(L.Select,{borderless:!0,value:U,onChange:s=>w(s),options:[{value:"all",label:T.t("threadCommentUI.filter.status.all")},{value:"resolved",label:T.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:T.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:T.t("threadCommentUI.filter.status.concernMe")}]})]}),ne.map(N),Y.length?i.jsx("div",{className:ee.threadCommentPanelSolved,children:"已解决"}):null,Y.map(N),G.length?null:i.jsxs("div",{className:ee.threadCommentPanelEmpty,children:[Q?T.t("threadCommentUI.panel.filterEmpty"):T.t("threadCommentUI.panel.empty"),Q?i.jsx(L.Button,{onClick:re,type:"link",children:T.t("threadCommentUI.panel.reset")}):i.jsxs(L.Button,{id:"thread-comment-add",className:ee.threadCommentPanelAdd,type:"primary",onClick:o,disabled:v,children:[i.jsx(be,{}),T.t("threadCommentUI.panel.addComment")]})]})]})};exports.SetActiveCommentOperation=B;exports.THREAD_COMMENT_PANEL=ve;exports.ThreadCommentPanel=Mt;exports.ThreadCommentTree=Ne;exports.ToggleSheetCommentPanelOperation=pe;
|