@univerjs/sheets-thread-comment 0.6.1 → 0.6.2

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.
@@ -11,10 +11,12 @@ interface ICommentEventMixin {
11
11
  * @see {@link ISheetCommentAddEvent}
12
12
  * @example
13
13
  * ```ts
14
- * univerAPI.addEventListener(CommentEvent.CommentAdded, (event) => {
15
- * const { comment, workbook, worksheet, row, col } = event;
16
- * console.log(event);
14
+ * const disposable = univerAPI.addEvent(univerAPI.Event.CommentAdded, (params) => {
15
+ * const { comment, workbook, worksheet, row, col } = params;
16
+ * console.log(params);
17
17
  * });
18
+ *
19
+ * // Remove the event listener, use `disposable.dispose()`
18
20
  * ```
19
21
  */
20
22
  readonly CommentAdded: 'CommentAdded';
@@ -23,10 +25,15 @@ interface ICommentEventMixin {
23
25
  * @see {@link IBeforeSheetCommentAddEvent}
24
26
  * @example
25
27
  * ```ts
26
- * univerAPI.addEventListener(CommentEvent.BeforeCommentAdd, (event) => {
27
- * const { comment, workbook, worksheet, row, col } = event;
28
- * console.log(event);
28
+ * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeCommentAdd, (params) => {
29
+ * const { comment, workbook, worksheet, row, col } = params;
30
+ * console.log(params);
31
+ *
32
+ * // Cancel the comment add operation
33
+ * params.cancel = true;
29
34
  * });
35
+ *
36
+ * // Remove the event listener, use `disposable.dispose()`
30
37
  * ```
31
38
  */
32
39
  readonly BeforeCommentAdd: 'BeforeCommentAdd';
@@ -35,10 +42,12 @@ interface ICommentEventMixin {
35
42
  * @see {@link ISheetCommentUpdateEvent}
36
43
  * @example
37
44
  * ```ts
38
- * univerAPI.addEventListener(CommentEvent.CommentUpdated, (event) => {
39
- * const { comment, workbook, worksheet, row, col } = event;
40
- * console.log(event);
45
+ * const disposable = univerAPI.addEvent(univerAPI.Event.CommentUpdated, (params) => {
46
+ * const { comment, workbook, worksheet, row, col } = params;
47
+ * console.log(params);
41
48
  * });
49
+ *
50
+ * // Remove the event listener, use `disposable.dispose()`
42
51
  * ```
43
52
  */
44
53
  readonly CommentUpdated: 'CommentUpdated';
@@ -47,10 +56,15 @@ interface ICommentEventMixin {
47
56
  * @see {@link IBeforeSheetCommentUpdateEvent}
48
57
  * @example
49
58
  * ```ts
50
- * univerAPI.addEventListener(CommentEvent.BeforeCommentUpdate, (event) => {
51
- * const { comment, workbook, worksheet, row, col, newContent } = event;
52
- * console.log(event);
59
+ * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeCommentUpdate, (params) => {
60
+ * const { comment, workbook, worksheet, row, col, newContent } = params;
61
+ * console.log(params);
62
+ *
63
+ * // Cancel the comment update operation
64
+ * params.cancel = true;
53
65
  * });
66
+ *
67
+ * // Remove the event listener, use `disposable.dispose()`
54
68
  * ```
55
69
  */
56
70
  readonly BeforeCommentUpdate: 'BeforeCommentUpdate';
@@ -59,10 +73,12 @@ interface ICommentEventMixin {
59
73
  * @see {@link ISheetCommentDeleteEvent}
60
74
  * @example
61
75
  * ```ts
62
- * univerAPI.addEventListener(CommentEvent.CommentDeleted, (event) => {
63
- * const { commentId, workbook, worksheet } = event;
64
- * console.log(event);
76
+ * const disposable = univerAPI.addEvent(univerAPI.Event.CommentDeleted, (params) => {
77
+ * const { commentId, workbook, worksheet } = params;
78
+ * console.log(params);
65
79
  * });
80
+ *
81
+ * // Remove the event listener, use `disposable.dispose()`
66
82
  * ```
67
83
  */
68
84
  readonly CommentDeleted: 'CommentDeleted';
@@ -71,22 +87,29 @@ interface ICommentEventMixin {
71
87
  * @see {@link IBeforeSheetCommentDeleteEvent}
72
88
  * @example
73
89
  * ```ts
74
- * univerAPI.addEventListener(CommentEvent.BeforeCommentDeleted, (event) => {
75
- * const { commentId, workbook, worksheet } = event;
76
- * console.log(event);
90
+ * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeCommentDelete, (params) => {
91
+ * const { comment, workbook, worksheet, row, col } = params;
92
+ * console.log(params);
93
+ *
94
+ * // Cancel the comment delete operation
95
+ * params.cancel = true;
77
96
  * });
97
+ *
98
+ * // Remove the event listener, use `disposable.dispose()`
78
99
  * ```
79
100
  */
80
- readonly BeforeCommentDeleted: 'BeforeCommentDeleted';
101
+ readonly BeforeCommentDelete: 'BeforeCommentDelete';
81
102
  /**
82
103
  * Event fired after comment resolve
83
104
  * @see {@link ISheetCommentResolveEvent}
84
105
  * @example
85
106
  * ```ts
86
- * univerAPI.addEventListener(CommentEvent.CommentResolved, (event) => {
87
- * const { comment, row, col, resolved, workbook, worksheet } = event;
88
- * console.log(event);
107
+ * const disposable = univerAPI.addEvent(univerAPI.Event.CommentResolved, (params) => {
108
+ * const { comment, row, col, resolved, workbook, worksheet } = params;
109
+ * console.log(params);
89
110
  * });
111
+ *
112
+ * // Remove the event listener, use `disposable.dispose()`
90
113
  * ```
91
114
  */
92
115
  readonly CommentResolved: 'CommentResolved';
@@ -95,10 +118,15 @@ interface ICommentEventMixin {
95
118
  * @see {@link ISheetCommentResolveEvent}
96
119
  * @example
97
120
  * ```ts
98
- * univerAPI.addEventListener(CommentEvent.BeforeCommentResolve, (event) => {
99
- * const { comment, row, col, resolved, workbook, worksheet } = event;
100
- * console.log(event);
121
+ * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeCommentResolve, (params) => {
122
+ * const { comment, row, col, resolved, workbook, worksheet } = params;
123
+ * console.log(params);
124
+ *
125
+ * // Cancel the comment resolve operation
126
+ * params.cancel = true;
101
127
  * });
128
+ *
129
+ * // Remove the event listener, use `disposable.dispose()`
102
130
  * ```
103
131
  */
104
132
  readonly BeforeCommentResolve: 'BeforeCommentResolve';
@@ -112,7 +140,7 @@ export declare class FCommentEvent extends FEventName {
112
140
  get CommentUpdated(): 'CommentUpdated';
113
141
  get BeforeCommentUpdate(): 'BeforeCommentUpdate';
114
142
  get CommentDeleted(): 'CommentDeleted';
115
- get BeforeCommentDeleted(): 'BeforeCommentDeleted';
143
+ get BeforeCommentDelete(): 'BeforeCommentDelete';
116
144
  get CommentResolved(): 'CommentResolved';
117
145
  get BeforeCommentResolve(): 'BeforeCommentResolve';
118
146
  }
@@ -243,7 +271,7 @@ export interface ISheetCommentEventConfig {
243
271
  CommentAdded: ISheetCommentAddEvent;
244
272
  BeforeCommentUpdate: IBeforeSheetCommentUpdateEvent;
245
273
  CommentUpdated: ISheetCommentUpdateEvent;
246
- BeforeCommentDeleted: IBeforeSheetCommentDeleteEvent;
274
+ BeforeCommentDelete: IBeforeSheetCommentDeleteEvent;
247
275
  CommentDeleted: ISheetCommentDeleteEvent;
248
276
  BeforeCommentResolve: ISheetCommentResolveEvent;
249
277
  CommentResolved: ISheetCommentResolveEvent;
@@ -14,7 +14,8 @@ export declare class FTheadCommentItem {
14
14
  * @returns {FTheadCommentItem} A new instance of FTheadCommentItem
15
15
  * @example
16
16
  * ```ts
17
- * const comment = univerAPI.newTheadComment();
17
+ * const commentBuilder = univerAPI.newTheadComment();
18
+ * console.log(commentBuilder);
18
19
  * ```
19
20
  */
20
21
  static create(comment?: IThreadComment): FTheadCommentItem;
@@ -24,10 +25,8 @@ export declare class FTheadCommentItem {
24
25
  * @returns {string} The person id of the comment
25
26
  * @example
26
27
  * ```ts
27
- * const comment = univerAPI.getActiveWorkbook()
28
- * .getSheetById(sheetId)
29
- * .getCommentById(commentId);
30
- * const personId = comment.personId;
28
+ * const commentBuilder = univerAPI.newTheadComment();
29
+ * console.log(commentBuilder.personId);
31
30
  * ```
32
31
  */
33
32
  get personId(): string;
@@ -36,10 +35,8 @@ export declare class FTheadCommentItem {
36
35
  * @returns {string} The date time of the comment
37
36
  * @example
38
37
  * ```ts
39
- * const comment = univerAPI.getActiveWorkbook()
40
- * .getSheetById(sheetId)
41
- * .getCommentById(commentId);
42
- * const dateTime = comment.dateTime;
38
+ * const commentBuilder = univerAPI.newTheadComment();
39
+ * console.log(commentBuilder.dateTime);
43
40
  * ```
44
41
  */
45
42
  get dateTime(): string;
@@ -48,10 +45,8 @@ export declare class FTheadCommentItem {
48
45
  * @returns {RichTextValue} The content of the comment
49
46
  * @example
50
47
  * ```ts
51
- * const comment = univerAPI.getActiveWorkbook()
52
- * .getSheetById(sheetId)
53
- * .getCommentById(commentId);
54
- * const content = comment.content;
48
+ * const commentBuilder = univerAPI.newTheadComment();
49
+ * console.log(commentBuilder.content);
55
50
  * ```
56
51
  */
57
52
  get content(): RichTextValue;
@@ -60,10 +55,8 @@ export declare class FTheadCommentItem {
60
55
  * @returns {string} The id of the comment
61
56
  * @example
62
57
  * ```ts
63
- * const comment = univerAPI.getActiveWorkbook()
64
- * .getSheetById(sheetId)
65
- * .getCommentById(commentId);
66
- * const id = comment.id;
58
+ * const commentBuilder = univerAPI.newTheadComment();
59
+ * console.log(commentBuilder.id);
67
60
  * ```
68
61
  */
69
62
  get id(): string;
@@ -72,10 +65,8 @@ export declare class FTheadCommentItem {
72
65
  * @returns {string} The thread id of the comment
73
66
  * @example
74
67
  * ```ts
75
- * const comment = univerAPI.getActiveWorkbook()
76
- * .getSheetById(sheetId)
77
- * .getCommentById(commentId);
78
- * const threadId = comment.threadId;
68
+ * const commentBuilder = univerAPI.newTheadComment();
69
+ * console.log(commentBuilder.threadId);
79
70
  * ```
80
71
  */
81
72
  get threadId(): string;
@@ -84,10 +75,9 @@ export declare class FTheadCommentItem {
84
75
  * @returns {FTheadCommentBuilder} The comment builder
85
76
  * @example
86
77
  * ```ts
87
- * const comment = univerAPI.getActiveWorkbook()
88
- * .getSheetById(sheetId)
89
- * .getCommentById(commentId);
90
- * const newComment = comment.copy();
78
+ * const commentBuilder = univerAPI.newTheadComment();
79
+ * const newCommentBuilder = commentBuilder.copy();
80
+ * console.log(newCommentBuilder);
91
81
  * ```
92
82
  */
93
83
  copy(): FTheadCommentBuilder;
@@ -100,44 +90,87 @@ export declare class FTheadCommentBuilder extends FTheadCommentItem {
100
90
  /**
101
91
  * Set the content of the comment
102
92
  * @param {IDocumentBody | RichTextValue} content The content of the comment
103
- * @returns {FTheadCommentBuilder} The comment builder
93
+ * @returns {FTheadCommentBuilder} The comment builder for chaining
104
94
  * @example
105
95
  * ```ts
106
- * const comment = univerAPI.newTheadComment()
107
- * .setContent(univerAPI.newRichText().insertText('hello zhangsan'));
96
+ * // Create a new comment
97
+ * const richText = univerAPI.newRichText().insertText('hello univer');
98
+ * const commentBuilder = univerAPI.newTheadComment()
99
+ * .setContent(richText);
100
+ * console.log(commentBuilder.content);
101
+ *
102
+ * // Add the comment to the cell A1
103
+ * const fWorkbook = univerAPI.getActiveWorkbook();
104
+ * const fWorksheet = fWorkbook.getActiveSheet();
105
+ * const cell = fWorksheet.getRange('A1');
106
+ * const result = await cell.addCommentAsync(commentBuilder);
107
+ * console.log(result);
108
108
  * ```
109
109
  */
110
110
  setContent(content: IDocumentBody | RichTextValue): FTheadCommentBuilder;
111
111
  /**
112
112
  * Set the person id of the comment
113
113
  * @param {string} userId The person id of the comment
114
- * @returns {FTheadCommentBuilder} The comment builder
114
+ * @returns {FTheadCommentBuilder} The comment builder for chaining
115
115
  * @example
116
116
  * ```ts
117
- * const comment = univerAPI.newTheadComment()
118
- * .setPersonId('123');
117
+ * // Create a new comment
118
+ * const richText = univerAPI.newRichText().insertText('hello univer');
119
+ * const commentBuilder = univerAPI.newTheadComment()
120
+ * .setContent(richText)
121
+ * .setPersonId('mock-user-id');
122
+ * console.log(commentBuilder.personId);
123
+ *
124
+ * // Add the comment to the cell A1
125
+ * const fWorkbook = univerAPI.getActiveWorkbook();
126
+ * const fWorksheet = fWorkbook.getActiveSheet();
127
+ * const cell = fWorksheet.getRange('A1');
128
+ * const result = await cell.addCommentAsync(commentBuilder);
129
+ * console.log(result);
119
130
  * ```
120
131
  */
121
132
  setPersonId(userId: string): FTheadCommentBuilder;
122
133
  /**
123
134
  * Set the date time of the comment
124
135
  * @param {Date} date The date time of the comment
125
- * @returns {FTheadCommentBuilder} The comment builder
136
+ * @returns {FTheadCommentBuilder} The comment builder for chaining
126
137
  * @example
127
138
  * ```ts
128
- * const comment = univerAPI.newTheadComment()
129
- * .setDateTime(new Date());
139
+ * // Create a new comment
140
+ * const richText = univerAPI.newRichText().insertText('hello univer');
141
+ * const commentBuilder = univerAPI.newTheadComment()
142
+ * .setContent(richText)
143
+ * .setDateTime(new Date('2025-02-21 14:22:22'));
144
+ * console.log(commentBuilder.dateTime);
145
+ *
146
+ * // Add the comment to the cell A1
147
+ * const fWorkbook = univerAPI.getActiveWorkbook();
148
+ * const fWorksheet = fWorkbook.getActiveSheet();
149
+ * const cell = fWorksheet.getRange('A1');
150
+ * const result = await cell.addCommentAsync(commentBuilder);
151
+ * console.log(result);
130
152
  * ```
131
153
  */
132
154
  setDateTime(date: Date): FTheadCommentBuilder;
133
155
  /**
134
156
  * Set the id of the comment
135
157
  * @param {string} id The id of the comment
136
- * @returns {FTheadCommentBuilder} The comment builder
158
+ * @returns {FTheadCommentBuilder} The comment builder for chaining
137
159
  * @example
138
160
  * ```ts
139
- * const comment = univerAPI.newTheadComment()
140
- * .setId('123');
161
+ * // Create a new comment
162
+ * const richText = univerAPI.newRichText().insertText('hello univer');
163
+ * const commentBuilder = univerAPI.newTheadComment()
164
+ * .setContent(richText)
165
+ * .setId('mock-comment-id');
166
+ * console.log(commentBuilder.id);
167
+ *
168
+ * // Add the comment to the cell A1
169
+ * const fWorkbook = univerAPI.getActiveWorkbook();
170
+ * const fWorksheet = fWorkbook.getActiveSheet();
171
+ * const cell = fWorksheet.getRange('A1');
172
+ * const result = await cell.addCommentAsync(commentBuilder);
173
+ * console.log(result);
141
174
  * ```
142
175
  */
143
176
  setId(id: string): FTheadCommentBuilder;
@@ -147,8 +180,19 @@ export declare class FTheadCommentBuilder extends FTheadCommentItem {
147
180
  * @returns {FTheadCommentBuilder} The comment builder
148
181
  * @example
149
182
  * ```ts
150
- * const comment = univerAPI.newTheadComment()
151
- * .setThreadId('123');
183
+ * // Create a new comment
184
+ * const richText = univerAPI.newRichText().insertText('hello univer');
185
+ * const commentBuilder = univerAPI.newTheadComment()
186
+ * .setContent(richText)
187
+ * .setThreadId('mock-thread-id');
188
+ * console.log(commentBuilder.threadId);
189
+ *
190
+ * // Add the comment to the cell A1
191
+ * const fWorkbook = univerAPI.getActiveWorkbook();
192
+ * const fWorksheet = fWorkbook.getActiveSheet();
193
+ * const cell = fWorksheet.getRange('A1');
194
+ * const result = await cell.addCommentAsync(commentBuilder);
195
+ * console.log(result);
152
196
  * ```
153
197
  */
154
198
  setThreadId(threadId: string): FTheadCommentBuilder;
@@ -157,9 +201,15 @@ export declare class FTheadCommentBuilder extends FTheadCommentItem {
157
201
  * @returns {IThreadComment} The comment
158
202
  * @example
159
203
  * ```ts
204
+ * const richText = univerAPI.newRichText().insertText('hello univer');
160
205
  * const comment = univerAPI.newTheadComment()
161
- * .setContent(univerAPI.newRichText().insertText('hello zhangsan'))
206
+ * .setContent(richText)
207
+ * .setPersonId('mock-user-id')
208
+ * .setDateTime(new Date('2025-02-21 14:22:22'))
209
+ * .setId('mock-comment-id')
210
+ * .setThreadId('mock-thread-id')
162
211
  * .build();
212
+ * console.log(comment);
163
213
  * ```
164
214
  */
165
215
  build(): IThreadComment;
@@ -185,10 +235,12 @@ export declare class FThreadComment {
185
235
  * @returns {boolean} Whether the comment is a root comment
186
236
  * @example
187
237
  * ```ts
188
- * const comment = univerAPI.getActiveWorkbook()
189
- * .getSheetById(sheetId)
190
- * .getCommentById(commentId);
191
- * const isRoot = comment.getIsRoot();
238
+ * const fWorkbook = univerAPI.getActiveWorkbook();
239
+ * const fWorksheet = fWorkbook.getActiveSheet();
240
+ * const comments = fWorksheet.getComments();
241
+ * comments.forEach((comment) => {
242
+ * console.log(comment.getIsRoot());
243
+ * });
192
244
  * ```
193
245
  */
194
246
  getIsRoot(): boolean;
@@ -197,10 +249,12 @@ export declare class FThreadComment {
197
249
  * @returns {IBaseComment} The comment data
198
250
  * @example
199
251
  * ```ts
200
- * const comment = univerAPI.getActiveWorkbook()
201
- * .getSheetById(sheetId)
202
- * .getCommentById(commentId);
203
- * const commentData = comment.getCommentData();
252
+ * const fWorkbook = univerAPI.getActiveWorkbook();
253
+ * const fWorksheet = fWorkbook.getActiveSheet();
254
+ * const comments = fWorksheet.getComments();
255
+ * comments.forEach((comment) => {
256
+ * console.log(comment.getCommentData());
257
+ * });
204
258
  * ```
205
259
  */
206
260
  getCommentData(): IBaseComment;
@@ -209,10 +263,17 @@ export declare class FThreadComment {
209
263
  * @returns {FThreadComment[]} the replies of the comment
210
264
  * @example
211
265
  * ```ts
212
- * const comment = univerAPI.getActiveWorkbook()
213
- * .getSheetById(sheetId)
214
- * .getCommentById(commentId);
215
- * const replies = comment.getReplies();
266
+ * const fWorkbook = univerAPI.getActiveWorkbook();
267
+ * const fWorksheet = fWorkbook.getActiveSheet();
268
+ * const comments = fWorksheet.getComments();
269
+ * comments.forEach((comment) => {
270
+ * if (comment.getIsRoot()) {
271
+ * const replies = comment.getReplies();
272
+ * replies.forEach((reply) => {
273
+ * console.log(reply.getCommentData());
274
+ * });
275
+ * }
276
+ * });
216
277
  * ```
217
278
  */
218
279
  getReplies(): FThreadComment[] | undefined;
@@ -221,10 +282,12 @@ export declare class FThreadComment {
221
282
  * @returns {FRange | null} The range of the comment
222
283
  * @example
223
284
  * ```ts
224
- * const comment = univerAPI.getActiveWorkbook()
225
- * .getSheetById(sheetId)
226
- * .getCommentById(commentId);
227
- * const range = comment.getRange();
285
+ * const fWorkbook = univerAPI.getActiveWorkbook();
286
+ * const fWorksheet = fWorkbook.getActiveSheet();
287
+ * const comments = fWorksheet.getComments();
288
+ * comments.forEach((comment) => {
289
+ * console.log(comment.getRange().getA1Notation());
290
+ * });
228
291
  * ```
229
292
  */
230
293
  getRange(): FRange | null;
@@ -237,22 +300,27 @@ export declare class FThreadComment {
237
300
  * @returns {RichTextValue} The rich text of the comment
238
301
  * @example
239
302
  * ```ts
240
- * const comment = univerAPI.getActiveWorkbook()
241
- * .getSheetById(sheetId)
242
- * .getCommentById(commentId);
243
- * const richText = comment.getRichText();
303
+ * const fWorkbook = univerAPI.getActiveWorkbook();
304
+ * const fWorksheet = fWorkbook.getActiveSheet();
305
+ * const comments = fWorksheet.getComments();
306
+ * comments.forEach((comment) => {
307
+ * console.log(comment.getRichText());
308
+ * });
244
309
  * ```
245
310
  */
246
311
  getRichText(): RichTextValue;
247
312
  /**
248
313
  * Delete the comment and it's replies
249
- * @returns {Promise<boolean>} success or not
314
+ * @returns {Promise<boolean>} Whether the comment is deleted successfully
250
315
  * @example
251
316
  * ```ts
252
- * const comment = univerAPI.getActiveWorkbook()
253
- * .getSheetById(sheetId)
254
- * .getCommentById(commentId);
255
- * const success = await comment.deleteAsync();
317
+ * const fWorkbook = univerAPI.getActiveWorkbook();
318
+ * const fWorksheet = fWorkbook.getActiveSheet();
319
+ * const comments = fWorksheet.getComments();
320
+ *
321
+ * // Delete the first comment
322
+ * const result = await comments[0]?.deleteAsync();
323
+ * console.log(result);
256
324
  * ```
257
325
  */
258
326
  deleteAsync(): Promise<boolean>;
@@ -267,13 +335,27 @@ export declare class FThreadComment {
267
335
  /**
268
336
  * Update the comment content
269
337
  * @param {IDocumentBody | RichTextValue} content The new content of the comment
270
- * @returns {Promise<boolean>} success or not
338
+ * @returns {Promise<boolean>} Whether the comment is updated successfully
271
339
  * @example
272
340
  * ```ts
273
- * const comment = univerAPI.getActiveWorkbook()
274
- * .getSheetById(sheetId)
275
- * .getCommentById(commentId);
276
- * const success = await comment.updateAsync(univerAPI.newRichText().insertText('hello zhangsan'));
341
+ * const fWorkbook = univerAPI.getActiveWorkbook();
342
+ * const fWorksheet = fWorkbook.getActiveSheet();
343
+ *
344
+ * // Create a new comment
345
+ * const richText = univerAPI.newRichText().insertText('hello univer');
346
+ * const commentBuilder = univerAPI.newTheadComment()
347
+ * .setContent(richText)
348
+ * .setId('mock-comment-id');
349
+ * const cell = fWorksheet.getRange('A1');
350
+ * await cell.addCommentAsync(commentBuilder);
351
+ *
352
+ * // Update the comment after 3 seconds
353
+ * setTimeout(async () => {
354
+ * const comment = fWorksheet.getCommentById('mock-comment-id');
355
+ * const newRichText = univerAPI.newRichText().insertText('Hello Univer AI');
356
+ * const result = await comment.updateAsync(newRichText);
357
+ * console.log(result);
358
+ * }, 3000);
277
359
  * ```
278
360
  */
279
361
  updateAsync(content: IDocumentBody | RichTextValue): Promise<boolean>;
@@ -284,30 +366,52 @@ export declare class FThreadComment {
284
366
  /**
285
367
  * Resolve the comment
286
368
  * @param {boolean} resolved Whether the comment is resolved
287
- * @returns {Promise<boolean>} success or not
369
+ * @returns {Promise<boolean>} Set the comment to resolved or not operation result
288
370
  * @example
289
371
  * ```ts
290
- * const comment = univerAPI.getActiveWorkbook()
291
- * .getSheetById(sheetId)
292
- * .getCommentById(commentId);
293
- * const success = await comment.resolveAsync(true);
372
+ * const fWorkbook = univerAPI.getActiveWorkbook();
373
+ * const fWorksheet = fWorkbook.getActiveSheet();
374
+ *
375
+ * // Create a new comment
376
+ * const richText = univerAPI.newRichText().insertText('hello univer');
377
+ * const commentBuilder = univerAPI.newTheadComment()
378
+ * .setContent(richText)
379
+ * .setId('mock-comment-id');
380
+ * const cell = fWorksheet.getRange('A1');
381
+ * await cell.addCommentAsync(commentBuilder);
382
+ *
383
+ * // Resolve the comment after 3 seconds
384
+ * setTimeout(async () => {
385
+ * const comment = fWorksheet.getCommentById('mock-comment-id');
386
+ * const result = await comment.resolveAsync(true);
387
+ * console.log(result);
388
+ * }, 3000);
294
389
  * ```
295
390
  */
296
391
  resolveAsync(resolved?: boolean): Promise<boolean>;
297
392
  /**
298
393
  * Reply to the comment
299
394
  * @param {FTheadCommentBuilder} comment The comment to reply to
300
- * @returns {Promise<boolean>} success or not
395
+ * @returns {Promise<boolean>} Whether the comment is replied successfully
301
396
  * @example
302
397
  * ```ts
303
- * const comment = univerAPI.getActiveWorkbook()
304
- * .getSheetById(sheetId)
305
- * .getCommentById(commentId);
398
+ * const fWorkbook = univerAPI.getActiveWorkbook();
399
+ * const fWorksheet = fWorkbook.getActiveSheet();
306
400
  *
307
- * const reply = univerAPI.newTheadComment()
308
- * .setContent(univerAPI.newRichText().insertText('hello zhangsan'));
401
+ * // Create a new comment
402
+ * const richText = univerAPI.newRichText().insertText('hello univer');
403
+ * const commentBuilder = univerAPI.newTheadComment()
404
+ * .setContent(richText)
405
+ * .setId('mock-comment-id');
406
+ * const cell = fWorksheet.getRange('A1');
407
+ * await cell.addCommentAsync(commentBuilder);
309
408
  *
310
- * const success = await comment.replyAsync(reply);
409
+ * // Reply to the comment
410
+ * const replyText = univerAPI.newRichText().insertText('Hello Univer AI');
411
+ * const reply = univerAPI.newTheadComment().setContent(replyText);
412
+ * const comment = fWorksheet.getCommentById('mock-comment-id');
413
+ * const result = await comment.replyAsync(reply);
414
+ * console.log(result);
311
415
  * ```
312
416
  */
313
417
  replyAsync(comment: FTheadCommentBuilder): Promise<boolean>;
@@ -8,27 +8,41 @@ import { FTheadCommentBuilder } from './f-thread-comment';
8
8
  */
9
9
  export interface IFUniverCommentMixin {
10
10
  /**
11
- * @deprecated use `univerAPI.addEvent(univerAPI.Event.CommentAdded, () => {})` as instead
11
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.CommentAdded, (params) => {})` as instead
12
12
  */
13
13
  onCommentAdded(callback: (event: ISheetCommentAddEvent) => void): IDisposable;
14
14
  /**
15
- * @deprecated use `univerAPI.addEvent(univerAPI.Event.CommentUpdated, () => {})` as instead
15
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.CommentUpdated, (params) => {})` as instead
16
16
  */
17
17
  onCommentUpdated(callback: (event: ISheetCommentUpdateEvent) => void): IDisposable;
18
18
  /**
19
- * @deprecated use `univerAPI.addEvent(univerAPI.Event.CommentDeleted, () => {})` as instead
19
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.CommentDeleted, (params) => {})` as instead
20
20
  */
21
21
  onCommentDeleted(callback: (event: ISheetCommentDeleteEvent) => void): IDisposable;
22
22
  /**
23
- * @deprecated use `univerAPI.addEvent(univerAPI.Event.CommentResolved, () => {})` as instead
23
+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.CommentResolved, (params) => {})` as instead
24
24
  */
25
25
  onCommentResolved(callback: (event: ISheetCommentResolveEvent) => void): IDisposable;
26
26
  /**
27
- * create a new thread comment
28
- * @returns {FTheadCommentBuilder} thead comment builder
27
+ * Create a new thread comment
28
+ * @returns {FTheadCommentBuilder} The thead comment builder
29
29
  * @example
30
30
  * ```ts
31
- * const comment = univerAPI.newTheadComment().setContent(univerAPI.newRichText().insertText('hello zhangsan'));
31
+ * // Create a new comment
32
+ * const richText = univerAPI.newRichText().insertText('hello univer');
33
+ * const commentBuilder = univerAPI.newTheadComment()
34
+ * .setContent(richText)
35
+ * .setPersonId('mock-user-id')
36
+ * .setDateTime(new Date('2025-02-21 14:22:22'))
37
+ * .setId('mock-comment-id')
38
+ * .setThreadId('mock-thread-id');
39
+ *
40
+ * // Add the comment to the cell A1
41
+ * const fWorkbook = univerAPI.getActiveWorkbook();
42
+ * const fWorksheet = fWorkbook.getActiveSheet();
43
+ * const cell = fWorksheet.getRange('A1');
44
+ * const result = await cell.addCommentAsync(commentBuilder);
45
+ * console.log(result);
32
46
  * ```
33
47
  */
34
48
  newTheadComment(): FTheadCommentBuilder;