@univerjs/thread-comment-ui 0.7.0 → 0.8.0-beta.0
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 +8 -11
- package/lib/es/index.js +22 -30
- package/lib/index.css +1 -1
- package/lib/index.js +22 -30
- package/lib/types/locale/fa-IR.d.ts +2 -2
- package/lib/umd/index.js +8 -11
- package/package.json +8 -8
package/lib/cjs/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";var ye=Object.defineProperty;var Se=(n,e,t)=>e in n?ye(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var K=(n,e,t)=>Se(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),B=require("@univerjs/thread-comment"),f=require("@univerjs/ui"),re=require("rxjs"),s=require("react/jsx-runtime"),H=require("@univerjs/design"),l=require("react"),ie=require("@univerjs/docs-ui");var _e=Object.getOwnPropertyDescriptor,je=(n,e,t,r)=>{for(var i=r>1?void 0:r?_e(e,t):e,a=n.length-1,c;a>=0;a--)(c=n[a])&&(i=c(i)||i);return i},ae=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends u.Disposable{constructor(t,r){super();K(this,"_panelVisible",!1);K(this,"_panelVisible$",new re.BehaviorSubject(!1));K(this,"_activeCommentId");K(this,"_activeCommentId$",new re.BehaviorSubject(void 0));K(this,"panelVisible$",this._panelVisible$.asObservable());K(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(u.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}};exports.ThreadCommentPanelService=je([ae(0,u.Inject(f.ISidebarService)),ae(1,u.IUniverInstanceService)],exports.ThreadCommentPanelService);const de="thread-comment-panel",Ne="UNIVER_THREAD_COMMENT_UI_PLUGIN",ue={id:"thread-comment-ui.operation.toggle-panel",type:u.CommandType.OPERATION,handler(n){const e=n.get(f.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:de},width:330}),t.setPanelVisible(!0)),!0}},F={id:"thread-comment-ui.operation.set-active-comment",type:u.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}},Te="thread-comment-ui.config",oe={};var we=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Oe=(n,e,t)=>e in n?we(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ee=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ue(e,t):e,a=n.length-1,c;a>=0;a--)(c=n[a])&&(i=c(i)||i);return i},se=(n,e)=>(t,r)=>e(t,r,n),ce=(n,e,t)=>Oe(n,typeof e!="symbol"?e+"":e,t);exports.UniverThreadCommentUIPlugin=class extends u.Plugin{constructor(e=oe,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:a,...c}=u.merge({},oe,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig(Te,c)}onStarting(){var e;u.mergeOverrideWithDependencies([[exports.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[ue,F].forEach(t=>{this._commandService.registerCommand(t)})}};ce(exports.UniverThreadCommentUIPlugin,"pluginName",Ne);ce(exports.UniverThreadCommentUIPlugin,"type",u.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=Ee([u.DependentOn(B.UniverThreadCommentPlugin),se(1,u.Inject(u.Injector)),se(2,u.ICommandService),se(3,u.IConfigService)],exports.UniverThreadCommentUIPlugin);var M=function(){return M=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},M.apply(this,arguments)},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 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},G=l.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,a=n.extend,c=De(n,["icon","id","className","extend"]),p="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),x=l.useRef("_".concat(Me()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:x.current},M({ref:e,className:p},c),a)});function ve(n,e,t,r,i){return l.createElement(n.tag,M(M({key:e},ke(n,t,i)),r),(Re(n,t).children||[]).map(function(a,c){return ve(a,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,i)}))}function ke(n,e,t){var r=M({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(a){var c=a[0],p=a[1];c==="mask"&&typeof p=="string"&&(r[c]=p.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(a){var c=a[0],p=a[1];typeof p=="string"&&(r[c]=p.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)?M(M({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?M(M({},i),{attrs:M(M({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Me(){return Math.random().toString(36).substring(2,8)}G.displayName="UniverIcon";var Pe={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"}}]},me=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"delete-single",ref:e,icon:Pe}))});me.displayName="DeleteSingle";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"increase-single",ref:e,icon:$e}))});fe.displayName="IncreaseSingle";var He={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"}}]},he=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:He}))});he.displayName="MoreHorizontalSingle";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},ge=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Le}))});ge.displayName="ReplyToCommentSingle";var Ve={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"}}]},pe=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"resolved-single",ref:e,icon:Ve}))});pe.displayName="ResolvedSingle";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}}]},xe=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"solve-single",ref:e,icon:Be}))});xe.displayName="SolveSingle";function le(n){return{id:"d",body:n,documentStyle:{}}}const Ce=l.forwardRef((n,e)=>{var P;const{comment:t,onSave:r,id:i,onCancel:a,autoFocus:c,unitId:p,type:x}=n,T=f.useDependency(u.ICommandService),U=f.useDependency(u.LocaleService),[A,O]=l.useState(!1),S=f.useDependency(ie.IEditorService),m=l.useRef(null),h=x===u.UniverInstanceType.UNIVER_SHEET?u.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:p,[E,_]=l.useState(()=>{var v,g,C;return u.BuildTextUtils.transform.getPlainText((C=(g=(v=m.current)==null?void 0:v.getDocumentData().body)==null?void 0:g.dataStream)!=null?C:"")});l.useEffect(()=>{var g,C,j,b;_(u.BuildTextUtils.transform.getPlainText((j=(C=(g=m.current)==null?void 0:g.getDocumentData().body)==null?void 0:C.dataStream)!=null?j:""));const v=(b=m.current)==null?void 0:b.selectionChange$.subscribe(()=>{var o,N,q;_(u.BuildTextUtils.transform.getPlainText((q=(N=(o=m.current)==null?void 0:o.getDocumentData().body)==null?void 0:N.dataStream)!=null?q:""))});return()=>v==null?void 0:v.unsubscribe()},[(P=m.current)==null?void 0:P.selectionChange$]);const W=l.useMemo(()=>({keyCodes:[{keyCode:f.KeyCode.ENTER}],handler:v=>{v===f.KeyCode.ENTER&&T.executeCommand(ie.BreakLineCommand.id)}}),[T]);l.useImperativeHandle(e,()=>({reply(v){var C,j;if(!m.current)return;S.focus((C=m.current.getEditorId())!=null?C:"");const g=le(v);(j=m.current)==null||j.setDocumentData(g,[{startOffset:g.body.dataStream.length-2,endOffset:g.body.dataStream.length-2,collapsed:!0}])}}));const I=()=>{if(m.current){const v=u.Tools.deepClone(m.current.getDocumentData().body);O(!1),r==null||r({...t,text:v}),m.current.replaceText(""),setTimeout(()=>{var g,C;(g=m.current)==null||g.setSelectionRanges([]),(C=m.current)==null||C.blur()},10)}};return s.jsxs("div",{onClick:v=>v.preventDefault(),children:[s.jsx(ie.RichTextEditor,{className:"univer-w-full",editorRef:m,autoFocus:c,keyboardEventConfig:W,placeholder:U.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&le(t.text),onFocusChange:v=>v&&O(v),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{S.focus(h)},30)}}),A?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end",children:[s.jsx(H.Button,{style:{marginRight:12},onClick:()=>{var v;a==null||a(),O(!1),(v=m.current)==null||v.replaceText("",!0),T.executeCommand(F.id)},children:U.t("threadCommentUI.editor.cancel")}),s.jsx(H.Button,{variant:"primary",disabled:!E,onClick:I,children:U.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
|
|
1
|
+
"use strict";var ye=Object.defineProperty;var Se=(n,e,t)=>e in n?ye(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var K=(n,e,t)=>Se(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),B=require("@univerjs/thread-comment"),f=require("@univerjs/ui"),re=require("rxjs"),s=require("react/jsx-runtime"),H=require("@univerjs/design"),l=require("react"),ie=require("@univerjs/docs-ui");var _e=Object.getOwnPropertyDescriptor,je=(n,e,t,r)=>{for(var i=r>1?void 0:r?_e(e,t):e,a=n.length-1,c;a>=0;a--)(c=n[a])&&(i=c(i)||i);return i},ae=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends u.Disposable{constructor(t,r){super();K(this,"_panelVisible",!1);K(this,"_panelVisible$",new re.BehaviorSubject(!1));K(this,"_activeCommentId");K(this,"_activeCommentId$",new re.BehaviorSubject(void 0));K(this,"panelVisible$",this._panelVisible$.asObservable());K(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(u.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}};exports.ThreadCommentPanelService=je([ae(0,u.Inject(f.ISidebarService)),ae(1,u.IUniverInstanceService)],exports.ThreadCommentPanelService);const de="thread-comment-panel",Ne="UNIVER_THREAD_COMMENT_UI_PLUGIN",ue={id:"thread-comment-ui.operation.toggle-panel",type:u.CommandType.OPERATION,handler(n){const e=n.get(f.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:de},width:330}),t.setPanelVisible(!0)),!0}},F={id:"thread-comment-ui.operation.set-active-comment",type:u.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}},Te="thread-comment-ui.config",oe={};var we=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Oe=(n,e,t)=>e in n?we(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ee=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ue(e,t):e,a=n.length-1,c;a>=0;a--)(c=n[a])&&(i=c(i)||i);return i},se=(n,e)=>(t,r)=>e(t,r,n),ce=(n,e,t)=>Oe(n,typeof e!="symbol"?e+"":e,t);exports.UniverThreadCommentUIPlugin=class extends u.Plugin{constructor(e=oe,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:a,...c}=u.merge({},oe,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig(Te,c)}onStarting(){var e;u.mergeOverrideWithDependencies([[exports.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[ue,F].forEach(t=>{this._commandService.registerCommand(t)})}};ce(exports.UniverThreadCommentUIPlugin,"pluginName",Ne);ce(exports.UniverThreadCommentUIPlugin,"type",u.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=Ee([u.DependentOn(B.UniverThreadCommentPlugin),se(1,u.Inject(u.Injector)),se(2,u.ICommandService),se(3,u.IConfigService)],exports.UniverThreadCommentUIPlugin);var R=function(){return R=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},R.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 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},G=l.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,a=n.extend,c=De(n,["icon","id","className","extend"]),p="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),x=l.useRef("_".concat(Re()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:x.current},R({ref:e,className:p},c),a)});function ve(n,e,t,r,i){return l.createElement(n.tag,R(R({key:e},ke(n,t,i)),r),(Me(n,t).children||[]).map(function(a,c){return ve(a,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,i)}))}function ke(n,e,t){var r=R({},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(a){var c=a[0],p=a[1];c==="mask"&&typeof p=="string"&&(r[c]=p.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(a){var c=a[0],p=a[1];typeof p=="string"&&(r[c]=p.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)?R(R({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?R(R({},i),{attrs:R(R({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Re(){return Math.random().toString(36).substring(2,8)}G.displayName="UniverIcon";var Pe={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"}}]},me=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"delete-single",ref:e,icon:Pe}))});me.displayName="DeleteSingle";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"increase-single",ref:e,icon:$e}))});fe.displayName="IncreaseSingle";var He={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"}}]},he=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:He}))});he.displayName="MoreHorizontalSingle";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},ge=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Le}))});ge.displayName="ReplyToCommentSingle";var Ve={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"}}]},pe=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"resolved-single",ref:e,icon:Ve}))});pe.displayName="ResolvedSingle";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}}]},xe=l.forwardRef(function(n,e){return l.createElement(G,Object.assign({},n,{id:"solve-single",ref:e,icon:Be}))});xe.displayName="SolveSingle";function le(n){return{id:"d",body:n,documentStyle:{}}}const Ce=l.forwardRef((n,e)=>{var P;const{comment:t,onSave:r,id:i,onCancel:a,autoFocus:c,unitId:p,type:x}=n,T=f.useDependency(u.ICommandService),U=f.useDependency(u.LocaleService),[A,O]=l.useState(!1),S=f.useDependency(ie.IEditorService),m=l.useRef(null),h=x===u.UniverInstanceType.UNIVER_SHEET?u.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:p,[E,_]=l.useState(()=>{var v,g,C;return u.BuildTextUtils.transform.getPlainText((C=(g=(v=m.current)==null?void 0:v.getDocumentData().body)==null?void 0:g.dataStream)!=null?C:"")});l.useEffect(()=>{var g,C,j,b;_(u.BuildTextUtils.transform.getPlainText((j=(C=(g=m.current)==null?void 0:g.getDocumentData().body)==null?void 0:C.dataStream)!=null?j:""));const v=(b=m.current)==null?void 0:b.selectionChange$.subscribe(()=>{var o,N,q;_(u.BuildTextUtils.transform.getPlainText((q=(N=(o=m.current)==null?void 0:o.getDocumentData().body)==null?void 0:N.dataStream)!=null?q:""))});return()=>v==null?void 0:v.unsubscribe()},[(P=m.current)==null?void 0:P.selectionChange$]);const W=l.useMemo(()=>({keyCodes:[{keyCode:f.KeyCode.ENTER}],handler:v=>{v===f.KeyCode.ENTER&&T.executeCommand(ie.BreakLineCommand.id)}}),[T]);l.useImperativeHandle(e,()=>({reply(v){var C,j;if(!m.current)return;S.focus((C=m.current.getEditorId())!=null?C:"");const g=le(v);(j=m.current)==null||j.setDocumentData(g,[{startOffset:g.body.dataStream.length-2,endOffset:g.body.dataStream.length-2,collapsed:!0}])}}));const I=()=>{if(m.current){const v=u.Tools.deepClone(m.current.getDocumentData().body);O(!1),r==null||r({...t,text:v}),m.current.replaceText(""),setTimeout(()=>{var g,C;(g=m.current)==null||g.setSelectionRanges([]),(C=m.current)==null||C.blur()},10)}};return s.jsxs("div",{onClick:v=>v.preventDefault(),children:[s.jsx(ie.RichTextEditor,{className:"univer-w-full",editorRef:m,autoFocus:c,keyboardEventConfig:W,placeholder:U.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&le(t.text),onFocusChange:v=>v&&O(v),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{S.focus(h)},30)}}),A?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[s.jsx(H.Button,{onClick:()=>{var v;a==null||a(),O(!1),(v=m.current)==null||v.replaceText("",!0),T.executeCommand(F.id)},children:U.t("threadCommentUI.editor.cancel")}),s.jsx(H.Button,{variant:"primary",disabled:!E,onClick:I,children:U.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
|
|
2
2
|
`)?e.length-2:e.length,i=[];let a=0;return t==null||t.forEach(c=>{a<c.startIndex&&i.push({type:"text",content:e.slice(a,c.startIndex)}),i.push({type:"mention",content:{label:e.slice(c.startIndex,c.endIndex+1),id:c.rangeId}}),a=c.endIndex+1}),i.push({type:"text",content:e.slice(a,r)}),i},We=n=>{const{paragraphs:e=[]}=n;let t=0;return e.map(r=>{const i=u.getBodySlice(n,t,r.startIndex);return t=r.startIndex+1,Ae(i)})},Fe=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const a=e.length-1;t.push({rangeId:r.content.id,rangeType:u.CustomRangeType.MENTION,startIndex:i,endIndex:a,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__",qe=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:a,onReply:c,resolved:p,isRoot:x,onClose:T,onDeleteComment:U,type:A}=n,O=f.useDependency(u.ICommandService),S=f.useDependency(u.LocaleService),m=f.useDependency(u.UserManagerService),h=m.getUser(e.personId),E=f.useObservable(m.currentUser$),_=(E==null?void 0:E.userID)===e.personId,W=e.id===be,[I,P]=l.useState(!1),v=f.useConfigValue(f.UI_PLUGIN_CONFIG_KEY),g=v==null?void 0:v.avatarFallback,C=()=>{(U==null?void 0:U(e))!==!1&&(O.executeCommand(x?B.DeleteCommentTreeCommand.id:B.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),x&&(T==null||T()))};return s.jsxs("div",{className:"univer-relative univer-mb-3 univer-pl-[30px]",onMouseLeave:()=>P(!1),onMouseEnter:()=>P(!0),children:[s.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(${(h==null?void 0:h.avatar)||g})`}}),h?s.jsxs("div",{className:"univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",children:[s.jsx("div",{className:"univer-text-sm univer-font-medium univer-leading-5",children:(h==null?void 0:h.name)||" "}),s.jsxs("div",{children:[W||p?null:I&&h?s.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:()=>c(h),children:s.jsx(ge,{})}):null,_&&!W&&!p?s.jsx(H.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg",children:s.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:[s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>a==null?void 0:a(!0),children:S.t("threadCommentUI.item.edit")})}),s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:C,children:S.t("threadCommentUI.item.delete")})})]})}),children:s.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:s.jsx(he,{})})}):null]})]}):null,s.jsx("time",{className:"univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark
|
|
4
|
-
\r`},personId:(ne=k==null?void 0:k.userID)!=null?ne:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(J=o==null?void 0:o.children)!=null?J:[]],$=l.useRef(null),Q=y=>{y.stopPropagation(),D?N.executeCommand(F.id,{unitId:t,subUnitId:r,commentId:e}):N.executeCommand(F.id),N.executeCommand(B.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!D}),E==null||E(!D)},Y=y=>{y.stopPropagation(),N.executeCommand(F.id),!(o!=null&&o.root&&(h==null?void 0:h(o.root))===!1)&&(N.executeCommand(B.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),x==null||x())};l.useEffect(()=>S==null?void 0:S(),[]);const X=T((d=o==null?void 0:o.root.subUnitId)!=null?d:r),ee=a&&!C&&!D,te=`${i||(o==null?void 0:o.root.ref)||""}${X?" · ":""}${X}`;return s.jsxs("div",{id:`${U}-${t}-${r}-${e}`,className:H.clsx(`
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
dark:hover:univer-bg-gray-800
|
|
11
|
-
hover:univer-bg-gray-50
|
|
12
|
-
`,{"univer-text-green-500":D}),onClick:Q,children:D?s.jsx(pe,{}):s.jsx(xe,{})}),(k==null?void 0:k.userID)===o.root.personId?s.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 dark:hover:univer-bg-gray-800 hover:univer-bg-gray-50",onClick:Y,children:s.jsx(me,{})}):null]}):null]}),s.jsx("div",{ref:$,className:"univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",children:Z.map(y=>s.jsx(qe,{onClose:x,unitId:t,subUnitId:r,item:y,isRoot:y.id===(o==null?void 0:o.root.id),editing:C===y.id,resolved:o==null?void 0:o.root.resolved,type:_,onEditingChange:R=>{j(R?y.id:"")},onReply:R=>{R&&requestAnimationFrame(()=>{var V;(V=L.current)==null||V.reply(Fe([{type:"mention",content:{id:R.userID,label:`@${R.name}`}},{type:"text",content:" "}]))})},onAddComment:m,onDeleteComment:h},y.id))}),ee?s.jsx("div",{children:s.jsx(Ce,{ref:L,type:_,unitId:t,subUnitId:r,onSave:async({text:y,attachments:R})=>{const V={text:y,attachments:R,dT:B.getDT(),id:u.generateRandomId(),ref:i,personId:k==null?void 0:k.userID,parentId:o==null?void 0:o.root.id,unitId:t,subUnitId:r,threadId:o==null?void 0:o.root.threadId};(m==null?void 0:m(V))!==!1&&(await N.executeCommand(B.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:V}),$.current&&($.current.scrollTop=$.current.scrollHeight))},autoFocus:A||!o,onCancel:()=>{o||x==null||x()}},`${A}`)}):null]})},ze=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:a,onResolve:c,sortComments:p,onItemLeave:x,onItemEnter:T,disableAdd:U,tempComment:A,onAddComment:O,onDeleteComment:S,showComments:m}=n,[h,E]=l.useState("all"),[_,W]=l.useState("all"),I=f.useDependency(u.LocaleService),P=f.useDependency(u.UserManagerService),v=f.useDependency(B.ThreadCommentModel),[g,C]=l.useState(()=>v.getUnit(e)),j=f.useDependency(exports.ThreadCommentPanelService),b=f.useObservable(j.activeCommentId$),o=f.useObservable(v.commentUpdate$),N=f.useDependency(u.ICommandService),q=f.useObservable(t),D=l.useRef(!0),k="panel",L=f.useObservable(P.currentUser$),Z=l.useMemo(()=>{var V;const d=h==="all"?g:(V=g.filter(w=>w.subUnitId===q))!=null?V:[],y=p!=null?p:w=>w,R=d.map(w=>{var z;return{...w.root,children:(z=w.children)!=null?z:[],users:w.relativeUsers}});if(m){const w=new Map;return R.forEach(z=>{w.set(z.id,z)}),[...m,""].map(z=>w.get(z)).filter(Boolean)}else return y(R)},[m,h,g,p,q]),$=l.useMemo(()=>[...Z.filter(d=>!d.resolved),...Z.filter(d=>d.resolved)],[Z]),Q=l.useMemo(()=>_==="resolved"?$.filter(d=>d.resolved):_==="unsolved"?$.filter(d=>!d.resolved):_==="concern_me"&&L!=null&&L.userID?$.filter(d=>d==null?void 0:d.users.has(L.userID)):$,[$,L==null?void 0:L.userID,_]),Y=A?[A,...Q]:Q,X=Y.filter(d=>!d.resolved),ee=Y.filter(d=>d.resolved),te=_!=="all"||h!=="all",ne=()=>{W("all"),E("all")};l.useEffect(()=>{e&&C(v.getUnit(e))},[e,v,o]),l.useEffect(()=>{var w;if(!b)return;if(!D.current){D.current=!0;return}const{unitId:d,subUnitId:y,commentId:R}=b,V=`${k}-${d}-${y}-${R}`;(w=document.getElementById(V))==null||w.scrollIntoView({block:"center"})},[b]);const J=d=>s.jsx(Ie,{full:!0,prefix:k,getSubUnitName:a,id:d.id,unitId:d.unitId,subUnitId:d.subUnitId,refStr:d.ref,type:r,showEdit:(b==null?void 0:b.commentId)===d.id,showHighlight:(b==null?void 0:b.commentId)===d.id,onClick:()=>{D.current=!1,d.resolved?N.executeCommand(F.id):N.executeCommand(F.id,{unitId:d.unitId,subUnitId:d.subUnitId,commentId:d.id,temp:!1})},onMouseEnter:()=>T==null?void 0:T(d),onMouseLeave:()=>x==null?void 0:x(d),onAddComment:O,onDeleteComment:S,onResolve:y=>c==null?void 0:c(d.id,y)},d.id);return s.jsxs("div",{className:"univer-flex univer-min-h-full univer-flex-col univer-pb-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-between",children:[r===u.UniverInstanceType.UNIVER_SHEET?s.jsx(H.Select,{borderless:!0,value:h,options:[{value:"current",label:I.t("threadCommentUI.filter.sheet.current")},{value:"all",label:I.t("threadCommentUI.filter.sheet.all")}],onChange:E}):null,s.jsx(H.Select,{borderless:!0,value:_,options:[{value:"all",label:I.t("threadCommentUI.filter.status.all")},{value:"resolved",label:I.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:I.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:I.t("threadCommentUI.filter.status.concernMe")}],onChange:W})]}),Y.length===0?s.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:[I.t("threadCommentUI.panel.empty"),te?s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsx(H.Button,{onClick:ne,children:I.t("threadCommentUI.panel.reset")})}):U?null:s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsxs(H.Button,{onClick:i,children:[s.jsx(fe,{className:"univer-mr-1.5"}),I.t("threadCommentUI.panel.add")]})})]}):s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[X.map(J),ee.length>0&&s.jsx("div",{className:"univer-text-xs",children:I.t("threadCommentUI.panel.solved")}),ee.map(J)]})]})};exports.SetActiveCommentOperation=F;exports.THREAD_COMMENT_PANEL=de;exports.ThreadCommentPanel=ze;exports.ThreadCommentTree=Ie;exports.ToggleSheetCommentPanelOperation=ue;
|
|
3
|
+
`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},be="__mock__",qe=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:a,onReply:c,resolved:p,isRoot:x,onClose:T,onDeleteComment:U,type:A}=n,O=f.useDependency(u.ICommandService),S=f.useDependency(u.LocaleService),m=f.useDependency(u.UserManagerService),h=m.getUser(e.personId),E=f.useObservable(m.currentUser$),_=(E==null?void 0:E.userID)===e.personId,W=e.id===be,[I,P]=l.useState(!1),v=f.useConfigValue(f.UI_PLUGIN_CONFIG_KEY),g=v==null?void 0:v.avatarFallback,C=()=>{(U==null?void 0:U(e))!==!1&&(O.executeCommand(x?B.DeleteCommentTreeCommand.id:B.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),x&&(T==null||T()))};return s.jsxs("div",{className:"univer-relative univer-mb-3 univer-pl-[30px]",onMouseLeave:()=>P(!1),onMouseEnter:()=>P(!0),children:[s.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(${(h==null?void 0:h.avatar)||g})`}}),h?s.jsxs("div",{className:"univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",children:[s.jsx("div",{className:"univer-text-sm univer-font-medium univer-leading-5",children:(h==null?void 0:h.name)||" "}),s.jsxs("div",{children:[W||p?null:I&&h?s.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:()=>c(h),children:s.jsx(ge,{})}):null,_&&!W&&!p?s.jsx(H.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg",children:s.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:[s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>a==null?void 0:a(!0),children:S.t("threadCommentUI.item.edit")})}),s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:C,children:S.t("threadCommentUI.item.delete")})})]})}),children:s.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:s.jsx(he,{})})}):null]})]}):null,s.jsx("time",{className:"univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",children:e.dT}),i?s.jsx(Ce,{type:A,id:e.id,comment:e,onCancel:()=>a==null?void 0:a(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:j,attachments:b})=>{a==null||a(!1),O.executeCommand(B.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:j,attachments:b}})}}):s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:We(e.text).map((j,b)=>s.jsx("div",{className:"univer-break-words",children:j.map((o,N)=>{switch(o.type){case"mention":return s.jsxs("a",{className:"univer-text-primary-600",children:[o.content.label," "]},N);default:return o.content}})},b))})]})},Ie=n=>{var ne,J,d;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:a=!0,onClick:c,showHighlight:p,onClose:x,getSubUnitName:T,prefix:U,autoFocus:A,onMouseEnter:O,onMouseLeave:S,onAddComment:m,onDeleteComment:h,onResolve:E,type:_,style:W,full:I}=n,P=f.useDependency(B.ThreadCommentModel),[v,g]=l.useState(!1),[C,j]=l.useState(""),b=l.useMemo(()=>P.commentUpdate$.pipe(re.debounceTime(16)),[P]);f.useObservable(b);const o=e?P.getCommentWithChildren(t,r,e):null,N=f.useDependency(u.ICommandService),q=f.useDependency(u.UserManagerService),D=o==null?void 0:o.root.resolved,k=f.useObservable(q.currentUser$),L=l.useRef(null),Z=[...o?[o.root]:[{id:be,text:{dataStream:`
|
|
4
|
+
\r`},personId:(ne=k==null?void 0:k.userID)!=null?ne:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(J=o==null?void 0:o.children)!=null?J:[]],$=l.useRef(null),Q=y=>{y.stopPropagation(),D?N.executeCommand(F.id,{unitId:t,subUnitId:r,commentId:e}):N.executeCommand(F.id),N.executeCommand(B.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!D}),E==null||E(!D)},Y=y=>{y.stopPropagation(),N.executeCommand(F.id),!(o!=null&&o.root&&(h==null?void 0:h(o.root))===!1)&&(N.executeCommand(B.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),x==null||x())};l.useEffect(()=>S==null?void 0:S(),[]);const X=T((d=o==null?void 0:o.root.subUnitId)!=null?d:r),ee=a&&!C&&!D,te=`${i||(o==null?void 0:o.root.ref)||""}${X?" · ":""}${X}`;return s.jsxs("div",{id:`${U}-${t}-${r}-${e}`,className:H.clsx("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white",H.borderClassName,{"univer-w-[278px]":!I,"univer-w-full":I,"univer-shadow":!D&&(p||v||U==="cell")}),style:W,onClick:c,onMouseEnter:()=>{O==null||O(),g(!0)},onMouseLeave:()=>{S==null||S(),g(!1)},children:[!D&&p&&s.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"}),s.jsxs("div",{className:"univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5",children:[s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",children:[s.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"}),s.jsx(H.Tooltip,{showIfEllipsis:!0,title:te,children:s.jsx("div",{className:"univer-flex-1 univer-truncate",children:te})})]}),!!o&&s.jsxs("div",{className:"univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",children:[s.jsx("div",{className:H.clsx(`
|
|
5
|
+
univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer
|
|
6
|
+
univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base
|
|
7
|
+
dark:hover:!univer-bg-gray-800
|
|
8
|
+
hover:univer-bg-gray-50
|
|
9
|
+
`,{"univer-text-green-500":D}),onClick:Q,children:D?s.jsx(pe,{}):s.jsx(xe,{})}),(k==null?void 0:k.userID)===o.root.personId?s.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 dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-50",onClick:Y,children:s.jsx(me,{})}):null]})]}),s.jsx("div",{ref:$,className:"univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",children:Z.map(y=>s.jsx(qe,{unitId:t,subUnitId:r,item:y,isRoot:y.id===(o==null?void 0:o.root.id),editing:C===y.id,resolved:o==null?void 0:o.root.resolved,type:_,onClose:x,onEditingChange:M=>{j(M?y.id:"")},onReply:M=>{M&&requestAnimationFrame(()=>{var V;(V=L.current)==null||V.reply(Fe([{type:"mention",content:{id:M.userID,label:`@${M.name}`}},{type:"text",content:" "}]))})},onAddComment:m,onDeleteComment:h},y.id))}),ee&&s.jsx("div",{children:s.jsx(Ce,{ref:L,type:_,unitId:t,subUnitId:r,onSave:async({text:y,attachments:M})=>{const V={text:y,attachments:M,dT:B.getDT(),id:u.generateRandomId(),ref:i,personId:k==null?void 0:k.userID,parentId:o==null?void 0:o.root.id,unitId:t,subUnitId:r,threadId:o==null?void 0:o.root.threadId};(m==null?void 0:m(V))!==!1&&(await N.executeCommand(B.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:V}),$.current&&($.current.scrollTop=$.current.scrollHeight))},autoFocus:A||!o,onCancel:()=>{o||x==null||x()}},`${A}`)})]})},ze=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:a,onResolve:c,sortComments:p,onItemLeave:x,onItemEnter:T,disableAdd:U,tempComment:A,onAddComment:O,onDeleteComment:S,showComments:m}=n,[h,E]=l.useState("all"),[_,W]=l.useState("all"),I=f.useDependency(u.LocaleService),P=f.useDependency(u.UserManagerService),v=f.useDependency(B.ThreadCommentModel),[g,C]=l.useState(()=>v.getUnit(e)),j=f.useDependency(exports.ThreadCommentPanelService),b=f.useObservable(j.activeCommentId$),o=f.useObservable(v.commentUpdate$),N=f.useDependency(u.ICommandService),q=f.useObservable(t),D=l.useRef(!0),k="panel",L=f.useObservable(P.currentUser$),Z=l.useMemo(()=>{var V;const d=h==="all"?g:(V=g.filter(w=>w.subUnitId===q))!=null?V:[],y=p!=null?p:w=>w,M=d.map(w=>{var z;return{...w.root,children:(z=w.children)!=null?z:[],users:w.relativeUsers}});if(m){const w=new Map;return M.forEach(z=>{w.set(z.id,z)}),[...m,""].map(z=>w.get(z)).filter(Boolean)}else return y(M)},[m,h,g,p,q]),$=l.useMemo(()=>[...Z.filter(d=>!d.resolved),...Z.filter(d=>d.resolved)],[Z]),Q=l.useMemo(()=>_==="resolved"?$.filter(d=>d.resolved):_==="unsolved"?$.filter(d=>!d.resolved):_==="concern_me"&&L!=null&&L.userID?$.filter(d=>d==null?void 0:d.users.has(L.userID)):$,[$,L==null?void 0:L.userID,_]),Y=A?[A,...Q]:Q,X=Y.filter(d=>!d.resolved),ee=Y.filter(d=>d.resolved),te=_!=="all"||h!=="all",ne=()=>{W("all"),E("all")};l.useEffect(()=>{e&&C(v.getUnit(e))},[e,v,o]),l.useEffect(()=>{var w;if(!b)return;if(!D.current){D.current=!0;return}const{unitId:d,subUnitId:y,commentId:M}=b,V=`${k}-${d}-${y}-${M}`;(w=document.getElementById(V))==null||w.scrollIntoView({block:"center"})},[b]);const J=d=>s.jsx(Ie,{full:!0,prefix:k,getSubUnitName:a,id:d.id,unitId:d.unitId,subUnitId:d.subUnitId,refStr:d.ref,type:r,showEdit:(b==null?void 0:b.commentId)===d.id,showHighlight:(b==null?void 0:b.commentId)===d.id,onClick:()=>{D.current=!1,d.resolved?N.executeCommand(F.id):N.executeCommand(F.id,{unitId:d.unitId,subUnitId:d.subUnitId,commentId:d.id,temp:!1})},onMouseEnter:()=>T==null?void 0:T(d),onMouseLeave:()=>x==null?void 0:x(d),onAddComment:O,onDeleteComment:S,onResolve:y=>c==null?void 0:c(d.id,y)},d.id);return s.jsxs("div",{className:"univer-flex univer-min-h-full univer-flex-col univer-pb-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-between",children:[r===u.UniverInstanceType.UNIVER_SHEET?s.jsx(H.Select,{borderless:!0,value:h,options:[{value:"current",label:I.t("threadCommentUI.filter.sheet.current")},{value:"all",label:I.t("threadCommentUI.filter.sheet.all")}],onChange:E}):null,s.jsx(H.Select,{borderless:!0,value:_,options:[{value:"all",label:I.t("threadCommentUI.filter.status.all")},{value:"resolved",label:I.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:I.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:I.t("threadCommentUI.filter.status.concernMe")}],onChange:W})]}),Y.length===0?s.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:[I.t("threadCommentUI.panel.empty"),te?s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsx(H.Button,{onClick:ne,children:I.t("threadCommentUI.panel.reset")})}):U?null:s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsxs(H.Button,{onClick:i,children:[s.jsx(fe,{className:"univer-mr-1.5"}),I.t("threadCommentUI.panel.add")]})})]}):s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[X.map(J),ee.length>0&&s.jsx("div",{className:"univer-text-xs",children:I.t("threadCommentUI.panel.solved")}),ee.map(J)]})]})};exports.SetActiveCommentOperation=F;exports.THREAD_COMMENT_PANEL=de;exports.ThreadCommentPanel=ze;exports.ThreadCommentTree=Ie;exports.ToggleSheetCommentPanelOperation=ue;
|
package/lib/es/index.js
CHANGED
|
@@ -277,11 +277,10 @@ const je = B((t, e) => {
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
),
|
|
280
|
-
P ? /* @__PURE__ */ b("div", { className: "univer-mt-3 univer-flex univer-flex-row univer-justify-end", children: [
|
|
280
|
+
P ? /* @__PURE__ */ b("div", { className: "univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2", children: [
|
|
281
281
|
/* @__PURE__ */ l(
|
|
282
282
|
se,
|
|
283
283
|
{
|
|
284
|
-
style: { marginRight: 12 },
|
|
285
284
|
onClick: () => {
|
|
286
285
|
var u;
|
|
287
286
|
a == null || a(), O(!1), (u = c.current) == null || u.replaceText("", !0), w.executeCommand(K.id);
|
|
@@ -439,7 +438,7 @@ const je = B((t, e) => {
|
|
|
439
438
|
/* @__PURE__ */ l(
|
|
440
439
|
"time",
|
|
441
440
|
{
|
|
442
|
-
className: "univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark
|
|
441
|
+
className: "univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",
|
|
443
442
|
children: e.dT
|
|
444
443
|
}
|
|
445
444
|
),
|
|
@@ -471,7 +470,7 @@ const je = B((t, e) => {
|
|
|
471
470
|
) : /* @__PURE__ */ l(
|
|
472
471
|
"div",
|
|
473
472
|
{
|
|
474
|
-
className: "univer-text-sm univer-text-gray-900 dark
|
|
473
|
+
className: "univer-text-sm univer-text-gray-900 dark:!univer-text-white",
|
|
475
474
|
children: Ht(e.text).map((S, p) => /* @__PURE__ */ l("div", { className: "univer-break-words", children: S.map((o, _) => {
|
|
476
475
|
switch (o.type) {
|
|
477
476
|
case "mention":
|
|
@@ -555,18 +554,11 @@ const je = B((t, e) => {
|
|
|
555
554
|
"div",
|
|
556
555
|
{
|
|
557
556
|
id: `${k}-${n}-${r}-${e}`,
|
|
558
|
-
className: Ce(
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
ut,
|
|
564
|
-
{
|
|
565
|
-
"univer-w-[278px]": !C,
|
|
566
|
-
"univer-w-full": C,
|
|
567
|
-
"univer-shadow": !E && (f || u || k === "cell")
|
|
568
|
-
}
|
|
569
|
-
),
|
|
557
|
+
className: Ce("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white", ut, {
|
|
558
|
+
"univer-w-[278px]": !C,
|
|
559
|
+
"univer-w-full": C,
|
|
560
|
+
"univer-shadow": !E && (f || u || k === "cell")
|
|
561
|
+
}),
|
|
570
562
|
style: V,
|
|
571
563
|
onClick: d,
|
|
572
564
|
onMouseEnter: () => {
|
|
@@ -576,12 +568,12 @@ const je = B((t, e) => {
|
|
|
576
568
|
x == null || x(), m(!1);
|
|
577
569
|
},
|
|
578
570
|
children: [
|
|
579
|
-
!E && f
|
|
571
|
+
!E && f && /* @__PURE__ */ l(
|
|
580
572
|
"div",
|
|
581
573
|
{
|
|
582
574
|
className: "univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400"
|
|
583
575
|
}
|
|
584
|
-
)
|
|
576
|
+
),
|
|
585
577
|
/* @__PURE__ */ b(
|
|
586
578
|
"div",
|
|
587
579
|
{
|
|
@@ -602,17 +594,17 @@ const je = B((t, e) => {
|
|
|
602
594
|
}
|
|
603
595
|
) })
|
|
604
596
|
] }),
|
|
605
|
-
o
|
|
597
|
+
!!o && /* @__PURE__ */ b("div", { className: "univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row", children: [
|
|
606
598
|
/* @__PURE__ */ l(
|
|
607
599
|
"div",
|
|
608
600
|
{
|
|
609
601
|
className: Ce(
|
|
610
602
|
`
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
603
|
+
univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer
|
|
604
|
+
univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base
|
|
605
|
+
dark:hover:!univer-bg-gray-800
|
|
606
|
+
hover:univer-bg-gray-50
|
|
607
|
+
`,
|
|
616
608
|
{
|
|
617
609
|
"univer-text-green-500": E
|
|
618
610
|
}
|
|
@@ -624,12 +616,12 @@ const je = B((t, e) => {
|
|
|
624
616
|
(D == null ? void 0 : D.userID) === o.root.personId ? /* @__PURE__ */ l(
|
|
625
617
|
"div",
|
|
626
618
|
{
|
|
627
|
-
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 dark:hover
|
|
619
|
+
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 dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-50",
|
|
628
620
|
onClick: Q,
|
|
629
621
|
children: /* @__PURE__ */ l(Te, {})
|
|
630
622
|
}
|
|
631
623
|
) : null
|
|
632
|
-
] })
|
|
624
|
+
] })
|
|
633
625
|
]
|
|
634
626
|
}
|
|
635
627
|
),
|
|
@@ -642,7 +634,6 @@ const je = B((t, e) => {
|
|
|
642
634
|
(I) => /* @__PURE__ */ l(
|
|
643
635
|
Pt,
|
|
644
636
|
{
|
|
645
|
-
onClose: h,
|
|
646
637
|
unitId: n,
|
|
647
638
|
subUnitId: r,
|
|
648
639
|
item: I,
|
|
@@ -650,6 +641,7 @@ const je = B((t, e) => {
|
|
|
650
641
|
editing: g === I.id,
|
|
651
642
|
resolved: o == null ? void 0 : o.root.resolved,
|
|
652
643
|
type: y,
|
|
644
|
+
onClose: h,
|
|
653
645
|
onEditingChange: ($) => {
|
|
654
646
|
S($ ? I.id : "");
|
|
655
647
|
},
|
|
@@ -679,7 +671,7 @@ const je = B((t, e) => {
|
|
|
679
671
|
)
|
|
680
672
|
}
|
|
681
673
|
),
|
|
682
|
-
ae
|
|
674
|
+
ae && /* @__PURE__ */ l("div", { children: /* @__PURE__ */ l(
|
|
683
675
|
je,
|
|
684
676
|
{
|
|
685
677
|
ref: H,
|
|
@@ -714,7 +706,7 @@ const je = B((t, e) => {
|
|
|
714
706
|
}
|
|
715
707
|
},
|
|
716
708
|
`${P}`
|
|
717
|
-
) })
|
|
709
|
+
) })
|
|
718
710
|
]
|
|
719
711
|
}
|
|
720
712
|
);
|
|
@@ -850,7 +842,7 @@ const je = B((t, e) => {
|
|
|
850
842
|
Q.length === 0 ? /* @__PURE__ */ b(
|
|
851
843
|
"div",
|
|
852
844
|
{
|
|
853
|
-
className: "univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark
|
|
845
|
+
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",
|
|
854
846
|
children: [
|
|
855
847
|
C.t("threadCommentUI.panel.empty"),
|
|
856
848
|
oe ? /* @__PURE__ */ l("div", { className: "univer-mt-2 univer-flex univer-flex-row", children: /* @__PURE__ */ l(se, { onClick: le, children: C.t("threadCommentUI.panel.reset") }) }) : k ? null : /* @__PURE__ */ l("div", { className: "univer-mt-2 univer-flex univer-flex-row", children: /* @__PURE__ */ b(se, { onClick: i, children: [
|
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-absolute{position:absolute}.univer-relative{position:relative}.univer-left-0{left:0}.univer-right-0{right:0}.univer-top-0{top:0}.univer-m-0{margin:0}.univer-mb-1{margin-bottom:4px}.univer-mb-3{margin-bottom:12px}.univer-mb-4{margin-bottom:16px}.univer-ml-1{margin-left:4px}.univer-mr-1\.5{margin-right:6px}.univer-mr-2{margin-right:8px}.univer-mt-2{margin-top:8px}.univer-mt-3{margin-top:12px}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-grid{display:grid}.univer-h-1\.5{height:6px}.univer-h-3\.5{height:14px}.univer-h-6{height:24px}.univer-max-h-80{max-height:320px}.univer-min-h-full{min-height:100%}.univer-w-6{width:24px}.univer-w-\[278px\]{width:278px}.univer-w-\[3px\]{width:3px}.univer-w-full{width:100%}.univer-flex-1{flex:1 1 0%}.univer-flex-shrink-0{flex-shrink:0}.univer-flex-grow-0{flex-grow:0}.univer-cursor-pointer{cursor:pointer}.univer-list-none{list-style-type:none}.univer-flex-row{flex-direction:row}.univer-flex-col{flex-direction:column}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-3{gap:12px}.univer-overflow-hidden{overflow:hidden}.univer-overflow-y-auto{overflow-y:auto}.univer-overflow-x-hidden{overflow-x:hidden}.univer-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-break-words{word-wrap:break-word}.univer-rounded-\[3px\]{border-radius:3px}.univer-rounded-full{border-radius:9999px}.univer-rounded-lg{border-radius:8px}.univer-rounded-md{border-radius:6px}.univer-rounded-sm{border-radius:2px}.univer-rounded-t-md{border-top-left-radius:6px;border-top-right-radius:6px}
|
|
1
|
+
.univer-absolute{position:absolute}.univer-relative{position:relative}.univer-left-0{left:0}.univer-right-0{right:0}.univer-top-0{top:0}.univer-m-0{margin:0}.univer-mb-1{margin-bottom:4px}.univer-mb-3{margin-bottom:12px}.univer-mb-4{margin-bottom:16px}.univer-ml-1{margin-left:4px}.univer-mr-1\.5{margin-right:6px}.univer-mr-2{margin-right:8px}.univer-mt-2{margin-top:8px}.univer-mt-3{margin-top:12px}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-grid{display:grid}.univer-h-1\.5{height:6px}.univer-h-3\.5{height:14px}.univer-h-6{height:24px}.univer-max-h-80{max-height:320px}.univer-min-h-full{min-height:100%}.univer-w-6{width:24px}.univer-w-\[278px\]{width:278px}.univer-w-\[3px\]{width:3px}.univer-w-full{width:100%}.univer-flex-1{flex:1 1 0%}.univer-flex-shrink-0{flex-shrink:0}.univer-flex-grow-0{flex-grow:0}.univer-cursor-pointer{cursor:pointer}.univer-list-none{list-style-type:none}.univer-flex-row{flex-direction:row}.univer-flex-col{flex-direction:column}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:8px}.univer-gap-3{gap:12px}.univer-overflow-hidden{overflow:hidden}.univer-overflow-y-auto{overflow-y:auto}.univer-overflow-x-hidden{overflow-x:hidden}.univer-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-break-words{word-wrap:break-word}.univer-rounded-\[3px\]{border-radius:3px}.univer-rounded-full{border-radius:9999px}.univer-rounded-lg{border-radius:8px}.univer-rounded-md{border-radius:6px}.univer-rounded-sm{border-radius:2px}.univer-rounded-t-md{border-top-left-radius:6px;border-top-right-radius:6px}.\!univer-bg-gray-900{background-color:var(--univer-gray-900)!important}.univer-bg-gray-50{background-color:var(--univer-gray-50)}.univer-bg-white{background-color:var(--univer-white)}.univer-bg-yellow-400{background-color:var(--univer-yellow-400)}.univer-bg-yellow-500{background-color:var(--univer-yellow-500)}.univer-bg-cover{background-size:cover}.univer-bg-center{background-position:center}.univer-bg-no-repeat{background-repeat:no-repeat}.univer-p-1\.5{padding:6px}.univer-p-4{padding:16px}.univer-pb-3{padding-bottom:12px}.univer-pl-\[30px\]{padding-left:30px}.univer-text-base{font-size:16px;line-height:24px}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-xs{font-size:12px;line-height:16px}.univer-text-xs\/normal{font-size:12px;line-height:1.5}.univer-font-medium{font-weight:500}.univer-leading-5{line-height:20px}.univer-text-gray-600{color:var(--univer-gray-600)}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-green-500{color:var(--univer-green-500)}.univer-text-primary-600{color:var(--univer-primary-600)}.univer-shadow{--tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, .1), 0 1px 2px -1px rgba(0, 0, 0, .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 3px #0000001a,0 1px 2px -1px #0000001a;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.hover\:univer-bg-gray-200:hover{background-color:var(--univer-gray-200)}.hover\:univer-bg-gray-50:hover{background-color:var(--univer-gray-50)}.dark\:\!univer-bg-gray-900:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.dark\:\!univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)!important}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\:hover\:\!univer-bg-gray-800:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-800)!important}.\[\&_a\]\:univer-block a{display:block}.\[\&_a\]\:univer-cursor-pointer a{cursor:pointer}.\[\&_a\]\:univer-rounded a{border-radius:4px}.\[\&_a\]\:univer-px-2 a{padding-left:8px;padding-right:8px}.\[\&_a\]\:univer-py-1\.5 a{padding-top:6px;padding-bottom:6px}.\[\&_a\]\:univer-transition-colors a{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}
|
package/lib/index.js
CHANGED
|
@@ -277,11 +277,10 @@ const je = B((t, e) => {
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
),
|
|
280
|
-
P ? /* @__PURE__ */ b("div", { className: "univer-mt-3 univer-flex univer-flex-row univer-justify-end", children: [
|
|
280
|
+
P ? /* @__PURE__ */ b("div", { className: "univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2", children: [
|
|
281
281
|
/* @__PURE__ */ l(
|
|
282
282
|
se,
|
|
283
283
|
{
|
|
284
|
-
style: { marginRight: 12 },
|
|
285
284
|
onClick: () => {
|
|
286
285
|
var u;
|
|
287
286
|
a == null || a(), O(!1), (u = c.current) == null || u.replaceText("", !0), w.executeCommand(K.id);
|
|
@@ -439,7 +438,7 @@ const je = B((t, e) => {
|
|
|
439
438
|
/* @__PURE__ */ l(
|
|
440
439
|
"time",
|
|
441
440
|
{
|
|
442
|
-
className: "univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark
|
|
441
|
+
className: "univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",
|
|
443
442
|
children: e.dT
|
|
444
443
|
}
|
|
445
444
|
),
|
|
@@ -471,7 +470,7 @@ const je = B((t, e) => {
|
|
|
471
470
|
) : /* @__PURE__ */ l(
|
|
472
471
|
"div",
|
|
473
472
|
{
|
|
474
|
-
className: "univer-text-sm univer-text-gray-900 dark
|
|
473
|
+
className: "univer-text-sm univer-text-gray-900 dark:!univer-text-white",
|
|
475
474
|
children: Ht(e.text).map((S, p) => /* @__PURE__ */ l("div", { className: "univer-break-words", children: S.map((o, _) => {
|
|
476
475
|
switch (o.type) {
|
|
477
476
|
case "mention":
|
|
@@ -555,18 +554,11 @@ const je = B((t, e) => {
|
|
|
555
554
|
"div",
|
|
556
555
|
{
|
|
557
556
|
id: `${k}-${n}-${r}-${e}`,
|
|
558
|
-
className: Ce(
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
ut,
|
|
564
|
-
{
|
|
565
|
-
"univer-w-[278px]": !C,
|
|
566
|
-
"univer-w-full": C,
|
|
567
|
-
"univer-shadow": !E && (f || u || k === "cell")
|
|
568
|
-
}
|
|
569
|
-
),
|
|
557
|
+
className: Ce("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white", ut, {
|
|
558
|
+
"univer-w-[278px]": !C,
|
|
559
|
+
"univer-w-full": C,
|
|
560
|
+
"univer-shadow": !E && (f || u || k === "cell")
|
|
561
|
+
}),
|
|
570
562
|
style: V,
|
|
571
563
|
onClick: d,
|
|
572
564
|
onMouseEnter: () => {
|
|
@@ -576,12 +568,12 @@ const je = B((t, e) => {
|
|
|
576
568
|
x == null || x(), m(!1);
|
|
577
569
|
},
|
|
578
570
|
children: [
|
|
579
|
-
!E && f
|
|
571
|
+
!E && f && /* @__PURE__ */ l(
|
|
580
572
|
"div",
|
|
581
573
|
{
|
|
582
574
|
className: "univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400"
|
|
583
575
|
}
|
|
584
|
-
)
|
|
576
|
+
),
|
|
585
577
|
/* @__PURE__ */ b(
|
|
586
578
|
"div",
|
|
587
579
|
{
|
|
@@ -602,17 +594,17 @@ const je = B((t, e) => {
|
|
|
602
594
|
}
|
|
603
595
|
) })
|
|
604
596
|
] }),
|
|
605
|
-
o
|
|
597
|
+
!!o && /* @__PURE__ */ b("div", { className: "univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row", children: [
|
|
606
598
|
/* @__PURE__ */ l(
|
|
607
599
|
"div",
|
|
608
600
|
{
|
|
609
601
|
className: Ce(
|
|
610
602
|
`
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
603
|
+
univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer
|
|
604
|
+
univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base
|
|
605
|
+
dark:hover:!univer-bg-gray-800
|
|
606
|
+
hover:univer-bg-gray-50
|
|
607
|
+
`,
|
|
616
608
|
{
|
|
617
609
|
"univer-text-green-500": E
|
|
618
610
|
}
|
|
@@ -624,12 +616,12 @@ const je = B((t, e) => {
|
|
|
624
616
|
(D == null ? void 0 : D.userID) === o.root.personId ? /* @__PURE__ */ l(
|
|
625
617
|
"div",
|
|
626
618
|
{
|
|
627
|
-
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 dark:hover
|
|
619
|
+
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 dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-50",
|
|
628
620
|
onClick: Q,
|
|
629
621
|
children: /* @__PURE__ */ l(Te, {})
|
|
630
622
|
}
|
|
631
623
|
) : null
|
|
632
|
-
] })
|
|
624
|
+
] })
|
|
633
625
|
]
|
|
634
626
|
}
|
|
635
627
|
),
|
|
@@ -642,7 +634,6 @@ const je = B((t, e) => {
|
|
|
642
634
|
(I) => /* @__PURE__ */ l(
|
|
643
635
|
Pt,
|
|
644
636
|
{
|
|
645
|
-
onClose: h,
|
|
646
637
|
unitId: n,
|
|
647
638
|
subUnitId: r,
|
|
648
639
|
item: I,
|
|
@@ -650,6 +641,7 @@ const je = B((t, e) => {
|
|
|
650
641
|
editing: g === I.id,
|
|
651
642
|
resolved: o == null ? void 0 : o.root.resolved,
|
|
652
643
|
type: y,
|
|
644
|
+
onClose: h,
|
|
653
645
|
onEditingChange: ($) => {
|
|
654
646
|
S($ ? I.id : "");
|
|
655
647
|
},
|
|
@@ -679,7 +671,7 @@ const je = B((t, e) => {
|
|
|
679
671
|
)
|
|
680
672
|
}
|
|
681
673
|
),
|
|
682
|
-
ae
|
|
674
|
+
ae && /* @__PURE__ */ l("div", { children: /* @__PURE__ */ l(
|
|
683
675
|
je,
|
|
684
676
|
{
|
|
685
677
|
ref: H,
|
|
@@ -714,7 +706,7 @@ const je = B((t, e) => {
|
|
|
714
706
|
}
|
|
715
707
|
},
|
|
716
708
|
`${P}`
|
|
717
|
-
) })
|
|
709
|
+
) })
|
|
718
710
|
]
|
|
719
711
|
}
|
|
720
712
|
);
|
|
@@ -850,7 +842,7 @@ const je = B((t, e) => {
|
|
|
850
842
|
Q.length === 0 ? /* @__PURE__ */ b(
|
|
851
843
|
"div",
|
|
852
844
|
{
|
|
853
|
-
className: "univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark
|
|
845
|
+
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",
|
|
854
846
|
children: [
|
|
855
847
|
C.t("threadCommentUI.panel.empty"),
|
|
856
848
|
oe ? /* @__PURE__ */ l("div", { className: "univer-mt-2 univer-flex univer-flex-row", children: /* @__PURE__ */ l(se, { onClick: le, children: C.t("threadCommentUI.panel.reset") }) }) : k ? null : /* @__PURE__ */ l("div", { className: "univer-mt-2 univer-flex univer-flex-row", children: /* @__PURE__ */ b(se, { onClick: i, children: [
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
declare const locale: typeof
|
|
1
|
+
import { default as enUS } from './en-US';
|
|
2
|
+
declare const locale: typeof enUS;
|
|
3
3
|
export default locale;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
(function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverThreadCommentUi={},c.UniverCore,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.UniverDesign,c.React,c.UniverDocsUi))})(this,function(c,a,_,f,X,s,L,d,se){"use strict";var Ke=Object.defineProperty;var Ge=(c,a,_)=>a in c?Ke(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var Y=(c,a,_)=>Ge(c,typeof a!="symbol"?a+"":a,_);var Se=Object.getOwnPropertyDescriptor,_e=(t,e,n,r)=>{for(var i=r>1?void 0:r?Se(e,n):e,l=t.length-1,v;l>=0;l--)(v=t[l])&&(i=v(i)||i);return i},le=(t,e)=>(n,r)=>e(n,r,t);c.ThreadCommentPanelService=class extends a.Disposable{constructor(n,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=n,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(X.filter(n=>!n)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(n){this._panelVisible=n,this._panelVisible$.next(n)}setActiveComment(n){this._activeCommentId=n,this._activeCommentId$.next(n)}},c.ThreadCommentPanelService=_e([le(0,a.Inject(f.ISidebarService)),le(1,a.IUniverInstanceService)],c.ThreadCommentPanelService);const oe="thread-comment-panel",Te="UNIVER_THREAD_COMMENT_UI_PLUGIN",de={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(t){const e=t.get(f.ISidebarService),n=t.get(c.ThreadCommentPanelService);return n.panelVisible?(e.close(),n.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:oe},width:330}),n.setPanelVisible(!0)),!0}},z={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(t,e){return t.get(c.ThreadCommentPanelService).setActiveComment(e),!0}},Ne="thread-comment-ui.config",ue={};var Ue=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Oe=(t,e,n)=>e in t?Ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n,r)=>{for(var i=r>1?void 0:r?we(e,n):e,l=t.length-1,v;l>=0;l--)(v=t[l])&&(i=v(i)||i);return i},ae=(t,e)=>(n,r)=>e(n,r,t),ce=(t,e,n)=>Oe(t,typeof e!="symbol"?e+"":e,n);c.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ue,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;const{menu:l,...v}=a.merge({},ue,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ne,v)}onStarting(){var e;a.mergeOverrideWithDependencies([[c.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(n=>{this._injector.add(n)}),[de,z].forEach(n=>{this._commandService.registerCommand(n)})}},ce(c.UniverThreadCommentUIPlugin,"pluginName",Te),ce(c.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),c.UniverThreadCommentUIPlugin=De([a.DependentOn(_.UniverThreadCommentPlugin),ae(1,a.Inject(a.Injector)),ae(2,a.ICommandService),ae(3,a.IConfigService)],c.UniverThreadCommentUIPlugin);var E=function(){return E=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},E.apply(this,arguments)},Ee=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n},K=d.forwardRef(function(t,e){var n=t.icon,r=t.id,i=t.className,l=t.extend,v=Ee(t,["icon","id","className","extend"]),C="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),I=d.useRef("_".concat(je()));return ve(n,"".concat(r),{defIds:n.defIds,idSuffix:I.current},E({ref:e,className:C},v),l)});function ve(t,e,n,r,i){return d.createElement(t.tag,E(E({key:e},ke(t,n,i)),r),(Me(t,n).children||[]).map(function(l,v){return ve(l,"".concat(e,"-").concat(t.tag,"-").concat(v),n,void 0,i)}))}function ke(t,e,n){var r=E({},t.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),t.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(l){var v=l[0],C=l[1];v==="mask"&&typeof C=="string"&&(r[v]=C.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(l){var v=l[0],C=l[1];typeof C=="string"&&(r[v]=C.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Me(t,e){var n,r=e.defIds;return!r||r.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?E(E({},t),{children:t.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?E(E({},i),{attrs:E(E({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):t}function je(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var Pe={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"}}]},me=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"delete-single",ref:e,icon:Pe}))});me.displayName="DeleteSingle";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"increase-single",ref:e,icon:$e}))});fe.displayName="IncreaseSingle";var He={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"}}]},he=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"more-horizontal-single",ref:e,icon:He}))});he.displayName="MoreHorizontalSingle";var Le={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}}]},pe=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"reply-to-comment-single",ref:e,icon:Le}))});pe.displayName="ReplyToCommentSingle";var Ve={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"}}]},ge=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"resolved-single",ref:e,icon:Ve}))});ge.displayName="ResolvedSingle";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}}]},Ce=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"solve-single",ref:e,icon:Be}))});Ce.displayName="SolveSingle";function Ie(t){return{id:"d",body:t,documentStyle:{}}}const be=d.forwardRef((t,e)=>{var V;const{comment:n,onSave:r,id:i,onCancel:l,autoFocus:v,unitId:C,type:I}=t,O=f.useDependency(a.ICommandService),k=f.useDependency(a.LocaleService),[F,M]=d.useState(!1),T=f.useDependency(se.IEditorService),h=d.useRef(null),p=I===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:C,[j,N]=d.useState(()=>{var m,g,b;return a.BuildTextUtils.transform.getPlainText((b=(g=(m=h.current)==null?void 0:m.getDocumentData().body)==null?void 0:g.dataStream)!=null?b:"")});d.useEffect(()=>{var g,b,U,y;N(a.BuildTextUtils.transform.getPlainText((U=(b=(g=h.current)==null?void 0:g.getDocumentData().body)==null?void 0:b.dataStream)!=null?U:""));const m=(y=h.current)==null?void 0:y.selectionChange$.subscribe(()=>{var o,w,G;N(a.BuildTextUtils.transform.getPlainText((G=(w=(o=h.current)==null?void 0:o.getDocumentData().body)==null?void 0:w.dataStream)!=null?G:""))});return()=>m==null?void 0:m.unsubscribe()},[(V=h.current)==null?void 0:V.selectionChange$]);const q=d.useMemo(()=>({keyCodes:[{keyCode:f.KeyCode.ENTER}],handler:m=>{m===f.KeyCode.ENTER&&O.executeCommand(se.BreakLineCommand.id)}}),[O]);d.useImperativeHandle(e,()=>({reply(m){var b,U;if(!h.current)return;T.focus((b=h.current.getEditorId())!=null?b:"");const g=Ie(m);(U=h.current)==null||U.setDocumentData(g,[{startOffset:g.body.dataStream.length-2,endOffset:g.body.dataStream.length-2,collapsed:!0}])}}));const x=()=>{if(h.current){const m=a.Tools.deepClone(h.current.getDocumentData().body);M(!1),r==null||r({...n,text:m}),h.current.replaceText(""),setTimeout(()=>{var g,b;(g=h.current)==null||g.setSelectionRanges([]),(b=h.current)==null||b.blur()},10)}};return s.jsxs("div",{onClick:m=>m.preventDefault(),children:[s.jsx(se.RichTextEditor,{className:"univer-w-full",editorRef:h,autoFocus:v,keyboardEventConfig:q,placeholder:k.t("threadCommentUI.editor.placeholder"),initialValue:(n==null?void 0:n.text)&&Ie(n.text),onFocusChange:m=>m&&M(m),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{T.focus(p)},30)}}),F?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end",children:[s.jsx(L.Button,{style:{marginRight:12},onClick:()=>{var m;l==null||l(),M(!1),(m=h.current)==null||m.replaceText("",!0),O.executeCommand(z.id)},children:k.t("threadCommentUI.editor.cancel")}),s.jsx(L.Button,{variant:"primary",disabled:!j,onClick:x,children:k.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=t=>{const{dataStream:e,customRanges:n}=t,r=e.endsWith(`\r
|
|
1
|
+
(function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverThreadCommentUi={},c.UniverCore,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.UniverDesign,c.React,c.UniverDocsUi))})(this,function(c,a,_,f,X,s,L,d,se){"use strict";var Ke=Object.defineProperty;var Ge=(c,a,_)=>a in c?Ke(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var Y=(c,a,_)=>Ge(c,typeof a!="symbol"?a+"":a,_);var Se=Object.getOwnPropertyDescriptor,_e=(t,e,n,r)=>{for(var i=r>1?void 0:r?Se(e,n):e,l=t.length-1,v;l>=0;l--)(v=t[l])&&(i=v(i)||i);return i},le=(t,e)=>(n,r)=>e(n,r,t);c.ThreadCommentPanelService=class extends a.Disposable{constructor(n,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=n,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(X.filter(n=>!n)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(n){this._panelVisible=n,this._panelVisible$.next(n)}setActiveComment(n){this._activeCommentId=n,this._activeCommentId$.next(n)}},c.ThreadCommentPanelService=_e([le(0,a.Inject(f.ISidebarService)),le(1,a.IUniverInstanceService)],c.ThreadCommentPanelService);const oe="thread-comment-panel",Te="UNIVER_THREAD_COMMENT_UI_PLUGIN",de={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(t){const e=t.get(f.ISidebarService),n=t.get(c.ThreadCommentPanelService);return n.panelVisible?(e.close(),n.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:oe},width:330}),n.setPanelVisible(!0)),!0}},z={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(t,e){return t.get(c.ThreadCommentPanelService).setActiveComment(e),!0}},Ne="thread-comment-ui.config",ue={};var Ue=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Oe=(t,e,n)=>e in t?Ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n,r)=>{for(var i=r>1?void 0:r?we(e,n):e,l=t.length-1,v;l>=0;l--)(v=t[l])&&(i=v(i)||i);return i},ae=(t,e)=>(n,r)=>e(n,r,t),ce=(t,e,n)=>Oe(t,typeof e!="symbol"?e+"":e,n);c.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ue,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;const{menu:l,...v}=a.merge({},ue,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ne,v)}onStarting(){var e;a.mergeOverrideWithDependencies([[c.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(n=>{this._injector.add(n)}),[de,z].forEach(n=>{this._commandService.registerCommand(n)})}},ce(c.UniverThreadCommentUIPlugin,"pluginName",Te),ce(c.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),c.UniverThreadCommentUIPlugin=De([a.DependentOn(_.UniverThreadCommentPlugin),ae(1,a.Inject(a.Injector)),ae(2,a.ICommandService),ae(3,a.IConfigService)],c.UniverThreadCommentUIPlugin);var E=function(){return E=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},E.apply(this,arguments)},Ee=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n},K=d.forwardRef(function(t,e){var n=t.icon,r=t.id,i=t.className,l=t.extend,v=Ee(t,["icon","id","className","extend"]),C="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),I=d.useRef("_".concat(je()));return ve(n,"".concat(r),{defIds:n.defIds,idSuffix:I.current},E({ref:e,className:C},v),l)});function ve(t,e,n,r,i){return d.createElement(t.tag,E(E({key:e},ke(t,n,i)),r),(Me(t,n).children||[]).map(function(l,v){return ve(l,"".concat(e,"-").concat(t.tag,"-").concat(v),n,void 0,i)}))}function ke(t,e,n){var r=E({},t.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),t.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(l){var v=l[0],C=l[1];v==="mask"&&typeof C=="string"&&(r[v]=C.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(l){var v=l[0],C=l[1];typeof C=="string"&&(r[v]=C.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Me(t,e){var n,r=e.defIds;return!r||r.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?E(E({},t),{children:t.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?E(E({},i),{attrs:E(E({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):t}function je(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var Pe={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"}}]},me=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"delete-single",ref:e,icon:Pe}))});me.displayName="DeleteSingle";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"increase-single",ref:e,icon:$e}))});fe.displayName="IncreaseSingle";var He={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"}}]},he=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"more-horizontal-single",ref:e,icon:He}))});he.displayName="MoreHorizontalSingle";var Le={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}}]},pe=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"reply-to-comment-single",ref:e,icon:Le}))});pe.displayName="ReplyToCommentSingle";var Ve={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"}}]},ge=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"resolved-single",ref:e,icon:Ve}))});ge.displayName="ResolvedSingle";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}}]},Ce=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"solve-single",ref:e,icon:Be}))});Ce.displayName="SolveSingle";function Ie(t){return{id:"d",body:t,documentStyle:{}}}const be=d.forwardRef((t,e)=>{var V;const{comment:n,onSave:r,id:i,onCancel:l,autoFocus:v,unitId:C,type:I}=t,O=f.useDependency(a.ICommandService),k=f.useDependency(a.LocaleService),[F,M]=d.useState(!1),T=f.useDependency(se.IEditorService),h=d.useRef(null),p=I===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:C,[j,N]=d.useState(()=>{var m,g,b;return a.BuildTextUtils.transform.getPlainText((b=(g=(m=h.current)==null?void 0:m.getDocumentData().body)==null?void 0:g.dataStream)!=null?b:"")});d.useEffect(()=>{var g,b,U,x;N(a.BuildTextUtils.transform.getPlainText((U=(b=(g=h.current)==null?void 0:g.getDocumentData().body)==null?void 0:b.dataStream)!=null?U:""));const m=(x=h.current)==null?void 0:x.selectionChange$.subscribe(()=>{var o,w,G;N(a.BuildTextUtils.transform.getPlainText((G=(w=(o=h.current)==null?void 0:o.getDocumentData().body)==null?void 0:w.dataStream)!=null?G:""))});return()=>m==null?void 0:m.unsubscribe()},[(V=h.current)==null?void 0:V.selectionChange$]);const q=d.useMemo(()=>({keyCodes:[{keyCode:f.KeyCode.ENTER}],handler:m=>{m===f.KeyCode.ENTER&&O.executeCommand(se.BreakLineCommand.id)}}),[O]);d.useImperativeHandle(e,()=>({reply(m){var b,U;if(!h.current)return;T.focus((b=h.current.getEditorId())!=null?b:"");const g=Ie(m);(U=h.current)==null||U.setDocumentData(g,[{startOffset:g.body.dataStream.length-2,endOffset:g.body.dataStream.length-2,collapsed:!0}])}}));const y=()=>{if(h.current){const m=a.Tools.deepClone(h.current.getDocumentData().body);M(!1),r==null||r({...n,text:m}),h.current.replaceText(""),setTimeout(()=>{var g,b;(g=h.current)==null||g.setSelectionRanges([]),(b=h.current)==null||b.blur()},10)}};return s.jsxs("div",{onClick:m=>m.preventDefault(),children:[s.jsx(se.RichTextEditor,{className:"univer-w-full",editorRef:h,autoFocus:v,keyboardEventConfig:q,placeholder:k.t("threadCommentUI.editor.placeholder"),initialValue:(n==null?void 0:n.text)&&Ie(n.text),onFocusChange:m=>m&&M(m),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{T.focus(p)},30)}}),F?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[s.jsx(L.Button,{onClick:()=>{var m;l==null||l(),M(!1),(m=h.current)==null||m.replaceText("",!0),O.executeCommand(z.id)},children:k.t("threadCommentUI.editor.cancel")}),s.jsx(L.Button,{variant:"primary",disabled:!j,onClick:y,children:k.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=t=>{const{dataStream:e,customRanges:n}=t,r=e.endsWith(`\r
|
|
2
2
|
`)?e.length-2:e.length,i=[];let l=0;return n==null||n.forEach(v=>{l<v.startIndex&&i.push({type:"text",content:e.slice(l,v.startIndex)}),i.push({type:"mention",content:{label:e.slice(v.startIndex,v.endIndex+1),id:v.rangeId}}),l=v.endIndex+1}),i.push({type:"text",content:e.slice(l,r)}),i},We=t=>{const{paragraphs:e=[]}=t;let n=0;return e.map(r=>{const i=a.getBodySlice(t,n,r.startIndex);return n=r.startIndex+1,Ae(i)})},Fe=t=>{let e="";const n=[];return t.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const l=e.length-1;n.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:i,endIndex:l,properties:{},wholeEntity:!0});break}}}),e+=`\r
|
|
3
|
-
`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:n}},
|
|
4
|
-
\r`},personId:(ie=$==null?void 0:$.userID)!=null?ie:"",ref:i!=null?i:"",dT:"",unitId:n,subUnitId:r,threadId:""}],...(Q=o==null?void 0:o.children)!=null?Q:[]],B=d.useRef(null),ee=S=>{S.stopPropagation(),P?w.executeCommand(z.id,{unitId:n,subUnitId:r,commentId:e}):w.executeCommand(z.id),w.executeCommand(_.ResolveCommentCommand.id,{unitId:n,subUnitId:r,commentId:e,resolved:!P}),j==null||j(!P)},J=S=>{S.stopPropagation(),w.executeCommand(z.id),!(o!=null&&o.root&&(p==null?void 0:p(o.root))===!1)&&(w.executeCommand(_.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:r,commentId:e}),I==null||I())};d.useEffect(()=>T==null?void 0:T(),[]);const ne=O((u=o==null?void 0:o.root.subUnitId)!=null?u:r),te=l&&!b&&!P,re=`${i||(o==null?void 0:o.root.ref)||""}${ne?" · ":""}${ne}`;return s.jsxs("div",{id:`${k}-${n}-${r}-${e}`,className:L.clsx(`
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
dark:hover:univer-bg-gray-800
|
|
11
|
-
hover:univer-bg-gray-50
|
|
12
|
-
`,{"univer-text-green-500":P}),onClick:ee,children:P?s.jsx(ge,{}):s.jsx(Ce,{})}),($==null?void 0:$.userID)===o.root.personId?s.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 dark:hover:univer-bg-gray-800 hover:univer-bg-gray-50",onClick:J,children:s.jsx(me,{})}):null]}):null]}),s.jsx("div",{ref:B,className:"univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",children:R.map(S=>s.jsx(qe,{onClose:I,unitId:n,subUnitId:r,item:S,isRoot:S.id===(o==null?void 0:o.root.id),editing:b===S.id,resolved:o==null?void 0:o.root.resolved,type:N,onEditingChange:H=>{U(H?S.id:"")},onReply:H=>{H&&requestAnimationFrame(()=>{var W;(W=A.current)==null||W.reply(Fe([{type:"mention",content:{id:H.userID,label:`@${H.name}`}},{type:"text",content:" "}]))})},onAddComment:h,onDeleteComment:p},S.id))}),te?s.jsx("div",{children:s.jsx(be,{ref:A,type:N,unitId:n,subUnitId:r,onSave:async({text:S,attachments:H})=>{const W={text:S,attachments:H,dT:_.getDT(),id:a.generateRandomId(),ref:i,personId:$==null?void 0:$.userID,parentId:o==null?void 0:o.root.id,unitId:n,subUnitId:r,threadId:o==null?void 0:o.root.threadId};(h==null?void 0:h(W))!==!1&&(await w.executeCommand(_.AddCommentCommand.id,{unitId:n,subUnitId:r,comment:W}),B.current&&(B.current.scrollTop=B.current.scrollHeight))},autoFocus:F||!o,onCancel:()=>{o||I==null||I()}},`${F}`)}):null]})},ze=t=>{const{unitId:e,subUnitId$:n,type:r,onAdd:i,getSubUnitName:l,onResolve:v,sortComments:C,onItemLeave:I,onItemEnter:O,disableAdd:k,tempComment:F,onAddComment:M,onDeleteComment:T,showComments:h}=t,[p,j]=d.useState("all"),[N,q]=d.useState("all"),x=f.useDependency(a.LocaleService),V=f.useDependency(a.UserManagerService),m=f.useDependency(_.ThreadCommentModel),[g,b]=d.useState(()=>m.getUnit(e)),U=f.useDependency(c.ThreadCommentPanelService),y=f.useObservable(U.activeCommentId$),o=f.useObservable(m.commentUpdate$),w=f.useDependency(a.ICommandService),G=f.useObservable(n),P=d.useRef(!0),$="panel",A=f.useObservable(V.currentUser$),R=d.useMemo(()=>{var W;const u=p==="all"?g:(W=g.filter(D=>D.subUnitId===G))!=null?W:[],S=C!=null?C:D=>D,H=u.map(D=>{var Z;return{...D.root,children:(Z=D.children)!=null?Z:[],users:D.relativeUsers}});if(h){const D=new Map;return H.forEach(Z=>{D.set(Z.id,Z)}),[...h,""].map(Z=>D.get(Z)).filter(Boolean)}else return S(H)},[h,p,g,C,G]),B=d.useMemo(()=>[...R.filter(u=>!u.resolved),...R.filter(u=>u.resolved)],[R]),ee=d.useMemo(()=>N==="resolved"?B.filter(u=>u.resolved):N==="unsolved"?B.filter(u=>!u.resolved):N==="concern_me"&&A!=null&&A.userID?B.filter(u=>u==null?void 0:u.users.has(A.userID)):B,[B,A==null?void 0:A.userID,N]),J=F?[F,...ee]:ee,ne=J.filter(u=>!u.resolved),te=J.filter(u=>u.resolved),re=N!=="all"||p!=="all",ie=()=>{q("all"),j("all")};d.useEffect(()=>{e&&b(m.getUnit(e))},[e,m,o]),d.useEffect(()=>{var D;if(!y)return;if(!P.current){P.current=!0;return}const{unitId:u,subUnitId:S,commentId:H}=y,W=`${$}-${u}-${S}-${H}`;(D=document.getElementById(W))==null||D.scrollIntoView({block:"center"})},[y]);const Q=u=>s.jsx(xe,{full:!0,prefix:$,getSubUnitName:l,id:u.id,unitId:u.unitId,subUnitId:u.subUnitId,refStr:u.ref,type:r,showEdit:(y==null?void 0:y.commentId)===u.id,showHighlight:(y==null?void 0:y.commentId)===u.id,onClick:()=>{P.current=!1,u.resolved?w.executeCommand(z.id):w.executeCommand(z.id,{unitId:u.unitId,subUnitId:u.subUnitId,commentId:u.id,temp:!1})},onMouseEnter:()=>O==null?void 0:O(u),onMouseLeave:()=>I==null?void 0:I(u),onAddComment:M,onDeleteComment:T,onResolve:S=>v==null?void 0:v(u.id,S)},u.id);return s.jsxs("div",{className:"univer-flex univer-min-h-full univer-flex-col univer-pb-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-between",children:[r===a.UniverInstanceType.UNIVER_SHEET?s.jsx(L.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:j}):null,s.jsx(L.Select,{borderless:!0,value:N,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:q})]}),J.length===0?s.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"),re?s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsx(L.Button,{onClick:ie,children:x.t("threadCommentUI.panel.reset")})}):k?null:s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsxs(L.Button,{onClick:i,children:[s.jsx(fe,{className:"univer-mr-1.5"}),x.t("threadCommentUI.panel.add")]})})]}):s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[ne.map(Q),te.length>0&&s.jsx("div",{className:"univer-text-xs",children:x.t("threadCommentUI.panel.solved")}),te.map(Q)]})]})};c.SetActiveCommentOperation=z,c.THREAD_COMMENT_PANEL=oe,c.ThreadCommentPanel=ze,c.ThreadCommentTree=xe,c.ToggleSheetCommentPanelOperation=de,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
3
|
+
`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:n}},xe="__mock__",qe=t=>{const{item:e,unitId:n,subUnitId:r,editing:i,onEditingChange:l,onReply:v,resolved:C,isRoot:I,onClose:O,onDeleteComment:k,type:F}=t,M=f.useDependency(a.ICommandService),T=f.useDependency(a.LocaleService),h=f.useDependency(a.UserManagerService),p=h.getUser(e.personId),j=f.useObservable(h.currentUser$),N=(j==null?void 0:j.userID)===e.personId,q=e.id===xe,[y,V]=d.useState(!1),m=f.useConfigValue(f.UI_PLUGIN_CONFIG_KEY),g=m==null?void 0:m.avatarFallback,b=()=>{(k==null?void 0:k(e))!==!1&&(M.executeCommand(I?_.DeleteCommentTreeCommand.id:_.DeleteCommentCommand.id,{unitId:n,subUnitId:r,commentId:e.id}),I&&(O==null||O()))};return s.jsxs("div",{className:"univer-relative univer-mb-3 univer-pl-[30px]",onMouseLeave:()=>V(!1),onMouseEnter:()=>V(!0),children:[s.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)||g})`}}),p?s.jsxs("div",{className:"univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",children:[s.jsx("div",{className:"univer-text-sm univer-font-medium univer-leading-5",children:(p==null?void 0:p.name)||" "}),s.jsxs("div",{children:[q||C?null:y&&p?s.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:s.jsx(pe,{})}):null,N&&!q&&!C?s.jsx(L.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg",children:s.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:[s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>l==null?void 0:l(!0),children:T.t("threadCommentUI.item.edit")})}),s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:b,children:T.t("threadCommentUI.item.delete")})})]})}),children:s.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:s.jsx(he,{})})}):null]})]}):null,s.jsx("time",{className:"univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",children:e.dT}),i?s.jsx(be,{type:F,id:e.id,comment:e,onCancel:()=>l==null?void 0:l(!1),autoFocus:!0,unitId:n,subUnitId:r,onSave:({text:U,attachments:x})=>{l==null||l(!1),M.executeCommand(_.UpdateCommentCommand.id,{unitId:n,subUnitId:r,payload:{commentId:e.id,text:U,attachments:x}})}}):s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:We(e.text).map((U,x)=>s.jsx("div",{className:"univer-break-words",children:U.map((o,w)=>{switch(o.type){case"mention":return s.jsxs("a",{className:"univer-text-primary-600",children:[o.content.label," "]},w);default:return o.content}})},x))})]})},ye=t=>{var ie,Q,u;const{id:e,unitId:n,subUnitId:r,refStr:i,showEdit:l=!0,onClick:v,showHighlight:C,onClose:I,getSubUnitName:O,prefix:k,autoFocus:F,onMouseEnter:M,onMouseLeave:T,onAddComment:h,onDeleteComment:p,onResolve:j,type:N,style:q,full:y}=t,V=f.useDependency(_.ThreadCommentModel),[m,g]=d.useState(!1),[b,U]=d.useState(""),x=d.useMemo(()=>V.commentUpdate$.pipe(X.debounceTime(16)),[V]);f.useObservable(x);const o=e?V.getCommentWithChildren(n,r,e):null,w=f.useDependency(a.ICommandService),G=f.useDependency(a.UserManagerService),P=o==null?void 0:o.root.resolved,$=f.useObservable(G.currentUser$),A=d.useRef(null),R=[...o?[o.root]:[{id:xe,text:{dataStream:`
|
|
4
|
+
\r`},personId:(ie=$==null?void 0:$.userID)!=null?ie:"",ref:i!=null?i:"",dT:"",unitId:n,subUnitId:r,threadId:""}],...(Q=o==null?void 0:o.children)!=null?Q:[]],B=d.useRef(null),ee=S=>{S.stopPropagation(),P?w.executeCommand(z.id,{unitId:n,subUnitId:r,commentId:e}):w.executeCommand(z.id),w.executeCommand(_.ResolveCommentCommand.id,{unitId:n,subUnitId:r,commentId:e,resolved:!P}),j==null||j(!P)},J=S=>{S.stopPropagation(),w.executeCommand(z.id),!(o!=null&&o.root&&(p==null?void 0:p(o.root))===!1)&&(w.executeCommand(_.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:r,commentId:e}),I==null||I())};d.useEffect(()=>T==null?void 0:T(),[]);const ne=O((u=o==null?void 0:o.root.subUnitId)!=null?u:r),te=l&&!b&&!P,re=`${i||(o==null?void 0:o.root.ref)||""}${ne?" · ":""}${ne}`;return s.jsxs("div",{id:`${k}-${n}-${r}-${e}`,className:L.clsx("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white",L.borderClassName,{"univer-w-[278px]":!y,"univer-w-full":y,"univer-shadow":!P&&(C||m||k==="cell")}),style:q,onClick:v,onMouseEnter:()=>{M==null||M(),g(!0)},onMouseLeave:()=>{T==null||T(),g(!1)},children:[!P&&C&&s.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"}),s.jsxs("div",{className:"univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5",children:[s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",children:[s.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"}),s.jsx(L.Tooltip,{showIfEllipsis:!0,title:re,children:s.jsx("div",{className:"univer-flex-1 univer-truncate",children:re})})]}),!!o&&s.jsxs("div",{className:"univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",children:[s.jsx("div",{className:L.clsx(`
|
|
5
|
+
univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer
|
|
6
|
+
univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base
|
|
7
|
+
dark:hover:!univer-bg-gray-800
|
|
8
|
+
hover:univer-bg-gray-50
|
|
9
|
+
`,{"univer-text-green-500":P}),onClick:ee,children:P?s.jsx(ge,{}):s.jsx(Ce,{})}),($==null?void 0:$.userID)===o.root.personId?s.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 dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-50",onClick:J,children:s.jsx(me,{})}):null]})]}),s.jsx("div",{ref:B,className:"univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",children:R.map(S=>s.jsx(qe,{unitId:n,subUnitId:r,item:S,isRoot:S.id===(o==null?void 0:o.root.id),editing:b===S.id,resolved:o==null?void 0:o.root.resolved,type:N,onClose:I,onEditingChange:H=>{U(H?S.id:"")},onReply:H=>{H&&requestAnimationFrame(()=>{var W;(W=A.current)==null||W.reply(Fe([{type:"mention",content:{id:H.userID,label:`@${H.name}`}},{type:"text",content:" "}]))})},onAddComment:h,onDeleteComment:p},S.id))}),te&&s.jsx("div",{children:s.jsx(be,{ref:A,type:N,unitId:n,subUnitId:r,onSave:async({text:S,attachments:H})=>{const W={text:S,attachments:H,dT:_.getDT(),id:a.generateRandomId(),ref:i,personId:$==null?void 0:$.userID,parentId:o==null?void 0:o.root.id,unitId:n,subUnitId:r,threadId:o==null?void 0:o.root.threadId};(h==null?void 0:h(W))!==!1&&(await w.executeCommand(_.AddCommentCommand.id,{unitId:n,subUnitId:r,comment:W}),B.current&&(B.current.scrollTop=B.current.scrollHeight))},autoFocus:F||!o,onCancel:()=>{o||I==null||I()}},`${F}`)})]})},ze=t=>{const{unitId:e,subUnitId$:n,type:r,onAdd:i,getSubUnitName:l,onResolve:v,sortComments:C,onItemLeave:I,onItemEnter:O,disableAdd:k,tempComment:F,onAddComment:M,onDeleteComment:T,showComments:h}=t,[p,j]=d.useState("all"),[N,q]=d.useState("all"),y=f.useDependency(a.LocaleService),V=f.useDependency(a.UserManagerService),m=f.useDependency(_.ThreadCommentModel),[g,b]=d.useState(()=>m.getUnit(e)),U=f.useDependency(c.ThreadCommentPanelService),x=f.useObservable(U.activeCommentId$),o=f.useObservable(m.commentUpdate$),w=f.useDependency(a.ICommandService),G=f.useObservable(n),P=d.useRef(!0),$="panel",A=f.useObservable(V.currentUser$),R=d.useMemo(()=>{var W;const u=p==="all"?g:(W=g.filter(D=>D.subUnitId===G))!=null?W:[],S=C!=null?C:D=>D,H=u.map(D=>{var Z;return{...D.root,children:(Z=D.children)!=null?Z:[],users:D.relativeUsers}});if(h){const D=new Map;return H.forEach(Z=>{D.set(Z.id,Z)}),[...h,""].map(Z=>D.get(Z)).filter(Boolean)}else return S(H)},[h,p,g,C,G]),B=d.useMemo(()=>[...R.filter(u=>!u.resolved),...R.filter(u=>u.resolved)],[R]),ee=d.useMemo(()=>N==="resolved"?B.filter(u=>u.resolved):N==="unsolved"?B.filter(u=>!u.resolved):N==="concern_me"&&A!=null&&A.userID?B.filter(u=>u==null?void 0:u.users.has(A.userID)):B,[B,A==null?void 0:A.userID,N]),J=F?[F,...ee]:ee,ne=J.filter(u=>!u.resolved),te=J.filter(u=>u.resolved),re=N!=="all"||p!=="all",ie=()=>{q("all"),j("all")};d.useEffect(()=>{e&&b(m.getUnit(e))},[e,m,o]),d.useEffect(()=>{var D;if(!x)return;if(!P.current){P.current=!0;return}const{unitId:u,subUnitId:S,commentId:H}=x,W=`${$}-${u}-${S}-${H}`;(D=document.getElementById(W))==null||D.scrollIntoView({block:"center"})},[x]);const Q=u=>s.jsx(ye,{full:!0,prefix:$,getSubUnitName:l,id:u.id,unitId:u.unitId,subUnitId:u.subUnitId,refStr:u.ref,type:r,showEdit:(x==null?void 0:x.commentId)===u.id,showHighlight:(x==null?void 0:x.commentId)===u.id,onClick:()=>{P.current=!1,u.resolved?w.executeCommand(z.id):w.executeCommand(z.id,{unitId:u.unitId,subUnitId:u.subUnitId,commentId:u.id,temp:!1})},onMouseEnter:()=>O==null?void 0:O(u),onMouseLeave:()=>I==null?void 0:I(u),onAddComment:M,onDeleteComment:T,onResolve:S=>v==null?void 0:v(u.id,S)},u.id);return s.jsxs("div",{className:"univer-flex univer-min-h-full univer-flex-col univer-pb-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-between",children:[r===a.UniverInstanceType.UNIVER_SHEET?s.jsx(L.Select,{borderless:!0,value:p,options:[{value:"current",label:y.t("threadCommentUI.filter.sheet.current")},{value:"all",label:y.t("threadCommentUI.filter.sheet.all")}],onChange:j}):null,s.jsx(L.Select,{borderless:!0,value:N,options:[{value:"all",label:y.t("threadCommentUI.filter.status.all")},{value:"resolved",label:y.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:y.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:y.t("threadCommentUI.filter.status.concernMe")}],onChange:q})]}),J.length===0?s.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:[y.t("threadCommentUI.panel.empty"),re?s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsx(L.Button,{onClick:ie,children:y.t("threadCommentUI.panel.reset")})}):k?null:s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsxs(L.Button,{onClick:i,children:[s.jsx(fe,{className:"univer-mr-1.5"}),y.t("threadCommentUI.panel.add")]})})]}):s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[ne.map(Q),te.length>0&&s.jsx("div",{className:"univer-text-xs",children:y.t("threadCommentUI.panel.solved")}),te.map(Q)]})]})};c.SetActiveCommentOperation=z,c.THREAD_COMMENT_PANEL=oe,c.ThreadCommentPanel=ze,c.ThreadCommentTree=ye,c.ToggleSheetCommentPanelOperation=de,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/thread-comment-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer common thread comment UI plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@univerjs/icons": "^0.3.24",
|
|
56
|
-
"@univerjs/core": "0.
|
|
57
|
-
"@univerjs/design": "0.
|
|
58
|
-
"@univerjs/ui": "0.
|
|
59
|
-
"@univerjs/thread-comment": "0.
|
|
60
|
-
"@univerjs/
|
|
56
|
+
"@univerjs/core": "0.8.0-beta.0",
|
|
57
|
+
"@univerjs/design": "0.8.0-beta.0",
|
|
58
|
+
"@univerjs/docs-ui": "0.8.0-beta.0",
|
|
59
|
+
"@univerjs/thread-comment": "0.8.0-beta.0",
|
|
60
|
+
"@univerjs/ui": "0.8.0-beta.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"postcss": "^8.5.3",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"tailwindcss": "^3.4.17",
|
|
67
67
|
"typescript": "^5.8.3",
|
|
68
68
|
"vite": "^6.3.5",
|
|
69
|
-
"vitest": "^3.1.
|
|
70
|
-
"@univerjs-infra/shared": "0.
|
|
69
|
+
"vitest": "^3.1.4",
|
|
70
|
+
"@univerjs-infra/shared": "0.8.0-beta.0"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"test": "vitest run",
|