@univerjs/sheets-thread-comment 0.15.2-insiders.20260124-12fc7f0 → 0.15.3-insiders.20260131-b9b8805

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var A = Object.defineProperty;
2
2
  var W = (a, e, r) => e in a ? A(a, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[e] = r;
3
3
  var _ = (a, e, r) => W(a, typeof e != "symbol" ? e + "" : e, r);
4
- import { Inject as h, IUniverInstanceService as $, Disposable as y, ObjectMatrix as j, UniverInstanceType as g, ICommandService as O, sequenceExecuteAsync as L, toDisposable as N, generateRandomId as b, DependentOn as V, Injector as B, Plugin as H, touchDependencies as F } from "@univerjs/core";
4
+ import { Inject as h, Disposable as y, ObjectMatrix as j, UniverInstanceType as g, IUniverInstanceService as $, sequenceExecuteAsync as L, toDisposable as N, ICommandService as O, generateRandomId as b, DependentOn as V, Injector as B, Plugin as H, touchDependencies as F } from "@univerjs/core";
5
5
  import { singleReferenceToGrid as p, serializeRange as T } from "@univerjs/engine-formula";
6
6
  import { RefRangeService as k, SheetsSelectionsService as z, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as G, SheetInterceptorService as q, RemoveSheetCommand as J, CopySheetCommand as K } from "@univerjs/sheets";
7
7
  import { ThreadCommentModel as R, AddCommentMutation as w, DeleteCommentMutation as I, UpdateCommentRefMutation as E, IThreadCommentDataSourceService as Q, UniverThreadCommentPlugin as X } from "@univerjs/thread-comment";
@@ -51,6 +51,7 @@ export interface IFUniverCommentMixin {
51
51
  * @ignore
52
52
  */
53
53
  export declare class FUniverCommentMixin extends FUniver implements IFUniverCommentMixin {
54
+ private _getTargetSheet;
54
55
  _initialize(injector: Injector): void;
55
56
  /**
56
57
  * @ignore
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(a,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-thread-comment"),require("@univerjs/sheets/facade"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("rxjs"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-thread-comment","@univerjs/sheets/facade","@univerjs/thread-comment","@univerjs/engine-formula","rxjs","@univerjs/core/facade"],s):(a=typeof globalThis<"u"?globalThis:a||self,s(a.UniverSheetsThreadCommentFacade={},a.UniverCore,a.UniverSheetsThreadComment,a.UniverSheetsFacade,a.UniverThreadComment,a.UniverEngineFormula,a.rxjs,a.UniverCoreFacade))})(this,(function(a,s,I,p,h,E,y,b){"use strict";var P=Object.defineProperty;var W=(a,s,I)=>s in a?P(a,s,{enumerable:!0,configurable:!0,writable:!0,value:I}):a[s]=I;var T=(a,s,I)=>W(a,typeof s!="symbol"?s+"":s,I);var A=Object.getOwnPropertyDescriptor,B=(f,t,r,e)=>{for(var n=e>1?void 0:e?A(t,r):t,o=f.length-1,i;o>=0;o--)(i=f[o])&&(n=i(n)||n);return n},U=(f,t)=>(r,e)=>t(r,e,f);class w{constructor(t){T(this,"_comment",{id:s.generateRandomId(),ref:"",threadId:"",dT:"",personId:"",text:s.RichTextBuilder.newEmptyData().body,attachments:[],unitId:"",subUnitId:""});t&&(this._comment=t)}static create(t){return new w(t)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return s.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return k.create(s.Tools.deepClone(this._comment))}}class k extends w{static create(t){return new k(t)}setContent(t){return t instanceof s.RichTextValue?this._comment.text=t.getData().body:this._comment.text=t,this}setPersonId(t){return this._comment.personId=t,this}setDateTime(t){return this._comment.dT=h.getDT(t),this}setId(t){return this._comment.id=t,this}setThreadId(t){return this._comment.threadId=t,this}build(){return this._comment}}a.FThreadComment=class{constructor(t,r,e,n,o,i,u){this._thread=t,this._parent=r,this._injector=e,this._commandService=n,this._univerInstanceService=o,this._threadCommentModel=i,this._userManagerService=u}_getRef(){var e;const t=((e=this._parent)==null?void 0:e.ref)||this._thread.ref;return E.deserializeRangeWithSheet(t).range}getIsRoot(){return!this._parent}getCommentData(){const{children:t,...r}=this._thread;return r}getReplies(){var e;const t=this._getRef(),r=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,t.startRow,t.startColumn);return(e=r==null?void 0:r.children)==null?void 0:e.map(n=>this._injector.createInstance(a.FThreadComment,n))}getRange(){const t=this._univerInstanceService.getUnit(this._thread.unitId,s.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const r=t.getSheetBySheetId(this._thread.subUnitId);if(!r)return null;const e=this._getRef();return this._injector.createInstance(p.FRange,t,r,e)}getContent(){return this._thread.text}getRichText(){const t=this._thread.text;return s.RichTextValue.create({body:t,documentStyle:{},id:"d"})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?h.DeleteCommentTreeCommand.id:h.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}delete(){return this.deleteAsync()}async update(t){return this.updateAsync(t)}async updateAsync(t){const r=t instanceof s.RichTextValue?t.getData().body:t,e=h.getDT();return await this._commandService.executeCommand(h.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:r,updated:!0,updateT:e}})}resolve(t){return this.resolveAsync(t)}resolveAsync(t){return this._commandService.executeCommand(h.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:t!=null?t:!this._thread.resolved})}replyAsync(t){var e;const r=t.build();return this._commandService.executeCommand(h.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:s.generateRandomId(),parentId:this._thread.id,threadId:this._thread.threadId,ref:((e=this._parent)==null?void 0:e.ref)||this._thread.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:r.text,attachments:r.attachments,dT:r.dT||h.getDT(),personId:r.personId||this._userManagerService.getCurrentUser().userID}})}},a.FThreadComment=B([U(2,s.Inject(s.Injector)),U(3,s.ICommandService),U(4,s.IUniverInstanceService),U(5,s.Inject(I.SheetsThreadCommentModel)),U(6,s.Inject(s.UserManagerService))],a.FThreadComment);class x extends p.FRange{getComment(){const r=this._injector.get(I.SheetsThreadCommentModel),e=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),o=r.getByLocation(e,n,this._range.startRow,this._range.startColumn);if(!o)return null;const i=r.getComment(e,n,o);return i?this._injector.createInstance(a.FThreadComment,i):null}getComments(){const r=this._injector.get(I.SheetsThreadCommentModel),e=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),o=[];return s.Range.foreach(this._range,(i,u)=>{const C=r.getByLocation(e,n,i,u);if(C){const m=r.getComment(e,n,C);m&&o.push(this._injector.createInstance(a.FThreadComment,m))}}),o}addComment(t){var c;const r=this._injector,e=(c=this.getComment())==null?void 0:c.getCommentData(),n=r.get(s.ICommandService),o=r.get(s.UserManagerService),i=this._workbook.getUnitId(),u=this._worksheet.getSheetId(),C=`${s.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,m=o.getCurrentUser(),d=t instanceof k?t.build():{text:t};return n.executeCommand(h.AddCommentCommand.id,{unitId:i,subUnitId:u,comment:{text:d.text,dT:d.dT||h.getDT(),attachments:[],id:d.id||s.generateRandomId(),ref:C,personId:d.personId||m.userID,parentId:e==null?void 0:e.id,unitId:i,subUnitId:u,threadId:(e==null?void 0:e.threadId)||s.generateRandomId()}})}clearComment(){var i;const t=this._injector,r=(i=this.getComment())==null?void 0:i.getCommentData(),e=t.get(s.ICommandService),n=this._workbook.getUnitId(),o=this._worksheet.getSheetId();return r?e.executeCommand(h.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:o,threadId:r.threadId,commentId:r.id}):Promise.resolve(!0)}clearComments(){const r=this.getComments().map(e=>e.deleteAsync());return Promise.all(r).then(()=>!0)}addCommentAsync(t){return this.addComment(t)}clearCommentAsync(){return this.clearComment()}clearCommentsAsync(){return this.clearComments()}}p.FRange.extend(x);class D extends p.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(h.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(t=>this._injector.createInstance(a.FThreadComment,t.root))}clearComments(){const r=this.getComments().map(e=>e.deleteAsync());return Promise.all(r).then(()=>!0)}onThreadCommentChange(t){return s.toDisposable(this._threadCommentModel.commentUpdate$.pipe(y.filter(r=>r.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddThreadComment(t){return s.toDisposable(this._commandService.beforeCommandExecuted((r,e)=>{const n=r.params;if(r.id===h.AddCommentCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(t(n,e)===!1)throw new Error("Command is stopped by the hook onBeforeAddThreadComment")}}))}onBeforeUpdateThreadComment(t){return s.toDisposable(this._commandService.beforeCommandExecuted((r,e)=>{const n=r.params;if(r.id===h.UpdateCommentCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(t(n,e)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment")}}))}onBeforeDeleteThreadComment(t){return s.toDisposable(this._commandService.beforeCommandExecuted((r,e)=>{const n=r.params;if(r.id===h.DeleteCommentCommand.id||r.id===h.DeleteCommentTreeCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(t(n,e)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment")}}))}}p.FWorkbook.extend(D);class j extends p.FWorksheet{getComments(){return this._injector.get(I.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>this._injector.createInstance(a.FThreadComment,e))}clearComments(){const r=this.getComments().map(e=>e.deleteAsync());return Promise.all(r).then(()=>!0)}onCommented(t){return this._injector.get(s.ICommandService).onCommandExecuted(e=>{if(e.id===h.AddCommentCommand.id){const n=e.params;t(n)}})}getCommentById(t){const e=this._injector.get(I.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),t);if(e)return this._injector.createInstance(a.FThreadComment,e)}}p.FWorksheet.extend(j);const _={CommentAdded:"CommentAdded",BeforeCommentAdd:"BeforeCommentAdd",CommentUpdated:"CommentUpdated",BeforeCommentUpdate:"BeforeCommentUpdate",CommentDeleted:"CommentDeleted",BeforeCommentDelete:"BeforeCommentDelete",CommentResolved:"CommentResolved",BeforeCommentResolve:"BeforeCommentResolve"};class F extends b.FEventName{get CommentAdded(){return _.CommentAdded}get BeforeCommentAdd(){return _.BeforeCommentAdd}get CommentUpdated(){return _.CommentUpdated}get BeforeCommentUpdate(){return _.BeforeCommentUpdate}get CommentDeleted(){return _.CommentDeleted}get BeforeCommentDelete(){return _.BeforeCommentDelete}get CommentResolved(){return _.CommentResolved}get BeforeCommentResolve(){return _.BeforeCommentResolve}}b.FEventName.extend(F);class M extends b.FUniver{_initialize(t){const r=t.get(s.ICommandService);this.registerEventHandler(this.Event.CommentAdded,()=>r.onCommandExecuted(e=>{var d,c,g,l,v;if(e.id!==h.AddCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{comment:C}=u,m=i.getRange(C.ref).getComment();m&&this.fireEvent(this.Event.CommentAdded,{workbook:o,worksheet:i,row:(g=(c=m.getRange())==null?void 0:c.getRow())!=null?g:0,col:(v=(l=m.getRange())==null?void 0:l.getColumn())!=null?v:0,comment:m})})),this.registerEventHandler(this.Event.CommentUpdated,()=>r.onCommandExecuted(e=>{var d,c,g,l,v;if(e.id!==h.UpdateCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C}=u.payload,m=i.getCommentById(C);m&&this.fireEvent(this.Event.CommentUpdated,{workbook:o,worksheet:i,row:(g=(c=m.getRange())==null?void 0:c.getRow())!=null?g:0,col:(v=(l=m.getRange())==null?void 0:l.getColumn())!=null?v:0,comment:m})})),this.registerEventHandler(this.Event.CommentDeleted,()=>r.onCommandExecuted(e=>{var m;if(e.id!==h.DeleteCommentCommand.id&&e.id!==h.DeleteCommentTreeCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(m=this.getActiveWorkbook)==null?void 0:m.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C}=u;this.fireEvent(this.Event.CommentDeleted,{workbook:o,worksheet:i,commentId:C})})),this.registerEventHandler(this.Event.CommentResolved,()=>r.onCommandExecuted(e=>{var c,g,l;if(e.id!==h.ResolveCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C,resolved:m}=u,d=i.getComments().find(v=>v.getCommentData().id===C);d&&this.fireEvent(this.Event.CommentResolved,{workbook:o,worksheet:i,row:(g=d.getRange().getRow())!=null?g:0,col:(l=d.getRange().getColumn())!=null?l:0,comment:d,resolved:m})})),this.registerEventHandler(this.Event.BeforeCommentAdd,()=>r.beforeCommandExecuted(e=>{var c,g,l;if(e.id!==h.AddCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{comment:C}=u,m=i.getActiveRange();if(!m)return;const d={workbook:o,worksheet:i,row:(g=m.getRow())!=null?g:0,col:(l=m.getColumn())!=null?l:0,comment:w.create(C)};if(this.fireEvent(this.Event.BeforeCommentAdd,d),d.cancel)throw new s.CanceledError})),this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>r.beforeCommandExecuted(e=>{var c,g,l,v,S;if(e.id!==h.UpdateCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C,text:m}=u.payload,d=i.getCommentById(C);if(d){const R={workbook:o,worksheet:i,row:(l=(g=d.getRange())==null?void 0:g.getRow())!=null?l:0,col:(S=(v=d.getRange())==null?void 0:v.getColumn())!=null?S:0,comment:d,newContent:s.RichTextValue.createByBody(m)};if(this.fireEvent(this.Event.BeforeCommentUpdate,R),R.cancel)throw new s.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommentDelete,()=>r.beforeCommandExecuted(e=>{var d,c,g,l,v;if(e.id!==h.DeleteCommentCommand.id&&e.id!==h.DeleteCommentTreeCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C}=u,m=i.getCommentById(C);if(m){const S={workbook:o,worksheet:i,row:(g=(c=m.getRange())==null?void 0:c.getRow())!=null?g:0,col:(v=(l=m.getRange())==null?void 0:l.getColumn())!=null?v:0,comment:m};if(this.fireEvent(this.Event.BeforeCommentDelete,S),S.cancel)throw new s.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommentResolve,()=>r.beforeCommandExecuted(e=>{var c,g,l;if(e.id!==h.ResolveCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C,resolved:m}=u,d=i.getComments().find(v=>v.getCommentData().id===C);if(d){const v={workbook:o,worksheet:i,row:(g=d.getRange().getRow())!=null?g:0,col:(l=d.getRange().getColumn())!=null?l:0,comment:d,resolved:m};if(this.fireEvent(this.Event.BeforeCommentResolve,v),v.cancel)throw new s.CanceledError}}))}newTheadComment(t){return new k(t)}}b.FUniver.extend(M),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(a,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/sheets-thread-comment"),require("@univerjs/sheets/facade"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("rxjs"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-thread-comment","@univerjs/sheets/facade","@univerjs/thread-comment","@univerjs/engine-formula","rxjs","@univerjs/core/facade"],o):(a=typeof globalThis<"u"?globalThis:a||self,o(a.UniverSheetsThreadCommentFacade={},a.UniverCore,a.UniverSheetsThreadComment,a.UniverSheetsFacade,a.UniverThreadComment,a.UniverEngineFormula,a.rxjs,a.UniverCoreFacade))})(this,(function(a,o,l,f,h,U,R,T){"use strict";var A=Object.defineProperty;var M=(a,o,l)=>o in a?A(a,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):a[o]=l;var b=(a,o,l)=>M(a,typeof o!="symbol"?o+"":o,l);var S=Object.getOwnPropertyDescriptor,E=(v,t,n,e)=>{for(var r=e>1?void 0:e?S(t,n):t,i=v.length-1,s;i>=0;i--)(s=v[i])&&(r=s(r)||r);return r},p=(v,t)=>(n,e)=>t(n,e,v);class k{constructor(t){b(this,"_comment",{id:o.generateRandomId(),ref:"",threadId:"",dT:"",personId:"",text:o.RichTextBuilder.newEmptyData().body,attachments:[],unitId:"",subUnitId:""});t&&(this._comment=t)}static create(t){return new k(t)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return o.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return w.create(o.Tools.deepClone(this._comment))}}class w extends k{static create(t){return new w(t)}setContent(t){return t instanceof o.RichTextValue?this._comment.text=t.getData().body:this._comment.text=t,this}setPersonId(t){return this._comment.personId=t,this}setDateTime(t){return this._comment.dT=h.getDT(t),this}setId(t){return this._comment.id=t,this}setThreadId(t){return this._comment.threadId=t,this}build(){return this._comment}}a.FThreadComment=class{constructor(t,n,e,r,i,s,c){this._thread=t,this._parent=n,this._injector=e,this._commandService=r,this._univerInstanceService=i,this._threadCommentModel=s,this._userManagerService=c}_getRef(){var e;const t=((e=this._parent)==null?void 0:e.ref)||this._thread.ref;return U.deserializeRangeWithSheet(t).range}getIsRoot(){return!this._parent}getCommentData(){const{children:t,...n}=this._thread;return n}getReplies(){var e;const t=this._getRef(),n=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,t.startRow,t.startColumn);return(e=n==null?void 0:n.children)==null?void 0:e.map(r=>this._injector.createInstance(a.FThreadComment,r))}getRange(){const t=this._univerInstanceService.getUnit(this._thread.unitId,o.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const n=t.getSheetBySheetId(this._thread.subUnitId);if(!n)return null;const e=this._getRef();return this._injector.createInstance(f.FRange,t,n,e)}getContent(){return this._thread.text}getRichText(){const t=this._thread.text;return o.RichTextValue.create({body:t,documentStyle:{},id:"d"})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?h.DeleteCommentTreeCommand.id:h.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}delete(){return this.deleteAsync()}async update(t){return this.updateAsync(t)}async updateAsync(t){const n=t instanceof o.RichTextValue?t.getData().body:t,e=h.getDT();return await this._commandService.executeCommand(h.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:n,updated:!0,updateT:e}})}resolve(t){return this.resolveAsync(t)}resolveAsync(t){return this._commandService.executeCommand(h.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:t!=null?t:!this._thread.resolved})}replyAsync(t){var e;const n=t.build();return this._commandService.executeCommand(h.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:o.generateRandomId(),parentId:this._thread.id,threadId:this._thread.threadId,ref:((e=this._parent)==null?void 0:e.ref)||this._thread.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:n.text,attachments:n.attachments,dT:n.dT||h.getDT(),personId:n.personId||this._userManagerService.getCurrentUser().userID}})}},a.FThreadComment=E([p(2,o.Inject(o.Injector)),p(3,o.ICommandService),p(4,o.IUniverInstanceService),p(5,o.Inject(l.SheetsThreadCommentModel)),p(6,o.Inject(o.UserManagerService))],a.FThreadComment);class y extends f.FRange{getComment(){const n=this._injector.get(l.SheetsThreadCommentModel),e=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),i=n.getByLocation(e,r,this._range.startRow,this._range.startColumn);if(!i)return null;const s=n.getComment(e,r,i);return s?this._injector.createInstance(a.FThreadComment,s):null}getComments(){const n=this._injector.get(l.SheetsThreadCommentModel),e=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),i=[];return o.Range.foreach(this._range,(s,c)=>{const m=n.getByLocation(e,r,s,c);if(m){const d=n.getComment(e,r,m);d&&i.push(this._injector.createInstance(a.FThreadComment,d))}}),i}addComment(t){var C;const n=this._injector,e=(C=this.getComment())==null?void 0:C.getCommentData(),r=n.get(o.ICommandService),i=n.get(o.UserManagerService),s=this._workbook.getUnitId(),c=this._worksheet.getSheetId(),m=`${o.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,d=i.getCurrentUser(),u=t instanceof w?t.build():{text:t};return r.executeCommand(h.AddCommentCommand.id,{unitId:s,subUnitId:c,comment:{text:u.text,dT:u.dT||h.getDT(),attachments:[],id:u.id||o.generateRandomId(),ref:m,personId:u.personId||d.userID,parentId:e==null?void 0:e.id,unitId:s,subUnitId:c,threadId:(e==null?void 0:e.threadId)||o.generateRandomId()}})}clearComment(){var s;const t=this._injector,n=(s=this.getComment())==null?void 0:s.getCommentData(),e=t.get(o.ICommandService),r=this._workbook.getUnitId(),i=this._worksheet.getSheetId();return n?e.executeCommand(h.DeleteCommentTreeCommand.id,{unitId:r,subUnitId:i,threadId:n.threadId,commentId:n.id}):Promise.resolve(!0)}clearComments(){const n=this.getComments().map(e=>e.deleteAsync());return Promise.all(n).then(()=>!0)}addCommentAsync(t){return this.addComment(t)}clearCommentAsync(){return this.clearComment()}clearCommentsAsync(){return this.clearComments()}}f.FRange.extend(y);class x extends f.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(h.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(t=>this._injector.createInstance(a.FThreadComment,t.root))}clearComments(){const n=this.getComments().map(e=>e.deleteAsync());return Promise.all(n).then(()=>!0)}onThreadCommentChange(t){return o.toDisposable(this._threadCommentModel.commentUpdate$.pipe(R.filter(n=>n.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddThreadComment(t){return o.toDisposable(this._commandService.beforeCommandExecuted((n,e)=>{const r=n.params;if(n.id===h.AddCommentCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,e)===!1)throw new Error("Command is stopped by the hook onBeforeAddThreadComment")}}))}onBeforeUpdateThreadComment(t){return o.toDisposable(this._commandService.beforeCommandExecuted((n,e)=>{const r=n.params;if(n.id===h.UpdateCommentCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,e)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment")}}))}onBeforeDeleteThreadComment(t){return o.toDisposable(this._commandService.beforeCommandExecuted((n,e)=>{const r=n.params;if(n.id===h.DeleteCommentCommand.id||n.id===h.DeleteCommentTreeCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,e)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment")}}))}}f.FWorkbook.extend(x);class B extends f.FWorksheet{getComments(){return this._injector.get(l.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>this._injector.createInstance(a.FThreadComment,e))}clearComments(){const n=this.getComments().map(e=>e.deleteAsync());return Promise.all(n).then(()=>!0)}onCommented(t){return this._injector.get(o.ICommandService).onCommandExecuted(e=>{if(e.id===h.AddCommentCommand.id){const r=e.params;t(r)}})}getCommentById(t){const e=this._injector.get(l.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),t);if(e)return this._injector.createInstance(a.FThreadComment,e)}}f.FWorksheet.extend(B);const _={CommentAdded:"CommentAdded",BeforeCommentAdd:"BeforeCommentAdd",CommentUpdated:"CommentUpdated",BeforeCommentUpdate:"BeforeCommentUpdate",CommentDeleted:"CommentDeleted",BeforeCommentDelete:"BeforeCommentDelete",CommentResolved:"CommentResolved",BeforeCommentResolve:"BeforeCommentResolve"};class j extends T.FEventName{get CommentAdded(){return _.CommentAdded}get BeforeCommentAdd(){return _.BeforeCommentAdd}get CommentUpdated(){return _.CommentUpdated}get BeforeCommentUpdate(){return _.BeforeCommentUpdate}get CommentDeleted(){return _.CommentDeleted}get BeforeCommentDelete(){return _.BeforeCommentDelete}get CommentResolved(){return _.CommentResolved}get BeforeCommentResolve(){return _.BeforeCommentResolve}}T.FEventName.extend(j);class D extends T.FUniver{_getTargetSheet(t={}){var r;const n=t.unitId?this.getUniverSheet(t.unitId):(r=this.getActiveWorkbook)==null?void 0:r.call(this);if(!n)return null;const e=t.subUnitId?n.getSheetBySheetId(t.subUnitId):n.getActiveSheet();return e?{workbook:n,worksheet:e}:null}_initialize(t){const n=t.get(o.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.CommentAdded,()=>n.onCommandExecuted(e=>{var d,u,C,g;if(e.id!==h.AddCommentCommand.id)return;const r=this._getTargetSheet(e.params);if(!r)return;const{workbook:i,worksheet:s}=r,{comment:c}=e.params,m=s.getCommentById(c.id);m&&this.fireEvent(this.Event.CommentAdded,{workbook:i,worksheet:s,row:(u=(d=m.getRange())==null?void 0:d.getRow())!=null?u:0,col:(g=(C=m.getRange())==null?void 0:C.getColumn())!=null?g:0,comment:m})}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentUpdated,()=>n.onCommandExecuted(e=>{var d,u,C,g;if(e.id!==h.UpdateCommentCommand.id)return;const r=this._getTargetSheet(e.params);if(!r)return;const{workbook:i,worksheet:s}=r,{payload:c}=e.params,m=s.getCommentById(c.commentId);m&&this.fireEvent(this.Event.CommentUpdated,{workbook:i,worksheet:s,row:(u=(d=m.getRange())==null?void 0:d.getRow())!=null?u:0,col:(g=(C=m.getRange())==null?void 0:C.getColumn())!=null?g:0,comment:m})}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentDeleted,()=>n.onCommandExecuted(e=>{if(e.id!==h.DeleteCommentCommand.id&&e.id!==h.DeleteCommentTreeCommand.id)return;const r=this._getTargetSheet(e.params);if(!r)return;const{workbook:i,worksheet:s}=r,{commentId:c}=e.params;this.fireEvent(this.Event.CommentDeleted,{workbook:i,worksheet:s,commentId:c})}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentResolved,()=>n.onCommandExecuted(e=>{var u,C,g,I;if(e.id!==h.ResolveCommentCommand.id)return;const r=this._getTargetSheet(e.params);if(!r)return;const{workbook:i,worksheet:s}=r,{commentId:c,resolved:m}=e.params,d=s.getCommentById(c);d&&this.fireEvent(this.Event.CommentResolved,{workbook:i,worksheet:s,row:(C=(u=d.getRange())==null?void 0:u.getRow())!=null?C:0,col:(I=(g=d.getRange())==null?void 0:g.getColumn())!=null?I:0,comment:d,resolved:m})}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentAdd,()=>n.beforeCommandExecuted(e=>{if(e.id!==h.AddCommentCommand.id)return;const r=this._getTargetSheet(e.params);if(!r)return;const{workbook:i,worksheet:s}=r,{comment:c}=e.params,{range:m}=U.deserializeRangeWithSheet(c.ref),d={workbook:i,worksheet:s,row:m.startRow,col:m.startColumn,comment:k.create(c)};if(this.fireEvent(this.Event.BeforeCommentAdd,d),d.cancel)throw new o.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>n.beforeCommandExecuted(e=>{var d,u,C,g;if(e.id!==h.UpdateCommentCommand.id)return;const r=this._getTargetSheet(e.params);if(!r)return;const{workbook:i,worksheet:s}=r,{payload:c}=e.params,m=s.getCommentById(c.commentId);if(m){const I={workbook:i,worksheet:s,row:(u=(d=m.getRange())==null?void 0:d.getRow())!=null?u:0,col:(g=(C=m.getRange())==null?void 0:C.getColumn())!=null?g:0,comment:m,newContent:o.RichTextValue.createByBody(c.text)};if(this.fireEvent(this.Event.BeforeCommentUpdate,I),I.cancel)throw new o.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentDelete,()=>n.beforeCommandExecuted(e=>{var d,u,C,g;if(e.id!==h.DeleteCommentCommand.id&&e.id!==h.DeleteCommentTreeCommand.id)return;const r=this._getTargetSheet(e.params);if(!r)return;const{workbook:i,worksheet:s}=r,{commentId:c}=e.params,m=s.getCommentById(c);if(m){const I={workbook:i,worksheet:s,row:(u=(d=m.getRange())==null?void 0:d.getRow())!=null?u:0,col:(g=(C=m.getRange())==null?void 0:C.getColumn())!=null?g:0,comment:m};if(this.fireEvent(this.Event.BeforeCommentDelete,I),I.cancel)throw new o.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentResolve,()=>n.beforeCommandExecuted(e=>{var u,C;if(e.id!==h.ResolveCommentCommand.id)return;const r=this._getTargetSheet(e.params);if(!r)return;const{workbook:i,worksheet:s}=r,{commentId:c,resolved:m}=e.params,d=s.getCommentById(c);if(d){const g={workbook:i,worksheet:s,row:(u=d.getRange().getRow())!=null?u:0,col:(C=d.getRange().getColumn())!=null?C:0,comment:d,resolved:m};if(this.fireEvent(this.Event.BeforeCommentResolve,g),g.cancel)throw new o.CanceledError}})))}newTheadComment(t){return new w(t)}}T.FUniver.extend(D),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-thread-comment",
3
- "version": "0.15.2-insiders.20260124-12fc7f0",
3
+ "version": "0.15.3-insiders.20260131-b9b8805",
4
4
  "private": false,
5
5
  "description": "Univer sheets thread comment base plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -56,17 +56,17 @@
56
56
  "rxjs": ">=7.0.0"
57
57
  },
58
58
  "dependencies": {
59
- "@univerjs/core": "0.15.2-insiders.20260124-12fc7f0",
60
- "@univerjs/engine-formula": "0.15.2-insiders.20260124-12fc7f0",
61
- "@univerjs/thread-comment": "0.15.2-insiders.20260124-12fc7f0",
62
- "@univerjs/sheets": "0.15.2-insiders.20260124-12fc7f0"
59
+ "@univerjs/core": "0.15.3-insiders.20260131-b9b8805",
60
+ "@univerjs/thread-comment": "0.15.3-insiders.20260131-b9b8805",
61
+ "@univerjs/engine-formula": "0.15.3-insiders.20260131-b9b8805",
62
+ "@univerjs/sheets": "0.15.3-insiders.20260131-b9b8805"
63
63
  },
64
64
  "devDependencies": {
65
65
  "rxjs": "^7.8.2",
66
66
  "typescript": "^5.9.3",
67
67
  "vite": "^7.3.1",
68
- "vitest": "^4.0.16",
69
- "@univerjs-infra/shared": "0.15.2"
68
+ "vitest": "^4.0.18",
69
+ "@univerjs-infra/shared": "0.15.3"
70
70
  },
71
71
  "scripts": {
72
72
  "test": "vitest run",