@univerjs/thread-comment-ui 0.1.13 → 0.1.15
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 +251 -258
- package/lib/types/plugin.d.ts +4 -5
- package/lib/types/types/const.d.ts +1 -1
- package/lib/types/views/thread-comment-tree/index.d.ts +1 -2
- package/lib/umd/index.js +3 -3
- package/package.json +34 -19
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";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IThreadComment } from '@univerjs/thread-comment';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
-
import { UniverInstanceType } from '@univerjs/core';
|
|
4
|
-
import { IUser } from '@univerjs/protocol';
|
|
3
|
+
import { IUser, UniverInstanceType } from '@univerjs/core';
|
|
5
4
|
|
|
6
5
|
export interface IThreadCommentTreeProps {
|
|
7
6
|
id?: string;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(m,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("@univerjs/thread-comment"),require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@wendellhu/redi/react-bindings"),require("@univerjs/design"),require("dayjs"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/thread-comment","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@wendellhu/redi/react-bindings","@univerjs/design","dayjs","clsx"],C):(m=typeof globalThis<"u"?globalThis:m||self,C(m.UniverThreadCommentUi={},m.UniverThreadComment,m.UniverCore,m["@wendellhu/redi"],m.UniverUi,m.rxjs,m.React,m["@wendellhu/redi/react-bindings"],m.UniverDesign,m.dayjs,m.clsx))})(this,function(m,C,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(l,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("@univerjs/thread-comment"),require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@wendellhu/redi/react-bindings"),require("@univerjs/design"),require("dayjs"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/thread-comment","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@wendellhu/redi/react-bindings","@univerjs/design","dayjs","clsx"],C):(l=typeof globalThis<"u"?globalThis:l||self,C(l.UniverThreadCommentUi={},l.UniverThreadComment,l.UniverCore,l["@wendellhu/redi"],l.UniverUi,l.rxjs,l.React,l["@wendellhu/redi/react-bindings"],l.UniverDesign,l.dayjs,l.clsx))})(this,function(l,C,d,F,D,J,i,T,_,pe,Ie){"use strict";var Ge=Object.defineProperty;var Ke=(l,C,d)=>C in l?Ge(l,C,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[C]=d;var $=(l,C,d)=>(Ke(l,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);l.ThreadCommentPanelService=class extends d.Disposable{constructor(t,r){super();$(this,"_panelVisible",!1);$(this,"_panelVisible$",new J.BehaviorSubject(!1));$(this,"_activeCommentId");$(this,"_activeCommentId$",new J.BehaviorSubject(void 0));$(this,"panelVisible$",this._panelVisible$.asObservable());$(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init()}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(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)}},l.ThreadCommentPanelService=be([ee(0,F.Inject(D.ISidebarService)),ee(1,d.IUniverInstanceService)],l.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(l.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:R},width:320}),t.setPanelVisible(!0)),!0}},Q={id:"thread-comment-ui.operation.set-active-comment",type:d.CommandType.OPERATION,handler(n,e){return n.get(l.ThreadCommentPanelService).setActiveComment(e),!0}};var Te=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ue=(n,e,t,r)=>{for(var o=r>1?void 0:r?_e(e,t):e,a=n.length-1,s;a>=0;a--)(s=n[a])&&(o=(r?s(e,t,o):s(o))||o);return r&&o&&Te(e,t,o),o},Pe=(n,e)=>(t,r)=>e(t,r,n);let B=class extends 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(){$(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);l.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],[l.ThreadCommentPanelService],[X,{useClass:Me}]],(t=this._config)==null?void 0:t.overrides).forEach(r=>{e.add(r)}),[te,Q].forEach(r=>{this._commandService.registerCommand(r)})}},ie(l.UniverThreadCommentUIPlugin,"pluginName",Se),ie(l.UniverThreadCommentUIPlugin,"type",d.UniverInstanceType.UNIVER_UNKNOWN),l.UniverThreadCommentUIPlugin=Oe([d.DependentOn(C.UniverThreadCommentPlugin),re(1,F.Inject(F.Injector)),re(2,d.ICommandService)],l.UniverThreadCommentUIPlugin);var U=function(){return U=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},U.apply(this,arguments)},we=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]]);return t},L=i.forwardRef(function(n,e){var t=n.icon,r=n.id,o=n.className,a=n.extend,s=we(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),u=i.useRef("_".concat(je()));return oe(t,"".concat(r),{defIds:t.defIds,idSuffix:u.current},U({ref:e,className:h},s),a)});function oe(n,e,t,r,o){return i.createElement(n.tag,U(U({key:e},De(n,t,o)),r),(He(n,t).children||[]).map(function(a,s){return oe(a,"".concat(e,"-").concat(n.tag,"-").concat(s),t,void 0,o)}))}function De(n,e,t){var r=U({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(a){var s=a[0],h=a[1];typeof h=="string"&&(r[s]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function He(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?U(U({},n),{children:n.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?U(U({},o),{attrs:U(U({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):n}function je(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ae=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"delete-single",ref:e,icon:$e}))});ae.displayName="DeleteSingle";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},me=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"increase-single",ref:e,icon:Le}))});me.displayName="IncreaseSingle";var Ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},le=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Ae}))});le.displayName="MoreHorizontalSingle";var ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},se=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:ke}))});se.displayName="ReplyToCommentSingle";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},de=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"resolved-single",ref:e,icon:Ve}))});de.displayName="ResolvedSingle";var Fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},ce=i.forwardRef(function(n,e){return i.createElement(L,Object.assign({},n,{id:"solve-single",ref:e,icon:Fe}))});ce.displayName="SolveSingle";const Z={threadCommentEditorButtons:"univer-thread-comment-editor-buttons",threadCommentEditorSuggestion:"univer-thread-comment-editor-suggestion",threadCommentEditorSuggestionActive:"univer-thread-comment-editor-suggestionActive",threadCommentEditorSuggestionIcon:"univer-thread-comment-editor-suggestion-icon"},We=n=>{const e=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let t,r=0;const o=[];for(;(t=e.exec(n))!==null;)t.index>r&&o.push({type:"text",content:n.substring(r,t.index)}),t[1]&&t[2]?o.push({type:"mention",content:{label:t[1],id:t[2]}}):t[3]&&o.push({type:"text",content:t[3]}),r=e.lastIndex;return r<n.length&&o.push({type:"text",content:n.substring(r)}),o},qe=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),ue=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,o=[];let a=0;return t==null||t.forEach(s=>{a<s.startIndex&&o.push({type:"text",content:e.slice(a,s.startIndex)}),o.push({type:"mention",content:{label:e.slice(s.startIndex,s.endIndex).slice(1,-1),id:s.rangeId}}),a=s.endIndex}),o.push({type:"text",content:e.slice(a,r)}),o},he=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const o=e.length;e+=`${r.content.label}`;const a=e.length;t.push({rangeId:r.content.id,rangeType: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}},ze=n=>({display:n.label,id:`${n.id}`,raw:n}),Be=(n,e,t,r,o)=>{var s,h;const a=(s=n.raw)==null?void 0:s.icon;return i.createElement("div",{className:Z.threadCommentEditorSuggestion},a?i.createElement("img",{className:Z.threadCommentEditorSuggestionIcon,src:a}):null,i.createElement("div",null,(h=n.display)!=null?h:n.id))},Ce=i.forwardRef((n,e)=>{var v;const{comment:t,onSave:r,id:o,onCancel:a,autoFocus:s}=n,h=T.useDependency(X),u=T.useDependency(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?qe(ue(I.text)):"",onChange:b=>{b.target.value||S({...t,text:void 0}),S==null||S({...t,text:he(We(b.target.value))})},onFocus:()=>{y(!0)}},i.createElement(_.Mention,{key:h.trigger,trigger:h.trigger,data:(b,f)=>h.getMentions(b).then(x=>x.map(ze)).then(f),displayTransform:(b,f)=>`@${f} `,renderSuggestion:(v=h.renderSuggestion)!=null?v:Be})),N?i.createElement("div",{className:Z.threadCommentEditorButtons},i.createElement(_.Button,{style:{marginRight:12},onClick:()=>{a==null||a(),y(!1),S({text:void 0})}},u.t("threadCommentUI.editor.cancel")),i.createElement(_.Button,{type:"primary",disabled:!I.text,onClick:()=>{I.text&&(r==null||r({...I,text:I.text}),y(!1),S({text:void 0}))}},u.t(o?"threadCommentUI.editor.save":"threadCommentUI.editor.reply"))):null)}),g={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",threadCommentUsername:"univer-thread-comment-username",threadCommentItem:"univer-thread-comment-item",threadCommentItemHead:"univer-thread-comment-item-head",threadCommentItemTitle:"univer-thread-comment-item-title",threadCommentItemTitlePosition:"univer-thread-comment-item-title-position",threadCommentItemTitleHighlight:"univer-thread-comment-item-title-highlight",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},ve="__mock__",Ze=n=>{const{item:e,unitId:t,subUnitId:r,editing:o,onEditingChange:a,onReply:s,resolved:h,isRoot:u,onClose:I}=n,S=T.useDependency(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(se,null)):null,b&&!f&&!h?i.createElement(_.Dropdown,{overlay:i.createElement(_.Menu,null,i.createElement(_.MenuItem,{key:"edit",onClick:()=>a==null?void 0:a(!0)},N.t("threadCommentUI.item.edit")),i.createElement(_.MenuItem,{key:"delete",onClick:c},N.t("threadCommentUI.item.delete")))},i.createElement("div",{className:g.threadCommentIcon},i.createElement(le,null))):null)),i.createElement("div",{className:g.threadCommentItemTime},e.dT),o?i.createElement(Ce,{id:e.id,comment:e,onCancel:()=>a==null?void 0:a(!1),autoFocus:!0,onSave:({text:p,attachments:k})=>{a==null||a(!1),S.executeCommand(C.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:p,attachments:k}})}}):i.createElement("div",{className:g.threadCommentItemContent},ue(e.text).map((p,k)=>{switch(p.type){case"mention":return i.createElement("a",{className:g.threadCommentItemAt,key:k},"@",p.content.label," ");default:return p.content}})))},fe=n=>{var V,q,K;const{id:e,unitId:t,subUnitId:r,refStr:o,showEdit:a=!0,onClick:s,showHighlight:h,onClose:u,getSubUnitName:I,prefix:S,autoFocus:N,onMouseEnter:y,onMouseLeave:E}=n,v=T.useDependency(C.ThreadCommentModel),[b,f]=i.useState(!1),[x,A]=i.useState("");D.useObservable(v.commentMap$);const 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()},j=()=>{p.executeCommand(C.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),u==null||u()};return i.createElement("div",{className:Ie(g.threadComment,{[g.threadCommentActive]:!H&&(h||b||S==="cell")}),onClick:s,id:`${S}-${t}-${r}-${e}`,onMouseEnter:()=>{y==null||y(),f(!0)},onMouseLeave:()=>{E==null||E(),f(!1)}},!H&&h?i.createElement("div",{className:g.threadCommentHighlight}):null,i.createElement("div",{className:g.threadCommentTitle},i.createElement("div",{className:g.threadCommentTitlePosition},i.createElement("div",{className:g.threadCommentTitleHighlight}),o||(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(de,null):i.createElement(ce,null)),(P==null?void 0:P.userID)===c.root.personId?i.createElement("div",{className:g.threadCommentIcon,onClick:j},i.createElement(ae,null)):null):null),i.createElement("div",{className:g.threadCommentContent},W.map(m=>i.createElement(Ze,{onClose:u,unitId:t,subUnitId:r,item:m,key:m.id,isRoot:m.id===(c==null?void 0:c.root.id),editing:x===m.id,resolved:c==null?void 0:c.root.resolved,onEditingChange:M=>{A(M?m.id:"")},onReply:M=>{var w;M&&((w=O.current)==null||w.reply(he([{type:"mention",content:{id:M.userID,label:M.name}}])))}}))),a&&!x&&!H?i.createElement("div",null,i.createElement(Ce,{key:`${N}`,ref:O,onSave:({text:m,attachments:M})=>{p.executeCommand(C.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:{text:m,attachments:M,dT:pe().format("YYYY/MM/DD HH:mm"),id: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"},Ye=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:o,getSubUnitName:a,onResolve:s,sortComments:h,onItemLeave:u,onItemEnter:I}=n,[S,N]=i.useState("all"),[y,E]=i.useState("all"),v=T.useDependency(d.LocaleService),b=T.useDependency(d.UserManagerService),f=T.useDependency(C.ThreadCommentModel),[x,A]=i.useState(()=>f.getUnit(e)),c=T.useDependency(l.ThreadCommentPanelService),p=D.useObservable(c.activeCommentId$),k=D.useObservable(f.commentUpdate$),H=T.useDependency(d.ICommandService),P=D.useObservable(t),O=b.getCurrentUser(),W=i.useRef(!0),G="panel",j=i.useMemo(()=>{var m,M;if(S==="all"){const w=x.map(z=>z[1]).flat().filter(z=>!z.parentId);return h?h(w):w}else return(M=(m=x.find(w=>w[0]===P))==null?void 0:m[1])!=null?M:[]},[S,x,P,h]),V=i.useMemo(()=>y==="resolved"?j.filter(m=>m.resolved):y==="unsolved"?j.filter(m=>!m.resolved):y==="concern_me"&&O!=null&&O.userID?j.map(m=>f.getCommentWithChildren(m.unitId,m.subUnitId,m.id)).map(m=>m!=null&&m.relativeUsers.has(O.userID)?m.root:null).filter(Boolean):j,[j,O==null?void 0:O.userID,y,f]),q=y!=="all"||S!=="all",K=()=>{E("all"),N("all")};return i.useEffect(()=>{e&&A(f.getUnit(e))},[e,f,k]),i.useEffect(()=>{var ge;if(!p)return;if(!W.current){W.current=!0;return}const{unitId:m,subUnitId:M,commentId:w}=p,z=`${G}-${m}-${M}-${w}`;(ge=document.getElementById(z))==null||ge.scrollIntoView({block:"center"})},[p]),i.createElement("div",{className:Y.threadCommentPanel},i.createElement("div",{className:Y.threadCommentPanelForms},i.createElement(_.Select,{borderless:!0,value:S,onChange:m=>N(m),options:[{value:"current",label:v.t("threadCommentUI.filter.sheet.current")},{value:"all",label:v.t("threadCommentUI.filter.sheet.all")}]}),i.createElement(_.Select,{borderless:!0,value:y,onChange:m=>E(m),options:[{value:"all",label:v.t("threadCommentUI.filter.status.all")},{value:"resolved",label:v.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:v.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:v.t("threadCommentUI.filter.status.concernMe")}]})),V==null?void 0:V.map(m=>i.createElement(fe,{prefix:G,getSubUnitName:a,key:m.id,id:m.id,unitId:m.unitId,subUnitId:m.subUnitId,type:r,showEdit:(p==null?void 0:p.commentId)===m.id,showHighlight:(p==null?void 0:p.commentId)===m.id,onClick:()=>{W.current=!1,H.executeCommand(Q.id,{unitId:m.unitId,subUnitId:m.subUnitId,commentId:m.id,temp:!0})},onClose:()=>s==null?void 0:s(m.id),onMouseEnter:()=>I==null?void 0:I(m),onMouseLeave:()=>u==null?void 0:u(m)})),V.length?null:i.createElement("div",{className:Y.threadCommentPanelEmpty},q?v.t("threadCommentUI.panel.filterEmpty"):v.t("threadCommentUI.panel.empty"),q?i.createElement(_.Button,{onClick:K,type:"link"},v.t("threadCommentUI.panel.reset")):i.createElement(_.Button,{id:"thread-comment-add",className:Y.threadCommentPanelAdd,type:"primary",onClick:o},i.createElement(me,null),v.t("threadCommentUI.panel.addComment"))))};l.IThreadCommentMentionDataService=X,l.SetActiveCommentOperation=Q,l.THREAD_COMMENT_PANEL=R,l.ThreadCommentPanel=Ye,l.ThreadCommentTree=fe,l.ToggleSheetCommentPanelOperation=te,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/thread-comment-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
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",
|
|
@@ -48,41 +48,56 @@
|
|
|
48
48
|
"lib"
|
|
49
49
|
],
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@wendellhu/redi": "0.15.
|
|
51
|
+
"@wendellhu/redi": "0.15.4",
|
|
52
52
|
"clsx": ">=2.0.0",
|
|
53
53
|
"dayjs": ">=1.11.0",
|
|
54
54
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
55
55
|
"rxjs": ">=7.0.0",
|
|
56
|
-
"@univerjs/core": "0.1.
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/ui": "0.1.
|
|
56
|
+
"@univerjs/core": "0.1.15",
|
|
57
|
+
"@univerjs/thread-comment": "0.1.15",
|
|
58
|
+
"@univerjs/design": "0.1.15",
|
|
59
|
+
"@univerjs/ui": "0.1.15"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@univerjs/icons": "^0.1.
|
|
63
|
-
"@univerjs/protocol": "
|
|
64
|
-
"@univerjs/thread-comment": "0.1.
|
|
62
|
+
"@univerjs/icons": "^0.1.56",
|
|
63
|
+
"@univerjs/protocol": "0.1.38-alpha.3",
|
|
64
|
+
"@univerjs/thread-comment": "0.1.15"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@wendellhu/redi": "0.15.
|
|
67
|
+
"@wendellhu/redi": "0.15.4",
|
|
68
68
|
"clsx": "^2.1.1",
|
|
69
69
|
"dayjs": "^1.11.11",
|
|
70
70
|
"less": "^4.2.0",
|
|
71
|
-
"react": "18.
|
|
71
|
+
"react": "18.3.1",
|
|
72
72
|
"rxjs": "^7.8.1",
|
|
73
73
|
"typescript": "^5.4.5",
|
|
74
|
-
"vite": "^5.2.
|
|
74
|
+
"vite": "^5.2.13",
|
|
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.15",
|
|
77
|
+
"@univerjs/design": "0.1.15",
|
|
78
|
+
"@univerjs/shared": "0.1.15",
|
|
79
|
+
"@univerjs/ui": "0.1.15"
|
|
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",
|
|
83
97
|
"test:watch": "vitest",
|
|
84
98
|
"coverage": "vitest run --coverage",
|
|
85
99
|
"lint:types": "tsc --noEmit",
|
|
86
|
-
"build": "tsc && vite build"
|
|
100
|
+
"build": "tsc && vite build",
|
|
101
|
+
"sync:cnpm": "cnpm sync"
|
|
87
102
|
}
|
|
88
103
|
}
|