@univerjs/preset-sheets-thread-comment 0.8.2 → 0.8.3-nightly.202506271607

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.
@@ -0,0 +1 @@
1
+ "use strict";const e=require("@univerjs/core"),r=require("@univerjs/sheets-thread-comment-ui/locale/ko-KR"),t=require("@univerjs/thread-comment-ui/locale/ko-KR"),s=e.merge({},r,t);module.exports=s;
@@ -0,0 +1,11 @@
1
+ import { merge as e } from "@univerjs/core";
2
+ import r from "@univerjs/sheets-thread-comment-ui/locale/ko-KR";
3
+ import m from "@univerjs/thread-comment-ui/locale/ko-KR";
4
+ const s = e(
5
+ {},
6
+ r,
7
+ m
8
+ );
9
+ export {
10
+ s as default
11
+ };
@@ -0,0 +1,11 @@
1
+ import { merge as e } from "@univerjs/core";
2
+ import r from "@univerjs/sheets-thread-comment-ui/locale/ko-KR";
3
+ import m from "@univerjs/thread-comment-ui/locale/ko-KR";
4
+ const s = e(
5
+ {},
6
+ r,
7
+ m
8
+ );
9
+ export {
10
+ s as default
11
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
package/lib/umd/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @univerjs/thread-comment/index
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"})});
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={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)}},g={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)}},D={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)}},S={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)}},O={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:v.id,params:{...m,comment:o}};return r?await e.executeCommand(i.id,i.params):e.executeCommand(i.id,i.params,{onlyLocal:!a})}},R={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:g.id,params:m};return o.executeCommand(f.id,f.params,{onlyLocal:!i}),!0}},w={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(S.id,m,{onlyLocal:!h})}},A={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})}},P={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})}};function G(c){return s.dayjs(c).format("YYYY/MM/DD HH:mm")}const y="UNIVER_THREAD_COMMENT_PLUGIN";var J=Object.getOwnPropertyDescriptor,V=(c,m,e,t)=>{for(var n=t>1?void 0:t?J(m,e):m,o=c.length-1,a;o>=0;o--)(a=c[o])&&(n=a(n)||n);return n},U=(c,m)=>(e,t)=>m(e,t,c);const j=`SHEET_${y}`;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:j,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=V([U(0,s.IResourceManagerService),U(1,s.Inject(d.ThreadCommentModel)),U(2,C)],d.ThreadCommentResourceController);const b="thread-comment.config",$={};var Y=Object.getOwnPropertyDescriptor,k=(c,m,e,t)=>{for(var n=t>1?void 0:t?Y(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(b,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)}),[O,R,A,w,P,v,g,D,_,S].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(d.ThreadCommentResourceController)}},u(T,"pluginName",y),u(T,"type",s.UniverInstanceType.UNIVER_UNKNOWN),T),d.UniverThreadCommentPlugin=k([E(1,s.Inject(s.Injector)),E(2,s.ICommandService),E(3,s.IConfigService)],d.UniverThreadCommentPlugin),d.AddCommentCommand=O,d.AddCommentMutation=v,d.DeleteCommentCommand=A,d.DeleteCommentMutation=_,d.DeleteCommentTreeCommand=P,d.IThreadCommentDataSourceService=C,d.ResolveCommentCommand=w,d.ResolveCommentMutation=S,d.SHEET_UNIVER_THREAD_COMMENT_PLUGIN=j,d.TC_PLUGIN_NAME=y,d.ThreadCommentDataSourceService=I,d.UpdateCommentCommand=R,d.UpdateCommentMutation=g,d.UpdateCommentRefMutation=D,d.getDT=G,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
3
3
 
4
4
 
5
5
  // @univerjs/sheets-thread-comment/index
6
- (function(d,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/thread-comment"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-formula","@univerjs/sheets","@univerjs/thread-comment","rxjs"],o):(d=typeof globalThis<"u"?globalThis:d||self,o(d.UniverSheetsThreadComment={},d.UniverCore,d.UniverEngineFormula,d.UniverSheets,d.UniverThreadComment,d.rxjs))})(this,function(d,o,l,p,g,w){"use strict";var $=Object.defineProperty;var D=(d,o,l)=>o in d?$(d,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[o]=l;var f=(d,o,l)=>D(d,typeof o!="symbol"?o+"":o,l);var S=Object.getOwnPropertyDescriptor,T=(h,m,e,n)=>{for(var t=n>1?void 0:n?S(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},M=(h,m)=>(e,n)=>m(e,n,h);d.SheetsThreadCommentModel=class extends o.Disposable{constructor(e,n){super();f(this,"_matrixMap",new Map);f(this,"_locationMap",new Map);f(this,"_commentUpdate$",new w.Subject);f(this,"commentUpdate$",this._commentUpdate$.asObservable());this._threadCommentModel=e,this._univerInstanceService=n,this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,n){let t=this._matrixMap.get(e);t||(t=new Map,this._matrixMap.set(e,t));let r=t.get(n);return r||(r=new o.ObjectMatrix,t.set(n,r)),r}_ensureCommentLocationMap(e,n){let t=this._locationMap.get(e);t||(t=new Map,this._locationMap.set(e,t));let r=t.get(n);return r||(r=new Map,t.set(n,r)),r}_addCommentToMatrix(e,n,t,r){var a;const s=(a=e.getValue(n,t))!=null?a:new Set;s.add(r),e.setValue(n,t,s)}_deleteCommentFromMatrix(e,n,t,r){if(n>=0&&t>=0){const s=e.getValue(n,t);s&&s.has(r)&&(s.delete(r),s.size===0&&e.realDeleteValue(n,t))}}_ensure(e,n){const t=this._ensureCommentMatrix(e,n),r=this._ensureCommentLocationMap(e,n);return{matrix:t,locationMap:r}}_initData(){const e=this._threadCommentModel.getAll();for(const n of e)for(const t of n.threads){const{unitId:r,subUnitId:s,root:a}=t;this._addComment(r,s,a)}}_addComment(e,n,t){const r=l.singleReferenceToGrid(t.ref),s=t.parentId,{row:a,column:i}=r,c=t.id,{matrix:_,locationMap:u}=this._ensure(e,n);!s&&a>=0&&i>=0&&(this._addCommentToMatrix(_,a,i,c),u.set(c,{row:a,column:i})),s||this._commentUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add",isRoot:!s,...r})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;try{if(this._univerInstanceService.getUnitType(n)!==o.UniverInstanceType.UNIVER_SHEET)return}catch{}const{matrix:r,locationMap:s}=this._ensure(n,t);switch(e.type){case"add":{this._addComment(e.unitId,e.subUnitId,e.payload);break}case"delete":{const{isRoot:a,comment:i}=e.payload;if(a){const c=l.singleReferenceToGrid(i.ref),{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,i.id),this._commentUpdate$.next({...e,...c})}break}case"update":{const{commentId:a}=e.payload,i=this._threadCommentModel.getComment(n,t,a);if(!i)return;const c=l.singleReferenceToGrid(i.ref);this._commentUpdate$.next({...e,...c});break}case"updateRef":{const a=l.singleReferenceToGrid(e.payload.ref),{commentId:i}=e.payload,c=s.get(i);if(!c)return;const{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,i),s.delete(i),a.row>=0&&a.column>=0&&(this._addCommentToMatrix(r,a.row,a.column,i),s.set(i,{row:a.row,column:a.column})),this._commentUpdate$.next({...e,...a});break}case"resolve":{const{unitId:a,subUnitId:i,payload:c}=e,{locationMap:_}=this._ensure(a,i),u=_.get(c.commentId);u&&this._commentUpdate$.next({...e,...u});break}}}))}getByLocation(e,n,t,r){var i;return(i=this.getAllByLocation(e,n,t,r).filter(c=>!c.resolved)[0])==null?void 0:i.id}getAllByLocation(e,n,t,r){const a=this._ensureCommentMatrix(e,n).getValue(t,r);return a?Array.from(a).map(i=>this.getComment(e,n,i)).filter(Boolean):[]}getComment(e,n,t){return this._threadCommentModel.getComment(e,n,t)}getCommentWithChildren(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return;const a=this.getComment(e,n,s);if(a)return this._threadCommentModel.getThread(e,n,a.threadId)}showCommentMarker(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return!1;const a=this.getComment(e,n,s);return!!(a&&!a.resolved)}getSubUnitAll(e,n){return this._threadCommentModel.getUnit(e).filter(t=>t.subUnitId===n).map(t=>t.root)}},d.SheetsThreadCommentModel=T([M(0,o.Inject(g.ThreadCommentModel)),M(1,o.IUniverInstanceService)],d.SheetsThreadCommentModel);var y=Object.getOwnPropertyDescriptor,U=(h,m,e,n)=>{for(var t=n>1?void 0:n?y(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},C=(h,m)=>(e,n)=>m(e,n,h);d.SheetsThreadCommentRefRangeController=class extends o.Disposable{constructor(e,n,t,r,s){super();f(this,"_disposableMap",new Map);f(this,"_watcherMap",new Map);f(this,"_handleRangeChange",(e,n,t,r,s)=>{const a=t.id,i={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:l.serializeRange(r),commentId:a},silent:s}}],undos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:l.serializeRange(i),commentId:a},silent:s}}]}:{redos:[{id:g.DeleteCommentMutation.id,params:{unitId:e,subUnitId:n,commentId:a}}],undos:[{id:g.AddCommentMutation.id,params:{unitId:e,subUnitId:n,comment:t,sync:!0}}]}});this._refRangeService=e,this._sheetsThreadCommentModel=n,this._threadCommentModel=t,this._selectionManagerService=r,this._commandService=s,this._initData(),this._initRefRange()}_getIdWithUnitId(e,n,t){return`${e}-${n}-${t}`}_register(e,n,t){const r=t.id,s={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._disposableMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.registerRefRange(s,a=>{const i=p.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,a,{selectionManagerService:this._selectionManagerService}),c=Array.isArray(i)?i[0]:i;return c&&c.startColumn===s.startColumn&&c.startRow===s.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,n,t,c,!1)},e,n))}_watch(e,n,t){const r=t.id,s={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watcherMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.watchRange(e,n,s,(a,i)=>{const{redos:c}=this._handleRangeChange(e,n,t,i,!0);o.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,n,t){var s;const r=this._getIdWithUnitId(e,n,t);(s=this._watcherMap.get(r))==null||s.dispose(),this._watcherMap.delete(r)}_unregister(e,n,t){var s;const r=this._getIdWithUnitId(e,n,t);(s=this._disposableMap.get(r))==null||s.dispose(),this._disposableMap.delete(r)}_initData(){const e=this._threadCommentModel.getAll();for(const n of e)for(const t of n.threads){const{unitId:r,subUnitId:s,root:a}=t,i=l.singleReferenceToGrid(a.ref),c={...a,...i};this._register(r,s,c),this._watch(r,s,c)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;switch(e.type){case"add":{if(e.payload.parentId)return;const r={...e.payload,row:e.row,column:e.column};this._register(e.unitId,e.subUnitId,r),this._watch(e.unitId,e.subUnitId,r);break}case"delete":{this._unregister(n,t,e.payload.commentId),this._unwatch(n,t,e.payload.commentId);break}case"updateRef":{const r=this._sheetsThreadCommentModel.getComment(n,t,e.payload.commentId);if(!r)return;this._unregister(n,t,e.payload.commentId);const s={...r,row:e.row,column:e.column};e.silent||(this._unwatch(n,t,e.payload.commentId),this._watch(n,t,s)),this._register(e.unitId,e.subUnitId,s);break}}})),this.disposeWithMe(o.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}},d.SheetsThreadCommentRefRangeController=U([C(0,o.Inject(p.RefRangeService)),C(1,o.Inject(d.SheetsThreadCommentModel)),C(2,o.Inject(g.ThreadCommentModel)),C(3,o.Inject(p.SheetsSelectionsService)),C(4,o.ICommandService)],d.SheetsThreadCommentRefRangeController);const I="SHEET_THREAD_COMMENT_BASE_PLUGIN";var b=Object.defineProperty,j=Object.getOwnPropertyDescriptor,P=(h,m,e)=>m in h?b(h,m,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[m]=e,E=(h,m,e,n)=>{for(var t=n>1?void 0:n?j(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},v=(h,m)=>(e,n)=>m(e,n,h),R=(h,m,e)=>P(h,typeof m!="symbol"?m+"":m,e);d.UniverSheetsThreadCommentPlugin=class extends o.Plugin{constructor(m,e,n){super(),this._injector=e,this._commandService=n}onStarting(){[[d.SheetsThreadCommentModel],[d.SheetsThreadCommentRefRangeController]].forEach(m=>{this._injector.add(m)}),this._injector.get(d.SheetsThreadCommentRefRangeController)}},R(d.UniverSheetsThreadCommentPlugin,"pluginName",I),R(d.UniverSheetsThreadCommentPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentPlugin=E([o.DependentOn(g.UniverThreadCommentPlugin),v(1,o.Inject(o.Injector)),v(2,o.Inject(o.ICommandService))],d.UniverSheetsThreadCommentPlugin),Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
6
+ (function(d,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/thread-comment"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-formula","@univerjs/sheets","@univerjs/thread-comment","rxjs"],o):(d=typeof globalThis<"u"?globalThis:d||self,o(d.UniverSheetsThreadComment={},d.UniverCore,d.UniverEngineFormula,d.UniverSheets,d.UniverThreadComment,d.rxjs))})(this,function(d,o,l,p,g,w){"use strict";var D=Object.defineProperty;var x=(d,o,l)=>o in d?D(d,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[o]=l;var f=(d,o,l)=>x(d,typeof o!="symbol"?o+"":o,l);var S=Object.getOwnPropertyDescriptor,T=(h,m,e,n)=>{for(var t=n>1?void 0:n?S(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},M=(h,m)=>(e,n)=>m(e,n,h);d.SheetsThreadCommentModel=class extends o.Disposable{constructor(e,n){super();f(this,"_matrixMap",new Map);f(this,"_locationMap",new Map);f(this,"_commentUpdate$",new w.Subject);f(this,"commentUpdate$",this._commentUpdate$.asObservable());this._threadCommentModel=e,this._univerInstanceService=n,this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,n){let t=this._matrixMap.get(e);t||(t=new Map,this._matrixMap.set(e,t));let r=t.get(n);return r||(r=new o.ObjectMatrix,t.set(n,r)),r}_ensureCommentLocationMap(e,n){let t=this._locationMap.get(e);t||(t=new Map,this._locationMap.set(e,t));let r=t.get(n);return r||(r=new Map,t.set(n,r)),r}_addCommentToMatrix(e,n,t,r){var a;const s=(a=e.getValue(n,t))!=null?a:new Set;s.add(r),e.setValue(n,t,s)}_deleteCommentFromMatrix(e,n,t,r){if(n>=0&&t>=0){const s=e.getValue(n,t);s&&s.has(r)&&(s.delete(r),s.size===0&&e.realDeleteValue(n,t))}}_ensure(e,n){const t=this._ensureCommentMatrix(e,n),r=this._ensureCommentLocationMap(e,n);return{matrix:t,locationMap:r}}_initData(){const e=this._threadCommentModel.getAll();for(const n of e)for(const t of n.threads){const{unitId:r,subUnitId:s,root:a}=t;this._addComment(r,s,a)}}_addComment(e,n,t){const r=l.singleReferenceToGrid(t.ref),s=t.parentId,{row:a,column:i}=r,c=t.id,{matrix:_,locationMap:u}=this._ensure(e,n);!s&&a>=0&&i>=0&&(this._addCommentToMatrix(_,a,i,c),u.set(c,{row:a,column:i})),s||this._commentUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add",isRoot:!s,...r})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;try{if(this._univerInstanceService.getUnitType(n)!==o.UniverInstanceType.UNIVER_SHEET)return}catch{}const{matrix:r,locationMap:s}=this._ensure(n,t);switch(e.type){case"add":{this._addComment(e.unitId,e.subUnitId,e.payload);break}case"delete":{const{isRoot:a,comment:i}=e.payload;if(a){const c=l.singleReferenceToGrid(i.ref),{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,i.id),this._commentUpdate$.next({...e,...c})}break}case"update":{const{commentId:a}=e.payload,i=this._threadCommentModel.getComment(n,t,a);if(!i)return;const c=l.singleReferenceToGrid(i.ref);this._commentUpdate$.next({...e,...c});break}case"updateRef":{const a=l.singleReferenceToGrid(e.payload.ref),{commentId:i}=e.payload,c=s.get(i);if(!c)return;const{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,i),s.delete(i),a.row>=0&&a.column>=0&&(this._addCommentToMatrix(r,a.row,a.column,i),s.set(i,{row:a.row,column:a.column})),this._commentUpdate$.next({...e,...a});break}case"resolve":{const{unitId:a,subUnitId:i,payload:c}=e,{locationMap:_}=this._ensure(a,i),u=_.get(c.commentId);u&&this._commentUpdate$.next({...e,...u});break}}}))}getByLocation(e,n,t,r){var i;return(i=this.getAllByLocation(e,n,t,r).filter(c=>!c.resolved)[0])==null?void 0:i.id}getAllByLocation(e,n,t,r){const a=this._ensureCommentMatrix(e,n).getValue(t,r);return a?Array.from(a).map(i=>this.getComment(e,n,i)).filter(Boolean):[]}getComment(e,n,t){return this._threadCommentModel.getComment(e,n,t)}getCommentWithChildren(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return;const a=this.getComment(e,n,s);if(a)return this._threadCommentModel.getThread(e,n,a.threadId)}showCommentMarker(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return!1;const a=this.getComment(e,n,s);return!!(a&&!a.resolved)}getSubUnitAll(e,n){return this._threadCommentModel.getUnit(e).filter(t=>t.subUnitId===n).map(t=>t.root)}},d.SheetsThreadCommentModel=T([M(0,o.Inject(g.ThreadCommentModel)),M(1,o.IUniverInstanceService)],d.SheetsThreadCommentModel);var y=Object.getOwnPropertyDescriptor,U=(h,m,e,n)=>{for(var t=n>1?void 0:n?y(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},C=(h,m)=>(e,n)=>m(e,n,h);d.SheetsThreadCommentRefRangeController=class extends o.Disposable{constructor(e,n,t,r,s){super();f(this,"_disposableMap",new Map);f(this,"_watcherMap",new Map);f(this,"_handleRangeChange",(e,n,t,r,s)=>{const a=t.id,i={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:l.serializeRange(r),commentId:a},silent:s}}],undos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:l.serializeRange(i),commentId:a},silent:s}}]}:{redos:[{id:g.DeleteCommentMutation.id,params:{unitId:e,subUnitId:n,commentId:a}}],undos:[{id:g.AddCommentMutation.id,params:{unitId:e,subUnitId:n,comment:t,sync:!0}}]}});this._refRangeService=e,this._sheetsThreadCommentModel=n,this._threadCommentModel=t,this._selectionManagerService=r,this._commandService=s,this._initData(),this._initRefRange()}_getIdWithUnitId(e,n,t){return`${e}-${n}-${t}`}_register(e,n,t){const r=t.id,s={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._disposableMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.registerRefRange(s,a=>{const i=p.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,a,{selectionManagerService:this._selectionManagerService}),c=Array.isArray(i)?i[0]:i;return c&&c.startColumn===s.startColumn&&c.startRow===s.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,n,t,c,!1)},e,n))}_watch(e,n,t){const r=t.id,s={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watcherMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.watchRange(e,n,s,(a,i)=>{const{redos:c}=this._handleRangeChange(e,n,t,i,!0);o.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,n,t){var s;const r=this._getIdWithUnitId(e,n,t);(s=this._watcherMap.get(r))==null||s.dispose(),this._watcherMap.delete(r)}_unregister(e,n,t){var s;const r=this._getIdWithUnitId(e,n,t);(s=this._disposableMap.get(r))==null||s.dispose(),this._disposableMap.delete(r)}_initData(){const e=this._threadCommentModel.getAll();for(const n of e)for(const t of n.threads){const{unitId:r,subUnitId:s,root:a}=t,i=l.singleReferenceToGrid(a.ref),c={...a,...i};this._register(r,s,c),this._watch(r,s,c)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;switch(e.type){case"add":{if(e.payload.parentId)return;const r={...e.payload,row:e.row,column:e.column};this._register(e.unitId,e.subUnitId,r),this._watch(e.unitId,e.subUnitId,r);break}case"delete":{this._unregister(n,t,e.payload.commentId),this._unwatch(n,t,e.payload.commentId);break}case"updateRef":{const r=this._sheetsThreadCommentModel.getComment(n,t,e.payload.commentId);if(!r)return;this._unregister(n,t,e.payload.commentId);const s={...r,row:e.row,column:e.column};e.silent||(this._unwatch(n,t,e.payload.commentId),this._watch(n,t,s)),this._register(e.unitId,e.subUnitId,s);break}}})),this.disposeWithMe(o.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}},d.SheetsThreadCommentRefRangeController=U([C(0,o.Inject(p.RefRangeService)),C(1,o.Inject(d.SheetsThreadCommentModel)),C(2,o.Inject(g.ThreadCommentModel)),C(3,o.Inject(p.SheetsSelectionsService)),C(4,o.ICommandService)],d.SheetsThreadCommentRefRangeController);const I={},b="SHEET_THREAD_COMMENT_BASE_PLUGIN";var j=Object.defineProperty,P=Object.getOwnPropertyDescriptor,E=(h,m,e)=>m in h?j(h,m,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[m]=e,$=(h,m,e,n)=>{for(var t=n>1?void 0:n?P(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},v=(h,m)=>(e,n)=>m(e,n,h),R=(h,m,e)=>E(h,typeof m!="symbol"?m+"":m,e);d.UniverSheetsThreadCommentPlugin=class extends o.Plugin{constructor(m=I,e,n){super(),this._config=m,this._injector=e,this._commandService=n}onStarting(){[[d.SheetsThreadCommentModel],[d.SheetsThreadCommentRefRangeController]].forEach(m=>{this._injector.add(m)}),this._injector.get(d.SheetsThreadCommentRefRangeController)}},R(d.UniverSheetsThreadCommentPlugin,"pluginName",b),R(d.UniverSheetsThreadCommentPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentPlugin=$([o.DependentOn(g.UniverThreadCommentPlugin),v(1,o.Inject(o.Injector)),v(2,o.Inject(o.ICommandService))],d.UniverSheetsThreadCommentPlugin),Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
7
7
 
8
8
 
9
9
  // @univerjs/sheets-thread-comment/facade
@@ -11,10 +11,10 @@
11
11
 
12
12
 
13
13
  // @univerjs/thread-comment-ui/index
14
- (function(u,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):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverThreadCommentUi={},u.UniverCore,u.UniverThreadComment,u.UniverUi,u.rxjs,u.React,u.UniverDesign,u.React,u.UniverDocsUi))})(this,function(u,a,w,f,X,s,O,d,se){"use strict";var Ke=Object.defineProperty;var Ge=(u,a,w)=>a in u?Ke(u,a,{enumerable:!0,configurable:!0,writable:!0,value:w}):u[a]=w;var Y=(u,a,w)=>Ge(u,typeof a!="symbol"?a+"":a,w);var Se=Object.getOwnPropertyDescriptor,we=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,o=n.length-1,v;o>=0;o--)(v=n[o])&&(i=v(i)||i);return i},oe=(n,e)=>(t,r)=>e(t,r,n);u.ThreadCommentPanelService=class extends a.Disposable{constructor(t,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=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(X.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)}},u.ThreadCommentPanelService=we([oe(0,a.Inject(f.ISidebarService)),oe(1,a.IUniverInstanceService)],u.ThreadCommentPanelService);const le="thread-comment-panel",_e="UNIVER_THREAD_COMMENT_UI_PLUGIN",de={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(f.ISidebarService),t=n.get(u.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:le},width:330}),t.setPanelVisible(!0)),!0}},q={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(u.ThreadCommentPanelService).setActiveComment(e),!0}},Te="thread-comment-ui.config",ce={};var Ne=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Oe=(n,e,t)=>e in n?Ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,De=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ue(e,t):e,o=n.length-1,v;o>=0;o--)(v=n[o])&&(i=v(i)||i);return i},ae=(n,e)=>(t,r)=>e(t,r,n),ue=(n,e,t)=>Oe(n,typeof e!="symbol"?e+"":e,t);u.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ce,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:o,...v}=a.merge({},ce,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Te,v)}onStarting(){var e;a.mergeOverrideWithDependencies([[u.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[de,q].forEach(t=>{this._commandService.registerCommand(t)})}},ue(u.UniverThreadCommentUIPlugin,"pluginName",_e),ue(u.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),u.UniverThreadCommentUIPlugin=De([a.DependentOn(w.UniverThreadCommentPlugin),ae(1,a.Inject(a.Injector)),ae(2,a.ICommandService),ae(3,a.IConfigService)],u.UniverThreadCommentUIPlugin);var k=function(){return k=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},k.apply(this,arguments)},Ee=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},K=d.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,o=n.extend,v=Ee(n,["icon","id","className","extend"]),g="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),I=d.useRef("_".concat(je()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:I.current},k({ref:e,className:g},v),o)});function ve(n,e,t,r,i){return d.createElement(n.tag,k(k({key:e},ke(n,t,i)),r),(Me(n,t).children||[]).map(function(o,v){return ve(o,"".concat(e,"-").concat(n.tag,"-").concat(v),t,void 0,i)}))}function ke(n,e,t){var r=k({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(o){var v=o[0],g=o[1];v==="mask"&&typeof g=="string"&&(r[v]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(o){var v=o[0],g=o[1];typeof g=="string"&&(r[v]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Me(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?k(k({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?k(k({},i),{attrs:k(k({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function je(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.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.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.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(n,e){return d.createElement(K,Object.assign({},n,{id:"delete-icon",ref:e,icon:Pe}))});me.displayName="DeleteIcon";var $e={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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(n,e){return d.createElement(K,Object.assign({},n,{id:"increase-icon",ref:e,icon:$e}))});fe.displayName="IncreaseIcon";var Le={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z"}}]},he=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"more-horizontal-icon",ref:e,icon:Le}))});he.displayName="MoreHorizontalIcon";var He={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.76813",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M8.91626 6.1311H9.27424",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},pe=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"reply-to-comment-icon",ref:e,icon:He}))});pe.displayName="ReplyToCommentIcon";var Ve={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ce=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"resolved-icon",ref:e,icon:Ve}))});Ce.displayName="ResolvedIcon";var Be={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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}}]},ge=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"solve-icon",ref:e,icon:Be}))});ge.displayName="SolveIcon";function Ie(n){return{id:"d",body:n,documentStyle:{}}}const be=d.forwardRef((n,e)=>{var V;const{comment:t,onSave:r,id:i,onCancel:o,autoFocus:v,unitId:g,type:I}=n,D=f.useDependency(a.ICommandService),M=f.useDependency(a.LocaleService),[Z,j]=d.useState(!1),_=f.useDependency(se.IEditorService),h=d.useRef(null),p=I===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:g,[P,T]=d.useState(()=>{var m,C,b;return a.BuildTextUtils.transform.getPlainText((b=(C=(m=h.current)==null?void 0:m.getDocumentData().body)==null?void 0:C.dataStream)!=null?b:"")});d.useEffect(()=>{var C,b,N,x;T(a.BuildTextUtils.transform.getPlainText((N=(b=(C=h.current)==null?void 0:C.getDocumentData().body)==null?void 0:b.dataStream)!=null?N:""));const m=(x=h.current)==null?void 0:x.selectionChange$.subscribe(()=>{var l,U,G;T(a.BuildTextUtils.transform.getPlainText((G=(U=(l=h.current)==null?void 0:l.getDocumentData().body)==null?void 0:U.dataStream)!=null?G:""))});return()=>m==null?void 0:m.unsubscribe()},[(V=h.current)==null?void 0:V.selectionChange$]);const F=d.useMemo(()=>({keyCodes:[{keyCode:f.KeyCode.ENTER}],handler:m=>{m===f.KeyCode.ENTER&&D.executeCommand(se.BreakLineCommand.id)}}),[D]);d.useImperativeHandle(e,()=>({reply(m){var b,N;if(!h.current)return;_.focus((b=h.current.getEditorId())!=null?b:"");const C=Ie(m);(N=h.current)==null||N.setDocumentData(C,[{startOffset:C.body.dataStream.length-2,endOffset:C.body.dataStream.length-2,collapsed:!0}])}}));const y=()=>{if(h.current){const m=a.Tools.deepClone(h.current.getDocumentData().body);j(!1),r==null||r({...t,text:m}),h.current.replaceText(""),setTimeout(()=>{var C,b;(C=h.current)==null||C.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:F,placeholder:M.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&Ie(t.text),onFocusChange:m=>m&&j(m),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{_.focus(p)},30)}}),Z?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[s.jsx(O.Button,{onClick:()=>{var m;o==null||o(),j(!1),(m=h.current)==null||m.replaceText("",!0),D.executeCommand(q.id)},children:M.t("threadCommentUI.editor.cancel")}),s.jsx(O.Button,{variant:"primary",disabled:!P,onClick:y,children:M.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
14
+ (function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/thread-comment"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/thread-comment","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverThreadCommentUi={},u.UniverCore,u.UniverUi,u.rxjs,u.UniverThreadComment,u.React,u.UniverDesign,u.React,u.UniverDocsUi))})(this,function(u,a,m,X,B,s,U,d,se){"use strict";var Ke=Object.defineProperty;var Ge=(u,a,m)=>a in u?Ke(u,a,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[a]=m;var Y=(u,a,m)=>Ge(u,typeof a!="symbol"?a+"":a,m);var Se=Object.getOwnPropertyDescriptor,we=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,o=n.length-1,v;o>=0;o--)(v=n[o])&&(i=v(i)||i);return i},oe=(n,e)=>(t,r)=>e(t,r,n);u.ThreadCommentPanelService=class extends a.Disposable{constructor(t,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=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(X.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)}},u.ThreadCommentPanelService=we([oe(0,a.Inject(m.ISidebarService)),oe(1,a.IUniverInstanceService)],u.ThreadCommentPanelService);const le="thread-comment-panel",_e="UNIVER_THREAD_COMMENT_UI_PLUGIN",de={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(m.ISidebarService),t=n.get(u.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:le},width:330}),t.setPanelVisible(!0)),!0}},q={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(u.ThreadCommentPanelService).setActiveComment(e),!0}},Te="thread-comment-ui.config",ce={};var Ne=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Oe=(n,e,t)=>e in n?Ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,De=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ue(e,t):e,o=n.length-1,v;o>=0;o--)(v=n[o])&&(i=v(i)||i);return i},ae=(n,e)=>(t,r)=>e(t,r,n),ue=(n,e,t)=>Oe(n,typeof e!="symbol"?e+"":e,t);u.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ce,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:o,...v}=a.merge({},ce,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Te,v)}onStarting(){var e;a.mergeOverrideWithDependencies([[u.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[de,q].forEach(t=>{this._commandService.registerCommand(t)})}},ue(u.UniverThreadCommentUIPlugin,"pluginName",_e),ue(u.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),u.UniverThreadCommentUIPlugin=De([a.DependentOn(B.UniverThreadCommentPlugin),ae(1,a.Inject(a.Injector)),ae(2,a.ICommandService),ae(3,a.IConfigService)],u.UniverThreadCommentUIPlugin);var E=function(){return E=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},E.apply(this,arguments)},Ee=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},K=d.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,o=n.extend,v=Ee(n,["icon","id","className","extend"]),g="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),I=d.useRef("_".concat(je()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:I.current},E({ref:e,className:g},v),o)});function ve(n,e,t,r,i){return d.createElement(n.tag,E(E({key:e},ke(n,t,i)),r),(Me(n,t).children||[]).map(function(o,v){return ve(o,"".concat(e,"-").concat(n.tag,"-").concat(v),t,void 0,i)}))}function ke(n,e,t){var r=E({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(o){var v=o[0],g=o[1];v==="mask"&&typeof g=="string"&&(r[v]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(o){var v=o[0],g=o[1];typeof g=="string"&&(r[v]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Me(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?E(E({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?E(E({},i),{attrs:E(E({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function je(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.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.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.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(n,e){return d.createElement(K,Object.assign({},n,{id:"delete-icon",ref:e,icon:Pe}))});me.displayName="DeleteIcon";var $e={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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(n,e){return d.createElement(K,Object.assign({},n,{id:"increase-icon",ref:e,icon:$e}))});fe.displayName="IncreaseIcon";var Le={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z"}}]},he=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"more-horizontal-icon",ref:e,icon:Le}))});he.displayName="MoreHorizontalIcon";var He={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.76813",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M8.91626 6.1311H9.27424",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},pe=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"reply-to-comment-icon",ref:e,icon:He}))});pe.displayName="ReplyToCommentIcon";var Ve={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ce=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"resolved-icon",ref:e,icon:Ve}))});Ce.displayName="ResolvedIcon";var Be={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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}}]},ge=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"solve-icon",ref:e,icon:Be}))});ge.displayName="SolveIcon";function Ie(n){return{id:"d",body:n,documentStyle:{}}}const be=d.forwardRef((n,e)=>{var H;const{comment:t,onSave:r,id:i,onCancel:o,autoFocus:v,unitId:g,type:I}=n,O=m.useDependency(a.ICommandService),k=m.useDependency(a.LocaleService),[Z,M]=d.useState(!1),w=m.useDependency(se.IEditorService),h=d.useRef(null),p=I===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:g,[j,_]=d.useState(()=>{var f,C,b;return a.BuildTextUtils.transform.getPlainText((b=(C=(f=h.current)==null?void 0:f.getDocumentData().body)==null?void 0:C.dataStream)!=null?b:"")});d.useEffect(()=>{var C,b,T,x;_(a.BuildTextUtils.transform.getPlainText((T=(b=(C=h.current)==null?void 0:C.getDocumentData().body)==null?void 0:b.dataStream)!=null?T:""));const f=(x=h.current)==null?void 0:x.selectionChange$.subscribe(()=>{var l,N,G;_(a.BuildTextUtils.transform.getPlainText((G=(N=(l=h.current)==null?void 0:l.getDocumentData().body)==null?void 0:N.dataStream)!=null?G:""))});return()=>f==null?void 0:f.unsubscribe()},[(H=h.current)==null?void 0:H.selectionChange$]);const F=d.useMemo(()=>({keyCodes:[{keyCode:m.KeyCode.ENTER}],handler:f=>{f===m.KeyCode.ENTER&&O.executeCommand(se.BreakLineCommand.id)}}),[O]);d.useImperativeHandle(e,()=>({reply(f){var b,T;if(!h.current)return;w.focus((b=h.current.getEditorId())!=null?b:"");const C=Ie(f);(T=h.current)==null||T.setDocumentData(C,[{startOffset:C.body.dataStream.length-2,endOffset:C.body.dataStream.length-2,collapsed:!0}])}}));const y=()=>{if(h.current){const f=a.Tools.deepClone(h.current.getDocumentData().body);M(!1),r==null||r({...t,text:f}),h.current.replaceText(""),setTimeout(()=>{var C,b;(C=h.current)==null||C.setSelectionRanges([]),(b=h.current)==null||b.blur()},10)}};return s.jsxs("div",{onClick:f=>f.preventDefault(),children:[s.jsx(se.RichTextEditor,{className:"univer-w-full",editorRef:h,autoFocus:v,keyboardEventConfig:F,placeholder:k.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&Ie(t.text),onFocusChange:f=>f&&M(f),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{w.focus(p)},30)}}),Z?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[s.jsx(U.Button,{onClick:()=>{var f;o==null||o(),M(!1),(f=h.current)==null||f.replaceText("",!0),O.executeCommand(q.id)},children:k.t("threadCommentUI.editor.cancel")}),s.jsx(U.Button,{variant:"primary",disabled:!j,onClick:y,children:k.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
15
15
  `)?e.length-2:e.length,i=[];let o=0;return t==null||t.forEach(v=>{o<v.startIndex&&i.push({type:"text",content:e.slice(o,v.startIndex)}),i.push({type:"mention",content:{label:e.slice(v.startIndex,v.endIndex+1),id:v.rangeId}}),o=v.endIndex+1}),i.push({type:"text",content:e.slice(o,r)}),i},We=n=>{const{paragraphs:e=[]}=n;let t=0;return e.map(r=>{const i=a.getBodySlice(n,t,r.startIndex);return t=r.startIndex+1,Ae(i)})},Ze=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const o=e.length-1;t.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:i,endIndex:o,properties:{},wholeEntity:!0});break}}}),e+=`\r
16
- `,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},xe="__mock__",Fe=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:o,onReply:v,resolved:g,isRoot:I,onClose:D,onDeleteComment:M,type:Z}=n,j=f.useDependency(a.ICommandService),_=f.useDependency(a.LocaleService),h=f.useDependency(a.UserManagerService),p=h.getUser(e.personId),P=f.useObservable(h.currentUser$),T=(P==null?void 0:P.userID)===e.personId,F=e.id===xe,[y,V]=d.useState(!1),m=f.useConfigValue(f.UI_PLUGIN_CONFIG_KEY),C=m==null?void 0:m.avatarFallback,b=()=>{(M==null?void 0:M(e))!==!1&&(j.executeCommand(I?w.DeleteCommentTreeCommand.id:w.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),I&&(D==null||D()))};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)||C})`}}),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:[F||g?null:y&&p?s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",onClick:()=>v(p),children:s.jsx(pe,{})}):null,T&&!F&&!g?s.jsx(O.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:()=>o==null?void 0:o(!0),children:_.t("threadCommentUI.item.edit")})}),s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:b,children:_.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:Z,id:e.id,comment:e,onCancel:()=>o==null?void 0:o(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:N,attachments:x})=>{o==null||o(!1),j.executeCommand(w.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:N,attachments:x}})}}):s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:We(e.text).map((N,x)=>s.jsx("div",{className:"univer-break-words",children:N.map((l,U)=>{switch(l.type){case"mention":return s.jsxs("a",{className:"univer-text-primary-600",children:[l.content.label," "]},U);default:return l.content}})},x))})]})},ye=n=>{var ie,Q,c;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:o=!0,onClick:v,showHighlight:g,onClose:I,getSubUnitName:D,prefix:M,autoFocus:Z,onMouseEnter:j,onMouseLeave:_,onAddComment:h,onDeleteComment:p,onResolve:P,type:T,style:F,full:y}=n,V=f.useDependency(w.ThreadCommentModel),[m,C]=d.useState(!1),[b,N]=d.useState(""),x=d.useMemo(()=>V.commentUpdate$.pipe(X.debounceTime(16)),[V]);f.useObservable(x);const l=e?V.getCommentWithChildren(t,r,e):null,U=f.useDependency(a.ICommandService),G=f.useDependency(a.UserManagerService),$=l==null?void 0:l.root.resolved,L=f.useObservable(G.currentUser$),A=d.useRef(null),R=[...l?[l.root]:[{id:xe,text:{dataStream:`
17
- \r`},personId:(ie=L==null?void 0:L.userID)!=null?ie:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(Q=l==null?void 0:l.children)!=null?Q:[]],B=d.useRef(null),ee=S=>{S.stopPropagation(),$?U.executeCommand(q.id,{unitId:t,subUnitId:r,commentId:e}):U.executeCommand(q.id),U.executeCommand(w.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!$}),P==null||P(!$)},J=S=>{S.stopPropagation(),U.executeCommand(q.id),!(l!=null&&l.root&&(p==null?void 0:p(l.root))===!1)&&(U.executeCommand(w.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),I==null||I())};d.useEffect(()=>_==null?void 0:_(),[]);const te=D((c=l==null?void 0:l.root.subUnitId)!=null?c:r),ne=o&&!b&&!$,re=`${i||(l==null?void 0:l.root.ref)||""}${te?" · ":""}${te}`;return s.jsxs("div",{id:`${M}-${t}-${r}-${e}`,className:O.clsx("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white",O.borderClassName,{"univer-w-[278px]":!y,"univer-w-full":y,"univer-shadow":!$&&(g||m||M==="cell")}),style:F,onClick:v,onMouseEnter:()=>{j==null||j(),C(!0)},onMouseLeave:()=>{_==null||_(),C(!1)},children:[!$&&g&&s.jsx("div",{className:"univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400"}),s.jsxs("div",{className:"univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5",children:[s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",children:[s.jsx("div",{className:"univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500"}),s.jsx(O.Tooltip,{showIfEllipsis:!0,title:re,children:s.jsx("div",{className:"univer-flex-1 univer-truncate",children:re})})]}),!!l&&s.jsxs("div",{className:"univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",children:[s.jsx("div",{className:O.clsx("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 hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800",{"univer-text-green-500":$}),onClick:ee,children:$?s.jsx(Ce,{}):s.jsx(ge,{})}),(L==null?void 0:L.userID)===l.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 hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800",onClick:J,children:s.jsx(me,{})}):null]})]}),s.jsx("div",{ref:B,className:O.clsx("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",O.scrollbarClassName),children:R.map(S=>s.jsx(Fe,{unitId:t,subUnitId:r,item:S,isRoot:S.id===(l==null?void 0:l.root.id),editing:b===S.id,resolved:l==null?void 0:l.root.resolved,type:T,onClose:I,onEditingChange:H=>{N(H?S.id:"")},onReply:H=>{H&&requestAnimationFrame(()=>{var W;(W=A.current)==null||W.reply(Ze([{type:"mention",content:{id:H.userID,label:`@${H.name}`}},{type:"text",content:" "}]))})},onAddComment:h,onDeleteComment:p},S.id))}),ne&&s.jsx("div",{children:s.jsx(be,{ref:A,type:T,unitId:t,subUnitId:r,onSave:async({text:S,attachments:H})=>{const W={text:S,attachments:H,dT:w.getDT(),id:a.generateRandomId(),ref:i,personId:L==null?void 0:L.userID,parentId:l==null?void 0:l.root.id,unitId:t,subUnitId:r,threadId:l==null?void 0:l.root.threadId};(h==null?void 0:h(W))!==!1&&(await U.executeCommand(w.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:W}),B.current&&(B.current.scrollTop=B.current.scrollHeight))},autoFocus:Z||!l,onCancel:()=>{l||I==null||I()}},`${Z}`)})]})},qe=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:o,onResolve:v,sortComments:g,onItemLeave:I,onItemEnter:D,disableAdd:M,tempComment:Z,onAddComment:j,onDeleteComment:_,showComments:h}=n,[p,P]=d.useState("all"),[T,F]=d.useState("all"),y=f.useDependency(a.LocaleService),V=f.useDependency(a.UserManagerService),m=f.useDependency(w.ThreadCommentModel),[C,b]=d.useState(()=>m.getUnit(e)),N=f.useDependency(u.ThreadCommentPanelService),x=f.useObservable(N.activeCommentId$),l=f.useObservable(m.commentUpdate$),U=f.useDependency(a.ICommandService),G=f.useObservable(t),$=d.useRef(!0),L="panel",A=f.useObservable(V.currentUser$),R=d.useMemo(()=>{var W;const c=p==="all"?C:(W=C.filter(E=>E.subUnitId===G))!=null?W:[],S=g!=null?g:E=>E,H=c.map(E=>{var z;return{...E.root,children:(z=E.children)!=null?z:[],users:E.relativeUsers}});if(h){const E=new Map;return H.forEach(z=>{E.set(z.id,z)}),[...h,""].map(z=>E.get(z)).filter(Boolean)}else return S(H)},[h,p,C,g,G]),B=d.useMemo(()=>[...R.filter(c=>!c.resolved),...R.filter(c=>c.resolved)],[R]),ee=d.useMemo(()=>T==="resolved"?B.filter(c=>c.resolved):T==="unsolved"?B.filter(c=>!c.resolved):T==="concern_me"&&A!=null&&A.userID?B.filter(c=>c==null?void 0:c.users.has(A.userID)):B,[B,A==null?void 0:A.userID,T]),J=Z?[Z,...ee]:ee,te=J.filter(c=>!c.resolved),ne=J.filter(c=>c.resolved),re=T!=="all"||p!=="all",ie=()=>{F("all"),P("all")};d.useEffect(()=>{e&&b(m.getUnit(e))},[e,m,l]),d.useEffect(()=>{var E;if(!x)return;if(!$.current){$.current=!0;return}const{unitId:c,subUnitId:S,commentId:H}=x,W=`${L}-${c}-${S}-${H}`;(E=document.getElementById(W))==null||E.scrollIntoView({block:"center"})},[x]);const Q=c=>s.jsx(ye,{full:!0,prefix:L,getSubUnitName:o,id:c.id,unitId:c.unitId,subUnitId:c.subUnitId,refStr:c.ref,type:r,showEdit:(x==null?void 0:x.commentId)===c.id,showHighlight:(x==null?void 0:x.commentId)===c.id,onClick:()=>{$.current=!1,c.resolved?U.executeCommand(q.id):U.executeCommand(q.id,{unitId:c.unitId,subUnitId:c.subUnitId,commentId:c.id,temp:!1})},onMouseEnter:()=>D==null?void 0:D(c),onMouseLeave:()=>I==null?void 0:I(c),onAddComment:j,onDeleteComment:_,onResolve:S=>v==null?void 0:v(c.id,S)},c.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(O.Select,{borderless:!0,value:p,options:[{value:"current",label:y.t("threadCommentUI.filter.sheet.current")},{value:"all",label:y.t("threadCommentUI.filter.sheet.all")}],onChange:P}):null,s.jsx(O.Select,{borderless:!0,value:T,options:[{value:"all",label:y.t("threadCommentUI.filter.status.all")},{value:"resolved",label:y.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:y.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:y.t("threadCommentUI.filter.status.concernMe")}],onChange:F})]}),J.length===0?s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[y.t("threadCommentUI.panel.empty"),re?s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsx(O.Button,{onClick:ie,children:y.t("threadCommentUI.panel.reset")})}):M?null:s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsxs(O.Button,{onClick:i,children:[s.jsx(fe,{className:"univer-mr-1.5"}),y.t("threadCommentUI.panel.add")]})})]}):s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[te.map(Q),ne.length>0&&s.jsx("div",{className:"univer-text-xs",children:y.t("threadCommentUI.panel.solved")}),ne.map(Q)]})]})};u.SetActiveCommentOperation=q,u.THREAD_COMMENT_PANEL=le,u.ThreadCommentPanel=qe,u.ThreadCommentTree=ye,u.ToggleSheetCommentPanelOperation=de,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
16
+ `,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},xe="__mock__",Fe=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:o,onReply:v,resolved:g,isRoot:I,onClose:O,onDeleteComment:k,type:Z}=n,M=m.useDependency(a.ICommandService),w=m.useDependency(a.LocaleService),h=m.useDependency(a.UserManagerService),p=h.getUser(e.personId),j=m.useObservable(h.currentUser$),_=(j==null?void 0:j.userID)===e.personId,F=e.id===xe,[y,H]=d.useState(!1),f=m.useConfigValue(m.UI_PLUGIN_CONFIG_KEY),C=f==null?void 0:f.avatarFallback,b=()=>{(k==null?void 0:k(e))!==!1&&(M.executeCommand(I?B.DeleteCommentTreeCommand.id:B.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),I&&(O==null||O()))};return s.jsxs("div",{className:"univer-relative univer-mb-3 univer-pl-[30px]",onMouseLeave:()=>H(!1),onMouseEnter:()=>H(!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)||C})`}}),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:[F||g?null:y&&p?s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",onClick:()=>v(p),children:s.jsx(pe,{})}):null,_&&!F&&!g?s.jsx(U.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:()=>o==null?void 0:o(!0),children:w.t("threadCommentUI.item.edit")})}),s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:b,children:w.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:Z,id:e.id,comment:e,onCancel:()=>o==null?void 0:o(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:T,attachments:x})=>{o==null||o(!1),M.executeCommand(B.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:T,attachments:x}})}}):s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:We(e.text).map((T,x)=>s.jsx("div",{className:"univer-break-words",children:T.map((l,N)=>{switch(l.type){case"mention":return s.jsxs("a",{className:"univer-text-primary-600",children:[l.content.label," "]},N);default:return l.content}})},x))})]})},ye=n=>{var ie,Q,c;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:o=!0,onClick:v,showHighlight:g,onClose:I,getSubUnitName:O,prefix:k,autoFocus:Z,onMouseEnter:M,onMouseLeave:w,onAddComment:h,onDeleteComment:p,onResolve:j,type:_,style:F,full:y}=n,H=m.useDependency(B.ThreadCommentModel),[f,C]=d.useState(!1),[b,T]=d.useState(""),x=d.useMemo(()=>H.commentUpdate$.pipe(X.debounceTime(16)),[H]);m.useObservable(x);const l=e?H.getCommentWithChildren(t,r,e):null,N=m.useDependency(a.ICommandService),G=m.useDependency(a.UserManagerService),P=l==null?void 0:l.root.resolved,$=m.useObservable(G.currentUser$),A=d.useRef(null),R=[...l?[l.root]:[{id:xe,text:{dataStream:`
17
+ \r`},personId:(ie=$==null?void 0:$.userID)!=null?ie:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(Q=l==null?void 0:l.children)!=null?Q:[]],V=d.useRef(null),ee=S=>{S.stopPropagation(),P?N.executeCommand(q.id,{unitId:t,subUnitId:r,commentId:e}):N.executeCommand(q.id),N.executeCommand(B.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!P}),j==null||j(!P)},J=S=>{S.stopPropagation(),N.executeCommand(q.id),!(l!=null&&l.root&&(p==null?void 0:p(l.root))===!1)&&(N.executeCommand(B.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),I==null||I())};d.useEffect(()=>w==null?void 0:w(),[]);const te=O((c=l==null?void 0:l.root.subUnitId)!=null?c:r),ne=o&&!b&&!P,re=`${i||(l==null?void 0:l.root.ref)||""}${te?" · ":""}${te}`;return s.jsxs("div",{id:`${k}-${t}-${r}-${e}`,className:U.clsx("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white",U.borderClassName,{"univer-w-[278px]":!y,"univer-w-full":y,"univer-shadow":!P&&(g||f||k==="cell")}),style:F,onClick:v,onMouseEnter:()=>{M==null||M(),C(!0)},onMouseLeave:()=>{w==null||w(),C(!1)},children:[!P&&g&&s.jsx("div",{className:"univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400"}),s.jsxs("div",{className:"univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5",children:[s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",children:[s.jsx("div",{className:"univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500"}),s.jsx(U.Tooltip,{showIfEllipsis:!0,title:re,children:s.jsx("div",{className:"univer-flex-1 univer-truncate",children:re})})]}),!!l&&s.jsxs("div",{className:"univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",children:[s.jsx("div",{className:U.clsx("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 hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800",{"univer-text-green-500":P}),onClick:ee,children:P?s.jsx(Ce,{}):s.jsx(ge,{})}),($==null?void 0:$.userID)===l.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 hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800",onClick:J,children:s.jsx(me,{})}):null]})]}),s.jsx("div",{ref:V,className:U.clsx("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",U.scrollbarClassName),children:R.map(S=>s.jsx(Fe,{unitId:t,subUnitId:r,item:S,isRoot:S.id===(l==null?void 0:l.root.id),editing:b===S.id,resolved:l==null?void 0:l.root.resolved,type:_,onClose:I,onEditingChange:L=>{T(L?S.id:"")},onReply:L=>{L&&requestAnimationFrame(()=>{var W;(W=A.current)==null||W.reply(Ze([{type:"mention",content:{id:L.userID,label:`@${L.name}`}},{type:"text",content:" "}]))})},onAddComment:h,onDeleteComment:p},S.id))}),ne&&s.jsx("div",{children:s.jsx(be,{ref:A,type:_,unitId:t,subUnitId:r,onSave:async({text:S,attachments:L})=>{const W={text:S,attachments:L,dT:B.getDT(),id:a.generateRandomId(),ref:i,personId:$==null?void 0:$.userID,parentId:l==null?void 0:l.root.id,unitId:t,subUnitId:r,threadId:l==null?void 0:l.root.threadId};(h==null?void 0:h(W))!==!1&&(await N.executeCommand(B.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:W}),V.current&&(V.current.scrollTop=V.current.scrollHeight))},autoFocus:Z||!l,onCancel:()=>{l||I==null||I()}},`${Z}`)})]})},qe=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:o,onResolve:v,sortComments:g,onItemLeave:I,onItemEnter:O,disableAdd:k,tempComment:Z,onAddComment:M,onDeleteComment:w,showComments:h}=n,[p,j]=d.useState("all"),[_,F]=d.useState("all"),y=m.useDependency(a.LocaleService),H=m.useDependency(a.UserManagerService),f=m.useDependency(B.ThreadCommentModel),[C,b]=d.useState(()=>f.getUnit(e)),T=m.useDependency(u.ThreadCommentPanelService),x=m.useObservable(T.activeCommentId$),l=m.useObservable(f.commentUpdate$),N=m.useDependency(a.ICommandService),G=m.useObservable(t),P=d.useRef(!0),$="panel",A=m.useObservable(H.currentUser$),R=d.useMemo(()=>{var W;const c=p==="all"?C:(W=C.filter(D=>D.subUnitId===G))!=null?W:[],S=g!=null?g:D=>D,L=c.map(D=>{var z;return{...D.root,children:(z=D.children)!=null?z:[],users:D.relativeUsers}});if(h){const D=new Map;return L.forEach(z=>{D.set(z.id,z)}),[...h,""].map(z=>D.get(z)).filter(Boolean)}else return S(L)},[h,p,C,g,G]),V=d.useMemo(()=>[...R.filter(c=>!c.resolved),...R.filter(c=>c.resolved)],[R]),ee=d.useMemo(()=>_==="resolved"?V.filter(c=>c.resolved):_==="unsolved"?V.filter(c=>!c.resolved):_==="concern_me"&&A!=null&&A.userID?V.filter(c=>c==null?void 0:c.users.has(A.userID)):V,[V,A==null?void 0:A.userID,_]),J=Z?[Z,...ee]:ee,te=J.filter(c=>!c.resolved),ne=J.filter(c=>c.resolved),re=_!=="all"||p!=="all",ie=()=>{F("all"),j("all")};d.useEffect(()=>{e&&b(f.getUnit(e))},[e,f,l]),d.useEffect(()=>{var D;if(!x)return;if(!P.current){P.current=!0;return}const{unitId:c,subUnitId:S,commentId:L}=x,W=`${$}-${c}-${S}-${L}`;(D=document.getElementById(W))==null||D.scrollIntoView({block:"center"})},[x]);const Q=c=>s.jsx(ye,{full:!0,prefix:$,getSubUnitName:o,id:c.id,unitId:c.unitId,subUnitId:c.subUnitId,refStr:c.ref,type:r,showEdit:(x==null?void 0:x.commentId)===c.id,showHighlight:(x==null?void 0:x.commentId)===c.id,onClick:()=>{P.current=!1,c.resolved?N.executeCommand(q.id):N.executeCommand(q.id,{unitId:c.unitId,subUnitId:c.subUnitId,commentId:c.id,temp:!1})},onMouseEnter:()=>O==null?void 0:O(c),onMouseLeave:()=>I==null?void 0:I(c),onAddComment:M,onDeleteComment:w,onResolve:S=>v==null?void 0:v(c.id,S)},c.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(U.Select,{borderless:!0,value:p,options:[{value:"current",label:y.t("threadCommentUI.filter.sheet.current")},{value:"all",label:y.t("threadCommentUI.filter.sheet.all")}],onChange:j}):null,s.jsx(U.Select,{borderless:!0,value:_,options:[{value:"all",label:y.t("threadCommentUI.filter.status.all")},{value:"resolved",label:y.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:y.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:y.t("threadCommentUI.filter.status.concernMe")}],onChange:F})]}),J.length===0?s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[y.t("threadCommentUI.panel.empty"),re?s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsx(U.Button,{onClick:ie,children:y.t("threadCommentUI.panel.reset")})}):k?null:s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsxs(U.Button,{onClick:i,children:[s.jsx(fe,{className:"univer-mr-1.5"}),y.t("threadCommentUI.panel.add")]})})]}):s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[te.map(Q),ne.length>0&&s.jsx("div",{className:"univer-text-xs",children:y.t("threadCommentUI.panel.solved")}),ne.map(Q)]})]})};u.SetActiveCommentOperation=q,u.THREAD_COMMENT_PANEL=le,u.ThreadCommentPanel=qe,u.ThreadCommentTree=ye,u.ToggleSheetCommentPanelOperation=de,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
18
18
 
19
19
 
20
20
  // @univerjs/sheets-thread-comment-ui/index
@@ -0,0 +1,10 @@
1
+ // @univerjs/thread-comment-ui/locale/ko-KR
2
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverThreadCommentUiKoKR=t())})(this,function(){"use strict";return{threadCommentUI:{panel:{title:"댓글 관리",empty:"아직 댓글이 없습니다",filterEmpty:"일치하는 결과가 없습니다",reset:"필터 초기화",addComment:"댓글 추가",solved:"해결됨"},editor:{placeholder:"답변 또는 @로 다른 사람 추가",reply:"댓글",cancel:"취소",save:"저장"},item:{edit:"편집",delete:"댓글 삭제"},filter:{sheet:{all:"모든 시트",current:"현재 시트"},status:{all:"모든 댓글",resolved:"해결됨",unsolved:"해결되지 않음",concernMe:"나에게 관련됨"}}}}});
3
+
4
+
5
+ // @univerjs/sheets-thread-comment-ui/locale/ko-KR
6
+ (function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsThreadCommentUiKoKR=n())})(this,function(){"use strict";return{sheetThreadComment:{menu:{addComment:"댓글 추가",commentManagement:"댓글 관리"}}}});
7
+
8
+
9
+ // locale/ko-KR
10
+ (function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n(require("@univerjs/core"),require("@univerjs/sheets-thread-comment-ui/locale/ko-KR"),require("@univerjs/thread-comment-ui/locale/ko-KR")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/sheets-thread-comment-ui/locale/ko-KR","@univerjs/thread-comment-ui/locale/ko-KR"],n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsThreadCommentKoKR=n(e.UniverCore,e.UniverSheetsThreadCommentUiKoKR,e.UniverThreadCommentUiKoKR))})(this,function(e,n,i){"use strict";return e.merge({},n,i)});
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-thread-comment",
3
- "version": "0.8.2",
3
+ "version": "0.8.3-nightly.202506271607",
4
4
  "private": false,
5
5
  "description": "",
6
- "author": "DreamNum <developer@univer.ai>",
6
+ "author": "DreamNum Co., Ltd. <developer@univer.ai>",
7
7
  "license": "Apache-2.0",
8
8
  "funding": {
9
9
  "type": "opencollective",
@@ -18,7 +18,8 @@
18
18
  "url": "https://github.com/dream-num/univer-presets/issues"
19
19
  },
20
20
  "keywords": [
21
- "univer"
21
+ "univer",
22
+ "univer-preset"
22
23
  ],
23
24
  "sideEffects": [
24
25
  "*.css"
@@ -57,18 +58,18 @@
57
58
  "rxjs": ">=7.0.0"
58
59
  },
59
60
  "dependencies": {
60
- "@univerjs/sheets-thread-comment": "0.8.2",
61
- "@univerjs/sheets-thread-comment-ui": "0.8.2",
62
- "@univerjs/thread-comment": "0.8.2",
63
- "@univerjs/thread-comment-ui": "0.8.2"
61
+ "@univerjs/sheets-thread-comment": "0.8.3-nightly.202506271607",
62
+ "@univerjs/sheets-thread-comment-ui": "0.8.3-nightly.202506271607",
63
+ "@univerjs/thread-comment": "0.8.3-nightly.202506271607",
64
+ "@univerjs/thread-comment-ui": "0.8.3-nightly.202506271607"
64
65
  },
65
66
  "devDependencies": {
66
- "@univerjs/core": "0.8.2",
67
+ "@univerjs/core": "0.8.3-nightly.202506271607",
67
68
  "react": "18.3.1",
68
69
  "react-dom": "18.3.1",
69
70
  "rxjs": "7.8.2",
70
71
  "typescript": "^5.8.3",
71
- "@univerjs-infra/shared": "0.8.2"
72
+ "@univerjs-infra/shared": "0.8.3"
72
73
  },
73
74
  "scripts": {
74
75
  "prebuild:preset": "tsx prepare.ts",