@univerjs/sheets-thread-comment 0.17.0 → 0.18.0

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/es/facade.js CHANGED
@@ -1,932 +1 @@
1
- var z = Object.defineProperty;
2
- var $ = (o, e, n) => e in o ? z(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
- var D = (o, e, n) => $(o, typeof e != "symbol" ? e + "" : e, n);
4
- import { Inject as B, Injector as L, ICommandService as p, IUniverInstanceService as N, UserManagerService as M, UniverInstanceType as V, RichTextValue as f, generateRandomId as E, RichTextBuilder as q, Tools as j, Range as G, toDisposable as b, CanceledError as U } from "@univerjs/core";
5
- import { SheetsThreadCommentModel as v } from "@univerjs/sheets-thread-comment";
6
- import { FRange as A, FWorkbook as W, FWorksheet as P } from "@univerjs/sheets/facade";
7
- import { DeleteCommentTreeCommand as w, DeleteCommentCommand as R, getDT as x, UpdateCommentCommand as y, ResolveCommentCommand as T, AddCommentCommand as _, ThreadCommentModel as J } from "@univerjs/thread-comment";
8
- import { deserializeRangeWithSheet as F } from "@univerjs/engine-formula";
9
- import { filter as K } from "rxjs";
10
- import { FEventName as H, FUniver as O } from "@univerjs/core/facade";
11
- var Q = Object.getOwnPropertyDescriptor, X = (o, e, n, t) => {
12
- for (var r = t > 1 ? void 0 : t ? Q(e, n) : e, i = o.length - 1, s; i >= 0; i--)
13
- (s = o[i]) && (r = s(r) || r);
14
- return r;
15
- }, I = (o, e) => (n, t) => e(n, t, o);
16
- class S {
17
- constructor(e) {
18
- D(this, "_comment", {
19
- id: E(),
20
- ref: "",
21
- threadId: "",
22
- dT: "",
23
- personId: "",
24
- text: q.newEmptyData().body,
25
- attachments: [],
26
- unitId: "",
27
- subUnitId: ""
28
- });
29
- e && (this._comment = e);
30
- }
31
- /**
32
- * Create a new FTheadCommentItem
33
- * @param {IThreadComment|undefined} comment The comment
34
- * @returns {FTheadCommentItem} A new instance of FTheadCommentItem
35
- * @example
36
- * ```ts
37
- * const commentBuilder = univerAPI.newTheadComment();
38
- * console.log(commentBuilder);
39
- * ```
40
- */
41
- static create(e) {
42
- return new S(e);
43
- }
44
- /**
45
- * Get the person id of the comment
46
- * @returns {string} The person id of the comment
47
- * @example
48
- * ```ts
49
- * const commentBuilder = univerAPI.newTheadComment();
50
- * console.log(commentBuilder.personId);
51
- * ```
52
- */
53
- get personId() {
54
- return this._comment.personId;
55
- }
56
- /**
57
- * Get the date time of the comment
58
- * @returns {string} The date time of the comment
59
- * @example
60
- * ```ts
61
- * const commentBuilder = univerAPI.newTheadComment();
62
- * console.log(commentBuilder.dateTime);
63
- * ```
64
- */
65
- get dateTime() {
66
- return this._comment.dT;
67
- }
68
- /**
69
- * Get the content of the comment
70
- * @returns {RichTextValue} The content of the comment
71
- * @example
72
- * ```ts
73
- * const commentBuilder = univerAPI.newTheadComment();
74
- * console.log(commentBuilder.content);
75
- * ```
76
- */
77
- get content() {
78
- return f.createByBody(this._comment.text);
79
- }
80
- /**
81
- * Get the id of the comment
82
- * @returns {string} The id of the comment
83
- * @example
84
- * ```ts
85
- * const commentBuilder = univerAPI.newTheadComment();
86
- * console.log(commentBuilder.id);
87
- * ```
88
- */
89
- get id() {
90
- return this._comment.id;
91
- }
92
- /**
93
- * Get the thread id of the comment
94
- * @returns {string} The thread id of the comment
95
- * @example
96
- * ```ts
97
- * const commentBuilder = univerAPI.newTheadComment();
98
- * console.log(commentBuilder.threadId);
99
- * ```
100
- */
101
- get threadId() {
102
- return this._comment.threadId;
103
- }
104
- /**
105
- * Copy the comment
106
- * @returns {FTheadCommentBuilder} The comment builder
107
- * @example
108
- * ```ts
109
- * const commentBuilder = univerAPI.newTheadComment();
110
- * const newCommentBuilder = commentBuilder.copy();
111
- * console.log(newCommentBuilder);
112
- * ```
113
- */
114
- copy() {
115
- return k.create(j.deepClone(this._comment));
116
- }
117
- }
118
- class k extends S {
119
- static create(e) {
120
- return new k(e);
121
- }
122
- /**
123
- * Set the content of the comment
124
- * @param {IDocumentBody | RichTextValue} content The content of the comment
125
- * @returns {FTheadCommentBuilder} The comment builder for chaining
126
- * @example
127
- * ```ts
128
- * // Create a new comment
129
- * const richText = univerAPI.newRichText().insertText('hello univer');
130
- * const commentBuilder = univerAPI.newTheadComment()
131
- * .setContent(richText);
132
- * console.log(commentBuilder.content);
133
- *
134
- * // Add the comment to the cell A1
135
- * const fWorkbook = univerAPI.getActiveWorkbook();
136
- * const fWorksheet = fWorkbook.getActiveSheet();
137
- * const cell = fWorksheet.getRange('A1');
138
- * const result = await cell.addCommentAsync(commentBuilder);
139
- * console.log(result);
140
- * ```
141
- */
142
- setContent(e) {
143
- return e instanceof f ? this._comment.text = e.getData().body : this._comment.text = e, this;
144
- }
145
- /**
146
- * Set the person id of the comment
147
- * @param {string} userId The person id of the comment
148
- * @returns {FTheadCommentBuilder} The comment builder for chaining
149
- * @example
150
- * ```ts
151
- * // Create a new comment
152
- * const richText = univerAPI.newRichText().insertText('hello univer');
153
- * const commentBuilder = univerAPI.newTheadComment()
154
- * .setContent(richText)
155
- * .setPersonId('mock-user-id');
156
- * console.log(commentBuilder.personId);
157
- *
158
- * // Add the comment to the cell A1
159
- * const fWorkbook = univerAPI.getActiveWorkbook();
160
- * const fWorksheet = fWorkbook.getActiveSheet();
161
- * const cell = fWorksheet.getRange('A1');
162
- * const result = await cell.addCommentAsync(commentBuilder);
163
- * console.log(result);
164
- * ```
165
- */
166
- setPersonId(e) {
167
- return this._comment.personId = e, this;
168
- }
169
- /**
170
- * Set the date time of the comment
171
- * @param {Date} date The date time of the comment
172
- * @returns {FTheadCommentBuilder} The comment builder for chaining
173
- * @example
174
- * ```ts
175
- * // Create a new comment
176
- * const richText = univerAPI.newRichText().insertText('hello univer');
177
- * const commentBuilder = univerAPI.newTheadComment()
178
- * .setContent(richText)
179
- * .setDateTime(new Date('2025-02-21 14:22:22'));
180
- * console.log(commentBuilder.dateTime);
181
- *
182
- * // Add the comment to the cell A1
183
- * const fWorkbook = univerAPI.getActiveWorkbook();
184
- * const fWorksheet = fWorkbook.getActiveSheet();
185
- * const cell = fWorksheet.getRange('A1');
186
- * const result = await cell.addCommentAsync(commentBuilder);
187
- * console.log(result);
188
- * ```
189
- */
190
- setDateTime(e) {
191
- return this._comment.dT = x(e), this;
192
- }
193
- /**
194
- * Set the id of the comment
195
- * @param {string} id The id of the comment
196
- * @returns {FTheadCommentBuilder} The comment builder for chaining
197
- * @example
198
- * ```ts
199
- * // Create a new comment
200
- * const richText = univerAPI.newRichText().insertText('hello univer');
201
- * const commentBuilder = univerAPI.newTheadComment()
202
- * .setContent(richText)
203
- * .setId('mock-comment-id');
204
- * console.log(commentBuilder.id);
205
- *
206
- * // Add the comment to the cell A1
207
- * const fWorkbook = univerAPI.getActiveWorkbook();
208
- * const fWorksheet = fWorkbook.getActiveSheet();
209
- * const cell = fWorksheet.getRange('A1');
210
- * const result = await cell.addCommentAsync(commentBuilder);
211
- * console.log(result);
212
- * ```
213
- */
214
- setId(e) {
215
- return this._comment.id = e, this;
216
- }
217
- /**
218
- * Set the thread id of the comment
219
- * @param {string} threadId The thread id of the comment
220
- * @returns {FTheadCommentBuilder} The comment builder
221
- * @example
222
- * ```ts
223
- * // Create a new comment
224
- * const richText = univerAPI.newRichText().insertText('hello univer');
225
- * const commentBuilder = univerAPI.newTheadComment()
226
- * .setContent(richText)
227
- * .setThreadId('mock-thread-id');
228
- * console.log(commentBuilder.threadId);
229
- *
230
- * // Add the comment to the cell A1
231
- * const fWorkbook = univerAPI.getActiveWorkbook();
232
- * const fWorksheet = fWorkbook.getActiveSheet();
233
- * const cell = fWorksheet.getRange('A1');
234
- * const result = await cell.addCommentAsync(commentBuilder);
235
- * console.log(result);
236
- * ```
237
- */
238
- setThreadId(e) {
239
- return this._comment.threadId = e, this;
240
- }
241
- /**
242
- * Build the comment
243
- * @returns {IThreadComment} The comment
244
- * @example
245
- * ```ts
246
- * const richText = univerAPI.newRichText().insertText('hello univer');
247
- * const comment = univerAPI.newTheadComment()
248
- * .setContent(richText)
249
- * .setPersonId('mock-user-id')
250
- * .setDateTime(new Date('2025-02-21 14:22:22'))
251
- * .setId('mock-comment-id')
252
- * .setThreadId('mock-thread-id')
253
- * .build();
254
- * console.log(comment);
255
- * ```
256
- */
257
- build() {
258
- return this._comment;
259
- }
260
- }
261
- let l = class {
262
- /**
263
- * @ignore
264
- */
265
- constructor(o, e, n, t, r, i, s) {
266
- this._thread = o, this._parent = e, this._injector = n, this._commandService = t, this._univerInstanceService = r, this._threadCommentModel = i, this._userManagerService = s;
267
- }
268
- _getRef() {
269
- var n;
270
- const o = ((n = this._parent) == null ? void 0 : n.ref) || this._thread.ref;
271
- return F(o).range;
272
- }
273
- /**
274
- * Whether the comment is a root comment
275
- * @returns {boolean} Whether the comment is a root comment
276
- * @example
277
- * ```ts
278
- * const fWorkbook = univerAPI.getActiveWorkbook();
279
- * const fWorksheet = fWorkbook.getActiveSheet();
280
- * const comments = fWorksheet.getComments();
281
- * comments.forEach((comment) => {
282
- * console.log(comment.getIsRoot());
283
- * });
284
- * ```
285
- */
286
- getIsRoot() {
287
- return !this._parent;
288
- }
289
- /**
290
- * Get the comment data
291
- * @returns {IBaseComment} The comment data
292
- * @example
293
- * ```ts
294
- * const fWorkbook = univerAPI.getActiveWorkbook();
295
- * const fWorksheet = fWorkbook.getActiveSheet();
296
- * const comments = fWorksheet.getComments();
297
- * comments.forEach((comment) => {
298
- * console.log(comment.getCommentData());
299
- * });
300
- * ```
301
- */
302
- getCommentData() {
303
- const { children: o, ...e } = this._thread;
304
- return e;
305
- }
306
- /**
307
- * Get the replies of the comment
308
- * @returns {FThreadComment[]} the replies of the comment
309
- * @example
310
- * ```ts
311
- * const fWorkbook = univerAPI.getActiveWorkbook();
312
- * const fWorksheet = fWorkbook.getActiveSheet();
313
- * const comments = fWorksheet.getComments();
314
- * comments.forEach((comment) => {
315
- * if (comment.getIsRoot()) {
316
- * const replies = comment.getReplies();
317
- * replies.forEach((reply) => {
318
- * console.log(reply.getCommentData());
319
- * });
320
- * }
321
- * });
322
- * ```
323
- */
324
- getReplies() {
325
- var n;
326
- const o = this._getRef(), e = this._threadCommentModel.getCommentWithChildren(this._thread.unitId, this._thread.subUnitId, o.startRow, o.startColumn);
327
- return (n = e == null ? void 0 : e.children) == null ? void 0 : n.map((t) => this._injector.createInstance(l, t));
328
- }
329
- /**
330
- * Get the range of the comment
331
- * @returns {FRange | null} The range of the comment
332
- * @example
333
- * ```ts
334
- * const fWorkbook = univerAPI.getActiveWorkbook();
335
- * const fWorksheet = fWorkbook.getActiveSheet();
336
- * const comments = fWorksheet.getComments();
337
- * comments.forEach((comment) => {
338
- * console.log(comment.getRange().getA1Notation());
339
- * });
340
- * ```
341
- */
342
- getRange() {
343
- const o = this._univerInstanceService.getUnit(this._thread.unitId, V.UNIVER_SHEET);
344
- if (!o)
345
- return null;
346
- const e = o.getSheetBySheetId(this._thread.subUnitId);
347
- if (!e)
348
- return null;
349
- const n = this._getRef();
350
- return this._injector.createInstance(A, o, e, n);
351
- }
352
- /**
353
- * @deprecated use `getRichText` as instead
354
- */
355
- getContent() {
356
- return this._thread.text;
357
- }
358
- /**
359
- * Get the rich text of the comment
360
- * @returns {RichTextValue} The rich text of the comment
361
- * @example
362
- * ```ts
363
- * const fWorkbook = univerAPI.getActiveWorkbook();
364
- * const fWorksheet = fWorkbook.getActiveSheet();
365
- * const comments = fWorksheet.getComments();
366
- * comments.forEach((comment) => {
367
- * console.log(comment.getRichText());
368
- * });
369
- * ```
370
- */
371
- getRichText() {
372
- const o = this._thread.text;
373
- return f.create({ body: o, documentStyle: {}, id: "d" });
374
- }
375
- /**
376
- * Delete the comment and it's replies
377
- * @returns {Promise<boolean>} Whether the comment is deleted successfully
378
- * @example
379
- * ```ts
380
- * const fWorkbook = univerAPI.getActiveWorkbook();
381
- * const fWorksheet = fWorkbook.getActiveSheet();
382
- * const comments = fWorksheet.getComments();
383
- *
384
- * // Delete the first comment
385
- * const result = await comments[0]?.deleteAsync();
386
- * console.log(result);
387
- * ```
388
- */
389
- deleteAsync() {
390
- return this._commandService.executeCommand(
391
- this.getIsRoot() ? w.id : R.id,
392
- {
393
- commentId: this._thread.id,
394
- unitId: this._thread.unitId,
395
- subUnitId: this._thread.subUnitId
396
- }
397
- );
398
- }
399
- /**
400
- * @deprecated use `deleteAsync` as instead.
401
- */
402
- delete() {
403
- return this.deleteAsync();
404
- }
405
- /**
406
- * @deprecated use `updateAsync` as instead
407
- */
408
- async update(o) {
409
- return this.updateAsync(o);
410
- }
411
- /**
412
- * Update the comment content
413
- * @param {IDocumentBody | RichTextValue} content The new content of the comment
414
- * @returns {Promise<boolean>} Whether the comment is updated successfully
415
- * @example
416
- * ```ts
417
- * const fWorkbook = univerAPI.getActiveWorkbook();
418
- * const fWorksheet = fWorkbook.getActiveSheet();
419
- *
420
- * // Create a new comment
421
- * const richText = univerAPI.newRichText().insertText('hello univer');
422
- * const commentBuilder = univerAPI.newTheadComment()
423
- * .setContent(richText)
424
- * .setId('mock-comment-id');
425
- * const cell = fWorksheet.getRange('A1');
426
- * await cell.addCommentAsync(commentBuilder);
427
- *
428
- * // Update the comment after 3 seconds
429
- * setTimeout(async () => {
430
- * const comment = fWorksheet.getCommentById('mock-comment-id');
431
- * const newRichText = univerAPI.newRichText().insertText('Hello Univer AI');
432
- * const result = await comment.updateAsync(newRichText);
433
- * console.log(result);
434
- * }, 3000);
435
- * ```
436
- */
437
- async updateAsync(o) {
438
- const e = o instanceof f ? o.getData().body : o, n = x();
439
- return await this._commandService.executeCommand(
440
- y.id,
441
- {
442
- unitId: this._thread.unitId,
443
- subUnitId: this._thread.subUnitId,
444
- payload: {
445
- commentId: this._thread.id,
446
- text: e,
447
- updated: !0,
448
- updateT: n
449
- }
450
- }
451
- );
452
- }
453
- /**
454
- * @deprecated use `resolveAsync` as instead
455
- */
456
- resolve(o) {
457
- return this.resolveAsync(o);
458
- }
459
- /**
460
- * Resolve the comment
461
- * @param {boolean} resolved Whether the comment is resolved
462
- * @returns {Promise<boolean>} Set the comment to resolved or not operation result
463
- * @example
464
- * ```ts
465
- * const fWorkbook = univerAPI.getActiveWorkbook();
466
- * const fWorksheet = fWorkbook.getActiveSheet();
467
- *
468
- * // Create a new comment
469
- * const richText = univerAPI.newRichText().insertText('hello univer');
470
- * const commentBuilder = univerAPI.newTheadComment()
471
- * .setContent(richText)
472
- * .setId('mock-comment-id');
473
- * const cell = fWorksheet.getRange('A1');
474
- * await cell.addCommentAsync(commentBuilder);
475
- *
476
- * // Resolve the comment after 3 seconds
477
- * setTimeout(async () => {
478
- * const comment = fWorksheet.getCommentById('mock-comment-id');
479
- * const result = await comment.resolveAsync(true);
480
- * console.log(result);
481
- * }, 3000);
482
- * ```
483
- */
484
- resolveAsync(o) {
485
- return this._commandService.executeCommand(
486
- T.id,
487
- {
488
- unitId: this._thread.unitId,
489
- subUnitId: this._thread.subUnitId,
490
- commentId: this._thread.id,
491
- resolved: o != null ? o : !this._thread.resolved
492
- }
493
- );
494
- }
495
- /**
496
- * Reply to the comment
497
- * @param {FTheadCommentBuilder} comment The comment to reply to
498
- * @returns {Promise<boolean>} Whether the comment is replied successfully
499
- * @example
500
- * ```ts
501
- * const fWorkbook = univerAPI.getActiveWorkbook();
502
- * const fWorksheet = fWorkbook.getActiveSheet();
503
- *
504
- * // Create a new comment
505
- * const richText = univerAPI.newRichText().insertText('hello univer');
506
- * const commentBuilder = univerAPI.newTheadComment()
507
- * .setContent(richText)
508
- * .setId('mock-comment-id');
509
- * const cell = fWorksheet.getRange('A1');
510
- * await cell.addCommentAsync(commentBuilder);
511
- *
512
- * // Reply to the comment
513
- * const replyText = univerAPI.newRichText().insertText('Hello Univer AI');
514
- * const reply = univerAPI.newTheadComment().setContent(replyText);
515
- * const comment = fWorksheet.getCommentById('mock-comment-id');
516
- * const result = await comment.replyAsync(reply);
517
- * console.log(result);
518
- * ```
519
- */
520
- replyAsync(o) {
521
- var n;
522
- const e = o.build();
523
- return this._commandService.executeCommand(
524
- _.id,
525
- {
526
- unitId: this._thread.unitId,
527
- subUnitId: this._thread.subUnitId,
528
- comment: {
529
- id: E(),
530
- parentId: this._thread.id,
531
- threadId: this._thread.threadId,
532
- ref: ((n = this._parent) == null ? void 0 : n.ref) || this._thread.ref,
533
- unitId: this._thread.unitId,
534
- subUnitId: this._thread.subUnitId,
535
- text: e.text,
536
- attachments: e.attachments,
537
- dT: e.dT || x(),
538
- personId: e.personId || this._userManagerService.getCurrentUser().userID
539
- }
540
- }
541
- );
542
- }
543
- };
544
- l = X([
545
- I(2, B(L)),
546
- I(3, p),
547
- I(4, N),
548
- I(5, B(v)),
549
- I(6, B(M))
550
- ], l);
551
- class Y extends A {
552
- getComment() {
553
- const n = this._injector.get(v), t = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = n.getByLocation(t, r, this._range.startRow, this._range.startColumn);
554
- if (!i)
555
- return null;
556
- const s = n.getComment(t, r, i);
557
- return s ? this._injector.createInstance(l, s) : null;
558
- }
559
- getComments() {
560
- const n = this._injector.get(v), t = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = [];
561
- return G.foreach(this._range, (s, a) => {
562
- const m = n.getByLocation(t, r, s, a);
563
- if (m) {
564
- const d = n.getComment(t, r, m);
565
- d && i.push(this._injector.createInstance(l, d));
566
- }
567
- }), i;
568
- }
569
- addComment(e) {
570
- var c;
571
- const n = this._injector, t = (c = this.getComment()) == null ? void 0 : c.getCommentData(), r = n.get(p), i = n.get(M), s = this._workbook.getUnitId(), a = this._worksheet.getSheetId(), m = `${j.chatAtABC(this._range.startColumn)}${this._range.startRow + 1}`, d = i.getCurrentUser(), h = e instanceof k ? e.build() : { text: e };
572
- return r.executeCommand(_.id, {
573
- unitId: s,
574
- subUnitId: a,
575
- comment: {
576
- text: h.text,
577
- dT: h.dT || x(),
578
- attachments: [],
579
- id: h.id || E(),
580
- ref: m,
581
- personId: h.personId || d.userID,
582
- parentId: t == null ? void 0 : t.id,
583
- unitId: s,
584
- subUnitId: a,
585
- threadId: (t == null ? void 0 : t.threadId) || E()
586
- }
587
- });
588
- }
589
- clearComment() {
590
- var s;
591
- const e = this._injector, n = (s = this.getComment()) == null ? void 0 : s.getCommentData(), t = e.get(p), r = this._workbook.getUnitId(), i = this._worksheet.getSheetId();
592
- return n ? t.executeCommand(w.id, {
593
- unitId: r,
594
- subUnitId: i,
595
- threadId: n.threadId,
596
- commentId: n.id
597
- }) : Promise.resolve(!0);
598
- }
599
- clearComments() {
600
- const n = this.getComments().map((t) => t.deleteAsync());
601
- return Promise.all(n).then(() => !0);
602
- }
603
- addCommentAsync(e) {
604
- return this.addComment(e);
605
- }
606
- clearCommentAsync() {
607
- return this.clearComment();
608
- }
609
- clearCommentsAsync() {
610
- return this.clearComments();
611
- }
612
- }
613
- A.extend(Y);
614
- class Z extends W {
615
- /**
616
- * @ignore
617
- */
618
- _initialize() {
619
- Object.defineProperty(this, "_threadCommentModel", {
620
- get() {
621
- return this._injector.get(J);
622
- }
623
- });
624
- }
625
- getComments() {
626
- return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map((e) => this._injector.createInstance(l, e.root));
627
- }
628
- clearComments() {
629
- const n = this.getComments().map((t) => t.deleteAsync());
630
- return Promise.all(n).then(() => !0);
631
- }
632
- /**
633
- * @param callback
634
- * @deprecated
635
- */
636
- onThreadCommentChange(e) {
637
- return b(this._threadCommentModel.commentUpdate$.pipe(K((n) => n.unitId === this._workbook.getUnitId())).subscribe(e));
638
- }
639
- /**
640
- * @param callback
641
- * @deprecated
642
- */
643
- onBeforeAddThreadComment(e) {
644
- return b(this._commandService.beforeCommandExecuted((n, t) => {
645
- const r = n.params;
646
- if (n.id === _.id) {
647
- if (r.unitId !== this._workbook.getUnitId())
648
- return;
649
- if (e(r, t) === !1)
650
- throw new Error("Command is stopped by the hook onBeforeAddThreadComment");
651
- }
652
- }));
653
- }
654
- /**
655
- * @param callback
656
- * @deprecated
657
- */
658
- onBeforeUpdateThreadComment(e) {
659
- return b(this._commandService.beforeCommandExecuted((n, t) => {
660
- const r = n.params;
661
- if (n.id === y.id) {
662
- if (r.unitId !== this._workbook.getUnitId())
663
- return;
664
- if (e(r, t) === !1)
665
- throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment");
666
- }
667
- }));
668
- }
669
- /**
670
- * @param callback
671
- * @deprecated
672
- */
673
- onBeforeDeleteThreadComment(e) {
674
- return b(this._commandService.beforeCommandExecuted((n, t) => {
675
- const r = n.params;
676
- if (n.id === R.id || n.id === w.id) {
677
- if (r.unitId !== this._workbook.getUnitId())
678
- return;
679
- if (e(r, t) === !1)
680
- throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment");
681
- }
682
- }));
683
- }
684
- }
685
- W.extend(Z);
686
- class ee extends P {
687
- getComments() {
688
- return this._injector.get(v).getSubUnitAll(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => this._injector.createInstance(l, t));
689
- }
690
- clearComments() {
691
- const n = this.getComments().map((t) => t.deleteAsync());
692
- return Promise.all(n).then(() => !0);
693
- }
694
- /**
695
- * Subscribe to comment events.
696
- * @param callback Callback function, param contains comment info and target cell.
697
- */
698
- onCommented(e) {
699
- return this._injector.get(p).onCommandExecuted((t) => {
700
- if (t.id === _.id) {
701
- const r = t.params;
702
- e(r);
703
- }
704
- });
705
- }
706
- getCommentById(e) {
707
- const t = this._injector.get(v).getComment(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
708
- if (t)
709
- return this._injector.createInstance(l, t);
710
- }
711
- }
712
- P.extend(ee);
713
- const C = {
714
- CommentAdded: "CommentAdded",
715
- BeforeCommentAdd: "BeforeCommentAdd",
716
- CommentUpdated: "CommentUpdated",
717
- BeforeCommentUpdate: "BeforeCommentUpdate",
718
- CommentDeleted: "CommentDeleted",
719
- BeforeCommentDelete: "BeforeCommentDelete",
720
- CommentResolved: "CommentResolved",
721
- BeforeCommentResolve: "BeforeCommentResolve"
722
- };
723
- class te extends H {
724
- get CommentAdded() {
725
- return C.CommentAdded;
726
- }
727
- get BeforeCommentAdd() {
728
- return C.BeforeCommentAdd;
729
- }
730
- get CommentUpdated() {
731
- return C.CommentUpdated;
732
- }
733
- get BeforeCommentUpdate() {
734
- return C.BeforeCommentUpdate;
735
- }
736
- get CommentDeleted() {
737
- return C.CommentDeleted;
738
- }
739
- get BeforeCommentDelete() {
740
- return C.BeforeCommentDelete;
741
- }
742
- get CommentResolved() {
743
- return C.CommentResolved;
744
- }
745
- get BeforeCommentResolve() {
746
- return C.BeforeCommentResolve;
747
- }
748
- }
749
- H.extend(te);
750
- class ne extends O {
751
- _getTargetSheet(e = {}) {
752
- var r;
753
- const n = e.unitId ? this.getUniverSheet(e.unitId) : (r = this.getActiveWorkbook) == null ? void 0 : r.call(this);
754
- if (!n) return null;
755
- const t = e.subUnitId ? n.getSheetBySheetId(e.subUnitId) : n.getActiveSheet();
756
- return t ? {
757
- workbook: n,
758
- worksheet: t
759
- } : null;
760
- }
761
- // eslint-disable-next-line max-lines-per-function
762
- _initialize(e) {
763
- const n = e.get(p);
764
- this.disposeWithMe(
765
- this.registerEventHandler(
766
- this.Event.CommentAdded,
767
- () => n.onCommandExecuted((t) => {
768
- var d, h, c, u;
769
- if (t.id !== _.id) return;
770
- const r = this._getTargetSheet(t.params);
771
- if (!r) return;
772
- const { workbook: i, worksheet: s } = r, { comment: a } = t.params, m = s.getCommentById(a.id);
773
- m && this.fireEvent(this.Event.CommentAdded, {
774
- workbook: i,
775
- worksheet: s,
776
- row: (h = (d = m.getRange()) == null ? void 0 : d.getRow()) != null ? h : 0,
777
- col: (u = (c = m.getRange()) == null ? void 0 : c.getColumn()) != null ? u : 0,
778
- comment: m
779
- });
780
- })
781
- )
782
- ), this.disposeWithMe(
783
- this.registerEventHandler(
784
- this.Event.CommentUpdated,
785
- () => n.onCommandExecuted((t) => {
786
- var d, h, c, u;
787
- if (t.id !== y.id) return;
788
- const r = this._getTargetSheet(t.params);
789
- if (!r) return;
790
- const { workbook: i, worksheet: s } = r, { payload: a } = t.params, m = s.getCommentById(a.commentId);
791
- m && this.fireEvent(this.Event.CommentUpdated, {
792
- workbook: i,
793
- worksheet: s,
794
- row: (h = (d = m.getRange()) == null ? void 0 : d.getRow()) != null ? h : 0,
795
- col: (u = (c = m.getRange()) == null ? void 0 : c.getColumn()) != null ? u : 0,
796
- comment: m
797
- });
798
- })
799
- )
800
- ), this.disposeWithMe(
801
- this.registerEventHandler(
802
- this.Event.CommentDeleted,
803
- () => n.onCommandExecuted((t) => {
804
- if (t.id !== R.id && t.id !== w.id) return;
805
- const r = this._getTargetSheet(t.params);
806
- if (!r) return;
807
- const { workbook: i, worksheet: s } = r, { commentId: a } = t.params;
808
- this.fireEvent(this.Event.CommentDeleted, {
809
- workbook: i,
810
- worksheet: s,
811
- commentId: a
812
- });
813
- })
814
- )
815
- ), this.disposeWithMe(
816
- this.registerEventHandler(
817
- this.Event.CommentResolved,
818
- () => n.onCommandExecuted((t) => {
819
- var h, c, u, g;
820
- if (t.id !== T.id) return;
821
- const r = this._getTargetSheet(t.params);
822
- if (!r) return;
823
- const { workbook: i, worksheet: s } = r, { commentId: a, resolved: m } = t.params, d = s.getCommentById(a);
824
- d && this.fireEvent(this.Event.CommentResolved, {
825
- workbook: i,
826
- worksheet: s,
827
- row: (c = (h = d.getRange()) == null ? void 0 : h.getRow()) != null ? c : 0,
828
- col: (g = (u = d.getRange()) == null ? void 0 : u.getColumn()) != null ? g : 0,
829
- comment: d,
830
- resolved: m
831
- });
832
- })
833
- )
834
- ), this.disposeWithMe(
835
- this.registerEventHandler(
836
- this.Event.BeforeCommentAdd,
837
- () => n.beforeCommandExecuted((t) => {
838
- if (t.id !== _.id) return;
839
- const r = this._getTargetSheet(t.params);
840
- if (!r) return;
841
- const { workbook: i, worksheet: s } = r, { comment: a } = t.params, { range: m } = F(a.ref), d = {
842
- workbook: i,
843
- worksheet: s,
844
- row: m.startRow,
845
- col: m.startColumn,
846
- comment: S.create(a)
847
- };
848
- if (this.fireEvent(this.Event.BeforeCommentAdd, d), d.cancel)
849
- throw new U();
850
- })
851
- )
852
- ), this.disposeWithMe(
853
- this.registerEventHandler(
854
- this.Event.BeforeCommentUpdate,
855
- () => n.beforeCommandExecuted((t) => {
856
- var d, h, c, u;
857
- if (t.id !== y.id) return;
858
- const r = this._getTargetSheet(t.params);
859
- if (!r) return;
860
- const { workbook: i, worksheet: s } = r, { payload: a } = t.params, m = s.getCommentById(a.commentId);
861
- if (m) {
862
- const g = {
863
- workbook: i,
864
- worksheet: s,
865
- row: (h = (d = m.getRange()) == null ? void 0 : d.getRow()) != null ? h : 0,
866
- col: (u = (c = m.getRange()) == null ? void 0 : c.getColumn()) != null ? u : 0,
867
- comment: m,
868
- newContent: f.createByBody(a.text)
869
- };
870
- if (this.fireEvent(this.Event.BeforeCommentUpdate, g), g.cancel)
871
- throw new U();
872
- }
873
- })
874
- )
875
- ), this.disposeWithMe(
876
- this.registerEventHandler(
877
- this.Event.BeforeCommentDelete,
878
- () => n.beforeCommandExecuted((t) => {
879
- var d, h, c, u;
880
- if (t.id !== R.id && t.id !== w.id) return;
881
- const r = this._getTargetSheet(t.params);
882
- if (!r) return;
883
- const { workbook: i, worksheet: s } = r, { commentId: a } = t.params, m = s.getCommentById(a);
884
- if (m) {
885
- const g = {
886
- workbook: i,
887
- worksheet: s,
888
- row: (h = (d = m.getRange()) == null ? void 0 : d.getRow()) != null ? h : 0,
889
- col: (u = (c = m.getRange()) == null ? void 0 : c.getColumn()) != null ? u : 0,
890
- comment: m
891
- };
892
- if (this.fireEvent(this.Event.BeforeCommentDelete, g), g.cancel)
893
- throw new U();
894
- }
895
- })
896
- )
897
- ), this.disposeWithMe(
898
- this.registerEventHandler(
899
- this.Event.BeforeCommentResolve,
900
- () => n.beforeCommandExecuted((t) => {
901
- var h, c;
902
- if (t.id !== T.id) return;
903
- const r = this._getTargetSheet(t.params);
904
- if (!r) return;
905
- const { workbook: i, worksheet: s } = r, { commentId: a, resolved: m } = t.params, d = s.getCommentById(a);
906
- if (d) {
907
- const u = {
908
- workbook: i,
909
- worksheet: s,
910
- row: (h = d.getRange().getRow()) != null ? h : 0,
911
- col: (c = d.getRange().getColumn()) != null ? c : 0,
912
- comment: d,
913
- resolved: m
914
- };
915
- if (this.fireEvent(this.Event.BeforeCommentResolve, u), u.cancel)
916
- throw new U();
917
- }
918
- })
919
- )
920
- );
921
- }
922
- /**
923
- * @ignore
924
- */
925
- newTheadComment(e) {
926
- return new k(e);
927
- }
928
- }
929
- O.extend(ne);
930
- export {
931
- l as FThreadComment
932
- };
1
+ import{CanceledError as e,ICommandService as t,IUniverInstanceService as n,Inject as r,Injector as i,Range as a,RichTextBuilder as o,RichTextValue as s,Tools as c,UniverInstanceType as l,UserManagerService as u,generateRandomId as d,toDisposable as f}from"@univerjs/core";import{SheetsThreadCommentModel as p}from"@univerjs/sheets-thread-comment";import{FRange as m,FWorkbook as h,FWorksheet as g}from"@univerjs/sheets/facade";import{AddCommentCommand as _,DeleteCommentCommand as v,DeleteCommentTreeCommand as y,ResolveCommentCommand as b,ThreadCommentModel as x,UpdateCommentCommand as S,getDT as C}from"@univerjs/thread-comment";import{deserializeRangeWithSheet as w}from"@univerjs/engine-formula";import{filter as T}from"rxjs";import{FEventName as E,FUniver as D}from"@univerjs/core/facade";function O(e){"@babel/helpers - typeof";return O=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},O(e)}function k(e,t){if(O(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(O(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function A(e){var t=k(e,`string`);return O(t)==`symbol`?t:t+``}function j(e,t,n){return(t=A(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e,t){return function(n,r){t(n,r,e)}}function N(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var P,F=class e{static create(t){return new e(t)}constructor(e){j(this,`_comment`,{id:d(),ref:``,threadId:``,dT:``,personId:``,text:o.newEmptyData().body,attachments:[],unitId:``,subUnitId:``}),e&&(this._comment=e)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return s.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return I.create(c.deepClone(this._comment))}},I=class e extends F{static create(t){return new e(t)}setContent(e){return e instanceof s?this._comment.text=e.getData().body:this._comment.text=e,this}setPersonId(e){return this._comment.personId=e,this}setDateTime(e){return this._comment.dT=C(e),this}setId(e){return this._comment.id=e,this}setThreadId(e){return this._comment.threadId=e,this}build(){return this._comment}};let L=P=class{constructor(e,t,n,r,i,a,o){this._thread=e,this._parent=t,this._injector=n,this._commandService=r,this._univerInstanceService=i,this._threadCommentModel=a,this._userManagerService=o}_getRef(){var e;return w(((e=this._parent)==null?void 0:e.ref)||this._thread.ref).range}getIsRoot(){return!this._parent}getCommentData(){let{children:e,...t}=this._thread;return t}getReplies(){var e;let t=this._getRef(),n=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,t.startRow,t.startColumn);return n==null||(e=n.children)==null?void 0:e.map(e=>this._injector.createInstance(P,e))}getRange(){let e=this._univerInstanceService.getUnit(this._thread.unitId,l.UNIVER_SHEET);if(!e)return null;let t=e.getSheetBySheetId(this._thread.subUnitId);if(!t)return null;let n=this._getRef();return this._injector.createInstance(m,e,t,n)}getContent(){return this._thread.text}getRichText(){let e=this._thread.text;return s.create({body:e,documentStyle:{},id:`d`})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?y.id:v.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}delete(){return this.deleteAsync()}async update(e){return this.updateAsync(e)}async updateAsync(e){let t=e instanceof s?e.getData().body:e,n=C();return await this._commandService.executeCommand(S.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:t,updated:!0,updateT:n}})}resolve(e){return this.resolveAsync(e)}resolveAsync(e){return this._commandService.executeCommand(b.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:e==null?!this._thread.resolved:e})}replyAsync(e){var t;let n=e.build();return this._commandService.executeCommand(_.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:d(),parentId:this._thread.id,threadId:this._thread.threadId,ref:((t=this._parent)==null?void 0:t.ref)||this._thread.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:n.text,attachments:n.attachments,dT:n.dT||C(),personId:n.personId||this._userManagerService.getCurrentUser().userID}})}};L=P=N([M(2,r(i)),M(3,t),M(4,n),M(5,r(p)),M(6,r(u))],L);var R=class extends m{getComment(){let e=this._injector.get(p),t=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),r=e.getByLocation(t,n,this._range.startRow,this._range.startColumn);if(!r)return null;let i=e.getComment(t,n,r);return i?this._injector.createInstance(L,i):null}getComments(){let e=this._injector.get(p),t=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),r=[];return a.foreach(this._range,(i,a)=>{let o=e.getByLocation(t,n,i,a);if(o){let i=e.getComment(t,n,o);i&&r.push(this._injector.createInstance(L,i))}}),r}addComment(e){var n;let r=this._injector,i=(n=this.getComment())==null?void 0:n.getCommentData(),a=r.get(t),o=r.get(u),s=this._workbook.getUnitId(),l=this._worksheet.getSheetId(),f=`${c.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,p=o.getCurrentUser(),m=e instanceof I?e.build():{text:e};return a.executeCommand(_.id,{unitId:s,subUnitId:l,comment:{text:m.text,dT:m.dT||C(),attachments:[],id:m.id||d(),ref:f,personId:m.personId||p.userID,parentId:i==null?void 0:i.id,unitId:s,subUnitId:l,threadId:(i==null?void 0:i.threadId)||d()}})}clearComment(){var e;let n=this._injector,r=(e=this.getComment())==null?void 0:e.getCommentData(),i=n.get(t),a=this._workbook.getUnitId(),o=this._worksheet.getSheetId();return r?i.executeCommand(y.id,{unitId:a,subUnitId:o,threadId:r.threadId,commentId:r.id}):Promise.resolve(!0)}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}addCommentAsync(e){return this.addComment(e)}clearCommentAsync(){return this.clearComment()}clearCommentsAsync(){return this.clearComments()}};m.extend(R);var z=class extends h{_initialize(){Object.defineProperty(this,`_threadCommentModel`,{get(){return this._injector.get(x)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(e=>this._injector.createInstance(L,e.root))}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}onThreadCommentChange(e){return f(this._threadCommentModel.commentUpdate$.pipe(T(e=>e.unitId===this._workbook.getUnitId())).subscribe(e))}onBeforeAddThreadComment(e){return f(this._commandService.beforeCommandExecuted((t,n)=>{let r=t.params;if(t.id===_.id){if(r.unitId!==this._workbook.getUnitId())return;if(e(r,n)===!1)throw Error(`Command is stopped by the hook onBeforeAddThreadComment`)}}))}onBeforeUpdateThreadComment(e){return f(this._commandService.beforeCommandExecuted((t,n)=>{let r=t.params;if(t.id===S.id){if(r.unitId!==this._workbook.getUnitId())return;if(e(r,n)===!1)throw Error(`Command is stopped by the hook onBeforeUpdateThreadComment`)}}))}onBeforeDeleteThreadComment(e){return f(this._commandService.beforeCommandExecuted((t,n)=>{let r=t.params;if(t.id===v.id||t.id===y.id){if(r.unitId!==this._workbook.getUnitId())return;if(e(r,n)===!1)throw Error(`Command is stopped by the hook onBeforeDeleteThreadComment`)}}))}};h.extend(z);var B=class extends g{getComments(){return this._injector.get(p).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>this._injector.createInstance(L,e))}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}onCommented(e){return this._injector.get(t).onCommandExecuted(t=>{if(t.id===_.id){let n=t.params;e(n)}})}getCommentById(e){let t=this._injector.get(p).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),e);if(t)return this._injector.createInstance(L,t)}};g.extend(B);const V={CommentAdded:`CommentAdded`,BeforeCommentAdd:`BeforeCommentAdd`,CommentUpdated:`CommentUpdated`,BeforeCommentUpdate:`BeforeCommentUpdate`,CommentDeleted:`CommentDeleted`,BeforeCommentDelete:`BeforeCommentDelete`,CommentResolved:`CommentResolved`,BeforeCommentResolve:`BeforeCommentResolve`};var H=class extends E{get CommentAdded(){return V.CommentAdded}get BeforeCommentAdd(){return V.BeforeCommentAdd}get CommentUpdated(){return V.CommentUpdated}get BeforeCommentUpdate(){return V.BeforeCommentUpdate}get CommentDeleted(){return V.CommentDeleted}get BeforeCommentDelete(){return V.BeforeCommentDelete}get CommentResolved(){return V.CommentResolved}get BeforeCommentResolve(){return V.BeforeCommentResolve}};E.extend(H);var U=class extends D{_getTargetSheet(e={}){var t;let n=e.unitId?this.getUniverSheet(e.unitId):(t=this.getActiveWorkbook)==null?void 0:t.call(this);if(!n)return null;let r=e.subUnitId?n.getSheetBySheetId(e.subUnitId):n.getActiveSheet();return r?{workbook:n,worksheet:r}:null}_initialize(n){let r=n.get(t);this.disposeWithMe(this.registerEventHandler(this.Event.CommentAdded,()=>r.onCommandExecuted(e=>{if(e.id!==_.id)return;let t=this._getTargetSheet(e.params);if(!t)return;let{workbook:n,worksheet:r}=t,{comment:i}=e.params,a=r.getCommentById(i.id);if(a){var o,s,c,l;this.fireEvent(this.Event.CommentAdded,{workbook:n,worksheet:r,row:(o=(s=a.getRange())==null?void 0:s.getRow())==null?0:o,col:(c=(l=a.getRange())==null?void 0:l.getColumn())==null?0:c,comment:a})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentUpdated,()=>r.onCommandExecuted(e=>{if(e.id!==S.id)return;let t=this._getTargetSheet(e.params);if(!t)return;let{workbook:n,worksheet:r}=t,{payload:i}=e.params,a=r.getCommentById(i.commentId);if(a){var o,s,c,l;this.fireEvent(this.Event.CommentUpdated,{workbook:n,worksheet:r,row:(o=(s=a.getRange())==null?void 0:s.getRow())==null?0:o,col:(c=(l=a.getRange())==null?void 0:l.getColumn())==null?0:c,comment:a})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentDeleted,()=>r.onCommandExecuted(e=>{if(e.id!==v.id&&e.id!==y.id)return;let t=this._getTargetSheet(e.params);if(!t)return;let{workbook:n,worksheet:r}=t,{commentId:i}=e.params;this.fireEvent(this.Event.CommentDeleted,{workbook:n,worksheet:r,commentId:i})}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentResolved,()=>r.onCommandExecuted(e=>{if(e.id!==b.id)return;let t=this._getTargetSheet(e.params);if(!t)return;let{workbook:n,worksheet:r}=t,{commentId:i,resolved:a}=e.params,o=r.getCommentById(i);if(o){var s,c,l,u;this.fireEvent(this.Event.CommentResolved,{workbook:n,worksheet:r,row:(s=(c=o.getRange())==null?void 0:c.getRow())==null?0:s,col:(l=(u=o.getRange())==null?void 0:u.getColumn())==null?0:l,comment:o,resolved:a})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentAdd,()=>r.beforeCommandExecuted(t=>{if(t.id!==_.id)return;let n=this._getTargetSheet(t.params);if(!n)return;let{workbook:r,worksheet:i}=n,{comment:a}=t.params,{range:o}=w(a.ref),s={workbook:r,worksheet:i,row:o.startRow,col:o.startColumn,comment:F.create(a)};if(this.fireEvent(this.Event.BeforeCommentAdd,s),s.cancel)throw new e}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>r.beforeCommandExecuted(t=>{if(t.id!==S.id)return;let n=this._getTargetSheet(t.params);if(!n)return;let{workbook:r,worksheet:i}=n,{payload:a}=t.params,o=i.getCommentById(a.commentId);if(o){var c,l,u,d;let t={workbook:r,worksheet:i,row:(c=(l=o.getRange())==null?void 0:l.getRow())==null?0:c,col:(u=(d=o.getRange())==null?void 0:d.getColumn())==null?0:u,comment:o,newContent:s.createByBody(a.text)};if(this.fireEvent(this.Event.BeforeCommentUpdate,t),t.cancel)throw new e}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentDelete,()=>r.beforeCommandExecuted(t=>{if(t.id!==v.id&&t.id!==y.id)return;let n=this._getTargetSheet(t.params);if(!n)return;let{workbook:r,worksheet:i}=n,{commentId:a}=t.params,o=i.getCommentById(a);if(o){var s,c,l,u;let t={workbook:r,worksheet:i,row:(s=(c=o.getRange())==null?void 0:c.getRow())==null?0:s,col:(l=(u=o.getRange())==null?void 0:u.getColumn())==null?0:l,comment:o};if(this.fireEvent(this.Event.BeforeCommentDelete,t),t.cancel)throw new e}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentResolve,()=>r.beforeCommandExecuted(t=>{if(t.id!==b.id)return;let n=this._getTargetSheet(t.params);if(!n)return;let{workbook:r,worksheet:i}=n,{commentId:a,resolved:o}=t.params,s=i.getCommentById(a);if(s){var c,l;let t={workbook:r,worksheet:i,row:(c=s.getRange().getRow())==null?0:c,col:(l=s.getRange().getColumn())==null?0:l,comment:s,resolved:o};if(this.fireEvent(this.Event.BeforeCommentResolve,t),t.cancel)throw new e}})))}newTheadComment(e){return new I(e)}};D.extend(U);export{L as FThreadComment};