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