@univerjs/preset-sheets-thread-comment 0.7.0-nightly.202505111606 → 0.7.0-nightly.202505141607

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.
Files changed (2) hide show
  1. package/lib/umd/index.js +4 -48
  2. package/package.json +8 -8
package/lib/umd/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @univerjs/thread-comment/index
2
- (function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.UniverThreadComment={},s.UniverCore,s.rxjs))})(this,function(s,c,M){"use strict";var B=Object.defineProperty;var q=(s,c,M)=>c in s?B(s,c,{enumerable:!0,configurable:!0,writable:!0,value:M}):s[c]=M;var u=(s,c,M)=>q(s,typeof c!="symbol"?c+"":c,M);var T;class I extends c.Disposable{constructor(){super();u(this,"_dataSource",null);u(this,"syncUpdateMutationToColla",!0)}set dataSource(e){this._dataSource=e}get dataSource(){return this._dataSource}async getThreadComment(e,t,n){return this._dataSource?(await this._dataSource.listComments(e,t,[n]))[0]:null}async addComment(e){var t;return this._dataSource?this._dataSource.addComment(e):{...e,threadId:(t=e.threadId)!=null?t:e.id}}async updateComment(e){return this._dataSource?this._dataSource.updateComment(e):!0}async resolveComment(e){return this._dataSource?this._dataSource.resolveComment(e):!0}async deleteComment(e,t,n,o){return this._dataSource?this._dataSource.deleteComment(e,t,n,o):!0}async listThreadComments(e,t,n){return this.dataSource?this.dataSource.listComments(e,t,n):!1}saveToSnapshot(e,t){if(this._dataSource){const n={};return Object.keys(e).forEach(o=>{const a=e[o];n[o]=a.map(this.dataSource.saveCommentToSnapshot)}),n}return e}}const C=c.createIdentifier("univer.thread-comment.data-source-service");var H=Object.getOwnPropertyDescriptor,W=(m,r,e,t)=>{for(var n=t>1?void 0:t?H(r,e):r,o=m.length-1,a;o>=0;o--)(a=m[o])&&(n=a(n)||n);return n},R=(m,r)=>(e,t)=>r(e,t,m);s.ThreadCommentModel=class extends c.Disposable{constructor(e,t){super();u(this,"_commentsMap",new Map);u(this,"_threadMap",new Map);u(this,"_commentUpdate$",new M.Subject);u(this,"commentUpdate$",this._commentUpdate$.asObservable());u(this,"_tasks",[]);this._dataSourceService=e,this._lifecycleService=t,this.disposeWithMe(()=>{this._commentUpdate$.complete()}),this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(n=>{const o=new Map;n===c.LifecycleStages.Rendered&&(this._tasks.forEach(({unitId:a,subUnitId:d,threadIds:i})=>{let h=o.get(a);h||(h=new Map,o.set(a,h));let l=h.get(d);l||(l=new Set,h.set(d,l));for(const p of i)l.add(p)}),this._tasks=[],o.forEach((a,d)=>{a.forEach((i,h)=>{this.syncThreadComments(d,h,Array.from(i))})}))}))}_ensureCommentMap(e,t){let n=this._commentsMap.get(e);n||(n=new Map,this._commentsMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}ensureMap(e,t){return this._ensureCommentMap(e,t)}_ensureThreadMap(e,t){let n=this._threadMap.get(e);n||(n=new Map,this._threadMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}_replaceComment(e,t,n){const o=this._ensureCommentMap(e,t),a=o.get(n.id);if(a){const{children:d,...i}=n,h={...i,ref:a.ref};o.set(n.id,h),d==null||d.forEach(l=>{o.set(l.id,{...l,ref:""})}),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"syncUpdate",payload:h}),!!n.resolved!=!!a.resolved&&this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n.id,resolved:!!n.resolved}})}}async syncThreadComments(e,t,n){if(this._lifecycleService.stage<c.LifecycleStages.Rendered){this._tasks.push({unitId:e,subUnitId:t,threadIds:n});return}const o=this._ensureThreadMap(e,t),a=this._ensureCommentMap(e,t),d=await this._dataSourceService.listThreadComments(e,t,n);if(!d)return;const i=new Set(n);d.forEach(h=>{this._replaceComment(e,t,h),i.delete(h.threadId)}),i.forEach(h=>{o.delete(h),a.forEach((l,p)=>{l.threadId===h&&a.delete(p)})})}addComment(e,t,n,o){const a=this._ensureCommentMap(e,t),{parentId:d,children:i=[],...h}=n,l={...h,parentId:d===n.id?void 0:d};l.threadId||(l.threadId=l.parentId||l.id);const p=f=>{a.set(f.id,f),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"add",payload:f,isRoot:!f.parentId})};p(l);const V=this._ensureThreadMap(e,t);if(!l.parentId){V.set(l.threadId,l);for(const f of i)p(f)}return o&&this.syncThreadComments(e,t,[l.threadId]),!0}updateComment(e,t,n,o){const d=this._ensureCommentMap(e,t).get(n.commentId);return d&&(d.updated=!0,d.text=n.text,d.attachments=n.attachments,d.updateT=n.updateT,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"update",payload:n,silent:o})),!0}updateCommentRef(e,t,n,o){const d=this._ensureCommentMap(e,t).get(n.commentId);return d?(d.ref=n.ref,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"updateRef",payload:n,silent:o,threadId:d.threadId}),!0):!1}resolveComment(e,t,n,o){const d=this._ensureCommentMap(e,t).get(n);return d?(d.resolved=o,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n,resolved:o}}),!0):!1}getComment(e,t,n){return this._ensureCommentMap(e,t).get(n)}getRootComment(e,t,n){return this._ensureThreadMap(e,t).get(n)}getThread(e,t,n){const o=this._ensureCommentMap(e,t),a=Array.from(o.values()).filter(l=>l.threadId===n);let d;const i=[],h=new Set;for(const l of a)l.parentId?i.push(l):d=l,h.add(l.personId);if(d)return{root:d,children:i,relativeUsers:h,unitId:e,subUnitId:t,threadId:n}}getCommentWithChildren(e,t,n){const o=this.getComment(e,t,n);if(o)return this.getThread(e,t,o.threadId)}_deleteComment(e,t,n){const o=this._ensureCommentMap(e,t),a=o.get(n);a&&(o.delete(n),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"delete",payload:{commentId:n,isRoot:!a.parentId,comment:a}}))}deleteThread(e,t,n){this._ensureThreadMap(e,t).delete(n),this._ensureCommentMap(e,t).forEach(d=>{d.threadId===n&&this._deleteComment(e,t,d.id)})}deleteComment(e,t,n){const a=this._ensureCommentMap(e,t).get(n);return a&&(a.parentId?this._deleteComment(e,t,n):this.deleteThread(e,t,a.threadId)),!0}deleteUnit(e){const t=this._commentsMap.get(e);t&&t.forEach((n,o)=>{n.forEach(a=>{this.deleteComment(e,o,a.id)})})}getUnit(e){const t=this._threadMap.get(e);if(!t)return[];const n=[];return t.forEach((o,a)=>{o.forEach((d,i)=>{const h=this.getThread(e,a,i);h&&n.push(h)})}),n}getAll(){const e=[];return this._commentsMap.forEach((t,n)=>{e.push({unitId:n,threads:this.getUnit(n)})}),e}},s.ThreadCommentModel=W([R(0,c.Inject(C)),R(1,c.Inject(c.LifecycleService))],s.ThreadCommentModel);var v=(m=>(m[m.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",m[m.UNIVER_DOC=1]="UNIVER_DOC",m[m.UNIVER_SHEET=2]="UNIVER_SHEET",m[m.UNIVER_SLIDE=3]="UNIVER_SLIDE",m[m.UNIVER_PROJECT=4]="UNIVER_PROJECT",m[m.UNRECOGNIZED=-1]="UNRECOGNIZED",m))(v||{});const S="UNIVER_THREAD_COMMENT_PLUGIN";var G=Object.getOwnPropertyDescriptor,J=(m,r,e,t)=>{for(var n=t>1?void 0:t?G(r,e):r,o=m.length-1,a;o>=0;o--)(a=m[o])&&(n=a(n)||n);return n},g=(m,r)=>(e,t)=>r(e,t,m);const O=`SHEET_${S}`;s.ThreadCommentResourceController=class extends c.Disposable{constructor(r,e,t){super(),this._resourceManagerService=r,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSnapshot()}_initSnapshot(){const r=t=>{const n=this._threadCommentModel.getUnit(t),o={};return n?(n.forEach(a=>{var i;const d=(i=o[a.subUnitId])!=null?i:[];d.push({...a.root,children:a.children}),o[a.subUnitId]=d}),JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(o,t))):""},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:O,businesses:[v.UNIVER_SHEET,v.UNIVER_DOC],toJson:t=>r(t),parseJson:t=>e(t),onUnLoad:t=>{this._threadCommentModel.deleteUnit(t)},onLoad:async(t,n)=>{Object.keys(n).forEach(o=>{const a=n[o];a.forEach(d=>{this._threadCommentModel.addComment(t,o,d)}),this._threadCommentModel.syncThreadComments(t,o,a.map(d=>d.threadId))})}}))}},s.ThreadCommentResourceController=J([g(0,c.IResourceManagerService),g(1,c.Inject(s.ThreadCommentModel)),g(2,C)],s.ThreadCommentResourceController);const y={id:"thread-comment.mutation.add-comment",type:c.CommandType.MUTATION,handler(m,r,e){if(!r)return!1;const t=m.get(s.ThreadCommentModel),{unitId:n,subUnitId:o,comment:a,sync:d}=r,i=d||(e==null?void 0:e.fromChangeset)&&!a.parentId;return t.addComment(n,o,a,i)}},U={id:"thread-comment.mutation.update-comment",type:c.CommandType.MUTATION,handler(m,r){if(!r)return!1;const e=m.get(s.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:a}=r;return e.updateComment(t,n,o,a)}},D={id:"thread-comment.mutation.update-comment-ref",type:c.CommandType.MUTATION,handler(m,r){if(!r)return!1;const e=m.get(s.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:a}=r;return e.updateCommentRef(t,n,o,a)}},N={id:"thread-comment.mutation.resolve-comment",type:c.CommandType.MUTATION,handler(m,r){if(!r)return!1;const e=m.get(s.ThreadCommentModel),{unitId:t,subUnitId:n,resolved:o,commentId:a}=r;return e.resolveComment(t,n,a,o)}},_={id:"thread-comment.mutation.delete-comment",type:c.CommandType.MUTATION,handler(m,r){if(!r)return!1;const e=m.get(s.ThreadCommentModel),{unitId:t,subUnitId:n,commentId:o}=r;return e.deleteComment(t,n,o)}},w={id:"thread-comment.command.add-comment",type:c.CommandType.COMMAND,async handler(m,r){if(!r)return!1;const e=m.get(c.ICommandService),t=m.get(C),{comment:n}=r,o=await t.addComment(n),a=t.syncUpdateMutationToColla,d=!n.parentId,i={id:y.id,params:{...r,comment:o}};return d?await e.executeCommand(i.id,i.params):e.executeCommand(i.id,i.params,{onlyLocal:!a})}},P={id:"thread-comment.command.update-comment",type:c.CommandType.COMMAND,async handler(m,r){if(!r)return!1;const{unitId:e,subUnitId:t,payload:n}=r,o=m.get(c.ICommandService),a=m.get(s.ThreadCommentModel),d=m.get(C),i=d.syncUpdateMutationToColla,h=a.getComment(e,t,n.commentId);if(!h)return!1;const{children:l,...p}=h;if(!await d.updateComment({...p,...n}))return!1;const f={id:U.id,params:r};return o.executeCommand(f.id,f.params,{onlyLocal:!i}),!0}},A={id:"thread-comment.command.resolve-comment",type:c.CommandType.COMMAND,async handler(m,r){if(!r)return!1;const{unitId:e,subUnitId:t,resolved:n,commentId:o}=r,a=m.get(C),i=m.get(s.ThreadCommentModel).getComment(e,t,o),h=a.syncUpdateMutationToColla;return!i||!await a.resolveComment({...i,resolved:n})?!1:m.get(c.ICommandService).executeCommand(N.id,r,{onlyLocal:!h})}},j={id:"thread-comment.command.delete-comment",type:c.CommandType.COMMAND,async handler(m,r){if(!r)return!1;const e=m.get(s.ThreadCommentModel),t=m.get(C),n=m.get(c.ICommandService),{unitId:o,subUnitId:a,commentId:d}=r,i=t.syncUpdateMutationToColla,h=e.getComment(o,a,d);if(!h||!await t.deleteComment(o,a,h.threadId,d))return!1;const l={id:_.id,params:r};return n.executeCommand(l.id,l.params,{onlyLocal:!i})}},$={id:"thread-comment.command.delete-comment-tree",type:c.CommandType.COMMAND,async handler(m,r){if(!r)return!1;const e=m.get(s.ThreadCommentModel),t=m.get(c.ICommandService),n=m.get(C),{unitId:o,subUnitId:a,commentId:d}=r,i=e.getCommentWithChildren(o,a,d);return!i||!await n.deleteComment(o,a,i.root.threadId,d)?!1:await t.executeCommand(_.id,{unitId:o,subUnitId:a,commentId:i.root.id})}},b="thread-comment.config",L={};var Y=Object.getOwnPropertyDescriptor,k=(m,r,e,t)=>{for(var n=t>1?void 0:t?Y(r,e):r,o=m.length-1,a;o>=0;o--)(a=m[o])&&(n=a(n)||n);return n},E=(m,r)=>(e,t)=>r(e,t,m);s.UniverThreadCommentPlugin=(T=class extends c.Plugin{constructor(r=L,e,t,n){super(),this._config=r,this._injector=e,this._commandService=t,this._configService=n;const{...o}=c.merge({},L,this._config);this._configService.setConfig(b,o)}onStarting(){var r;c.mergeOverrideWithDependencies([[C,{useClass:I}],[s.ThreadCommentModel],[s.ThreadCommentResourceController]],(r=this._config)==null?void 0:r.overrides).forEach(e=>{this._injector.add(e)}),[w,P,j,A,$,y,U,D,_,N].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(s.ThreadCommentResourceController)}},u(T,"pluginName",S),u(T,"type",c.UniverInstanceType.UNIVER_UNKNOWN),T),s.UniverThreadCommentPlugin=k([E(1,c.Inject(c.Injector)),E(2,c.ICommandService),E(3,c.IConfigService)],s.UniverThreadCommentPlugin);function K(m){return c.dayjs(m).format("YYYY/MM/DD HH:mm")}s.AddCommentCommand=w,s.AddCommentMutation=y,s.DeleteCommentCommand=j,s.DeleteCommentMutation=_,s.DeleteCommentTreeCommand=$,s.IThreadCommentDataSourceService=C,s.ResolveCommentCommand=A,s.ResolveCommentMutation=N,s.SHEET_UNIVER_THREAD_COMMENT_PLUGIN=O,s.TC_PLUGIN_NAME=S,s.ThreadCommentDataSourceService=I,s.UpdateCommentCommand=P,s.UpdateCommentMutation=U,s.UpdateCommentRefMutation=D,s.getDT=K,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
2
+ (function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverThreadComment={},d.UniverCore,d.rxjs))})(this,function(d,s,M){"use strict";var B=Object.defineProperty;var q=(d,s,M)=>s in d?B(d,s,{enumerable:!0,configurable:!0,writable:!0,value:M}):d[s]=M;var u=(d,s,M)=>q(d,typeof s!="symbol"?s+"":s,M);var T;class I extends s.Disposable{constructor(){super();u(this,"_dataSource",null);u(this,"syncUpdateMutationToColla",!0)}set dataSource(e){this._dataSource=e}get dataSource(){return this._dataSource}async getThreadComment(e,t,n){return this._dataSource?(await this._dataSource.listComments(e,t,[n]))[0]:null}async addComment(e){var t;return this._dataSource?this._dataSource.addComment(e):{...e,threadId:(t=e.threadId)!=null?t:e.id}}async updateComment(e){return this._dataSource?this._dataSource.updateComment(e):!0}async resolveComment(e){return this._dataSource?this._dataSource.resolveComment(e):!0}async deleteComment(e,t,n,o){return this._dataSource?this._dataSource.deleteComment(e,t,n,o):!0}async listThreadComments(e,t,n){return this.dataSource?this.dataSource.listComments(e,t,n):!1}saveToSnapshot(e,t){if(this._dataSource){const n={};return Object.keys(e).forEach(o=>{const a=e[o];n[o]=a.map(this.dataSource.saveCommentToSnapshot)}),n}return e}}const C=s.createIdentifier("univer.thread-comment.data-source-service");var H=Object.getOwnPropertyDescriptor,W=(c,m,e,t)=>{for(var n=t>1?void 0:t?H(m,e):m,o=c.length-1,a;o>=0;o--)(a=c[o])&&(n=a(n)||n);return n},N=(c,m)=>(e,t)=>m(e,t,c);d.ThreadCommentModel=class extends s.Disposable{constructor(e,t){super();u(this,"_commentsMap",new Map);u(this,"_threadMap",new Map);u(this,"_commentUpdate$",new M.Subject);u(this,"commentUpdate$",this._commentUpdate$.asObservable());u(this,"_tasks",[]);this._dataSourceService=e,this._lifecycleService=t,this.disposeWithMe(()=>{this._commentUpdate$.complete()}),this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(n=>{const o=new Map;n===s.LifecycleStages.Rendered&&(this._tasks.forEach(({unitId:a,subUnitId:r,threadIds:i})=>{let h=o.get(a);h||(h=new Map,o.set(a,h));let l=h.get(r);l||(l=new Set,h.set(r,l));for(const p of i)l.add(p)}),this._tasks=[],o.forEach((a,r)=>{a.forEach((i,h)=>{this.syncThreadComments(r,h,Array.from(i))})}))}))}_ensureCommentMap(e,t){let n=this._commentsMap.get(e);n||(n=new Map,this._commentsMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}ensureMap(e,t){return this._ensureCommentMap(e,t)}_ensureThreadMap(e,t){let n=this._threadMap.get(e);n||(n=new Map,this._threadMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}_replaceComment(e,t,n){const o=this._ensureCommentMap(e,t),a=o.get(n.id);if(a){const{children:r,...i}=n,h={...i,ref:a.ref};o.set(n.id,h),r==null||r.forEach(l=>{o.set(l.id,{...l,ref:""})}),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"syncUpdate",payload:h}),!!n.resolved!=!!a.resolved&&this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n.id,resolved:!!n.resolved}})}}async syncThreadComments(e,t,n){if(this._lifecycleService.stage<s.LifecycleStages.Rendered){this._tasks.push({unitId:e,subUnitId:t,threadIds:n});return}const o=this._ensureThreadMap(e,t),a=this._ensureCommentMap(e,t),r=await this._dataSourceService.listThreadComments(e,t,n);if(!r)return;const i=new Set(n);r.forEach(h=>{this._replaceComment(e,t,h),i.delete(h.threadId)}),i.forEach(h=>{o.delete(h),a.forEach((l,p)=>{l.threadId===h&&a.delete(p)})})}addComment(e,t,n,o){const a=this._ensureCommentMap(e,t),{parentId:r,children:i=[],...h}=n,l={...h,parentId:r===n.id?void 0:r};l.threadId||(l.threadId=l.parentId||l.id);const p=f=>{a.set(f.id,f),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"add",payload:f,isRoot:!f.parentId})};p(l);const L=this._ensureThreadMap(e,t);if(!l.parentId){L.set(l.threadId,l);for(const f of i)p(f)}return o&&this.syncThreadComments(e,t,[l.threadId]),!0}updateComment(e,t,n,o){const r=this._ensureCommentMap(e,t).get(n.commentId);return r&&(r.updated=!0,r.text=n.text,r.attachments=n.attachments,r.updateT=n.updateT,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"update",payload:n,silent:o})),!0}updateCommentRef(e,t,n,o){const r=this._ensureCommentMap(e,t).get(n.commentId);return r?(r.ref=n.ref,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"updateRef",payload:n,silent:o,threadId:r.threadId}),!0):!1}resolveComment(e,t,n,o){const r=this._ensureCommentMap(e,t).get(n);return r?(r.resolved=o,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n,resolved:o}}),!0):!1}getComment(e,t,n){return this._ensureCommentMap(e,t).get(n)}getRootComment(e,t,n){return this._ensureThreadMap(e,t).get(n)}getThread(e,t,n){const o=this._ensureCommentMap(e,t),a=Array.from(o.values()).filter(l=>l.threadId===n);let r;const i=[],h=new Set;for(const l of a)l.parentId?i.push(l):r=l,h.add(l.personId);if(r)return{root:r,children:i,relativeUsers:h,unitId:e,subUnitId:t,threadId:n}}getCommentWithChildren(e,t,n){const o=this.getComment(e,t,n);if(o)return this.getThread(e,t,o.threadId)}_deleteComment(e,t,n){const o=this._ensureCommentMap(e,t),a=o.get(n);a&&(o.delete(n),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"delete",payload:{commentId:n,isRoot:!a.parentId,comment:a}}))}deleteThread(e,t,n){this._ensureThreadMap(e,t).delete(n),this._ensureCommentMap(e,t).forEach(r=>{r.threadId===n&&this._deleteComment(e,t,r.id)})}deleteComment(e,t,n){const a=this._ensureCommentMap(e,t).get(n);return a&&(a.parentId?this._deleteComment(e,t,n):this.deleteThread(e,t,a.threadId)),!0}deleteUnit(e){const t=this._commentsMap.get(e);t&&t.forEach((n,o)=>{n.forEach(a=>{this.deleteComment(e,o,a.id)})})}getUnit(e){const t=this._threadMap.get(e);if(!t)return[];const n=[];return t.forEach((o,a)=>{o.forEach((r,i)=>{const h=this.getThread(e,a,i);h&&n.push(h)})}),n}getAll(){const e=[];return this._commentsMap.forEach((t,n)=>{e.push({unitId:n,threads:this.getUnit(n)})}),e}},d.ThreadCommentModel=W([N(0,s.Inject(C)),N(1,s.Inject(s.LifecycleService))],d.ThreadCommentModel);const v="UNIVER_THREAD_COMMENT_PLUGIN";var G=Object.getOwnPropertyDescriptor,J=(c,m,e,t)=>{for(var n=t>1?void 0:t?G(m,e):m,o=c.length-1,a;o>=0;o--)(a=c[o])&&(n=a(n)||n);return n},g=(c,m)=>(e,t)=>m(e,t,c);const D=`SHEET_${v}`;d.ThreadCommentResourceController=class extends s.Disposable{constructor(m,e,t){super(),this._resourceManagerService=m,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSnapshot()}_initSnapshot(){const m=t=>{const n=this._threadCommentModel.getUnit(t),o={};return n?(n.forEach(a=>{var i;const r=(i=o[a.subUnitId])!=null?i:[];r.push({...a.root,children:a.children}),o[a.subUnitId]=r}),JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(o,t))):""},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:D,businesses:[s.UniverInstanceType.UNIVER_SHEET,s.UniverInstanceType.UNIVER_DOC],toJson:t=>m(t),parseJson:t=>e(t),onUnLoad:t=>{this._threadCommentModel.deleteUnit(t)},onLoad:async(t,n)=>{Object.keys(n).forEach(o=>{const a=n[o];a.forEach(r=>{this._threadCommentModel.addComment(t,o,r)}),this._threadCommentModel.syncThreadComments(t,o,a.map(r=>r.threadId))})}}))}},d.ThreadCommentResourceController=J([g(0,s.IResourceManagerService),g(1,s.Inject(d.ThreadCommentModel)),g(2,C)],d.ThreadCommentResourceController);const S={id:"thread-comment.mutation.add-comment",type:s.CommandType.MUTATION,handler(c,m,e){if(!m)return!1;const t=c.get(d.ThreadCommentModel),{unitId:n,subUnitId:o,comment:a,sync:r}=m,i=r||(e==null?void 0:e.fromChangeset)&&!a.parentId;return t.addComment(n,o,a,i)}},y={id:"thread-comment.mutation.update-comment",type:s.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:a}=m;return e.updateComment(t,n,o,a)}},O={id:"thread-comment.mutation.update-comment-ref",type:s.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:a}=m;return e.updateCommentRef(t,n,o,a)}},U={id:"thread-comment.mutation.resolve-comment",type:s.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),{unitId:t,subUnitId:n,resolved:o,commentId:a}=m;return e.resolveComment(t,n,a,o)}},_={id:"thread-comment.mutation.delete-comment",type:s.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),{unitId:t,subUnitId:n,commentId:o}=m;return e.deleteComment(t,n,o)}},R={id:"thread-comment.command.add-comment",type:s.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const e=c.get(s.ICommandService),t=c.get(C),{comment:n}=m,o=await t.addComment(n),a=t.syncUpdateMutationToColla,r=!n.parentId,i={id:S.id,params:{...m,comment:o}};return r?await e.executeCommand(i.id,i.params):e.executeCommand(i.id,i.params,{onlyLocal:!a})}},w={id:"thread-comment.command.update-comment",type:s.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const{unitId:e,subUnitId:t,payload:n}=m,o=c.get(s.ICommandService),a=c.get(d.ThreadCommentModel),r=c.get(C),i=r.syncUpdateMutationToColla,h=a.getComment(e,t,n.commentId);if(!h)return!1;const{children:l,...p}=h;if(!await r.updateComment({...p,...n}))return!1;const f={id:y.id,params:m};return o.executeCommand(f.id,f.params,{onlyLocal:!i}),!0}},A={id:"thread-comment.command.resolve-comment",type:s.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const{unitId:e,subUnitId:t,resolved:n,commentId:o}=m,a=c.get(C),i=c.get(d.ThreadCommentModel).getComment(e,t,o),h=a.syncUpdateMutationToColla;return!i||!await a.resolveComment({...i,resolved:n})?!1:c.get(s.ICommandService).executeCommand(U.id,m,{onlyLocal:!h})}},P={id:"thread-comment.command.delete-comment",type:s.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),t=c.get(C),n=c.get(s.ICommandService),{unitId:o,subUnitId:a,commentId:r}=m,i=t.syncUpdateMutationToColla,h=e.getComment(o,a,r);if(!h||!await t.deleteComment(o,a,h.threadId,r))return!1;const l={id:_.id,params:m};return n.executeCommand(l.id,l.params,{onlyLocal:!i})}},j={id:"thread-comment.command.delete-comment-tree",type:s.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),t=c.get(s.ICommandService),n=c.get(C),{unitId:o,subUnitId:a,commentId:r}=m,i=e.getCommentWithChildren(o,a,r);return!i||!await n.deleteComment(o,a,i.root.threadId,r)?!1:await t.executeCommand(_.id,{unitId:o,subUnitId:a,commentId:i.root.id})}},V="thread-comment.config",$={};var b=Object.getOwnPropertyDescriptor,Y=(c,m,e,t)=>{for(var n=t>1?void 0:t?b(m,e):m,o=c.length-1,a;o>=0;o--)(a=c[o])&&(n=a(n)||n);return n},E=(c,m)=>(e,t)=>m(e,t,c);d.UniverThreadCommentPlugin=(T=class extends s.Plugin{constructor(m=$,e,t,n){super(),this._config=m,this._injector=e,this._commandService=t,this._configService=n;const{...o}=s.merge({},$,this._config);this._configService.setConfig(V,o)}onStarting(){var m;s.mergeOverrideWithDependencies([[C,{useClass:I}],[d.ThreadCommentModel],[d.ThreadCommentResourceController]],(m=this._config)==null?void 0:m.overrides).forEach(e=>{this._injector.add(e)}),[R,w,P,A,j,S,y,O,_,U].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(d.ThreadCommentResourceController)}},u(T,"pluginName",v),u(T,"type",s.UniverInstanceType.UNIVER_UNKNOWN),T),d.UniverThreadCommentPlugin=Y([E(1,s.Inject(s.Injector)),E(2,s.ICommandService),E(3,s.IConfigService)],d.UniverThreadCommentPlugin);function k(c){return s.dayjs(c).format("YYYY/MM/DD HH:mm")}d.AddCommentCommand=R,d.AddCommentMutation=S,d.DeleteCommentCommand=P,d.DeleteCommentMutation=_,d.DeleteCommentTreeCommand=j,d.IThreadCommentDataSourceService=C,d.ResolveCommentCommand=A,d.ResolveCommentMutation=U,d.SHEET_UNIVER_THREAD_COMMENT_PLUGIN=D,d.TC_PLUGIN_NAME=v,d.ThreadCommentDataSourceService=I,d.UpdateCommentCommand=w,d.UpdateCommentMutation=y,d.UpdateCommentRefMutation=O,d.getDT=k,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
3
3
 
4
4
 
5
5
  // @univerjs/sheets-thread-comment/index
@@ -13,60 +13,16 @@
13
13
  // @univerjs/thread-comment-ui/index
14
14
  (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverThreadCommentUi={},c.UniverCore,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.UniverDesign,c.React,c.UniverDocsUi))})(this,function(c,a,_,f,X,s,L,d,se){"use strict";var Ke=Object.defineProperty;var Ge=(c,a,_)=>a in c?Ke(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var Y=(c,a,_)=>Ge(c,typeof a!="symbol"?a+"":a,_);var Se=Object.getOwnPropertyDescriptor,_e=(t,e,n,r)=>{for(var i=r>1?void 0:r?Se(e,n):e,l=t.length-1,v;l>=0;l--)(v=t[l])&&(i=v(i)||i);return i},le=(t,e)=>(n,r)=>e(n,r,t);c.ThreadCommentPanelService=class extends a.Disposable{constructor(n,r){super();Y(this,"_panelVisible",!1);Y(this,"_panelVisible$",new X.BehaviorSubject(!1));Y(this,"_activeCommentId");Y(this,"_activeCommentId$",new X.BehaviorSubject(void 0));Y(this,"panelVisible$",this._panelVisible$.asObservable());Y(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=n,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(X.filter(n=>!n)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(n){this._panelVisible=n,this._panelVisible$.next(n)}setActiveComment(n){this._activeCommentId=n,this._activeCommentId$.next(n)}},c.ThreadCommentPanelService=_e([le(0,a.Inject(f.ISidebarService)),le(1,a.IUniverInstanceService)],c.ThreadCommentPanelService);const oe="thread-comment-panel",Te="UNIVER_THREAD_COMMENT_UI_PLUGIN",de={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(t){const e=t.get(f.ISidebarService),n=t.get(c.ThreadCommentPanelService);return n.panelVisible?(e.close(),n.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:oe},width:330}),n.setPanelVisible(!0)),!0}},z={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(t,e){return t.get(c.ThreadCommentPanelService).setActiveComment(e),!0}},Ne="thread-comment-ui.config",ue={};var Ue=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Oe=(t,e,n)=>e in t?Ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n,r)=>{for(var i=r>1?void 0:r?we(e,n):e,l=t.length-1,v;l>=0;l--)(v=t[l])&&(i=v(i)||i);return i},ae=(t,e)=>(n,r)=>e(n,r,t),ce=(t,e,n)=>Oe(t,typeof e!="symbol"?e+"":e,n);c.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ue,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;const{menu:l,...v}=a.merge({},ue,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ne,v)}onStarting(){var e;a.mergeOverrideWithDependencies([[c.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(n=>{this._injector.add(n)}),[de,z].forEach(n=>{this._commandService.registerCommand(n)})}},ce(c.UniverThreadCommentUIPlugin,"pluginName",Te),ce(c.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),c.UniverThreadCommentUIPlugin=De([a.DependentOn(_.UniverThreadCommentPlugin),ae(1,a.Inject(a.Injector)),ae(2,a.ICommandService),ae(3,a.IConfigService)],c.UniverThreadCommentUIPlugin);var E=function(){return E=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},E.apply(this,arguments)},Ee=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n},K=d.forwardRef(function(t,e){var n=t.icon,r=t.id,i=t.className,l=t.extend,v=Ee(t,["icon","id","className","extend"]),C="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),I=d.useRef("_".concat(je()));return ve(n,"".concat(r),{defIds:n.defIds,idSuffix:I.current},E({ref:e,className:C},v),l)});function ve(t,e,n,r,i){return d.createElement(t.tag,E(E({key:e},ke(t,n,i)),r),(Me(t,n).children||[]).map(function(l,v){return ve(l,"".concat(e,"-").concat(t.tag,"-").concat(v),n,void 0,i)}))}function ke(t,e,n){var r=E({},t.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),t.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(l){var v=l[0],C=l[1];v==="mask"&&typeof C=="string"&&(r[v]=C.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(l){var v=l[0],C=l[1];typeof C=="string"&&(r[v]=C.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Me(t,e){var n,r=e.defIds;return!r||r.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?E(E({},t),{children:t.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?E(E({},i),{attrs:E(E({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):t}function je(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var Pe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},me=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"delete-single",ref:e,icon:Pe}))});me.displayName="DeleteSingle";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"increase-single",ref:e,icon:$e}))});fe.displayName="IncreaseSingle";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},he=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"more-horizontal-single",ref:e,icon:He}))});he.displayName="MoreHorizontalSingle";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},pe=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"reply-to-comment-single",ref:e,icon:Le}))});pe.displayName="ReplyToCommentSingle";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ge=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"resolved-single",ref:e,icon:Ve}))});ge.displayName="ResolvedSingle";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},Ce=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"solve-single",ref:e,icon:Be}))});Ce.displayName="SolveSingle";function Ie(t){return{id:"d",body:t,documentStyle:{}}}const be=d.forwardRef((t,e)=>{var V;const{comment:n,onSave:r,id:i,onCancel:l,autoFocus:v,unitId:C,type:I}=t,O=f.useDependency(a.ICommandService),k=f.useDependency(a.LocaleService),[F,M]=d.useState(!1),T=f.useDependency(se.IEditorService),h=d.useRef(null),p=I===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:C,[j,N]=d.useState(()=>{var m,g,b;return a.BuildTextUtils.transform.getPlainText((b=(g=(m=h.current)==null?void 0:m.getDocumentData().body)==null?void 0:g.dataStream)!=null?b:"")});d.useEffect(()=>{var g,b,U,y;N(a.BuildTextUtils.transform.getPlainText((U=(b=(g=h.current)==null?void 0:g.getDocumentData().body)==null?void 0:b.dataStream)!=null?U:""));const m=(y=h.current)==null?void 0:y.selectionChange$.subscribe(()=>{var o,w,G;N(a.BuildTextUtils.transform.getPlainText((G=(w=(o=h.current)==null?void 0:o.getDocumentData().body)==null?void 0:w.dataStream)!=null?G:""))});return()=>m==null?void 0:m.unsubscribe()},[(V=h.current)==null?void 0:V.selectionChange$]);const q=d.useMemo(()=>({keyCodes:[{keyCode:f.KeyCode.ENTER}],handler:m=>{m===f.KeyCode.ENTER&&O.executeCommand(se.BreakLineCommand.id)}}),[O]);d.useImperativeHandle(e,()=>({reply(m){var b,U;if(!h.current)return;T.focus((b=h.current.getEditorId())!=null?b:"");const g=Ie(m);(U=h.current)==null||U.setDocumentData(g,[{startOffset:g.body.dataStream.length-2,endOffset:g.body.dataStream.length-2,collapsed:!0}])}}));const x=()=>{if(h.current){const m=a.Tools.deepClone(h.current.getDocumentData().body);M(!1),r==null||r({...n,text:m}),h.current.replaceText(""),setTimeout(()=>{var g,b;(g=h.current)==null||g.setSelectionRanges([]),(b=h.current)==null||b.blur()},10)}};return s.jsxs("div",{onClick:m=>m.preventDefault(),children:[s.jsx(se.RichTextEditor,{className:"univer-w-full",editorRef:h,autoFocus:v,keyboardEventConfig:q,placeholder:k.t("threadCommentUI.editor.placeholder"),initialValue:(n==null?void 0:n.text)&&Ie(n.text),onFocusChange:m=>m&&M(m),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{T.focus(p)},30)}}),F?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end",children:[s.jsx(L.Button,{style:{marginRight:12},onClick:()=>{var m;l==null||l(),M(!1),(m=h.current)==null||m.replaceText("",!0),O.executeCommand(z.id)},children:k.t("threadCommentUI.editor.cancel")}),s.jsx(L.Button,{variant:"primary",disabled:!j,onClick:x,children:k.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=t=>{const{dataStream:e,customRanges:n}=t,r=e.endsWith(`\r
15
15
  `)?e.length-2:e.length,i=[];let l=0;return n==null||n.forEach(v=>{l<v.startIndex&&i.push({type:"text",content:e.slice(l,v.startIndex)}),i.push({type:"mention",content:{label:e.slice(v.startIndex,v.endIndex+1),id:v.rangeId}}),l=v.endIndex+1}),i.push({type:"text",content:e.slice(l,r)}),i},We=t=>{const{paragraphs:e=[]}=t;let n=0;return e.map(r=>{const i=a.getBodySlice(t,n,r.startIndex);return n=r.startIndex+1,Ae(i)})},Fe=t=>{let e="";const n=[];return t.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const l=e.length-1;n.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:i,endIndex:l,properties:{},wholeEntity:!0});break}}}),e+=`\r
16
- `,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:n}},ye="__mock__",qe=t=>{const{item:e,unitId:n,subUnitId:r,editing:i,onEditingChange:l,onReply:v,resolved:C,isRoot:I,onClose:O,onDeleteComment:k,type:F}=t,M=f.useDependency(a.ICommandService),T=f.useDependency(a.LocaleService),h=f.useDependency(a.UserManagerService),p=h.getUser(e.personId),j=f.useObservable(h.currentUser$),N=(j==null?void 0:j.userID)===e.personId,q=e.id===ye,[x,V]=d.useState(!1),m=f.useConfigValue(f.UI_PLUGIN_CONFIG_KEY),g=m==null?void 0:m.avatarFallback,b=()=>{(k==null?void 0:k(e))!==!1&&(M.executeCommand(I?_.DeleteCommentTreeCommand.id:_.DeleteCommentCommand.id,{unitId:n,subUnitId:r,commentId:e.id}),I&&(O==null||O()))};return s.jsxs("div",{className:"univer-relative univer-mb-3 univer-pl-[30px]",onMouseLeave:()=>V(!1),onMouseEnter:()=>V(!0),children:[s.jsx("div",{className:`
17
- univer-absolute univer-left-0 univer-top-0 univer-h-6 univer-w-6 univer-rounded-full univer-bg-cover
18
- univer-bg-center univer-bg-no-repeat
19
- `,style:{backgroundImage:`url(${(p==null?void 0:p.avatar)||g})`}}),p?s.jsxs("div",{className:"univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",children:[s.jsx("div",{className:"univer-text-sm univer-font-medium univer-leading-5",children:(p==null?void 0:p.name)||" "}),s.jsxs("div",{children:[q||C?null:x&&p?s.jsx("div",{className:`
20
- univer-ml-1 univer-inline-flex univer-h-6 univer-w-6
21
- univer-cursor-pointer univer-items-center univer-justify-center
22
- univer-rounded-sm univer-text-base
23
- hover:univer-bg-gray-50
24
- `,onClick:()=>v(p),children:s.jsx(pe,{})}):null,N&&!q&&!C?s.jsx(L.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg",children:s.jsxs("ul",{className:`
25
- univer-m-0 univer-box-border univer-grid univer-list-none
26
- univer-p-1.5 univer-text-sm
27
- [&_a]:univer-block [&_a]:univer-cursor-pointer
28
- [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5
29
- [&_a]:univer-transition-colors
30
- `,children:[s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>l==null?void 0:l(!0),children:T.t("threadCommentUI.item.edit")})}),s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:b,children:T.t("threadCommentUI.item.delete")})})]})}),children:s.jsx("div",{className:`
31
- univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer
32
- univer-items-center univer-justify-center univer-rounded-sm
33
- univer-text-base
34
- hover:univer-bg-gray-50
35
- `,children:s.jsx(he,{})})}):null]})]}):null,s.jsx("time",{className:`
36
- univer-mb-1 univer-text-xs/normal univer-text-gray-600
37
- dark:univer-text-gray-200
38
- `,children:e.dT}),i?s.jsx(be,{type:F,id:e.id,comment:e,onCancel:()=>l==null?void 0:l(!1),autoFocus:!0,unitId:n,subUnitId:r,onSave:({text:U,attachments:y})=>{l==null||l(!1),M.executeCommand(_.UpdateCommentCommand.id,{unitId:n,subUnitId:r,payload:{commentId:e.id,text:U,attachments:y}})}}):s.jsx("div",{className:`
39
- univer-text-sm univer-text-gray-900
40
- dark:univer-text-white
41
- `,children:We(e.text).map((U,y)=>s.jsx("div",{className:"univer-break-words",children:U.map((o,w)=>{switch(o.type){case"mention":return s.jsxs("a",{className:"univer-text-primary-600",children:[o.content.label," "]},w);default:return o.content}})},y))})]})},xe=t=>{var ie,Q,u;const{id:e,unitId:n,subUnitId:r,refStr:i,showEdit:l=!0,onClick:v,showHighlight:C,onClose:I,getSubUnitName:O,prefix:k,autoFocus:F,onMouseEnter:M,onMouseLeave:T,onAddComment:h,onDeleteComment:p,onResolve:j,type:N,style:q,full:x}=t,V=f.useDependency(_.ThreadCommentModel),[m,g]=d.useState(!1),[b,U]=d.useState(""),y=d.useMemo(()=>V.commentUpdate$.pipe(X.debounceTime(16)),[V]);f.useObservable(y);const o=e?V.getCommentWithChildren(n,r,e):null,w=f.useDependency(a.ICommandService),G=f.useDependency(a.UserManagerService),P=o==null?void 0:o.root.resolved,$=f.useObservable(G.currentUser$),A=d.useRef(null),R=[...o?[o.root]:[{id:ye,text:{dataStream:`
16
+ `,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:n}},ye="__mock__",qe=t=>{const{item:e,unitId:n,subUnitId:r,editing:i,onEditingChange:l,onReply:v,resolved:C,isRoot:I,onClose:O,onDeleteComment:k,type:F}=t,M=f.useDependency(a.ICommandService),T=f.useDependency(a.LocaleService),h=f.useDependency(a.UserManagerService),p=h.getUser(e.personId),j=f.useObservable(h.currentUser$),N=(j==null?void 0:j.userID)===e.personId,q=e.id===ye,[x,V]=d.useState(!1),m=f.useConfigValue(f.UI_PLUGIN_CONFIG_KEY),g=m==null?void 0:m.avatarFallback,b=()=>{(k==null?void 0:k(e))!==!1&&(M.executeCommand(I?_.DeleteCommentTreeCommand.id:_.DeleteCommentCommand.id,{unitId:n,subUnitId:r,commentId:e.id}),I&&(O==null||O()))};return s.jsxs("div",{className:"univer-relative univer-mb-3 univer-pl-[30px]",onMouseLeave:()=>V(!1),onMouseEnter:()=>V(!0),children:[s.jsx("div",{className:"univer-absolute univer-left-0 univer-top-0 univer-h-6 univer-w-6 univer-rounded-full univer-bg-cover univer-bg-center univer-bg-no-repeat",style:{backgroundImage:`url(${(p==null?void 0:p.avatar)||g})`}}),p?s.jsxs("div",{className:"univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",children:[s.jsx("div",{className:"univer-text-sm univer-font-medium univer-leading-5",children:(p==null?void 0:p.name)||" "}),s.jsxs("div",{children:[q||C?null:x&&p?s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",onClick:()=>v(p),children:s.jsx(pe,{})}):null,N&&!q&&!C?s.jsx(L.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg",children:s.jsxs("ul",{className:"univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors",children:[s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>l==null?void 0:l(!0),children:T.t("threadCommentUI.item.edit")})}),s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:b,children:T.t("threadCommentUI.item.delete")})})]})}),children:s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",children:s.jsx(he,{})})}):null]})]}):null,s.jsx("time",{className:"univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:univer-text-gray-200",children:e.dT}),i?s.jsx(be,{type:F,id:e.id,comment:e,onCancel:()=>l==null?void 0:l(!1),autoFocus:!0,unitId:n,subUnitId:r,onSave:({text:U,attachments:y})=>{l==null||l(!1),M.executeCommand(_.UpdateCommentCommand.id,{unitId:n,subUnitId:r,payload:{commentId:e.id,text:U,attachments:y}})}}):s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:univer-text-white",children:We(e.text).map((U,y)=>s.jsx("div",{className:"univer-break-words",children:U.map((o,w)=>{switch(o.type){case"mention":return s.jsxs("a",{className:"univer-text-primary-600",children:[o.content.label," "]},w);default:return o.content}})},y))})]})},xe=t=>{var ie,Q,u;const{id:e,unitId:n,subUnitId:r,refStr:i,showEdit:l=!0,onClick:v,showHighlight:C,onClose:I,getSubUnitName:O,prefix:k,autoFocus:F,onMouseEnter:M,onMouseLeave:T,onAddComment:h,onDeleteComment:p,onResolve:j,type:N,style:q,full:x}=t,V=f.useDependency(_.ThreadCommentModel),[m,g]=d.useState(!1),[b,U]=d.useState(""),y=d.useMemo(()=>V.commentUpdate$.pipe(X.debounceTime(16)),[V]);f.useObservable(y);const o=e?V.getCommentWithChildren(n,r,e):null,w=f.useDependency(a.ICommandService),G=f.useDependency(a.UserManagerService),P=o==null?void 0:o.root.resolved,$=f.useObservable(G.currentUser$),A=d.useRef(null),R=[...o?[o.root]:[{id:ye,text:{dataStream:`
42
17
  \r`},personId:(ie=$==null?void 0:$.userID)!=null?ie:"",ref:i!=null?i:"",dT:"",unitId:n,subUnitId:r,threadId:""}],...(Q=o==null?void 0:o.children)!=null?Q:[]],B=d.useRef(null),ee=S=>{S.stopPropagation(),P?w.executeCommand(z.id,{unitId:n,subUnitId:r,commentId:e}):w.executeCommand(z.id),w.executeCommand(_.ResolveCommentCommand.id,{unitId:n,subUnitId:r,commentId:e,resolved:!P}),j==null||j(!P)},J=S=>{S.stopPropagation(),w.executeCommand(z.id),!(o!=null&&o.root&&(p==null?void 0:p(o.root))===!1)&&(w.executeCommand(_.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:r,commentId:e}),I==null||I())};d.useEffect(()=>T==null?void 0:T(),[]);const ne=O((u=o==null?void 0:o.root.subUnitId)!=null?u:r),te=l&&!b&&!P,re=`${i||(o==null?void 0:o.root.ref)||""}${ne?" · ":""}${ne}`;return s.jsxs("div",{id:`${k}-${n}-${r}-${e}`,className:L.clsx(`
43
18
  univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4
44
19
  dark:univer-bg-gray-900 dark:univer-text-white
45
- `,L.borderClassName,{"univer-w-[278px]":!x,"univer-w-full":x,"univer-shadow":!P&&(C||m||k==="cell")}),style:q,onClick:v,onMouseEnter:()=>{M==null||M(),g(!0)},onMouseLeave:()=>{T==null||T(),g(!1)},children:[!P&&C?s.jsx("div",{className:`
46
- univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md
47
- univer-bg-yellow-400
48
- `}):null,s.jsxs("div",{className:`
49
- univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm
50
- univer-leading-5
51
- `,children:[s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",children:[s.jsx("div",{className:`
52
- univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0
53
- univer-rounded-sm univer-bg-yellow-500
54
- `}),s.jsx(L.Tooltip,{showIfEllipsis:!0,title:re,children:s.jsx("div",{className:"univer-flex-1 univer-truncate",children:re})})]}),o?s.jsxs("div",{className:"univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",children:[s.jsx("div",{className:L.clsx(`
20
+ `,L.borderClassName,{"univer-w-[278px]":!x,"univer-w-full":x,"univer-shadow":!P&&(C||m||k==="cell")}),style:q,onClick:v,onMouseEnter:()=>{M==null||M(),g(!0)},onMouseLeave:()=>{T==null||T(),g(!1)},children:[!P&&C?s.jsx("div",{className:"univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400"}):null,s.jsxs("div",{className:"univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5",children:[s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",children:[s.jsx("div",{className:"univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500"}),s.jsx(L.Tooltip,{showIfEllipsis:!0,title:re,children:s.jsx("div",{className:"univer-flex-1 univer-truncate",children:re})})]}),o?s.jsxs("div",{className:"univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",children:[s.jsx("div",{className:L.clsx(`
55
21
  univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer
56
22
  univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base
57
23
  dark:hover:univer-bg-gray-800
58
24
  hover:univer-bg-gray-50
59
- `,{"univer-text-green-500":P}),onClick:ee,children:P?s.jsx(ge,{}):s.jsx(Ce,{})}),($==null?void 0:$.userID)===o.root.personId?s.jsx("div",{className:`
60
- univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer
61
- univer-items-center univer-justify-center univer-rounded-[3px]
62
- univer-text-base
63
- dark:hover:univer-bg-gray-800
64
- hover:univer-bg-gray-50
65
- `,onClick:J,children:s.jsx(me,{})}):null]}):null]}),s.jsx("div",{ref:B,className:"univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",children:R.map(S=>s.jsx(qe,{onClose:I,unitId:n,subUnitId:r,item:S,isRoot:S.id===(o==null?void 0:o.root.id),editing:b===S.id,resolved:o==null?void 0:o.root.resolved,type:N,onEditingChange:H=>{U(H?S.id:"")},onReply:H=>{H&&requestAnimationFrame(()=>{var W;(W=A.current)==null||W.reply(Fe([{type:"mention",content:{id:H.userID,label:`@${H.name}`}},{type:"text",content:" "}]))})},onAddComment:h,onDeleteComment:p},S.id))}),te?s.jsx("div",{children:s.jsx(be,{ref:A,type:N,unitId:n,subUnitId:r,onSave:async({text:S,attachments:H})=>{const W={text:S,attachments:H,dT:_.getDT(),id:a.generateRandomId(),ref:i,personId:$==null?void 0:$.userID,parentId:o==null?void 0:o.root.id,unitId:n,subUnitId:r,threadId:o==null?void 0:o.root.threadId};(h==null?void 0:h(W))!==!1&&(await w.executeCommand(_.AddCommentCommand.id,{unitId:n,subUnitId:r,comment:W}),B.current&&(B.current.scrollTop=B.current.scrollHeight))},autoFocus:F||!o,onCancel:()=>{o||I==null||I()}},`${F}`)}):null]})},ze=t=>{const{unitId:e,subUnitId$:n,type:r,onAdd:i,getSubUnitName:l,onResolve:v,sortComments:C,onItemLeave:I,onItemEnter:O,disableAdd:k,tempComment:F,onAddComment:M,onDeleteComment:T,showComments:h}=t,[p,j]=d.useState("all"),[N,q]=d.useState("all"),x=f.useDependency(a.LocaleService),V=f.useDependency(a.UserManagerService),m=f.useDependency(_.ThreadCommentModel),[g,b]=d.useState(()=>m.getUnit(e)),U=f.useDependency(c.ThreadCommentPanelService),y=f.useObservable(U.activeCommentId$),o=f.useObservable(m.commentUpdate$),w=f.useDependency(a.ICommandService),G=f.useObservable(n),P=d.useRef(!0),$="panel",A=f.useObservable(V.currentUser$),R=d.useMemo(()=>{var W;const u=p==="all"?g:(W=g.filter(D=>D.subUnitId===G))!=null?W:[],S=C!=null?C:D=>D,H=u.map(D=>{var Z;return{...D.root,children:(Z=D.children)!=null?Z:[],users:D.relativeUsers}});if(h){const D=new Map;return H.forEach(Z=>{D.set(Z.id,Z)}),[...h,""].map(Z=>D.get(Z)).filter(Boolean)}else return S(H)},[h,p,g,C,G]),B=d.useMemo(()=>[...R.filter(u=>!u.resolved),...R.filter(u=>u.resolved)],[R]),ee=d.useMemo(()=>N==="resolved"?B.filter(u=>u.resolved):N==="unsolved"?B.filter(u=>!u.resolved):N==="concern_me"&&A!=null&&A.userID?B.filter(u=>u==null?void 0:u.users.has(A.userID)):B,[B,A==null?void 0:A.userID,N]),J=F?[F,...ee]:ee,ne=J.filter(u=>!u.resolved),te=J.filter(u=>u.resolved),re=N!=="all"||p!=="all",ie=()=>{q("all"),j("all")};d.useEffect(()=>{e&&b(m.getUnit(e))},[e,m,o]),d.useEffect(()=>{var D;if(!y)return;if(!P.current){P.current=!0;return}const{unitId:u,subUnitId:S,commentId:H}=y,W=`${$}-${u}-${S}-${H}`;(D=document.getElementById(W))==null||D.scrollIntoView({block:"center"})},[y]);const Q=u=>s.jsx(xe,{full:!0,prefix:$,getSubUnitName:l,id:u.id,unitId:u.unitId,subUnitId:u.subUnitId,refStr:u.ref,type:r,showEdit:(y==null?void 0:y.commentId)===u.id,showHighlight:(y==null?void 0:y.commentId)===u.id,onClick:()=>{P.current=!1,u.resolved?w.executeCommand(z.id):w.executeCommand(z.id,{unitId:u.unitId,subUnitId:u.subUnitId,commentId:u.id,temp:!1})},onMouseEnter:()=>O==null?void 0:O(u),onMouseLeave:()=>I==null?void 0:I(u),onAddComment:M,onDeleteComment:T,onResolve:S=>v==null?void 0:v(u.id,S)},u.id);return s.jsxs("div",{className:"univer-flex univer-min-h-full univer-flex-col univer-pb-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-between",children:[r===a.UniverInstanceType.UNIVER_SHEET?s.jsx(L.Select,{borderless:!0,value:p,options:[{value:"current",label:x.t("threadCommentUI.filter.sheet.current")},{value:"all",label:x.t("threadCommentUI.filter.sheet.all")}],onChange:j}):null,s.jsx(L.Select,{borderless:!0,value:N,options:[{value:"all",label:x.t("threadCommentUI.filter.status.all")},{value:"resolved",label:x.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:x.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:x.t("threadCommentUI.filter.status.concernMe")}],onChange:q})]}),J.length===0?s.jsxs("div",{className:`
66
- univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center
67
- univer-text-sm univer-text-gray-600
68
- dark:univer-text-gray-200
69
- `,children:[x.t("threadCommentUI.panel.empty"),re?s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsx(L.Button,{onClick:ie,children:x.t("threadCommentUI.panel.reset")})}):k?null:s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsxs(L.Button,{onClick:i,children:[s.jsx(fe,{className:"univer-mr-1.5"}),x.t("threadCommentUI.panel.add")]})})]}):s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[ne.map(Q),te.length>0&&s.jsx("div",{className:"univer-text-xs",children:x.t("threadCommentUI.panel.solved")}),te.map(Q)]})]})};c.SetActiveCommentOperation=z,c.THREAD_COMMENT_PANEL=oe,c.ThreadCommentPanel=ze,c.ThreadCommentTree=xe,c.ToggleSheetCommentPanelOperation=de,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
25
+ `,{"univer-text-green-500":P}),onClick:ee,children:P?s.jsx(ge,{}):s.jsx(Ce,{})}),($==null?void 0:$.userID)===o.root.personId?s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base dark:hover:univer-bg-gray-800 hover:univer-bg-gray-50",onClick:J,children:s.jsx(me,{})}):null]}):null]}),s.jsx("div",{ref:B,className:"univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",children:R.map(S=>s.jsx(qe,{onClose:I,unitId:n,subUnitId:r,item:S,isRoot:S.id===(o==null?void 0:o.root.id),editing:b===S.id,resolved:o==null?void 0:o.root.resolved,type:N,onEditingChange:H=>{U(H?S.id:"")},onReply:H=>{H&&requestAnimationFrame(()=>{var W;(W=A.current)==null||W.reply(Fe([{type:"mention",content:{id:H.userID,label:`@${H.name}`}},{type:"text",content:" "}]))})},onAddComment:h,onDeleteComment:p},S.id))}),te?s.jsx("div",{children:s.jsx(be,{ref:A,type:N,unitId:n,subUnitId:r,onSave:async({text:S,attachments:H})=>{const W={text:S,attachments:H,dT:_.getDT(),id:a.generateRandomId(),ref:i,personId:$==null?void 0:$.userID,parentId:o==null?void 0:o.root.id,unitId:n,subUnitId:r,threadId:o==null?void 0:o.root.threadId};(h==null?void 0:h(W))!==!1&&(await w.executeCommand(_.AddCommentCommand.id,{unitId:n,subUnitId:r,comment:W}),B.current&&(B.current.scrollTop=B.current.scrollHeight))},autoFocus:F||!o,onCancel:()=>{o||I==null||I()}},`${F}`)}):null]})},ze=t=>{const{unitId:e,subUnitId$:n,type:r,onAdd:i,getSubUnitName:l,onResolve:v,sortComments:C,onItemLeave:I,onItemEnter:O,disableAdd:k,tempComment:F,onAddComment:M,onDeleteComment:T,showComments:h}=t,[p,j]=d.useState("all"),[N,q]=d.useState("all"),x=f.useDependency(a.LocaleService),V=f.useDependency(a.UserManagerService),m=f.useDependency(_.ThreadCommentModel),[g,b]=d.useState(()=>m.getUnit(e)),U=f.useDependency(c.ThreadCommentPanelService),y=f.useObservable(U.activeCommentId$),o=f.useObservable(m.commentUpdate$),w=f.useDependency(a.ICommandService),G=f.useObservable(n),P=d.useRef(!0),$="panel",A=f.useObservable(V.currentUser$),R=d.useMemo(()=>{var W;const u=p==="all"?g:(W=g.filter(D=>D.subUnitId===G))!=null?W:[],S=C!=null?C:D=>D,H=u.map(D=>{var Z;return{...D.root,children:(Z=D.children)!=null?Z:[],users:D.relativeUsers}});if(h){const D=new Map;return H.forEach(Z=>{D.set(Z.id,Z)}),[...h,""].map(Z=>D.get(Z)).filter(Boolean)}else return S(H)},[h,p,g,C,G]),B=d.useMemo(()=>[...R.filter(u=>!u.resolved),...R.filter(u=>u.resolved)],[R]),ee=d.useMemo(()=>N==="resolved"?B.filter(u=>u.resolved):N==="unsolved"?B.filter(u=>!u.resolved):N==="concern_me"&&A!=null&&A.userID?B.filter(u=>u==null?void 0:u.users.has(A.userID)):B,[B,A==null?void 0:A.userID,N]),J=F?[F,...ee]:ee,ne=J.filter(u=>!u.resolved),te=J.filter(u=>u.resolved),re=N!=="all"||p!=="all",ie=()=>{q("all"),j("all")};d.useEffect(()=>{e&&b(m.getUnit(e))},[e,m,o]),d.useEffect(()=>{var D;if(!y)return;if(!P.current){P.current=!0;return}const{unitId:u,subUnitId:S,commentId:H}=y,W=`${$}-${u}-${S}-${H}`;(D=document.getElementById(W))==null||D.scrollIntoView({block:"center"})},[y]);const Q=u=>s.jsx(xe,{full:!0,prefix:$,getSubUnitName:l,id:u.id,unitId:u.unitId,subUnitId:u.subUnitId,refStr:u.ref,type:r,showEdit:(y==null?void 0:y.commentId)===u.id,showHighlight:(y==null?void 0:y.commentId)===u.id,onClick:()=>{P.current=!1,u.resolved?w.executeCommand(z.id):w.executeCommand(z.id,{unitId:u.unitId,subUnitId:u.subUnitId,commentId:u.id,temp:!1})},onMouseEnter:()=>O==null?void 0:O(u),onMouseLeave:()=>I==null?void 0:I(u),onAddComment:M,onDeleteComment:T,onResolve:S=>v==null?void 0:v(u.id,S)},u.id);return s.jsxs("div",{className:"univer-flex univer-min-h-full univer-flex-col univer-pb-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-between",children:[r===a.UniverInstanceType.UNIVER_SHEET?s.jsx(L.Select,{borderless:!0,value:p,options:[{value:"current",label:x.t("threadCommentUI.filter.sheet.current")},{value:"all",label:x.t("threadCommentUI.filter.sheet.all")}],onChange:j}):null,s.jsx(L.Select,{borderless:!0,value:N,options:[{value:"all",label:x.t("threadCommentUI.filter.status.all")},{value:"resolved",label:x.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:x.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:x.t("threadCommentUI.filter.status.concernMe")}],onChange:q})]}),J.length===0?s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:[x.t("threadCommentUI.panel.empty"),re?s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsx(L.Button,{onClick:ie,children:x.t("threadCommentUI.panel.reset")})}):k?null:s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsxs(L.Button,{onClick:i,children:[s.jsx(fe,{className:"univer-mr-1.5"}),x.t("threadCommentUI.panel.add")]})})]}):s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[ne.map(Q),te.length>0&&s.jsx("div",{className:"univer-text-xs",children:x.t("threadCommentUI.panel.solved")}),te.map(Q)]})]})};c.SetActiveCommentOperation=z,c.THREAD_COMMENT_PANEL=oe,c.ThreadCommentPanel=ze,c.ThreadCommentTree=xe,c.ToggleSheetCommentPanelOperation=de,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
70
26
 
71
27
 
72
28
  // @univerjs/sheets-thread-comment-ui/index
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-thread-comment",
3
- "version": "0.7.0-nightly.202505111606",
3
+ "version": "0.7.0-nightly.202505141607",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,18 +57,18 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/sheets-thread-comment": "0.7.0-nightly.202505111606",
61
- "@univerjs/sheets-thread-comment-ui": "0.7.0-nightly.202505111606",
62
- "@univerjs/thread-comment": "0.7.0-nightly.202505111606",
63
- "@univerjs/thread-comment-ui": "0.7.0-nightly.202505111606",
64
- "rxjs": ">=7.0.0"
60
+ "@univerjs/sheets-thread-comment": "0.7.0-nightly.202505141607",
61
+ "@univerjs/sheets-thread-comment-ui": "0.7.0-nightly.202505141607",
62
+ "@univerjs/thread-comment": "0.7.0-nightly.202505141607",
63
+ "@univerjs/thread-comment-ui": "0.7.0-nightly.202505141607"
65
64
  },
66
65
  "devDependencies": {
67
- "@univerjs/core": "0.7.0-nightly.202505111606",
66
+ "@univerjs/core": "0.7.0-nightly.202505141607",
68
67
  "react": "18.3.1",
69
68
  "react-dom": "18.3.1",
69
+ "rxjs": "7.8.2",
70
70
  "typescript": "^5.8.3",
71
- "@univerjs-infra/shared": "0.7.0-beta.1"
71
+ "@univerjs-infra/shared": "0.7.0"
72
72
  },
73
73
  "scripts": {
74
74
  "prebuild:preset": "tsx prepare.ts",