@univerjs/thread-comment-ui 0.1.14 → 0.1.16
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 +3 -3
- package/lib/es/index.js +192 -199
- package/lib/types/views/thread-comment-tree/index.d.ts +1 -2
- package/lib/umd/index.js +3 -3
- package/package.json +17 -16
package/lib/cjs/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var fe=Object.defineProperty;var pe=(n,e,t)=>e in n?fe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var w=(n,e,t)=>(pe(n,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("@univerjs/thread-comment"),c=require("@univerjs/core"),W=require("@wendellhu/redi"),R=require("@univerjs/ui"),G=require("rxjs"),a=require("react"),y=require("@wendellhu/redi/react-bindings"),x=require("@univerjs/design"),Ie=require("dayjs"),Se=require("clsx"),te="thread-comment-panel",be="THREAD_COMMENT_UI_PLUGIN";var ye=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Te=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ee(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&ye(e,t,o),o},X=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends c.Disposable{constructor(t,r){super();w(this,"_panelVisible",!1);w(this,"_panelVisible$",new G.BehaviorSubject(!1));w(this,"_activeCommentId");w(this,"_activeCommentId$",new G.BehaviorSubject(void 0));w(this,"panelVisible$",this._panelVisible$.asObservable());w(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init()}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).pipe(G.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}};exports.ThreadCommentPanelService=Te([X(0,W.Inject(R.ISidebarService)),X(1,c.IUniverInstanceService)],exports.ThreadCommentPanelService);const ne={id:"thread-comment-ui.operation.toggle-panel",type:c.CommandType.OPERATION,handler(n){const e=n.get(R.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:te},width:320}),t.setPanelVisible(!0)),!0}},K={id:"thread-comment-ui.operation.set-active-comment",type:c.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}};var _e=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Me=(n,e,t,r)=>{for(var o=r>1?void 0:r?xe(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&_e(e,t,o),o},Ue=(n,e)=>(t,r)=>e(t,r,n);let Z=class extends c.Disposable{constructor(n){super(),this._localeService=n}};Z=Me([c.OnLifecycle(c.LifecycleStages.Starting,Z),Ue(0,W.Inject(c.LocaleService))],Z);class Pe{constructor(){w(this,"trigger","@")}async getMentions(e){return[]}}const J=W.createIdentifier("thread-comment.mention-data.service");var re=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Oe=(n,e,t)=>e in n?re(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,De=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ne(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&re(e,t,o),o},ee=(n,e)=>(t,r)=>e(t,r,n),ae=(n,e,t)=>(Oe(n,typeof e!="symbol"?e+"":e,t),t);exports.UniverThreadCommentUIPlugin=class extends c.Plugin{constructor(e,t,r){super(),this._config=e,this._injector=t,this._commandService=r}onStarting(e){var t;c.mergeOverrideWithDependencies([[Z],[exports.ThreadCommentPanelService],[J,{useClass:Pe}]],(t=this._config)==null?void 0:t.overrides).forEach(r=>{e.add(r)}),[ne,K].forEach(r=>{this._commandService.registerCommand(r)})}};ae(exports.UniverThreadCommentUIPlugin,"pluginName",be);ae(exports.UniverThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=De([c.DependentOn(O.UniverThreadCommentPlugin),ee(1,W.Inject(W.Injector)),ee(2,c.ICommandService)],exports.UniverThreadCommentUIPlugin);var _=function(){return _=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},_.apply(this,arguments)},$e=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]]);return t},k=a.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,i=n.extend,s=$e(n,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),d=a.useRef("_".concat(He()));return oe(t,"".concat(r),{defIds:t.defIds,idSuffix:d.current},_({ref:e,className:u},s),i)});function oe(n,e,t,r,o){return a.createElement(n.tag,_(_({key:e},we(n,t,o)),r),(Re(n,t).children||[]).map(function(i,s){return oe(i,"".concat(e,"-").concat(n.tag,"-").concat(s),t,void 0,o)}))}function we(n,e,t){var r=_({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(i){var s=i[0],u=i[1];typeof u=="string"&&(r[s]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Re(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?_(_({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?_(_({},o),{attrs:_(_({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function He(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"delete-single",ref:e,icon:Le}))});ie.displayName="DeleteSingle";const je=ie;var ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},le=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"increase-single",ref:e,icon:ke}))});le.displayName="IncreaseSingle";const Ae=le;var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},se=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Ve}))});se.displayName="MoreHorizontalSingle";const Be=se;var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},me=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:We}))});me.displayName="ReplyToCommentSingle";const qe=me;var ze={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ce=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"resolved-single",ref:e,icon:ze}))});ce.displayName="ResolvedSingle";const Fe=ce;var Ze={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},de=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"solve-single",ref:e,icon:Ze}))});de.displayName="SolveSingle";const Ye=de,Ge="univer-thread-comment-editor-buttons",Ke="univer-thread-comment-editor-suggestion",Je="univer-thread-comment-editor-suggestionActive",Qe="univer-thread-comment-editor-suggestion-icon",Y={threadCommentEditorButtons:Ge,threadCommentEditorSuggestion:Ke,threadCommentEditorSuggestionActive:Je,threadCommentEditorSuggestionIcon:Qe},Xe=n=>{const e=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let t,r=0;const o=[];for(;(t=e.exec(n))!==null;)t.index>r&&o.push({type:"text",content:n.substring(r,t.index)}),t[1]&&t[2]?o.push({type:"mention",content:{label:t[1],id:t[2]}}):t[3]&&o.push({type:"text",content:t[3]}),r=e.lastIndex;return r<n.length&&o.push({type:"text",content:n.substring(r)}),o},et=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),ue=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let i=0;return t==null||t.forEach(s=>{i<s.startIndex&&o.push({type:"text",content:e.slice(i,s.startIndex)}),o.push({type:"mention",content:{label:e.slice(s.startIndex,s.endIndex).slice(1,-1),id:s.rangeId}}),i=s.endIndex}),o.push({type:"text",content:e.slice(i,r)}),o},he=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const o=e.length;e+=`${r.content.label}`;const i=e.length;t.push({rangeId:r.content.id,rangeType:c.CustomRangeType.MENTION,startIndex:o,endIndex:i});break}}}),e+=`
|
|
2
|
-
\r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},
|
|
3
|
-
\r`},personId:(j=E==null?void 0:E.userID)!=null?j:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r}],...(V=m==null?void 0:m.children)!=null?V:[]],q=()=>{C.executeCommand(O.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!D}),
|
|
1
|
+
"use strict";var ge=Object.defineProperty;var pe=(n,e,t)=>e in n?ge(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var $=(n,e,t)=>pe(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("@univerjs/thread-comment"),d=require("@univerjs/core"),W=require("@wendellhu/redi"),R=require("@univerjs/ui"),G=require("rxjs"),a=require("react"),y=require("@wendellhu/redi/react-bindings"),x=require("@univerjs/design"),Ie=require("dayjs"),Se=require("clsx"),te="thread-comment-panel",be="THREAD_COMMENT_UI_PLUGIN";var ye=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Te=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ee(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&ye(e,t,o),o},X=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends d.Disposable{constructor(t,r){super();$(this,"_panelVisible",!1);$(this,"_panelVisible$",new G.BehaviorSubject(!1));$(this,"_activeCommentId");$(this,"_activeCommentId$",new G.BehaviorSubject(void 0));$(this,"panelVisible$",this._panelVisible$.asObservable());$(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init()}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(G.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}};exports.ThreadCommentPanelService=Te([X(0,W.Inject(R.ISidebarService)),X(1,d.IUniverInstanceService)],exports.ThreadCommentPanelService);const ne={id:"thread-comment-ui.operation.toggle-panel",type:d.CommandType.OPERATION,handler(n){const e=n.get(R.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:te},width:320}),t.setPanelVisible(!0)),!0}},K={id:"thread-comment-ui.operation.set-active-comment",type:d.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}};var _e=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Ue=(n,e,t,r)=>{for(var o=r>1?void 0:r?xe(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&_e(e,t,o),o},Me=(n,e)=>(t,r)=>e(t,r,n);let Z=class extends d.Disposable{constructor(n){super(),this._localeService=n}};Z=Ue([d.OnLifecycle(d.LifecycleStages.Starting,Z),Me(0,W.Inject(d.LocaleService))],Z);class Pe{constructor(){$(this,"trigger","@")}async getMentions(e){return[]}}const J=W.createIdentifier("thread-comment.mention-data.service");var re=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Oe=(n,e,t)=>e in n?re(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,De=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ne(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&re(e,t,o),o},ee=(n,e)=>(t,r)=>e(t,r,n),ae=(n,e,t)=>Oe(n,typeof e!="symbol"?e+"":e,t);exports.UniverThreadCommentUIPlugin=class extends d.Plugin{constructor(e,t,r){super(),this._config=e,this._injector=t,this._commandService=r}onStarting(e){var t;d.mergeOverrideWithDependencies([[Z],[exports.ThreadCommentPanelService],[J,{useClass:Pe}]],(t=this._config)==null?void 0:t.overrides).forEach(r=>{e.add(r)}),[ne,K].forEach(r=>{this._commandService.registerCommand(r)})}};ae(exports.UniverThreadCommentUIPlugin,"pluginName",be);ae(exports.UniverThreadCommentUIPlugin,"type",d.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=De([d.DependentOn(O.UniverThreadCommentPlugin),ee(1,W.Inject(W.Injector)),ee(2,d.ICommandService)],exports.UniverThreadCommentUIPlugin);var _=function(){return _=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},_.apply(this,arguments)},we=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]]);return t},k=a.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,i=n.extend,s=we(n,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),c=a.useRef("_".concat(He()));return oe(t,"".concat(r),{defIds:t.defIds,idSuffix:c.current},_({ref:e,className:u},s),i)});function oe(n,e,t,r,o){return a.createElement(n.tag,_(_({key:e},$e(n,t,o)),r),(Re(n,t).children||[]).map(function(i,s){return oe(i,"".concat(e,"-").concat(n.tag,"-").concat(s),t,void 0,o)}))}function $e(n,e,t){var r=_({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(i){var s=i[0],u=i[1];typeof u=="string"&&(r[s]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Re(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?_(_({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?_(_({},o),{attrs:_(_({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function He(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"delete-single",ref:e,icon:Le}))});ie.displayName="DeleteSingle";var je={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},le=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"increase-single",ref:e,icon:je}))});le.displayName="IncreaseSingle";var ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},se=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:ke}))});se.displayName="MoreHorizontalSingle";var Ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},me=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Ae}))});me.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"}}]},de=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"resolved-single",ref:e,icon:Ve}))});de.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=a.forwardRef(function(n,e){return a.createElement(k,Object.assign({},n,{id:"solve-single",ref:e,icon:Be}))});ce.displayName="SolveSingle";const We="univer-thread-comment-editor-buttons",qe="univer-thread-comment-editor-suggestion",Fe="univer-thread-comment-editor-suggestionActive",ze="univer-thread-comment-editor-suggestion-icon",Y={threadCommentEditorButtons:We,threadCommentEditorSuggestion:qe,threadCommentEditorSuggestionActive:Fe,threadCommentEditorSuggestionIcon:ze},Ze=n=>{const e=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let t,r=0;const o=[];for(;(t=e.exec(n))!==null;)t.index>r&&o.push({type:"text",content:n.substring(r,t.index)}),t[1]&&t[2]?o.push({type:"mention",content:{label:t[1],id:t[2]}}):t[3]&&o.push({type:"text",content:t[3]}),r=e.lastIndex;return r<n.length&&o.push({type:"text",content:n.substring(r)}),o},Ye=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),ue=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let i=0;return t==null||t.forEach(s=>{i<s.startIndex&&o.push({type:"text",content:e.slice(i,s.startIndex)}),o.push({type:"mention",content:{label:e.slice(s.startIndex,s.endIndex).slice(1,-1),id:s.rangeId}}),i=s.endIndex}),o.push({type:"text",content:e.slice(i,r)}),o},he=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const o=e.length;e+=`${r.content.label}`;const i=e.length;t.push({rangeId:r.content.id,rangeType:d.CustomRangeType.MENTION,startIndex:o,endIndex:i});break}}}),e+=`
|
|
2
|
+
\r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},Ge=n=>({display:n.label,id:`${n.id}`,raw:n}),Ke=(n,e,t,r,o)=>{var s,u;const i=(s=n.raw)==null?void 0:s.icon;return a.createElement("div",{className:Y.threadCommentEditorSuggestion},i?a.createElement("img",{className:Y.threadCommentEditorSuggestionIcon,src:i}):null,a.createElement("div",null,(u=n.display)!=null?u:n.id))},ve=a.forwardRef((n,e)=>{var h;const{comment:t,onSave:r,id:o,onCancel:i,autoFocus:s}=n,u=y.useDependency(J),c=y.useDependency(d.LocaleService),[g,p]=a.useState({...t}),[U,I]=a.useState(!1),S=a.useRef(null);return a.useImperativeHandle(e,()=>({reply(b){var v;p({...t,text:b,attachments:[]}),(v=S.current)==null||v.inputElement.focus()}})),a.createElement("div",{className:Y.threadCommentEditor,onClick:b=>b.preventDefault()},a.createElement(x.Mentions,{ref:S,autoFocus:s,style:{width:"100%"},placeholder:c.t("threadCommentUI.editor.placeholder"),value:g!=null&&g.text?Ye(ue(g.text)):"",onChange:b=>{b.target.value||p({...t,text:void 0}),p==null||p({...t,text:he(Ze(b.target.value))})},onFocus:()=>{I(!0)}},a.createElement(x.Mention,{key:u.trigger,trigger:u.trigger,data:(b,v)=>u.getMentions(b).then(M=>M.map(Ge)).then(v),displayTransform:(b,v)=>`@${v} `,renderSuggestion:(h=u.renderSuggestion)!=null?h:Ke})),U?a.createElement("div",{className:Y.threadCommentEditorButtons},a.createElement(x.Button,{style:{marginRight:12},onClick:()=>{i==null||i(),I(!1),p({text:void 0})}},c.t("threadCommentUI.editor.cancel")),a.createElement(x.Button,{type:"primary",disabled:!g.text,onClick:()=>{g.text&&(r==null||r({...g,text:g.text}),I(!1),p({text:void 0}))}},c.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),Je="univer-thread-comment",Qe="univer-thread-comment-active",Xe="univer-thread-comment-content",et="univer-thread-comment-highlight",tt="univer-thread-comment-icon-container",nt="univer-thread-comment-icon",rt="univer-thread-comment-title",at="univer-thread-comment-title-position",ot="univer-thread-comment-title-highlight",it="univer-thread-comment-username",lt="univer-thread-comment-item",st="univer-thread-comment-item-head",mt="univer-thread-comment-item-title",dt="univer-thread-comment-item-title-position",ct="univer-thread-comment-item-title-highlight",ut="univer-thread-comment-item-time",ht="univer-thread-comment-item-content",vt="univer-thread-comment-item-at",f={threadComment:Je,threadCommentActive:Qe,threadCommentContent:Xe,threadCommentHighlight:et,threadCommentIconContainer:tt,threadCommentIcon:nt,threadCommentTitle:rt,threadCommentTitlePosition:at,threadCommentTitleHighlight:ot,threadCommentUsername:it,threadCommentItem:lt,threadCommentItemHead:st,threadCommentItemTitle:mt,threadCommentItemTitlePosition:dt,threadCommentItemTitleHighlight:ct,threadCommentItemTime:ut,threadCommentItemContent:ht,threadCommentItemAt:vt},Ce="__mock__",Ct=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:i,onReply:s,resolved:u,isRoot:c,onClose:g}=n,p=y.useDependency(d.ICommandService),U=y.useDependency(d.LocaleService),I=y.useDependency(d.UserManagerService),S=I.getUser(e.personId),h=R.useObservable(I.currentUser$),b=(h==null?void 0:h.userID)===e.personId,v=e.id===Ce,[M,H]=a.useState(!1),m=()=>{p.executeCommand(c?O.DeleteCommentTreeCommand.id:O.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),c&&(g==null||g())};return a.createElement("div",{className:f.threadCommentItem,onMouseLeave:()=>H(!1),onMouseEnter:()=>H(!0)},a.createElement("img",{className:f.threadCommentItemHead,src:S==null?void 0:S.avatar}),a.createElement("div",{className:f.threadCommentItemTitle},a.createElement("div",{className:f.threadCommentUsername},(S==null?void 0:S.name)||" "),a.createElement("div",null,v||u?null:M?a.createElement("div",{className:f.threadCommentIcon,onClick:()=>s(S)},a.createElement(me,null)):null,b&&!v&&!u?a.createElement(x.Dropdown,{overlay:a.createElement(x.Menu,null,a.createElement(x.MenuItem,{key:"edit",onClick:()=>i==null?void 0:i(!0)},U.t("threadCommentUI.item.edit")),a.createElement(x.MenuItem,{key:"delete",onClick:m},U.t("threadCommentUI.item.delete")))},a.createElement("div",{className:f.threadCommentIcon},a.createElement(se,null))):null)),a.createElement("div",{className:f.threadCommentItemTime},e.dT),o?a.createElement(ve,{id:e.id,comment:e,onCancel:()=>i==null?void 0:i(!1),autoFocus:!0,onSave:({text:C,attachments:L})=>{i==null||i(!1),p.executeCommand(O.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:C,attachments:L}})}}):a.createElement("div",{className:f.threadCommentItemContent},ue(e.text).map((C,L)=>{switch(C.type){case"mention":return a.createElement("a",{className:f.threadCommentItemAt,key:L},"@",C.content.label," ");default:return C.content}})))},fe=n=>{var j,V,F;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:i=!0,onClick:s,showHighlight:u,onClose:c,getSubUnitName:g,prefix:p,autoFocus:U,onMouseEnter:I,onMouseLeave:S}=n,h=y.useDependency(O.ThreadCommentModel),[b,v]=a.useState(!1),[M,H]=a.useState("");R.useObservable(h.commentMap$);const m=e?h.getCommentWithChildren(t,r,e):null,C=y.useDependency(d.ICommandService),L=y.useDependency(d.UserManagerService),D=m==null?void 0:m.root.resolved,E=R.useObservable(L.currentUser$),P=a.useRef(null),A=[...m?[m.root]:[{id:Ce,text:{dataStream:`
|
|
3
|
+
\r`},personId:(j=E==null?void 0:E.userID)!=null?j:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r}],...(V=m==null?void 0:m.children)!=null?V:[]],q=()=>{C.executeCommand(O.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!D}),c==null||c()},w=()=>{C.executeCommand(O.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),c==null||c()};return a.createElement("div",{className:Se(f.threadComment,{[f.threadCommentActive]:!D&&(u||b||p==="cell")}),onClick:s,id:`${p}-${t}-${r}-${e}`,onMouseEnter:()=>{I==null||I(),v(!0)},onMouseLeave:()=>{S==null||S(),v(!1)}},!D&&u?a.createElement("div",{className:f.threadCommentHighlight}):null,a.createElement("div",{className:f.threadCommentTitle},a.createElement("div",{className:f.threadCommentTitlePosition},a.createElement("div",{className:f.threadCommentTitleHighlight}),o||(m==null?void 0:m.root.ref)," · ",g((F=m==null?void 0:m.root.subUnitId)!=null?F:r)),m?a.createElement("div",{className:f.threadCommentIconContainer},a.createElement("div",{onClick:q,className:f.threadCommentIcon,style:{color:D?"rgb(var(--green-500))":""}},D?a.createElement(de,null):a.createElement(ce,null)),(E==null?void 0:E.userID)===m.root.personId?a.createElement("div",{className:f.threadCommentIcon,onClick:w},a.createElement(ie,null)):null):null),a.createElement("div",{className:f.threadCommentContent},A.map(l=>a.createElement(Ct,{onClose:c,unitId:t,subUnitId:r,item:l,key:l.id,isRoot:l.id===(m==null?void 0:m.root.id),editing:M===l.id,resolved:m==null?void 0:m.root.resolved,onEditingChange:T=>{H(T?l.id:"")},onReply:T=>{var N;T&&((N=P.current)==null||N.reply(he([{type:"mention",content:{id:T.userID,label:T.name}}])))}}))),i&&!M&&!D?a.createElement("div",null,a.createElement(ve,{key:`${U}`,ref:P,onSave:({text:l,attachments:T})=>{C.executeCommand(O.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:{text:l,attachments:T,dT:Ie().format("YYYY/MM/DD HH:mm"),id:d.Tools.generateRandomId(),ref:o,personId:E==null?void 0:E.userID,parentId:m==null?void 0:m.root.id,unitId:t,subUnitId:r}})},autoFocus:U||!m,onCancel:()=>{m||c==null||c()}})):null)},ft="univer-thread-comment-panel",gt="univer-thread-comment",pt="univer-thread-comment-panel-forms",It="univer-select",St="univer-thread-comment-panel-empty",bt="univer-thread-comment-panel-add",z={threadCommentPanel:ft,threadComment:gt,threadCommentPanelForms:pt,select:It,threadCommentPanelEmpty:St,threadCommentPanelAdd:bt},yt=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:i,onResolve:s,sortComments:u,onItemLeave:c,onItemEnter:g}=n,[p,U]=a.useState("all"),[I,S]=a.useState("all"),h=y.useDependency(d.LocaleService),b=y.useDependency(d.UserManagerService),v=y.useDependency(O.ThreadCommentModel),[M,H]=a.useState(()=>v.getUnit(e)),m=y.useDependency(exports.ThreadCommentPanelService),C=R.useObservable(m.activeCommentId$),L=R.useObservable(v.commentUpdate$),D=y.useDependency(d.ICommandService),E=R.useObservable(t),P=b.getCurrentUser(),A=a.useRef(!0),q="panel",w=a.useMemo(()=>{var l,T;if(p==="all"){const N=M.map(B=>B[1]).flat().filter(B=>!B.parentId);return u?u(N):N}else return(T=(l=M.find(N=>N[0]===E))==null?void 0:l[1])!=null?T:[]},[p,M,E,u]),j=a.useMemo(()=>I==="resolved"?w.filter(l=>l.resolved):I==="unsolved"?w.filter(l=>!l.resolved):I==="concern_me"&&P!=null&&P.userID?w.map(l=>v.getCommentWithChildren(l.unitId,l.subUnitId,l.id)).map(l=>l!=null&&l.relativeUsers.has(P.userID)?l.root:null).filter(Boolean):w,[w,P==null?void 0:P.userID,I,v]),V=I!=="all"||p!=="all",F=()=>{S("all"),U("all")};return a.useEffect(()=>{e&&H(v.getUnit(e))},[e,v,L]),a.useEffect(()=>{var Q;if(!C)return;if(!A.current){A.current=!0;return}const{unitId:l,subUnitId:T,commentId:N}=C,B=`${q}-${l}-${T}-${N}`;(Q=document.getElementById(B))==null||Q.scrollIntoView({block:"center"})},[C]),a.createElement("div",{className:z.threadCommentPanel},a.createElement("div",{className:z.threadCommentPanelForms},a.createElement(x.Select,{borderless:!0,value:p,onChange:l=>U(l),options:[{value:"current",label:h.t("threadCommentUI.filter.sheet.current")},{value:"all",label:h.t("threadCommentUI.filter.sheet.all")}]}),a.createElement(x.Select,{borderless:!0,value:I,onChange:l=>S(l),options:[{value:"all",label:h.t("threadCommentUI.filter.status.all")},{value:"resolved",label:h.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:h.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:h.t("threadCommentUI.filter.status.concernMe")}]})),j==null?void 0:j.map(l=>a.createElement(fe,{prefix:q,getSubUnitName:i,key:l.id,id:l.id,unitId:l.unitId,subUnitId:l.subUnitId,type:r,showEdit:(C==null?void 0:C.commentId)===l.id,showHighlight:(C==null?void 0:C.commentId)===l.id,onClick:()=>{A.current=!1,D.executeCommand(K.id,{unitId:l.unitId,subUnitId:l.subUnitId,commentId:l.id,temp:!0})},onClose:()=>s==null?void 0:s(l.id),onMouseEnter:()=>g==null?void 0:g(l),onMouseLeave:()=>c==null?void 0:c(l)})),j.length?null:a.createElement("div",{className:z.threadCommentPanelEmpty},V?h.t("threadCommentUI.panel.filterEmpty"):h.t("threadCommentUI.panel.empty"),V?a.createElement(x.Button,{onClick:F,type:"link"},h.t("threadCommentUI.panel.reset")):a.createElement(x.Button,{id:"thread-comment-add",className:z.threadCommentPanelAdd,type:"primary",onClick:o},a.createElement(le,null),h.t("threadCommentUI.panel.addComment"))))};exports.IThreadCommentMentionDataService=J;exports.SetActiveCommentOperation=K;exports.THREAD_COMMENT_PANEL=te;exports.ThreadCommentPanel=yt;exports.ThreadCommentTree=fe;exports.ToggleSheetCommentPanelOperation=ne;
|
package/lib/es/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var Pe = Object.defineProperty;
|
|
2
|
+
var $e = (t, e, n) => e in t ? Pe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var P = (t, e, n) => $e(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
4
|
import { UniverThreadCommentPlugin as He, ThreadCommentModel as de, AddCommentCommand as we, UpdateCommentCommand as De, ResolveCommentCommand as Re, DeleteCommentTreeCommand as ce, DeleteCommentCommand as Le } from "@univerjs/thread-comment";
|
|
5
|
-
import { Disposable as ue, UniverInstanceType as he, IUniverInstanceService as ke, CommandType as
|
|
5
|
+
import { Disposable as ue, UniverInstanceType as he, IUniverInstanceService as ke, CommandType as Ce, OnLifecycle as je, LifecycleStages as Ae, LocaleService as J, Plugin as Ve, mergeOverrideWithDependencies as Be, DependentOn as We, ICommandService as Q, CustomRangeType as Fe, UserManagerService as ee, Tools as ze } from "@univerjs/core";
|
|
6
6
|
import { Inject as te, createIdentifier as Ze, Injector as Ye } from "@wendellhu/redi";
|
|
7
|
-
import { ISidebarService as
|
|
7
|
+
import { ISidebarService as ve, useObservable as j } from "@univerjs/ui";
|
|
8
8
|
import { BehaviorSubject as re, filter as Ge } from "rxjs";
|
|
9
|
-
import
|
|
9
|
+
import o, { forwardRef as H, useRef as X, createElement as L, useState as $, useImperativeHandle as Ke, useMemo as ae, useEffect as oe } from "react";
|
|
10
10
|
import { useDependency as E } from "@wendellhu/redi/react-bindings";
|
|
11
11
|
import { Mentions as qe, Mention as Je, Button as G, Dropdown as Qe, Menu as Xe, MenuItem as ie, Select as le } from "@univerjs/design";
|
|
12
12
|
import et from "dayjs";
|
|
13
13
|
import tt from "clsx";
|
|
14
14
|
const nt = "thread-comment-panel", rt = "THREAD_COMMENT_UI_PLUGIN";
|
|
15
|
-
var
|
|
16
|
-
for (var
|
|
17
|
-
(s = t[i]) && (
|
|
18
|
-
return r &&
|
|
15
|
+
var at = Object.defineProperty, ot = Object.getOwnPropertyDescriptor, it = (t, e, n, r) => {
|
|
16
|
+
for (var a = r > 1 ? void 0 : r ? ot(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
17
|
+
(s = t[i]) && (a = (r ? s(e, n, a) : s(a)) || a);
|
|
18
|
+
return r && a && at(e, n, a), a;
|
|
19
19
|
}, se = (t, e) => (n, r) => e(n, r, t);
|
|
20
20
|
let A = class extends ue {
|
|
21
21
|
constructor(e, n) {
|
|
22
22
|
super();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
P(this, "_panelVisible", !1);
|
|
24
|
+
P(this, "_panelVisible$", new re(!1));
|
|
25
|
+
P(this, "_activeCommentId");
|
|
26
|
+
P(this, "_activeCommentId$", new re(void 0));
|
|
27
|
+
P(this, "panelVisible$", this._panelVisible$.asObservable());
|
|
28
|
+
P(this, "activeCommentId$", this._activeCommentId$.asObservable());
|
|
29
29
|
this._sidebarService = e, this._univerInstanceService = n, this._init();
|
|
30
30
|
}
|
|
31
31
|
_init() {
|
|
@@ -53,14 +53,14 @@ let A = class extends ue {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
A = it([
|
|
56
|
-
se(0, te(
|
|
56
|
+
se(0, te(ve)),
|
|
57
57
|
se(1, ke)
|
|
58
58
|
], A);
|
|
59
59
|
const lt = {
|
|
60
60
|
id: "thread-comment-ui.operation.toggle-panel",
|
|
61
|
-
type:
|
|
61
|
+
type: Ce.OPERATION,
|
|
62
62
|
handler(t) {
|
|
63
|
-
const e = t.get(
|
|
63
|
+
const e = t.get(ve), n = t.get(A);
|
|
64
64
|
return n.panelVisible ? (e.close(), n.setPanelVisible(!1)) : (e.open({
|
|
65
65
|
header: { title: "threadCommentUI.panel.title" },
|
|
66
66
|
children: { label: nt },
|
|
@@ -69,15 +69,15 @@ const lt = {
|
|
|
69
69
|
}
|
|
70
70
|
}, fe = {
|
|
71
71
|
id: "thread-comment-ui.operation.set-active-comment",
|
|
72
|
-
type:
|
|
72
|
+
type: Ce.OPERATION,
|
|
73
73
|
handler(t, e) {
|
|
74
74
|
return t.get(A).setActiveComment(e), !0;
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
var st = Object.defineProperty, mt = Object.getOwnPropertyDescriptor, dt = (t, e, n, r) => {
|
|
78
|
-
for (var
|
|
79
|
-
(s = t[i]) && (
|
|
80
|
-
return r &&
|
|
78
|
+
for (var a = r > 1 ? void 0 : r ? mt(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
79
|
+
(s = t[i]) && (a = (r ? s(e, n, a) : s(a)) || a);
|
|
80
|
+
return r && a && st(e, n, a), a;
|
|
81
81
|
}, ct = (t, e) => (n, r) => e(n, r, t);
|
|
82
82
|
let Y = class extends ue {
|
|
83
83
|
constructor(t) {
|
|
@@ -90,18 +90,18 @@ Y = dt([
|
|
|
90
90
|
], Y);
|
|
91
91
|
class ut {
|
|
92
92
|
constructor() {
|
|
93
|
-
|
|
93
|
+
P(this, "trigger", "@");
|
|
94
94
|
}
|
|
95
95
|
async getMentions(e) {
|
|
96
96
|
return [];
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
const ge = Ze("thread-comment.mention-data.service");
|
|
100
|
-
var pe = Object.defineProperty, ht = Object.getOwnPropertyDescriptor,
|
|
101
|
-
for (var
|
|
102
|
-
(s = t[i]) && (
|
|
103
|
-
return r &&
|
|
104
|
-
}, me = (t, e) => (n, r) => e(n, r, t), Ie = (t, e, n) => (
|
|
100
|
+
var pe = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, Ct = (t, e, n) => e in t ? pe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, vt = (t, e, n, r) => {
|
|
101
|
+
for (var a = r > 1 ? void 0 : r ? ht(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
102
|
+
(s = t[i]) && (a = (r ? s(e, n, a) : s(a)) || a);
|
|
103
|
+
return r && a && pe(e, n, a), a;
|
|
104
|
+
}, me = (t, e) => (n, r) => e(n, r, t), Ie = (t, e, n) => Ct(t, typeof e != "symbol" ? e + "" : e, n);
|
|
105
105
|
let K = class extends Ve {
|
|
106
106
|
constructor(t, e, n) {
|
|
107
107
|
super(), this._config = t, this._injector = e, this._commandService = n;
|
|
@@ -121,7 +121,7 @@ let K = class extends Ve {
|
|
|
121
121
|
};
|
|
122
122
|
Ie(K, "pluginName", rt);
|
|
123
123
|
Ie(K, "type", he.UNIVER_UNKNOWN);
|
|
124
|
-
K =
|
|
124
|
+
K = vt([
|
|
125
125
|
We(He),
|
|
126
126
|
me(1, te(Ye)),
|
|
127
127
|
me(2, Q)
|
|
@@ -130,41 +130,39 @@ var _ = function() {
|
|
|
130
130
|
return _ = Object.assign || function(t) {
|
|
131
131
|
for (var e, n = 1, r = arguments.length; n < r; n++) {
|
|
132
132
|
e = arguments[n];
|
|
133
|
-
for (var
|
|
134
|
-
Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
|
|
133
|
+
for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && (t[a] = e[a]);
|
|
135
134
|
}
|
|
136
135
|
return t;
|
|
137
136
|
}, _.apply(this, arguments);
|
|
138
137
|
}, ft = function(t, e) {
|
|
139
138
|
var n = {};
|
|
140
|
-
for (var r in t)
|
|
141
|
-
Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
|
|
139
|
+
for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
|
|
142
140
|
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
143
|
-
for (var
|
|
144
|
-
e.indexOf(r[
|
|
141
|
+
for (var a = 0, r = Object.getOwnPropertySymbols(t); a < r.length; a++)
|
|
142
|
+
e.indexOf(r[a]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[a]) && (n[r[a]] = t[r[a]]);
|
|
145
143
|
return n;
|
|
146
144
|
}, k = H(function(t, e) {
|
|
147
|
-
var n = t.icon, r = t.id,
|
|
145
|
+
var n = t.icon, r = t.id, a = t.className, i = t.extend, s = ft(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(r, " ").concat(a || "").trim(), d = X("_".concat(It()));
|
|
148
146
|
return be(n, "".concat(r), { defIds: n.defIds, idSuffix: d.current }, _({ ref: e, className: c }, s), i);
|
|
149
147
|
});
|
|
150
|
-
function be(t, e, n, r,
|
|
151
|
-
return L(t.tag, _(_({ key: e }, gt(t, n,
|
|
152
|
-
return be(i, "".concat(e, "-").concat(t.tag, "-").concat(s), n, void 0,
|
|
148
|
+
function be(t, e, n, r, a) {
|
|
149
|
+
return L(t.tag, _(_({ key: e }, gt(t, n, a)), r), (pt(t, n).children || []).map(function(i, s) {
|
|
150
|
+
return be(i, "".concat(e, "-").concat(t.tag, "-").concat(s), n, void 0, a);
|
|
153
151
|
}));
|
|
154
152
|
}
|
|
155
153
|
function gt(t, e, n) {
|
|
156
154
|
var r = _({}, t.attrs);
|
|
157
155
|
n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1);
|
|
158
|
-
var
|
|
159
|
-
return !
|
|
156
|
+
var a = e.defIds;
|
|
157
|
+
return !a || a.length === 0 || (t.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(i) {
|
|
160
158
|
var s = i[0], c = i[1];
|
|
161
159
|
typeof c == "string" && (r[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
162
160
|
})), r;
|
|
163
161
|
}
|
|
164
162
|
function pt(t, e) {
|
|
165
163
|
var n, r = e.defIds;
|
|
166
|
-
return !r || r.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? _(_({}, t), { children: t.children.map(function(
|
|
167
|
-
return typeof
|
|
164
|
+
return !r || r.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? _(_({}, t), { children: t.children.map(function(a) {
|
|
165
|
+
return typeof a.attrs.id == "string" && r && r.indexOf(a.attrs.id) > -1 ? _(_({}, a), { attrs: _(_({}, a.attrs), { id: a.attrs.id + e.idSuffix }) }) : a;
|
|
168
166
|
}) }) : t;
|
|
169
167
|
}
|
|
170
168
|
function It() {
|
|
@@ -179,79 +177,74 @@ var bt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em"
|
|
|
179
177
|
}));
|
|
180
178
|
});
|
|
181
179
|
Ee.displayName = "DeleteSingle";
|
|
182
|
-
|
|
183
|
-
var St = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z" } }] }, Se = H(function(t, e) {
|
|
180
|
+
var Et = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z" } }] }, ye = H(function(t, e) {
|
|
184
181
|
return L(k, Object.assign({}, t, {
|
|
185
182
|
id: "increase-single",
|
|
186
183
|
ref: e,
|
|
187
|
-
icon:
|
|
184
|
+
icon: Et
|
|
188
185
|
}));
|
|
189
186
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
var _t = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z" } }] }, ye = H(function(t, e) {
|
|
187
|
+
ye.displayName = "IncreaseSingle";
|
|
188
|
+
var yt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z" } }] }, Se = H(function(t, e) {
|
|
193
189
|
return L(k, Object.assign({}, t, {
|
|
194
190
|
id: "more-horizontal-single",
|
|
195
191
|
ref: e,
|
|
196
|
-
icon:
|
|
192
|
+
icon: yt
|
|
197
193
|
}));
|
|
198
194
|
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
var Nt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { stroke: "currentColor", d: "M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252", strokeLinecap: "round", strokeWidth: 1.2 } }] }, _e = H(function(t, e) {
|
|
195
|
+
Se.displayName = "MoreHorizontalSingle";
|
|
196
|
+
var St = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { stroke: "currentColor", d: "M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252", strokeLinecap: "round", strokeWidth: 1.2 } }] }, _e = H(function(t, e) {
|
|
202
197
|
return L(k, Object.assign({}, t, {
|
|
203
198
|
id: "reply-to-comment-single",
|
|
204
199
|
ref: e,
|
|
205
|
-
icon:
|
|
200
|
+
icon: St
|
|
206
201
|
}));
|
|
207
202
|
});
|
|
208
203
|
_e.displayName = "ReplyToCommentSingle";
|
|
209
|
-
|
|
210
|
-
var Mt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, xe = H(function(t, e) {
|
|
204
|
+
var _t = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, xe = H(function(t, e) {
|
|
211
205
|
return L(k, Object.assign({}, t, {
|
|
212
206
|
id: "resolved-single",
|
|
213
207
|
ref: e,
|
|
214
|
-
icon:
|
|
208
|
+
icon: _t
|
|
215
209
|
}));
|
|
216
210
|
});
|
|
217
211
|
xe.displayName = "ResolvedSingle";
|
|
218
|
-
|
|
219
|
-
var Ut = { 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 } }] }, Ne = H(function(t, e) {
|
|
212
|
+
var xt = { 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 } }] }, Ne = H(function(t, e) {
|
|
220
213
|
return L(k, Object.assign({}, t, {
|
|
221
214
|
id: "solve-single",
|
|
222
215
|
ref: e,
|
|
223
|
-
icon:
|
|
216
|
+
icon: xt
|
|
224
217
|
}));
|
|
225
218
|
});
|
|
226
219
|
Ne.displayName = "SolveSingle";
|
|
227
|
-
const
|
|
228
|
-
threadCommentEditorButtons:
|
|
229
|
-
threadCommentEditorSuggestion:
|
|
230
|
-
threadCommentEditorSuggestionActive:
|
|
231
|
-
threadCommentEditorSuggestionIcon:
|
|
232
|
-
},
|
|
220
|
+
const Nt = "univer-thread-comment-editor-buttons", Tt = "univer-thread-comment-editor-suggestion", Mt = "univer-thread-comment-editor-suggestionActive", Ut = "univer-thread-comment-editor-suggestion-icon", q = {
|
|
221
|
+
threadCommentEditorButtons: Nt,
|
|
222
|
+
threadCommentEditorSuggestion: Tt,
|
|
223
|
+
threadCommentEditorSuggestionActive: Mt,
|
|
224
|
+
threadCommentEditorSuggestionIcon: Ut
|
|
225
|
+
}, Ot = (t) => {
|
|
233
226
|
const e = /@\[(.*?)\]\((.*?)\)|(\w+)/g;
|
|
234
227
|
let n, r = 0;
|
|
235
|
-
const
|
|
228
|
+
const a = [];
|
|
236
229
|
for (; (n = e.exec(t)) !== null; )
|
|
237
|
-
n.index > r &&
|
|
230
|
+
n.index > r && a.push({
|
|
238
231
|
type: "text",
|
|
239
232
|
content: t.substring(r, n.index)
|
|
240
|
-
}), n[1] && n[2] ?
|
|
233
|
+
}), n[1] && n[2] ? a.push({
|
|
241
234
|
type: "mention",
|
|
242
235
|
content: {
|
|
243
236
|
label: n[1],
|
|
244
237
|
id: n[2]
|
|
245
238
|
}
|
|
246
|
-
}) : n[3] &&
|
|
239
|
+
}) : n[3] && a.push({
|
|
247
240
|
type: "text",
|
|
248
241
|
content: n[3]
|
|
249
242
|
}), r = e.lastIndex;
|
|
250
|
-
return r < t.length &&
|
|
243
|
+
return r < t.length && a.push({
|
|
251
244
|
type: "text",
|
|
252
245
|
content: t.substring(r)
|
|
253
|
-
}),
|
|
254
|
-
},
|
|
246
|
+
}), a;
|
|
247
|
+
}, Pt = (t) => t.map((e) => {
|
|
255
248
|
switch (e.type) {
|
|
256
249
|
case "mention":
|
|
257
250
|
return `@[${e.content.label}](${e.content.id})`;
|
|
@@ -259,23 +252,23 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
259
252
|
return e.content;
|
|
260
253
|
}
|
|
261
254
|
}).join(""), Te = (t) => {
|
|
262
|
-
const { dataStream: e, customRanges: n } = t, r = e.length - 2,
|
|
255
|
+
const { dataStream: e, customRanges: n } = t, r = e.length - 2, a = [];
|
|
263
256
|
let i = 0;
|
|
264
257
|
return n == null || n.forEach((s) => {
|
|
265
|
-
i < s.startIndex &&
|
|
258
|
+
i < s.startIndex && a.push({
|
|
266
259
|
type: "text",
|
|
267
260
|
content: e.slice(i, s.startIndex)
|
|
268
|
-
}),
|
|
261
|
+
}), a.push({
|
|
269
262
|
type: "mention",
|
|
270
263
|
content: {
|
|
271
264
|
label: e.slice(s.startIndex, s.endIndex).slice(1, -1),
|
|
272
265
|
id: s.rangeId
|
|
273
266
|
}
|
|
274
267
|
}), i = s.endIndex;
|
|
275
|
-
}),
|
|
268
|
+
}), a.push({
|
|
276
269
|
type: "text",
|
|
277
270
|
content: e.slice(i, r)
|
|
278
|
-
}),
|
|
271
|
+
}), a;
|
|
279
272
|
}, Me = (t) => {
|
|
280
273
|
let e = "";
|
|
281
274
|
const n = [];
|
|
@@ -285,13 +278,13 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
285
278
|
e += r.content;
|
|
286
279
|
break;
|
|
287
280
|
case "mention": {
|
|
288
|
-
const
|
|
281
|
+
const a = e.length;
|
|
289
282
|
e += `${r.content.label}`;
|
|
290
283
|
const i = e.length;
|
|
291
284
|
n.push({
|
|
292
285
|
rangeId: r.content.id,
|
|
293
|
-
rangeType:
|
|
294
|
-
startIndex:
|
|
286
|
+
rangeType: Fe.MENTION,
|
|
287
|
+
startIndex: a,
|
|
295
288
|
endIndex: i
|
|
296
289
|
});
|
|
297
290
|
break;
|
|
@@ -314,17 +307,17 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
314
307
|
dataStream: e,
|
|
315
308
|
customRanges: n
|
|
316
309
|
};
|
|
317
|
-
},
|
|
310
|
+
}, $t = (t) => ({
|
|
318
311
|
display: t.label,
|
|
319
312
|
id: `${t.id}`,
|
|
320
313
|
raw: t
|
|
321
|
-
}),
|
|
314
|
+
}), Ht = (t, e, n, r, a) => {
|
|
322
315
|
var s, c;
|
|
323
316
|
const i = (s = t.raw) == null ? void 0 : s.icon;
|
|
324
|
-
return /* @__PURE__ */
|
|
325
|
-
},
|
|
317
|
+
return /* @__PURE__ */ o.createElement("div", { className: q.threadCommentEditorSuggestion }, i ? /* @__PURE__ */ o.createElement("img", { className: q.threadCommentEditorSuggestionIcon, src: i }) : null, /* @__PURE__ */ o.createElement("div", null, (c = t.display) != null ? c : t.id));
|
|
318
|
+
}, Ue = H((t, e) => {
|
|
326
319
|
var u;
|
|
327
|
-
const { comment: n, onSave: r, id:
|
|
320
|
+
const { comment: n, onSave: r, id: a, onCancel: i, autoFocus: s } = t, c = E(ge), d = E(J), [f, g] = $({ ...n }), [x, p] = $(!1), I = X(null);
|
|
328
321
|
return Ke(e, () => ({
|
|
329
322
|
reply(b) {
|
|
330
323
|
var h;
|
|
@@ -334,32 +327,32 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
334
327
|
attachments: []
|
|
335
328
|
}), (h = I.current) == null || h.inputElement.focus();
|
|
336
329
|
}
|
|
337
|
-
})), /* @__PURE__ */
|
|
330
|
+
})), /* @__PURE__ */ o.createElement("div", { className: q.threadCommentEditor, onClick: (b) => b.preventDefault() }, /* @__PURE__ */ o.createElement(
|
|
338
331
|
qe,
|
|
339
332
|
{
|
|
340
333
|
ref: I,
|
|
341
334
|
autoFocus: s,
|
|
342
335
|
style: { width: "100%" },
|
|
343
336
|
placeholder: d.t("threadCommentUI.editor.placeholder"),
|
|
344
|
-
value: f != null && f.text ?
|
|
337
|
+
value: f != null && f.text ? Pt(Te(f.text)) : "",
|
|
345
338
|
onChange: (b) => {
|
|
346
|
-
b.target.value || g({ ...n, text: void 0 }), g == null || g({ ...n, text: Me(
|
|
339
|
+
b.target.value || g({ ...n, text: void 0 }), g == null || g({ ...n, text: Me(Ot(b.target.value)) });
|
|
347
340
|
},
|
|
348
341
|
onFocus: () => {
|
|
349
342
|
p(!0);
|
|
350
343
|
}
|
|
351
344
|
},
|
|
352
|
-
/* @__PURE__ */
|
|
345
|
+
/* @__PURE__ */ o.createElement(
|
|
353
346
|
Je,
|
|
354
347
|
{
|
|
355
348
|
key: c.trigger,
|
|
356
349
|
trigger: c.trigger,
|
|
357
|
-
data: (b, h) => c.getMentions(b).then((N) => N.map(
|
|
350
|
+
data: (b, h) => c.getMentions(b).then((N) => N.map($t)).then(h),
|
|
358
351
|
displayTransform: (b, h) => `@${h} `,
|
|
359
|
-
renderSuggestion: (u = c.renderSuggestion) != null ? u :
|
|
352
|
+
renderSuggestion: (u = c.renderSuggestion) != null ? u : Ht
|
|
360
353
|
}
|
|
361
354
|
)
|
|
362
|
-
), x ? /* @__PURE__ */
|
|
355
|
+
), x ? /* @__PURE__ */ o.createElement("div", { className: q.threadCommentEditorButtons }, /* @__PURE__ */ o.createElement(
|
|
363
356
|
G,
|
|
364
357
|
{
|
|
365
358
|
style: { marginRight: 12 },
|
|
@@ -368,7 +361,7 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
368
361
|
}
|
|
369
362
|
},
|
|
370
363
|
d.t("threadCommentUI.editor.cancel")
|
|
371
|
-
), /* @__PURE__ */
|
|
364
|
+
), /* @__PURE__ */ o.createElement(
|
|
372
365
|
G,
|
|
373
366
|
{
|
|
374
367
|
type: "primary",
|
|
@@ -380,29 +373,29 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
380
373
|
}), p(!1), g({ text: void 0 }));
|
|
381
374
|
}
|
|
382
375
|
},
|
|
383
|
-
d.t(
|
|
376
|
+
d.t(a ? "threadCommentUI.editor.save" : "threadCommentUI.editor.reply")
|
|
384
377
|
)) : null);
|
|
385
|
-
}),
|
|
386
|
-
threadComment:
|
|
387
|
-
threadCommentActive:
|
|
388
|
-
threadCommentContent:
|
|
389
|
-
threadCommentHighlight:
|
|
390
|
-
threadCommentIconContainer:
|
|
391
|
-
threadCommentIcon:
|
|
392
|
-
threadCommentTitle:
|
|
393
|
-
threadCommentTitlePosition:
|
|
394
|
-
threadCommentTitleHighlight:
|
|
395
|
-
threadCommentUsername:
|
|
396
|
-
threadCommentItem:
|
|
397
|
-
threadCommentItemHead:
|
|
398
|
-
threadCommentItemTitle:
|
|
399
|
-
threadCommentItemTitlePosition:
|
|
400
|
-
threadCommentItemTitleHighlight:
|
|
401
|
-
threadCommentItemTime:
|
|
402
|
-
threadCommentItemContent:
|
|
403
|
-
threadCommentItemAt:
|
|
404
|
-
},
|
|
405
|
-
const { item: e, unitId: n, subUnitId: r, editing:
|
|
378
|
+
}), wt = "univer-thread-comment", Dt = "univer-thread-comment-active", Rt = "univer-thread-comment-content", Lt = "univer-thread-comment-highlight", kt = "univer-thread-comment-icon-container", jt = "univer-thread-comment-icon", At = "univer-thread-comment-title", Vt = "univer-thread-comment-title-position", Bt = "univer-thread-comment-title-highlight", Wt = "univer-thread-comment-username", Ft = "univer-thread-comment-item", zt = "univer-thread-comment-item-head", Zt = "univer-thread-comment-item-title", Yt = "univer-thread-comment-item-title-position", Gt = "univer-thread-comment-item-title-highlight", Kt = "univer-thread-comment-item-time", qt = "univer-thread-comment-item-content", Jt = "univer-thread-comment-item-at", v = {
|
|
379
|
+
threadComment: wt,
|
|
380
|
+
threadCommentActive: Dt,
|
|
381
|
+
threadCommentContent: Rt,
|
|
382
|
+
threadCommentHighlight: Lt,
|
|
383
|
+
threadCommentIconContainer: kt,
|
|
384
|
+
threadCommentIcon: jt,
|
|
385
|
+
threadCommentTitle: At,
|
|
386
|
+
threadCommentTitlePosition: Vt,
|
|
387
|
+
threadCommentTitleHighlight: Bt,
|
|
388
|
+
threadCommentUsername: Wt,
|
|
389
|
+
threadCommentItem: Ft,
|
|
390
|
+
threadCommentItemHead: zt,
|
|
391
|
+
threadCommentItemTitle: Zt,
|
|
392
|
+
threadCommentItemTitlePosition: Yt,
|
|
393
|
+
threadCommentItemTitleHighlight: Gt,
|
|
394
|
+
threadCommentItemTime: Kt,
|
|
395
|
+
threadCommentItemContent: qt,
|
|
396
|
+
threadCommentItemAt: Jt
|
|
397
|
+
}, Oe = "__mock__", Qt = (t) => {
|
|
398
|
+
const { item: e, unitId: n, subUnitId: r, editing: a, onEditingChange: i, onReply: s, resolved: c, isRoot: d, onClose: f } = t, g = E(Q), x = E(J), p = E(ee), I = p.getUser(e.personId), u = j(p.currentUser$), b = (u == null ? void 0 : u.userID) === e.personId, h = e.id === Oe, [N, w] = $(!1), m = () => {
|
|
406
399
|
g.executeCommand(
|
|
407
400
|
d ? ce.id : Le.id,
|
|
408
401
|
{
|
|
@@ -412,20 +405,20 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
412
405
|
}
|
|
413
406
|
), d && (f == null || f());
|
|
414
407
|
};
|
|
415
|
-
return /* @__PURE__ */
|
|
408
|
+
return /* @__PURE__ */ o.createElement("div", { className: v.threadCommentItem, onMouseLeave: () => w(!1), onMouseEnter: () => w(!0) }, /* @__PURE__ */ o.createElement("img", { className: v.threadCommentItemHead, src: I == null ? void 0 : I.avatar }), /* @__PURE__ */ o.createElement("div", { className: v.threadCommentItemTitle }, /* @__PURE__ */ o.createElement("div", { className: v.threadCommentUsername }, (I == null ? void 0 : I.name) || " "), /* @__PURE__ */ o.createElement("div", null, h || c ? null : N ? /* @__PURE__ */ o.createElement("div", { className: v.threadCommentIcon, onClick: () => s(I) }, /* @__PURE__ */ o.createElement(_e, null)) : null, b && !h && !c ? /* @__PURE__ */ o.createElement(
|
|
416
409
|
Qe,
|
|
417
410
|
{
|
|
418
|
-
overlay: /* @__PURE__ */
|
|
411
|
+
overlay: /* @__PURE__ */ o.createElement(Xe, null, /* @__PURE__ */ o.createElement(ie, { key: "edit", onClick: () => i == null ? void 0 : i(!0) }, x.t("threadCommentUI.item.edit")), /* @__PURE__ */ o.createElement(ie, { key: "delete", onClick: m }, x.t("threadCommentUI.item.delete")))
|
|
419
412
|
},
|
|
420
|
-
/* @__PURE__ */
|
|
421
|
-
) : null)), /* @__PURE__ */
|
|
422
|
-
|
|
413
|
+
/* @__PURE__ */ o.createElement("div", { className: v.threadCommentIcon }, /* @__PURE__ */ o.createElement(Se, null))
|
|
414
|
+
) : null)), /* @__PURE__ */ o.createElement("div", { className: v.threadCommentItemTime }, e.dT), a ? /* @__PURE__ */ o.createElement(
|
|
415
|
+
Ue,
|
|
423
416
|
{
|
|
424
417
|
id: e.id,
|
|
425
418
|
comment: e,
|
|
426
419
|
onCancel: () => i == null ? void 0 : i(!1),
|
|
427
420
|
autoFocus: !0,
|
|
428
|
-
onSave: ({ text:
|
|
421
|
+
onSave: ({ text: C, attachments: D }) => {
|
|
429
422
|
i == null || i(!1), g.executeCommand(
|
|
430
423
|
De.id,
|
|
431
424
|
{
|
|
@@ -433,28 +426,28 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
433
426
|
subUnitId: r,
|
|
434
427
|
payload: {
|
|
435
428
|
commentId: e.id,
|
|
436
|
-
text:
|
|
429
|
+
text: C,
|
|
437
430
|
attachments: D
|
|
438
431
|
}
|
|
439
432
|
}
|
|
440
433
|
);
|
|
441
434
|
}
|
|
442
435
|
}
|
|
443
|
-
) : /* @__PURE__ */
|
|
444
|
-
switch (
|
|
436
|
+
) : /* @__PURE__ */ o.createElement("div", { className: v.threadCommentItemContent }, Te(e.text).map((C, D) => {
|
|
437
|
+
switch (C.type) {
|
|
445
438
|
case "mention":
|
|
446
|
-
return /* @__PURE__ */
|
|
439
|
+
return /* @__PURE__ */ o.createElement("a", { className: v.threadCommentItemAt, key: D }, "@", C.content.label, " ");
|
|
447
440
|
default:
|
|
448
|
-
return
|
|
441
|
+
return C.content;
|
|
449
442
|
}
|
|
450
443
|
})));
|
|
451
|
-
},
|
|
452
|
-
var R, B,
|
|
444
|
+
}, Xt = (t) => {
|
|
445
|
+
var R, B, z;
|
|
453
446
|
const {
|
|
454
447
|
id: e,
|
|
455
448
|
unitId: n,
|
|
456
449
|
subUnitId: r,
|
|
457
|
-
refStr:
|
|
450
|
+
refStr: a,
|
|
458
451
|
showEdit: i = !0,
|
|
459
452
|
onClick: s,
|
|
460
453
|
showHighlight: c,
|
|
@@ -464,34 +457,34 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
464
457
|
autoFocus: x,
|
|
465
458
|
onMouseEnter: p,
|
|
466
459
|
onMouseLeave: I
|
|
467
|
-
} = t, u = E(de), [b, h] =
|
|
460
|
+
} = t, u = E(de), [b, h] = $(!1), [N, w] = $("");
|
|
468
461
|
j(u.commentMap$);
|
|
469
|
-
const m = e ? u.getCommentWithChildren(n, r, e) : null,
|
|
462
|
+
const m = e ? u.getCommentWithChildren(n, r, e) : null, C = E(Q), D = E(ee), U = m == null ? void 0 : m.root.resolved, y = j(D.currentUser$), T = X(null), V = [
|
|
470
463
|
...m ? [m.root] : (
|
|
471
464
|
// mock empty comment
|
|
472
465
|
[{
|
|
473
|
-
id:
|
|
466
|
+
id: Oe,
|
|
474
467
|
text: {
|
|
475
468
|
dataStream: `
|
|
476
469
|
\r`
|
|
477
470
|
},
|
|
478
|
-
personId: (R =
|
|
479
|
-
ref:
|
|
471
|
+
personId: (R = y == null ? void 0 : y.userID) != null ? R : "",
|
|
472
|
+
ref: a != null ? a : "",
|
|
480
473
|
dT: "",
|
|
481
474
|
unitId: n,
|
|
482
475
|
subUnitId: r
|
|
483
476
|
}]
|
|
484
477
|
),
|
|
485
478
|
...(B = m == null ? void 0 : m.children) != null ? B : []
|
|
486
|
-
],
|
|
487
|
-
|
|
479
|
+
], F = () => {
|
|
480
|
+
C.executeCommand(Re.id, {
|
|
488
481
|
unitId: n,
|
|
489
482
|
subUnitId: r,
|
|
490
483
|
commentId: e,
|
|
491
|
-
resolved:
|
|
484
|
+
resolved: !U
|
|
492
485
|
}), d == null || d();
|
|
493
|
-
},
|
|
494
|
-
|
|
486
|
+
}, O = () => {
|
|
487
|
+
C.executeCommand(
|
|
495
488
|
ce.id,
|
|
496
489
|
{
|
|
497
490
|
unitId: n,
|
|
@@ -500,11 +493,11 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
500
493
|
}
|
|
501
494
|
), d == null || d();
|
|
502
495
|
};
|
|
503
|
-
return /* @__PURE__ */
|
|
496
|
+
return /* @__PURE__ */ o.createElement(
|
|
504
497
|
"div",
|
|
505
498
|
{
|
|
506
|
-
className: tt(
|
|
507
|
-
[
|
|
499
|
+
className: tt(v.threadComment, {
|
|
500
|
+
[v.threadCommentActive]: !U && (c || b || g === "cell")
|
|
508
501
|
}),
|
|
509
502
|
onClick: s,
|
|
510
503
|
id: `${g}-${n}-${r}-${e}`,
|
|
@@ -515,19 +508,19 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
515
508
|
I == null || I(), h(!1);
|
|
516
509
|
}
|
|
517
510
|
},
|
|
518
|
-
|
|
519
|
-
/* @__PURE__ */
|
|
511
|
+
!U && c ? /* @__PURE__ */ o.createElement("div", { className: v.threadCommentHighlight }) : null,
|
|
512
|
+
/* @__PURE__ */ o.createElement("div", { className: v.threadCommentTitle }, /* @__PURE__ */ o.createElement("div", { className: v.threadCommentTitlePosition }, /* @__PURE__ */ o.createElement("div", { className: v.threadCommentTitleHighlight }), a || (m == null ? void 0 : m.root.ref), " · ", f((z = m == null ? void 0 : m.root.subUnitId) != null ? z : r)), m ? /* @__PURE__ */ o.createElement("div", { className: v.threadCommentIconContainer }, /* @__PURE__ */ o.createElement(
|
|
520
513
|
"div",
|
|
521
514
|
{
|
|
522
|
-
onClick:
|
|
523
|
-
className:
|
|
524
|
-
style: { color:
|
|
515
|
+
onClick: F,
|
|
516
|
+
className: v.threadCommentIcon,
|
|
517
|
+
style: { color: U ? "rgb(var(--green-500))" : "" }
|
|
525
518
|
},
|
|
526
|
-
|
|
527
|
-
), (
|
|
528
|
-
/* @__PURE__ */
|
|
529
|
-
(l) => /* @__PURE__ */
|
|
530
|
-
|
|
519
|
+
U ? /* @__PURE__ */ o.createElement(xe, null) : /* @__PURE__ */ o.createElement(Ne, null)
|
|
520
|
+
), (y == null ? void 0 : y.userID) === m.root.personId ? /* @__PURE__ */ o.createElement("div", { className: v.threadCommentIcon, onClick: O }, /* @__PURE__ */ o.createElement(Ee, null)) : null) : null),
|
|
521
|
+
/* @__PURE__ */ o.createElement("div", { className: v.threadCommentContent }, V.map(
|
|
522
|
+
(l) => /* @__PURE__ */ o.createElement(
|
|
523
|
+
Qt,
|
|
531
524
|
{
|
|
532
525
|
onClose: d,
|
|
533
526
|
unitId: n,
|
|
@@ -537,40 +530,40 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
537
530
|
isRoot: l.id === (m == null ? void 0 : m.root.id),
|
|
538
531
|
editing: N === l.id,
|
|
539
532
|
resolved: m == null ? void 0 : m.root.resolved,
|
|
540
|
-
onEditingChange: (
|
|
541
|
-
w(
|
|
533
|
+
onEditingChange: (S) => {
|
|
534
|
+
w(S ? l.id : "");
|
|
542
535
|
},
|
|
543
|
-
onReply: (
|
|
536
|
+
onReply: (S) => {
|
|
544
537
|
var M;
|
|
545
|
-
|
|
538
|
+
S && ((M = T.current) == null || M.reply(Me([{
|
|
546
539
|
type: "mention",
|
|
547
540
|
content: {
|
|
548
|
-
id:
|
|
549
|
-
label:
|
|
541
|
+
id: S.userID,
|
|
542
|
+
label: S.name
|
|
550
543
|
}
|
|
551
544
|
}])));
|
|
552
545
|
}
|
|
553
546
|
}
|
|
554
547
|
)
|
|
555
548
|
)),
|
|
556
|
-
i && !N &&
|
|
557
|
-
|
|
549
|
+
i && !N && !U ? /* @__PURE__ */ o.createElement("div", null, /* @__PURE__ */ o.createElement(
|
|
550
|
+
Ue,
|
|
558
551
|
{
|
|
559
552
|
key: `${x}`,
|
|
560
553
|
ref: T,
|
|
561
|
-
onSave: ({ text: l, attachments:
|
|
562
|
-
|
|
554
|
+
onSave: ({ text: l, attachments: S }) => {
|
|
555
|
+
C.executeCommand(
|
|
563
556
|
we.id,
|
|
564
557
|
{
|
|
565
558
|
unitId: n,
|
|
566
559
|
subUnitId: r,
|
|
567
560
|
comment: {
|
|
568
561
|
text: l,
|
|
569
|
-
attachments:
|
|
562
|
+
attachments: S,
|
|
570
563
|
dT: et().format("YYYY/MM/DD HH:mm"),
|
|
571
|
-
id:
|
|
572
|
-
ref:
|
|
573
|
-
personId:
|
|
564
|
+
id: ze.generateRandomId(),
|
|
565
|
+
ref: a,
|
|
566
|
+
personId: y == null ? void 0 : y.userID,
|
|
574
567
|
parentId: m == null ? void 0 : m.root.id,
|
|
575
568
|
unitId: n,
|
|
576
569
|
subUnitId: r
|
|
@@ -585,39 +578,39 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
585
578
|
}
|
|
586
579
|
)) : null
|
|
587
580
|
);
|
|
588
|
-
},
|
|
589
|
-
threadCommentPanel:
|
|
590
|
-
threadComment:
|
|
591
|
-
threadCommentPanelForms:
|
|
592
|
-
select:
|
|
593
|
-
threadCommentPanelEmpty:
|
|
594
|
-
threadCommentPanelAdd:
|
|
595
|
-
},
|
|
596
|
-
const { unitId: e, subUnitId$: n, type: r, onAdd:
|
|
597
|
-
var l,
|
|
581
|
+
}, en = "univer-thread-comment-panel", tn = "univer-thread-comment", nn = "univer-thread-comment-panel-forms", rn = "univer-select", an = "univer-thread-comment-panel-empty", on = "univer-thread-comment-panel-add", Z = {
|
|
582
|
+
threadCommentPanel: en,
|
|
583
|
+
threadComment: tn,
|
|
584
|
+
threadCommentPanelForms: nn,
|
|
585
|
+
select: rn,
|
|
586
|
+
threadCommentPanelEmpty: an,
|
|
587
|
+
threadCommentPanelAdd: on
|
|
588
|
+
}, pn = (t) => {
|
|
589
|
+
const { unitId: e, subUnitId$: n, type: r, onAdd: a, getSubUnitName: i, onResolve: s, sortComments: c, onItemLeave: d, onItemEnter: f } = t, [g, x] = $("all"), [p, I] = $("all"), u = E(J), b = E(ee), h = E(de), [N, w] = $(() => h.getUnit(e)), m = E(A), C = j(m.activeCommentId$), D = j(h.commentUpdate$), U = E(Q), y = j(n), T = b.getCurrentUser(), V = X(!0), F = "panel", O = ae(() => {
|
|
590
|
+
var l, S;
|
|
598
591
|
if (g === "all") {
|
|
599
592
|
const M = N.map((W) => W[1]).flat().filter((W) => !W.parentId);
|
|
600
593
|
return c ? c(M) : M;
|
|
601
594
|
} else
|
|
602
|
-
return (
|
|
603
|
-
}, [g, N,
|
|
595
|
+
return (S = (l = N.find((M) => M[0] === y)) == null ? void 0 : l[1]) != null ? S : [];
|
|
596
|
+
}, [g, N, y, c]), R = ae(() => p === "resolved" ? O.filter((l) => l.resolved) : p === "unsolved" ? O.filter((l) => !l.resolved) : p === "concern_me" && T != null && T.userID ? O.map((l) => h.getCommentWithChildren(l.unitId, l.subUnitId, l.id)).map((l) => l != null && l.relativeUsers.has(T.userID) ? l.root : null).filter(Boolean) : O, [O, T == null ? void 0 : T.userID, p, h]), B = p !== "all" || g !== "all", z = () => {
|
|
604
597
|
I("all"), x("all");
|
|
605
598
|
};
|
|
606
|
-
return
|
|
599
|
+
return oe(() => {
|
|
607
600
|
e && w(
|
|
608
601
|
h.getUnit(e)
|
|
609
602
|
);
|
|
610
|
-
}, [e, h, D]),
|
|
603
|
+
}, [e, h, D]), oe(() => {
|
|
611
604
|
var ne;
|
|
612
|
-
if (!
|
|
605
|
+
if (!C)
|
|
613
606
|
return;
|
|
614
607
|
if (!V.current) {
|
|
615
608
|
V.current = !0;
|
|
616
609
|
return;
|
|
617
610
|
}
|
|
618
|
-
const { unitId: l, subUnitId:
|
|
611
|
+
const { unitId: l, subUnitId: S, commentId: M } = C, W = `${F}-${l}-${S}-${M}`;
|
|
619
612
|
(ne = document.getElementById(W)) == null || ne.scrollIntoView({ block: "center" });
|
|
620
|
-
}, [
|
|
613
|
+
}, [C]), /* @__PURE__ */ o.createElement("div", { className: Z.threadCommentPanel }, /* @__PURE__ */ o.createElement("div", { className: Z.threadCommentPanelForms }, /* @__PURE__ */ o.createElement(
|
|
621
614
|
le,
|
|
622
615
|
{
|
|
623
616
|
borderless: !0,
|
|
@@ -634,7 +627,7 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
634
627
|
}
|
|
635
628
|
]
|
|
636
629
|
}
|
|
637
|
-
), /* @__PURE__ */
|
|
630
|
+
), /* @__PURE__ */ o.createElement(
|
|
638
631
|
le,
|
|
639
632
|
{
|
|
640
633
|
borderless: !0,
|
|
@@ -659,20 +652,20 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
659
652
|
}
|
|
660
653
|
]
|
|
661
654
|
}
|
|
662
|
-
)), R == null ? void 0 : R.map((l) => /* @__PURE__ */
|
|
663
|
-
|
|
655
|
+
)), R == null ? void 0 : R.map((l) => /* @__PURE__ */ o.createElement(
|
|
656
|
+
Xt,
|
|
664
657
|
{
|
|
665
|
-
prefix:
|
|
658
|
+
prefix: F,
|
|
666
659
|
getSubUnitName: i,
|
|
667
660
|
key: l.id,
|
|
668
661
|
id: l.id,
|
|
669
662
|
unitId: l.unitId,
|
|
670
663
|
subUnitId: l.subUnitId,
|
|
671
664
|
type: r,
|
|
672
|
-
showEdit: (
|
|
673
|
-
showHighlight: (
|
|
665
|
+
showEdit: (C == null ? void 0 : C.commentId) === l.id,
|
|
666
|
+
showHighlight: (C == null ? void 0 : C.commentId) === l.id,
|
|
674
667
|
onClick: () => {
|
|
675
|
-
V.current = !1,
|
|
668
|
+
V.current = !1, U.executeCommand(fe.id, {
|
|
676
669
|
unitId: l.unitId,
|
|
677
670
|
subUnitId: l.subUnitId,
|
|
678
671
|
commentId: l.id,
|
|
@@ -683,22 +676,22 @@ const Ot = Ne, Pt = "univer-thread-comment-editor-buttons", Ht = "univer-thread-
|
|
|
683
676
|
onMouseEnter: () => f == null ? void 0 : f(l),
|
|
684
677
|
onMouseLeave: () => d == null ? void 0 : d(l)
|
|
685
678
|
}
|
|
686
|
-
)), R.length ? null : /* @__PURE__ */
|
|
679
|
+
)), R.length ? null : /* @__PURE__ */ o.createElement("div", { className: Z.threadCommentPanelEmpty }, B ? u.t("threadCommentUI.panel.filterEmpty") : u.t("threadCommentUI.panel.empty"), B ? /* @__PURE__ */ o.createElement(
|
|
687
680
|
G,
|
|
688
681
|
{
|
|
689
|
-
onClick:
|
|
682
|
+
onClick: z,
|
|
690
683
|
type: "link"
|
|
691
684
|
},
|
|
692
685
|
u.t("threadCommentUI.panel.reset")
|
|
693
|
-
) : /* @__PURE__ */
|
|
686
|
+
) : /* @__PURE__ */ o.createElement(
|
|
694
687
|
G,
|
|
695
688
|
{
|
|
696
689
|
id: "thread-comment-add",
|
|
697
690
|
className: Z.threadCommentPanelAdd,
|
|
698
691
|
type: "primary",
|
|
699
|
-
onClick:
|
|
692
|
+
onClick: a
|
|
700
693
|
},
|
|
701
|
-
/* @__PURE__ */
|
|
694
|
+
/* @__PURE__ */ o.createElement(ye, null),
|
|
702
695
|
u.t("threadCommentUI.panel.addComment")
|
|
703
696
|
)));
|
|
704
697
|
};
|
|
@@ -706,9 +699,9 @@ export {
|
|
|
706
699
|
ge as IThreadCommentMentionDataService,
|
|
707
700
|
fe as SetActiveCommentOperation,
|
|
708
701
|
nt as THREAD_COMMENT_PANEL,
|
|
709
|
-
|
|
702
|
+
pn as ThreadCommentPanel,
|
|
710
703
|
A as ThreadCommentPanelService,
|
|
711
|
-
|
|
704
|
+
Xt as ThreadCommentTree,
|
|
712
705
|
lt as ToggleSheetCommentPanelOperation,
|
|
713
706
|
K as UniverThreadCommentUIPlugin
|
|
714
707
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IThreadComment } from '@univerjs/thread-comment';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
-
import { UniverInstanceType } from '@univerjs/core';
|
|
4
|
-
import { IUser } from '@univerjs/protocol';
|
|
3
|
+
import { IUser, UniverInstanceType } from '@univerjs/core';
|
|
5
4
|
|
|
6
5
|
export interface IThreadCommentTreeProps {
|
|
7
6
|
id?: string;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(m,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("@univerjs/thread-comment"),require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@wendellhu/redi/react-bindings"),require("@univerjs/design"),require("dayjs"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/thread-comment","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@wendellhu/redi/react-bindings","@univerjs/design","dayjs","clsx"],C):(m=typeof globalThis<"u"?globalThis:m||self,C(m.UniverThreadCommentUi={},m.UniverThreadComment,m.UniverCore,m["@wendellhu/redi"],m.UniverUi,m.rxjs,m.React,m["@wendellhu/redi/react-bindings"],m.UniverDesign,m.dayjs,m.clsx))})(this,function(m,C,d,F,D,J,i,T,_,pe,Ie){"use strict";var et=Object.defineProperty;var tt=(m,C,d)=>C in m?et(m,C,{enumerable:!0,configurable:!0,writable:!0,value:d}):m[C]=d;var j=(m,C,d)=>(tt(m,typeof C!="symbol"?C+"":C,d),d);const R="thread-comment-panel",Se="THREAD_COMMENT_UI_PLUGIN";var ye=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,be=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ee(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&ye(e,t,o),o},ee=(n,e)=>(t,r)=>e(t,r,n);m.ThreadCommentPanelService=class extends d.Disposable{constructor(t,r){super();j(this,"_panelVisible",!1);j(this,"_panelVisible$",new J.BehaviorSubject(!1));j(this,"_activeCommentId");j(this,"_activeCommentId$",new J.BehaviorSubject(void 0));j(this,"panelVisible$",this._panelVisible$.asObservable());j(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init()}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(J.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}},m.ThreadCommentPanelService=be([ee(0,F.Inject(D.ISidebarService)),ee(1,d.IUniverInstanceService)],m.ThreadCommentPanelService);const te={id:"thread-comment-ui.operation.toggle-panel",type:d.CommandType.OPERATION,handler(n){const e=n.get(D.ISidebarService),t=n.get(m.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:R},width:320}),t.setPanelVisible(!0)),!0}},Q={id:"thread-comment-ui.operation.set-active-comment",type:d.CommandType.OPERATION,handler(n,e){return n.get(m.ThreadCommentPanelService).setActiveComment(e),!0}};var Te=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ue=(n,e,t,r)=>{for(var o=r>1?void 0:r?_e(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&Te(e,t,o),o},Pe=(n,e)=>(t,r)=>e(t,r,n);let B=class extends d.Disposable{constructor(n){super(),this._localeService=n}};B=Ue([d.OnLifecycle(d.LifecycleStages.Starting,B),Pe(0,F.Inject(d.LocaleService))],B);class Me{constructor(){j(this,"trigger","@")}async getMentions(e){return[]}}const X=F.createIdentifier("thread-comment.mention-data.service");var ne=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,xe=(n,e,t)=>e in n?ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Oe=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ne(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&ne(e,t,o),o},re=(n,e)=>(t,r)=>e(t,r,n),ie=(n,e,t)=>(xe(n,typeof e!="symbol"?e+"":e,t),t);m.UniverThreadCommentUIPlugin=class extends d.Plugin{constructor(e,t,r){super(),this._config=e,this._injector=t,this._commandService=r}onStarting(e){var t;d.mergeOverrideWithDependencies([[B],[m.ThreadCommentPanelService],[X,{useClass:Me}]],(t=this._config)==null?void 0:t.overrides).forEach(r=>{e.add(r)}),[te,Q].forEach(r=>{this._commandService.registerCommand(r)})}},ie(m.UniverThreadCommentUIPlugin,"pluginName",Se),ie(m.UniverThreadCommentUIPlugin,"type",d.UniverInstanceType.UNIVER_UNKNOWN),m.UniverThreadCommentUIPlugin=Oe([d.DependentOn(C.UniverThreadCommentPlugin),re(1,F.Inject(F.Injector)),re(2,d.ICommandService)],m.UniverThreadCommentUIPlugin);var U=function(){return U=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},U.apply(this,arguments)},we=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]]);return t},L=i.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,a=n.extend,s=we(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),u=i.useRef("_".concat($e()));return oe(t,"".concat(r),{defIds:t.defIds,idSuffix:u.current},U({ref:e,className:h},s),a)});function oe(n,e,t,r,o){return i.createElement(n.tag,U(U({key:e},De(n,t,o)),r),(He(n,t).children||[]).map(function(a,s){return oe(a,"".concat(e,"-").concat(n.tag,"-").concat(s),t,void 0,o)}))}function De(n,e,t){var r=U({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(a){var s=a[0],h=a[1];typeof h=="string"&&(r[s]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function He(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?U(U({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?U(U({},o),{attrs:U(U({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function $e(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var je={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ae=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"delete-single",ref:e,icon:je}))});ae.displayName="DeleteSingle";const Le=ae;var Ae={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"}}]},le=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"increase-single",ref:e,icon:Ae}))});le.displayName="IncreaseSingle";const ke=le;var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},me=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Ve}))});me.displayName="MoreHorizontalSingle";const Fe=me;var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},se=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:We}))});se.displayName="ReplyToCommentSingle";const qe=se;var ze={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},de=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"resolved-single",ref:e,icon:ze}))});de.displayName="ResolvedSingle";const Be=de;var Ze={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},ce=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"solve-single",ref:e,icon:Ze}))});ce.displayName="SolveSingle";const Ye=ce,Z={threadCommentEditorButtons:"univer-thread-comment-editor-buttons",threadCommentEditorSuggestion:"univer-thread-comment-editor-suggestion",threadCommentEditorSuggestionActive:"univer-thread-comment-editor-suggestionActive",threadCommentEditorSuggestionIcon:"univer-thread-comment-editor-suggestion-icon"},Ge=n=>{const e=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let t,r=0;const o=[];for(;(t=e.exec(n))!==null;)t.index>r&&o.push({type:"text",content:n.substring(r,t.index)}),t[1]&&t[2]?o.push({type:"mention",content:{label:t[1],id:t[2]}}):t[3]&&o.push({type:"text",content:t[3]}),r=e.lastIndex;return r<n.length&&o.push({type:"text",content:n.substring(r)}),o},Ke=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),ue=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let a=0;return t==null||t.forEach(s=>{a<s.startIndex&&o.push({type:"text",content:e.slice(a,s.startIndex)}),o.push({type:"mention",content:{label:e.slice(s.startIndex,s.endIndex).slice(1,-1),id:s.rangeId}}),a=s.endIndex}),o.push({type:"text",content:e.slice(a,r)}),o},he=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const o=e.length;e+=`${r.content.label}`;const a=e.length;t.push({rangeId:r.content.id,rangeType:d.CustomRangeType.MENTION,startIndex:o,endIndex:a});break}}}),e+=`
|
|
2
|
-
\r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},
|
|
3
|
-
\r`},personId:(V=P==null?void 0:P.userID)!=null?V:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r}],...(q=
|
|
1
|
+
(function(l,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("@univerjs/thread-comment"),require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@wendellhu/redi/react-bindings"),require("@univerjs/design"),require("dayjs"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/thread-comment","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@wendellhu/redi/react-bindings","@univerjs/design","dayjs","clsx"],C):(l=typeof globalThis<"u"?globalThis:l||self,C(l.UniverThreadCommentUi={},l.UniverThreadComment,l.UniverCore,l["@wendellhu/redi"],l.UniverUi,l.rxjs,l.React,l["@wendellhu/redi/react-bindings"],l.UniverDesign,l.dayjs,l.clsx))})(this,function(l,C,c,F,D,J,i,T,_,pe,Ie){"use strict";var Ge=Object.defineProperty;var Ke=(l,C,c)=>C in l?Ge(l,C,{enumerable:!0,configurable:!0,writable:!0,value:c}):l[C]=c;var $=(l,C,c)=>Ke(l,typeof C!="symbol"?C+"":C,c);const R="thread-comment-panel",Se="THREAD_COMMENT_UI_PLUGIN";var ye=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,be=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ee(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&ye(e,t,o),o},ee=(n,e)=>(t,r)=>e(t,r,n);l.ThreadCommentPanelService=class extends c.Disposable{constructor(t,r){super();$(this,"_panelVisible",!1);$(this,"_panelVisible$",new J.BehaviorSubject(!1));$(this,"_activeCommentId");$(this,"_activeCommentId$",new J.BehaviorSubject(void 0));$(this,"panelVisible$",this._panelVisible$.asObservable());$(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init()}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).pipe(J.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)}},l.ThreadCommentPanelService=be([ee(0,F.Inject(D.ISidebarService)),ee(1,c.IUniverInstanceService)],l.ThreadCommentPanelService);const te={id:"thread-comment-ui.operation.toggle-panel",type:c.CommandType.OPERATION,handler(n){const e=n.get(D.ISidebarService),t=n.get(l.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:R},width:320}),t.setPanelVisible(!0)),!0}},Q={id:"thread-comment-ui.operation.set-active-comment",type:c.CommandType.OPERATION,handler(n,e){return n.get(l.ThreadCommentPanelService).setActiveComment(e),!0}};var Te=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ue=(n,e,t,r)=>{for(var o=r>1?void 0:r?_e(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&Te(e,t,o),o},Pe=(n,e)=>(t,r)=>e(t,r,n);let B=class extends c.Disposable{constructor(n){super(),this._localeService=n}};B=Ue([c.OnLifecycle(c.LifecycleStages.Starting,B),Pe(0,F.Inject(c.LocaleService))],B);class Me{constructor(){$(this,"trigger","@")}async getMentions(e){return[]}}const X=F.createIdentifier("thread-comment.mention-data.service");var ne=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,xe=(n,e,t)=>e in n?ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Oe=(n,e,t,r)=>{for(var o=r>1?void 0:r?Ne(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&ne(e,t,o),o},re=(n,e)=>(t,r)=>e(t,r,n),ie=(n,e,t)=>xe(n,typeof e!="symbol"?e+"":e,t);l.UniverThreadCommentUIPlugin=class extends c.Plugin{constructor(e,t,r){super(),this._config=e,this._injector=t,this._commandService=r}onStarting(e){var t;c.mergeOverrideWithDependencies([[B],[l.ThreadCommentPanelService],[X,{useClass:Me}]],(t=this._config)==null?void 0:t.overrides).forEach(r=>{e.add(r)}),[te,Q].forEach(r=>{this._commandService.registerCommand(r)})}},ie(l.UniverThreadCommentUIPlugin,"pluginName",Se),ie(l.UniverThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_UNKNOWN),l.UniverThreadCommentUIPlugin=Oe([c.DependentOn(C.UniverThreadCommentPlugin),re(1,F.Inject(F.Injector)),re(2,c.ICommandService)],l.UniverThreadCommentUIPlugin);var U=function(){return U=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},U.apply(this,arguments)},we=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]]);return t},L=i.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,a=n.extend,s=we(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),u=i.useRef("_".concat(je()));return oe(t,"".concat(r),{defIds:t.defIds,idSuffix:u.current},U({ref:e,className:h},s),a)});function oe(n,e,t,r,o){return i.createElement(n.tag,U(U({key:e},De(n,t,o)),r),(He(n,t).children||[]).map(function(a,s){return oe(a,"".concat(e,"-").concat(n.tag,"-").concat(s),t,void 0,o)}))}function De(n,e,t){var r=U({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(a){var s=a[0],h=a[1];typeof h=="string"&&(r[s]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function He(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?U(U({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?U(U({},o),{attrs:U(U({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function je(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ae=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"delete-single",ref:e,icon:$e}))});ae.displayName="DeleteSingle";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},me=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"increase-single",ref:e,icon:Le}))});me.displayName="IncreaseSingle";var Ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},le=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Ae}))});le.displayName="MoreHorizontalSingle";var ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},se=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:ke}))});se.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"}}]},de=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"resolved-single",ref:e,icon:Ve}))});de.displayName="ResolvedSingle";var Fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},ce=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"solve-single",ref:e,icon:Fe}))});ce.displayName="SolveSingle";const Z={threadCommentEditorButtons:"univer-thread-comment-editor-buttons",threadCommentEditorSuggestion:"univer-thread-comment-editor-suggestion",threadCommentEditorSuggestionActive:"univer-thread-comment-editor-suggestionActive",threadCommentEditorSuggestionIcon:"univer-thread-comment-editor-suggestion-icon"},We=n=>{const e=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let t,r=0;const o=[];for(;(t=e.exec(n))!==null;)t.index>r&&o.push({type:"text",content:n.substring(r,t.index)}),t[1]&&t[2]?o.push({type:"mention",content:{label:t[1],id:t[2]}}):t[3]&&o.push({type:"text",content:t[3]}),r=e.lastIndex;return r<n.length&&o.push({type:"text",content:n.substring(r)}),o},qe=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),ue=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let a=0;return t==null||t.forEach(s=>{a<s.startIndex&&o.push({type:"text",content:e.slice(a,s.startIndex)}),o.push({type:"mention",content:{label:e.slice(s.startIndex,s.endIndex).slice(1,-1),id:s.rangeId}}),a=s.endIndex}),o.push({type:"text",content:e.slice(a,r)}),o},he=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const o=e.length;e+=`${r.content.label}`;const a=e.length;t.push({rangeId:r.content.id,rangeType:c.CustomRangeType.MENTION,startIndex:o,endIndex:a});break}}}),e+=`
|
|
2
|
+
\r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},ze=n=>({display:n.label,id:`${n.id}`,raw:n}),Be=(n,e,t,r,o)=>{var s,h;const a=(s=n.raw)==null?void 0:s.icon;return i.createElement("div",{className:Z.threadCommentEditorSuggestion},a?i.createElement("img",{className:Z.threadCommentEditorSuggestionIcon,src:a}):null,i.createElement("div",null,(h=n.display)!=null?h:n.id))},Ce=i.forwardRef((n,e)=>{var v;const{comment:t,onSave:r,id:o,onCancel:a,autoFocus:s}=n,h=T.useDependency(X),u=T.useDependency(c.LocaleService),[I,S]=i.useState({...t}),[N,y]=i.useState(!1),E=i.useRef(null);return i.useImperativeHandle(e,()=>({reply(b){var f;S({...t,text:b,attachments:[]}),(f=E.current)==null||f.inputElement.focus()}})),i.createElement("div",{className:Z.threadCommentEditor,onClick:b=>b.preventDefault()},i.createElement(_.Mentions,{ref:E,autoFocus:s,style:{width:"100%"},placeholder:u.t("threadCommentUI.editor.placeholder"),value:I!=null&&I.text?qe(ue(I.text)):"",onChange:b=>{b.target.value||S({...t,text:void 0}),S==null||S({...t,text:he(We(b.target.value))})},onFocus:()=>{y(!0)}},i.createElement(_.Mention,{key:h.trigger,trigger:h.trigger,data:(b,f)=>h.getMentions(b).then(x=>x.map(ze)).then(f),displayTransform:(b,f)=>`@${f} `,renderSuggestion:(v=h.renderSuggestion)!=null?v:Be})),N?i.createElement("div",{className:Z.threadCommentEditorButtons},i.createElement(_.Button,{style:{marginRight:12},onClick:()=>{a==null||a(),y(!1),S({text:void 0})}},u.t("threadCommentUI.editor.cancel")),i.createElement(_.Button,{type:"primary",disabled:!I.text,onClick:()=>{I.text&&(r==null||r({...I,text:I.text}),y(!1),S({text:void 0}))}},u.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),g={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",threadCommentUsername:"univer-thread-comment-username",threadCommentItem:"univer-thread-comment-item",threadCommentItemHead:"univer-thread-comment-item-head",threadCommentItemTitle:"univer-thread-comment-item-title",threadCommentItemTitlePosition:"univer-thread-comment-item-title-position",threadCommentItemTitleHighlight:"univer-thread-comment-item-title-highlight",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},ve="__mock__",Ze=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:a,onReply:s,resolved:h,isRoot:u,onClose:I}=n,S=T.useDependency(c.ICommandService),N=T.useDependency(c.LocaleService),y=T.useDependency(c.UserManagerService),E=y.getUser(e.personId),v=D.useObservable(y.currentUser$),b=(v==null?void 0:v.userID)===e.personId,f=e.id===ve,[x,A]=i.useState(!1),d=()=>{S.executeCommand(u?C.DeleteCommentTreeCommand.id:C.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),u&&(I==null||I())};return i.createElement("div",{className:g.threadCommentItem,onMouseLeave:()=>A(!1),onMouseEnter:()=>A(!0)},i.createElement("img",{className:g.threadCommentItemHead,src:E==null?void 0:E.avatar}),i.createElement("div",{className:g.threadCommentItemTitle},i.createElement("div",{className:g.threadCommentUsername},(E==null?void 0:E.name)||" "),i.createElement("div",null,f||h?null:x?i.createElement("div",{className:g.threadCommentIcon,onClick:()=>s(E)},i.createElement(se,null)):null,b&&!f&&!h?i.createElement(_.Dropdown,{overlay:i.createElement(_.Menu,null,i.createElement(_.MenuItem,{key:"edit",onClick:()=>a==null?void 0:a(!0)},N.t("threadCommentUI.item.edit")),i.createElement(_.MenuItem,{key:"delete",onClick:d},N.t("threadCommentUI.item.delete")))},i.createElement("div",{className:g.threadCommentIcon},i.createElement(le,null))):null)),i.createElement("div",{className:g.threadCommentItemTime},e.dT),o?i.createElement(Ce,{id:e.id,comment:e,onCancel:()=>a==null?void 0:a(!1),autoFocus:!0,onSave:({text:p,attachments:k})=>{a==null||a(!1),S.executeCommand(C.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:p,attachments:k}})}}):i.createElement("div",{className:g.threadCommentItemContent},ue(e.text).map((p,k)=>{switch(p.type){case"mention":return i.createElement("a",{className:g.threadCommentItemAt,key:k},"@",p.content.label," ");default:return p.content}})))},fe=n=>{var V,q,K;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:a=!0,onClick:s,showHighlight:h,onClose:u,getSubUnitName:I,prefix:S,autoFocus:N,onMouseEnter:y,onMouseLeave:E}=n,v=T.useDependency(C.ThreadCommentModel),[b,f]=i.useState(!1),[x,A]=i.useState("");D.useObservable(v.commentMap$);const d=e?v.getCommentWithChildren(t,r,e):null,p=T.useDependency(c.ICommandService),k=T.useDependency(c.UserManagerService),H=d==null?void 0:d.root.resolved,P=D.useObservable(k.currentUser$),O=i.useRef(null),W=[...d?[d.root]:[{id:ve,text:{dataStream:`
|
|
3
|
+
\r`},personId:(V=P==null?void 0:P.userID)!=null?V:"",ref:o!=null?o:"",dT:"",unitId:t,subUnitId:r}],...(q=d==null?void 0:d.children)!=null?q:[]],G=()=>{p.executeCommand(C.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!H}),u==null||u()},j=()=>{p.executeCommand(C.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),u==null||u()};return i.createElement("div",{className:Ie(g.threadComment,{[g.threadCommentActive]:!H&&(h||b||S==="cell")}),onClick:s,id:`${S}-${t}-${r}-${e}`,onMouseEnter:()=>{y==null||y(),f(!0)},onMouseLeave:()=>{E==null||E(),f(!1)}},!H&&h?i.createElement("div",{className:g.threadCommentHighlight}):null,i.createElement("div",{className:g.threadCommentTitle},i.createElement("div",{className:g.threadCommentTitlePosition},i.createElement("div",{className:g.threadCommentTitleHighlight}),o||(d==null?void 0:d.root.ref)," · ",I((K=d==null?void 0:d.root.subUnitId)!=null?K:r)),d?i.createElement("div",{className:g.threadCommentIconContainer},i.createElement("div",{onClick:G,className:g.threadCommentIcon,style:{color:H?"rgb(var(--green-500))":""}},H?i.createElement(de,null):i.createElement(ce,null)),(P==null?void 0:P.userID)===d.root.personId?i.createElement("div",{className:g.threadCommentIcon,onClick:j},i.createElement(ae,null)):null):null),i.createElement("div",{className:g.threadCommentContent},W.map(m=>i.createElement(Ze,{onClose:u,unitId:t,subUnitId:r,item:m,key:m.id,isRoot:m.id===(d==null?void 0:d.root.id),editing:x===m.id,resolved:d==null?void 0:d.root.resolved,onEditingChange:M=>{A(M?m.id:"")},onReply:M=>{var w;M&&((w=O.current)==null||w.reply(he([{type:"mention",content:{id:M.userID,label:M.name}}])))}}))),a&&!x&&!H?i.createElement("div",null,i.createElement(Ce,{key:`${N}`,ref:O,onSave:({text:m,attachments:M})=>{p.executeCommand(C.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:{text:m,attachments:M,dT:pe().format("YYYY/MM/DD HH:mm"),id:c.Tools.generateRandomId(),ref:o,personId:P==null?void 0:P.userID,parentId:d==null?void 0:d.root.id,unitId:t,subUnitId:r}})},autoFocus:N||!d,onCancel:()=>{d||u==null||u()}})):null)},Y={threadCommentPanel:"univer-thread-comment-panel",threadComment:"univer-thread-comment",threadCommentPanelForms:"univer-thread-comment-panel-forms",select:"univer-select",threadCommentPanelEmpty:"univer-thread-comment-panel-empty",threadCommentPanelAdd:"univer-thread-comment-panel-add"},Ye=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:a,onResolve:s,sortComments:h,onItemLeave:u,onItemEnter:I}=n,[S,N]=i.useState("all"),[y,E]=i.useState("all"),v=T.useDependency(c.LocaleService),b=T.useDependency(c.UserManagerService),f=T.useDependency(C.ThreadCommentModel),[x,A]=i.useState(()=>f.getUnit(e)),d=T.useDependency(l.ThreadCommentPanelService),p=D.useObservable(d.activeCommentId$),k=D.useObservable(f.commentUpdate$),H=T.useDependency(c.ICommandService),P=D.useObservable(t),O=b.getCurrentUser(),W=i.useRef(!0),G="panel",j=i.useMemo(()=>{var m,M;if(S==="all"){const w=x.map(z=>z[1]).flat().filter(z=>!z.parentId);return h?h(w):w}else return(M=(m=x.find(w=>w[0]===P))==null?void 0:m[1])!=null?M:[]},[S,x,P,h]),V=i.useMemo(()=>y==="resolved"?j.filter(m=>m.resolved):y==="unsolved"?j.filter(m=>!m.resolved):y==="concern_me"&&O!=null&&O.userID?j.map(m=>f.getCommentWithChildren(m.unitId,m.subUnitId,m.id)).map(m=>m!=null&&m.relativeUsers.has(O.userID)?m.root:null).filter(Boolean):j,[j,O==null?void 0:O.userID,y,f]),q=y!=="all"||S!=="all",K=()=>{E("all"),N("all")};return i.useEffect(()=>{e&&A(f.getUnit(e))},[e,f,k]),i.useEffect(()=>{var ge;if(!p)return;if(!W.current){W.current=!0;return}const{unitId:m,subUnitId:M,commentId:w}=p,z=`${G}-${m}-${M}-${w}`;(ge=document.getElementById(z))==null||ge.scrollIntoView({block:"center"})},[p]),i.createElement("div",{className:Y.threadCommentPanel},i.createElement("div",{className:Y.threadCommentPanelForms},i.createElement(_.Select,{borderless:!0,value:S,onChange:m=>N(m),options:[{value:"current",label:v.t("threadCommentUI.filter.sheet.current")},{value:"all",label:v.t("threadCommentUI.filter.sheet.all")}]}),i.createElement(_.Select,{borderless:!0,value:y,onChange:m=>E(m),options:[{value:"all",label:v.t("threadCommentUI.filter.status.all")},{value:"resolved",label:v.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:v.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:v.t("threadCommentUI.filter.status.concernMe")}]})),V==null?void 0:V.map(m=>i.createElement(fe,{prefix:G,getSubUnitName:a,key:m.id,id:m.id,unitId:m.unitId,subUnitId:m.subUnitId,type:r,showEdit:(p==null?void 0:p.commentId)===m.id,showHighlight:(p==null?void 0:p.commentId)===m.id,onClick:()=>{W.current=!1,H.executeCommand(Q.id,{unitId:m.unitId,subUnitId:m.subUnitId,commentId:m.id,temp:!0})},onClose:()=>s==null?void 0:s(m.id),onMouseEnter:()=>I==null?void 0:I(m),onMouseLeave:()=>u==null?void 0:u(m)})),V.length?null:i.createElement("div",{className:Y.threadCommentPanelEmpty},q?v.t("threadCommentUI.panel.filterEmpty"):v.t("threadCommentUI.panel.empty"),q?i.createElement(_.Button,{onClick:K,type:"link"},v.t("threadCommentUI.panel.reset")):i.createElement(_.Button,{id:"thread-comment-add",className:Y.threadCommentPanelAdd,type:"primary",onClick:o},i.createElement(me,null),v.t("threadCommentUI.panel.addComment"))))};l.IThreadCommentMentionDataService=X,l.SetActiveCommentOperation=Q,l.THREAD_COMMENT_PANEL=R,l.ThreadCommentPanel=Ye,l.ThreadCommentTree=fe,l.ToggleSheetCommentPanelOperation=te,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/thread-comment-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer common thread comment UI plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,35 +48,35 @@
|
|
|
48
48
|
"lib"
|
|
49
49
|
],
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@wendellhu/redi": "0.15.
|
|
51
|
+
"@wendellhu/redi": "0.15.4",
|
|
52
52
|
"clsx": ">=2.0.0",
|
|
53
53
|
"dayjs": ">=1.11.0",
|
|
54
54
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
55
55
|
"rxjs": ">=7.0.0",
|
|
56
|
-
"@univerjs/core": "0.1.
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/ui": "0.1.
|
|
59
|
-
"@univerjs/
|
|
56
|
+
"@univerjs/core": "0.1.16",
|
|
57
|
+
"@univerjs/design": "0.1.16",
|
|
58
|
+
"@univerjs/ui": "0.1.16",
|
|
59
|
+
"@univerjs/thread-comment": "0.1.16"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@univerjs/icons": "^0.1.
|
|
63
|
-
"@univerjs/protocol": "
|
|
64
|
-
"@univerjs/thread-comment": "0.1.
|
|
62
|
+
"@univerjs/icons": "^0.1.57",
|
|
63
|
+
"@univerjs/protocol": "0.1.38-alpha.6",
|
|
64
|
+
"@univerjs/thread-comment": "0.1.16"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@wendellhu/redi": "0.15.
|
|
67
|
+
"@wendellhu/redi": "0.15.4",
|
|
68
68
|
"clsx": "^2.1.1",
|
|
69
69
|
"dayjs": "^1.11.11",
|
|
70
70
|
"less": "^4.2.0",
|
|
71
71
|
"react": "18.3.1",
|
|
72
72
|
"rxjs": "^7.8.1",
|
|
73
73
|
"typescript": "^5.4.5",
|
|
74
|
-
"vite": "^5.
|
|
74
|
+
"vite": "^5.3.1",
|
|
75
75
|
"vitest": "^1.6.0",
|
|
76
|
-
"@univerjs/core": "0.1.
|
|
77
|
-
"@univerjs/design": "0.1.
|
|
78
|
-
"@univerjs/shared": "0.1.
|
|
79
|
-
"@univerjs/ui": "0.1.
|
|
76
|
+
"@univerjs/core": "0.1.16",
|
|
77
|
+
"@univerjs/design": "0.1.16",
|
|
78
|
+
"@univerjs/shared": "0.1.16",
|
|
79
|
+
"@univerjs/ui": "0.1.16"
|
|
80
80
|
},
|
|
81
81
|
"univerSpace": {
|
|
82
82
|
".": {
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
"test:watch": "vitest",
|
|
98
98
|
"coverage": "vitest run --coverage",
|
|
99
99
|
"lint:types": "tsc --noEmit",
|
|
100
|
-
"build": "tsc && vite build"
|
|
100
|
+
"build": "tsc && vite build",
|
|
101
|
+
"sync:cnpm": "cnpm sync"
|
|
101
102
|
}
|
|
102
103
|
}
|