@univerjs/sheets-thread-comment 0.5.3 → 0.5.4

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,26 +1,231 @@
1
- import { Inject as l, Injector as x, UniverInstanceType as T, ICommandService as h, IUniverInstanceService as j, UserManagerService as R, Tools as p, toDisposable as m } from "@univerjs/core";
2
- import { SheetsThreadCommentModel as c } from "@univerjs/sheets-thread-comment";
3
- import { FRange as u, FWorkbook as f, FWorksheet as b } from "@univerjs/sheets/facade";
4
- import { DeleteCommentTreeCommand as _, DeleteCommentCommand as U, getDT as v, UpdateCommentCommand as S, ResolveCommentCommand as M, AddCommentCommand as I, ThreadCommentModel as D } from "@univerjs/thread-comment";
5
- import { deserializeRangeWithSheet as E } from "@univerjs/engine-formula";
6
- import { filter as y } from "rxjs";
7
- var B = Object.defineProperty, F = Object.getOwnPropertyDescriptor, P = (o, t, e, n) => {
8
- for (var r = n > 1 ? void 0 : n ? F(t, e) : t, i = o.length - 1, s; i >= 0; i--)
9
- (s = o[i]) && (r = (n ? s(t, e, r) : s(r)) || r);
10
- return n && r && B(t, e, r), r;
11
- }, a = (o, t) => (e, n) => t(e, n, o);
12
- let d = class {
13
- constructor(o, t, e, n, r, i) {
14
- this._thread = o, this._parent = t, this._injector = e, this._commandService = n, this._univerInstanceService = r, this._threadCommentModel = i;
1
+ var E = Object.defineProperty;
2
+ var P = (r, e, t) => e in r ? E(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var y = (r, e, t) => P(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Inject as v, Injector as F, UserManagerService as S, UniverInstanceType as W, RichTextValue as l, generateRandomId as g, ICommandService as p, IUniverInstanceService as O, RichTextBuilder as $, Tools as B, Range as z, toDisposable as I, FEventName as R } from "@univerjs/core";
5
+ import { SheetsThreadCommentModel as h } from "@univerjs/sheets-thread-comment";
6
+ import { FRange as x, FWorkbook as j, FWorksheet as D } from "@univerjs/sheets/facade";
7
+ import { DeleteCommentTreeCommand as T, DeleteCommentCommand as A, getDT as f, UpdateCommentCommand as M, ResolveCommentCommand as L, AddCommentCommand as b, ThreadCommentModel as N } from "@univerjs/thread-comment";
8
+ import { deserializeRangeWithSheet as V } from "@univerjs/engine-formula";
9
+ import { filter as H } from "rxjs";
10
+ var q = Object.defineProperty, G = Object.getOwnPropertyDescriptor, J = (r, e, t, n) => {
11
+ for (var o = n > 1 ? void 0 : n ? G(e, t) : e, m = r.length - 1, s; m >= 0; m--)
12
+ (s = r[m]) && (o = (n ? s(e, t, o) : s(o)) || o);
13
+ return n && o && q(e, t, o), o;
14
+ }, a = (r, e) => (t, n) => e(t, n, r);
15
+ class k {
16
+ constructor(e) {
17
+ y(this, "_comment", {
18
+ id: g(),
19
+ ref: "",
20
+ threadId: "",
21
+ dT: "",
22
+ personId: "",
23
+ text: $.newEmptyData().body,
24
+ attachments: [],
25
+ unitId: "",
26
+ subUnitId: ""
27
+ });
28
+ e && (this._comment = e);
29
+ }
30
+ /**
31
+ * Create a new FTheadCommentItem
32
+ * @param {IThreadComment|undefined} comment The comment
33
+ * @returns {FTheadCommentItem} A new instance of FTheadCommentItem
34
+ * @example
35
+ * ```ts
36
+ * const comment = univerAPI.newTheadComment();
37
+ * ```
38
+ */
39
+ static create(e) {
40
+ return new k(e);
41
+ }
42
+ /**
43
+ * Get the person id of the comment
44
+ * @returns {string} The person id of the comment
45
+ * @example
46
+ * ```ts
47
+ * const comment = univerAPI.getActiveWorkbook()
48
+ * .getSheetById(sheetId)
49
+ * .getCommentById(commentId);
50
+ * const personId = comment.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 comment = univerAPI.getActiveWorkbook()
62
+ * .getSheetById(sheetId)
63
+ * .getCommentById(commentId);
64
+ * const dateTime = comment.dateTime;
65
+ * ```
66
+ */
67
+ get dateTime() {
68
+ return this._comment.dT;
69
+ }
70
+ /**
71
+ * Get the content of the comment
72
+ * @returns {RichTextValue} The content of the comment
73
+ * @example
74
+ * ```ts
75
+ * const comment = univerAPI.getActiveWorkbook()
76
+ * .getSheetById(sheetId)
77
+ * .getCommentById(commentId);
78
+ * const content = comment.content;
79
+ * ```
80
+ */
81
+ get content() {
82
+ return l.createByBody(this._comment.text);
83
+ }
84
+ /**
85
+ * Get the id of the comment
86
+ * @returns {string} The id of the comment
87
+ * @example
88
+ * ```ts
89
+ * const comment = univerAPI.getActiveWorkbook()
90
+ * .getSheetById(sheetId)
91
+ * .getCommentById(commentId);
92
+ * const id = comment.id;
93
+ * ```
94
+ */
95
+ get id() {
96
+ return this._comment.id;
97
+ }
98
+ /**
99
+ * Get the thread id of the comment
100
+ * @returns {string} The thread id of the comment
101
+ * @example
102
+ * ```ts
103
+ * const comment = univerAPI.getActiveWorkbook()
104
+ * .getSheetById(sheetId)
105
+ * .getCommentById(commentId);
106
+ * const threadId = comment.threadId;
107
+ * ```
108
+ */
109
+ get threadId() {
110
+ return this._comment.threadId;
111
+ }
112
+ /**
113
+ * Copy the comment
114
+ * @returns {FTheadCommentBuilder} The comment builder
115
+ * @example
116
+ * ```ts
117
+ * const comment = univerAPI.getActiveWorkbook()
118
+ * .getSheetById(sheetId)
119
+ * .getCommentById(commentId);
120
+ * const newComment = comment.copy();
121
+ * ```
122
+ */
123
+ copy() {
124
+ return U.create(B.deepClone(this._comment));
125
+ }
126
+ }
127
+ class U extends k {
128
+ static create(e) {
129
+ return new U(e);
130
+ }
131
+ /**
132
+ * Set the content of the comment
133
+ * @param {IDocumentBody | RichTextValue} content The content of the comment
134
+ * @returns {FTheadCommentBuilder} The comment builder
135
+ * @example
136
+ * ```ts
137
+ * const comment = univerAPI.newTheadComment()
138
+ * .setContent(univerAPI.newRichText().insertText('hello zhangsan'));
139
+ * ```
140
+ */
141
+ setContent(e) {
142
+ return e instanceof l ? this._comment.text = e.getData().body : this._comment.text = e, this;
143
+ }
144
+ /**
145
+ * Set the person id of the comment
146
+ * @param {string} userId The person id of the comment
147
+ * @returns {FTheadCommentBuilder} The comment builder
148
+ * @example
149
+ * ```ts
150
+ * const comment = univerAPI.newTheadComment()
151
+ * .setPersonId('123');
152
+ * ```
153
+ */
154
+ setPersonId(e) {
155
+ return this._comment.personId = e, this;
156
+ }
157
+ /**
158
+ * Set the date time of the comment
159
+ * @param {Date} date The date time of the comment
160
+ * @returns {FTheadCommentBuilder} The comment builder
161
+ * @example
162
+ * ```ts
163
+ * const comment = univerAPI.newTheadComment()
164
+ * .setDateTime(new Date());
165
+ * ```
166
+ */
167
+ setDateTime(e) {
168
+ return this._comment.dT = f(e), this;
169
+ }
170
+ /**
171
+ * Set the id of the comment
172
+ * @param {string} id The id of the comment
173
+ * @returns {FTheadCommentBuilder} The comment builder
174
+ * @example
175
+ * ```ts
176
+ * const comment = univerAPI.newTheadComment()
177
+ * .setId('123');
178
+ * ```
179
+ */
180
+ setId(e) {
181
+ return this._comment.id = e, this;
182
+ }
183
+ /**
184
+ * Set the thread id of the comment
185
+ * @param {string} threadId The thread id of the comment
186
+ * @returns {FTheadCommentBuilder} The comment builder
187
+ * @example
188
+ * ```ts
189
+ * const comment = univerAPI.newTheadComment()
190
+ * .setThreadId('123');
191
+ * ```
192
+ */
193
+ setThreadId(e) {
194
+ return this._comment.threadId = e, this;
195
+ }
196
+ /**
197
+ * Build the comment
198
+ * @returns {IThreadComment} The comment
199
+ * @example
200
+ * ```ts
201
+ * const comment = univerAPI.newTheadComment()
202
+ * .setContent(univerAPI.newRichText().insertText('hello zhangsan'))
203
+ * .build();
204
+ * ```
205
+ */
206
+ build() {
207
+ return this._comment;
208
+ }
209
+ }
210
+ let i = class {
211
+ constructor(r, e, t, n, o, m, s) {
212
+ this._thread = r, this._parent = e, this._injector = t, this._commandService = n, this._univerInstanceService = o, this._threadCommentModel = m, this._userManagerService = s;
15
213
  }
16
214
  _getRef() {
17
- var e;
18
- const o = ((e = this._parent) == null ? void 0 : e.ref) || this._thread.ref;
19
- return E(o).range;
215
+ var t;
216
+ const r = ((t = this._parent) == null ? void 0 : t.ref) || this._thread.ref;
217
+ return V(r).range;
20
218
  }
21
219
  /**
22
220
  * Whether the comment is a root comment
23
221
  * @returns Whether the comment is a root comment
222
+ * @example
223
+ * ```ts
224
+ * const comment = univerAPI.getActiveWorkbook()
225
+ * .getSheetById(sheetId)
226
+ * .getCommentById(commentId);
227
+ * const isRoot = comment.getIsRoot();
228
+ * ```
24
229
  */
25
230
  getIsRoot() {
26
231
  return !this._parent;
@@ -28,48 +233,90 @@ let d = class {
28
233
  /**
29
234
  * Get the comment data
30
235
  * @returns The comment data
236
+ * @example
237
+ * ```ts
238
+ * const comment = univerAPI.getActiveWorkbook()
239
+ * .getSheetById(sheetId)
240
+ * .getCommentById(commentId);
241
+ * const commentData = comment.getCommentData();
242
+ * ```
31
243
  */
32
244
  getCommentData() {
33
- const { children: o, ...t } = this._thread;
34
- return t;
245
+ const { children: r, ...e } = this._thread;
246
+ return e;
35
247
  }
36
248
  /**
37
249
  * Get the replies of the comment
38
250
  * @returns the replies of the comment
251
+ * @example
252
+ * ```ts
253
+ * const comment = univerAPI.getActiveWorkbook()
254
+ * .getSheetById(sheetId)
255
+ * .getCommentById(commentId);
256
+ * const replies = comment.getReplies();
257
+ * ```
39
258
  */
40
259
  getReplies() {
41
- var e;
42
- const o = this._getRef(), t = this._threadCommentModel.getCommentWithChildren(this._thread.unitId, this._thread.subUnitId, o.startRow, o.startColumn);
43
- return (e = t == null ? void 0 : t.children) == null ? void 0 : e.map((n) => this._injector.createInstance(d, n));
260
+ var t;
261
+ const r = this._getRef(), e = this._threadCommentModel.getCommentWithChildren(this._thread.unitId, this._thread.subUnitId, r.startRow, r.startColumn);
262
+ return (t = e == null ? void 0 : e.children) == null ? void 0 : t.map((n) => this._injector.createInstance(i, n));
44
263
  }
45
264
  /**
46
265
  * Get the range of the comment
47
266
  * @returns The range of the comment
267
+ * @example
268
+ * ```ts
269
+ * const comment = univerAPI.getActiveWorkbook()
270
+ * .getSheetById(sheetId)
271
+ * .getCommentById(commentId);
272
+ * const range = comment.getRange();
273
+ * ```
48
274
  */
49
275
  getRange() {
50
- const o = this._univerInstanceService.getUnit(this._thread.unitId, T.UNIVER_SHEET);
51
- if (!o)
276
+ const r = this._univerInstanceService.getUnit(this._thread.unitId, W.UNIVER_SHEET);
277
+ if (!r)
52
278
  return null;
53
- const t = o.getSheetBySheetId(this._thread.subUnitId);
54
- if (!t)
279
+ const e = r.getSheetBySheetId(this._thread.subUnitId);
280
+ if (!e)
55
281
  return null;
56
- const e = this._getRef();
57
- return this._injector.createInstance(u, o, t, e);
282
+ const t = this._getRef();
283
+ return this._injector.createInstance(x, r, e, t);
58
284
  }
59
285
  /**
60
- * Get the content of the comment
61
- * @returns The content of the comment
286
+ * @deprecated use `getRichText` as instead
62
287
  */
63
288
  getContent() {
64
289
  return this._thread.text;
65
290
  }
291
+ /**
292
+ * Get the rich text of the comment
293
+ * @returns {RichTextValue} The rich text of the comment
294
+ * @example
295
+ * ```ts
296
+ * const comment = univerAPI.getActiveWorkbook()
297
+ * .getSheetById(sheetId)
298
+ * .getCommentById(commentId);
299
+ * const richText = comment.getRichText();
300
+ * ```
301
+ */
302
+ getRichText() {
303
+ const r = this._thread.text;
304
+ return l.create({ body: r, documentStyle: {}, id: "d" });
305
+ }
66
306
  /**
67
307
  * Delete the comment and it's replies
68
- * @returns success or not
308
+ * @returns {Promise<boolean>} success or not
309
+ * @example
310
+ * ```ts
311
+ * const comment = univerAPI.getActiveWorkbook()
312
+ * .getSheetById(sheetId)
313
+ * .getCommentById(commentId);
314
+ * const success = await comment.deleteAsync();
315
+ * ```
69
316
  */
70
- delete() {
317
+ deleteAsync() {
71
318
  return this._commandService.executeCommand(
72
- this.getIsRoot() ? _.id : U.id,
319
+ this.getIsRoot() ? T.id : A.id,
73
320
  {
74
321
  commentId: this._thread.id,
75
322
  unitId: this._thread.unitId,
@@ -77,154 +324,307 @@ let d = class {
77
324
  }
78
325
  );
79
326
  }
327
+ /**
328
+ * @deprecated use `deleteAsync` as instead.
329
+ */
330
+ delete() {
331
+ return this.deleteAsync();
332
+ }
333
+ /**
334
+ * @param content
335
+ * @deprecated use `updateAsync` as instead
336
+ */
337
+ async update(r) {
338
+ return this.updateAsync(r);
339
+ }
80
340
  /**
81
341
  * Update the comment content
82
342
  * @param content The new content of the comment
83
343
  * @returns success or not
344
+ * @example
345
+ * ```ts
346
+ * const comment = univerAPI.getActiveWorkbook()
347
+ * .getSheetById(sheetId)
348
+ * .getCommentById(commentId);
349
+ * const success = await comment.updateAsync(univerAPI.newRichText().insertText('hello zhangsan'));
350
+ * ```
84
351
  */
85
- async update(o) {
86
- const t = v();
352
+ async updateAsync(r) {
353
+ const e = r instanceof l ? r.getData().body : r, t = f();
87
354
  return await this._commandService.executeCommand(
88
- S.id,
355
+ M.id,
89
356
  {
90
357
  unitId: this._thread.unitId,
91
358
  subUnitId: this._thread.subUnitId,
92
359
  payload: {
93
360
  commentId: this._thread.id,
94
- text: o,
361
+ text: e,
95
362
  updated: !0,
96
363
  updateT: t
97
364
  }
98
365
  }
99
366
  );
100
367
  }
368
+ /**
369
+ * @param resolved
370
+ * @deprecated use `resolveAsync` as instead
371
+ */
372
+ resolve(r) {
373
+ return this.resolveAsync(r);
374
+ }
101
375
  /**
102
376
  * Resolve the comment
103
377
  * @param resolved Whether the comment is resolved
104
378
  * @returns success or not
379
+ * @example
380
+ * ```ts
381
+ * const comment = univerAPI.getActiveWorkbook()
382
+ * .getSheetById(sheetId)
383
+ * .getCommentById(commentId);
384
+ * const success = await comment.resolveAsync(true);
385
+ * ```
105
386
  */
106
- resolve(o) {
387
+ resolveAsync(r) {
107
388
  return this._commandService.executeCommand(
108
- M.id,
389
+ L.id,
109
390
  {
110
391
  unitId: this._thread.unitId,
111
392
  subUnitId: this._thread.subUnitId,
112
393
  commentId: this._thread.id,
113
- resolved: o != null ? o : !this._thread.resolved
394
+ resolved: r != null ? r : !this._thread.resolved
395
+ }
396
+ );
397
+ }
398
+ /**
399
+ * Reply to the comment
400
+ * @param comment The comment to reply to
401
+ * @returns success or not
402
+ * @example
403
+ * ```ts
404
+ * const comment = univerAPI.getActiveWorkbook()
405
+ * .getSheetById(sheetId)
406
+ * .getCommentById(commentId);
407
+ *
408
+ * const reply = univerAPI.newTheadComment()
409
+ * .setContent(univerAPI.newRichText().insertText('hello zhangsan'));
410
+ *
411
+ * const success = await comment.replyAsync(reply);
412
+ * ```
413
+ */
414
+ async replyAsync(r) {
415
+ var t;
416
+ const e = r.build();
417
+ return this._commandService.executeCommand(
418
+ b.id,
419
+ {
420
+ unitId: this._thread.unitId,
421
+ subUnitId: this._thread.subUnitId,
422
+ comment: {
423
+ id: g(),
424
+ parentId: this._thread.id,
425
+ threadId: this._thread.threadId,
426
+ ref: (t = this._parent) == null ? void 0 : t.ref,
427
+ unitId: this._thread.unitId,
428
+ subUnitId: this._thread.subUnitId,
429
+ text: e.text,
430
+ attachments: e.attachments,
431
+ dT: e.dT || f(),
432
+ personId: e.personId || this._userManagerService.getCurrentUser().userID
433
+ }
114
434
  }
115
435
  );
116
436
  }
117
437
  };
118
- d = P([
119
- a(2, l(x)),
120
- a(3, h),
121
- a(4, j),
122
- a(5, l(c))
123
- ], d);
124
- class A extends u {
438
+ i = J([
439
+ a(2, v(F)),
440
+ a(3, p),
441
+ a(4, O),
442
+ a(5, v(h)),
443
+ a(6, v(S))
444
+ ], i);
445
+ class K extends x {
125
446
  getComment() {
126
- const e = this._injector.get(c), n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = e.getByLocation(n, r, this._range.startRow, this._range.startColumn);
127
- if (!i)
447
+ const t = this._injector.get(h), n = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), m = t.getByLocation(n, o, this._range.startRow, this._range.startColumn);
448
+ if (!m)
128
449
  return null;
129
- const s = e.getComment(n, r, i);
130
- return s ? this._injector.createInstance(d, s) : null;
450
+ const s = t.getComment(n, o, m);
451
+ return s ? this._injector.createInstance(i, s) : null;
452
+ }
453
+ getComments() {
454
+ const t = this._injector.get(h), n = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), m = [];
455
+ return z.foreach(this._range, (s, c) => {
456
+ const u = t.getByLocation(n, o, s, c);
457
+ if (u) {
458
+ const C = t.getComment(n, o, u);
459
+ C && m.push(this._injector.createInstance(i, C));
460
+ }
461
+ }), m;
131
462
  }
132
- addComment(t) {
133
- var g;
134
- const e = this._injector, n = (g = this.getComment()) == null ? void 0 : g.getCommentData(), r = e.get(h), i = e.get(R), s = this._workbook.getUnitId(), C = this._worksheet.getSheetId(), k = `${p.chatAtABC(this._range.startColumn)}${this._range.startRow + 1}`, w = i.getCurrentUser();
135
- return r.executeCommand(I.id, {
463
+ addComment(e) {
464
+ var w;
465
+ const t = this._injector, n = (w = this.getComment()) == null ? void 0 : w.getCommentData(), o = t.get(p), m = t.get(S), s = this._workbook.getUnitId(), c = this._worksheet.getSheetId(), u = `${B.chatAtABC(this._range.startColumn)}${this._range.startRow + 1}`, C = m.getCurrentUser(), _ = e instanceof U ? e.build() : { text: e };
466
+ return o.executeCommand(b.id, {
136
467
  unitId: s,
137
- subUnitId: C,
468
+ subUnitId: c,
138
469
  comment: {
139
- text: t,
470
+ text: _.text,
471
+ dT: _.dT || f(),
140
472
  attachments: [],
141
- dT: v(),
142
- id: p.generateRandomId(),
143
- ref: k,
144
- personId: w.userID,
473
+ id: _.id || g(),
474
+ ref: u,
475
+ personId: _.personId || C.userID,
145
476
  parentId: n == null ? void 0 : n.id,
146
477
  unitId: s,
147
- subUnitId: C,
148
- threadId: n == null ? void 0 : n.threadId
478
+ subUnitId: c,
479
+ threadId: (n == null ? void 0 : n.threadId) || g()
149
480
  }
150
481
  });
151
482
  }
152
483
  clearComment() {
153
484
  var s;
154
- const t = this._injector, e = (s = this.getComment()) == null ? void 0 : s.getCommentData(), n = t.get(h), r = this._workbook.getUnitId(), i = this._worksheet.getSheetId();
155
- return e ? n.executeCommand(_.id, {
156
- unitId: r,
157
- subUnitId: i,
158
- threadId: e.threadId,
159
- commentId: e.id
485
+ const e = this._injector, t = (s = this.getComment()) == null ? void 0 : s.getCommentData(), n = e.get(p), o = this._workbook.getUnitId(), m = this._worksheet.getSheetId();
486
+ return t ? n.executeCommand(T.id, {
487
+ unitId: o,
488
+ subUnitId: m,
489
+ threadId: t.threadId,
490
+ commentId: t.id
160
491
  }) : Promise.resolve(!0);
161
492
  }
493
+ clearComments() {
494
+ const t = this.getComments().map((n) => n.deleteAsync());
495
+ return Promise.all(t).then(() => !0);
496
+ }
162
497
  }
163
- u.extend(A);
164
- class W extends f {
498
+ x.extend(K);
499
+ class Q extends j {
165
500
  _initialize() {
166
501
  Object.defineProperty(this, "_threadCommentModel", {
167
502
  get() {
168
- return this._injector.get(D);
503
+ return this._injector.get(N);
169
504
  }
170
505
  });
171
506
  }
172
- onThreadCommentChange(t) {
173
- return m(this._threadCommentModel.commentUpdate$.pipe(y((e) => e.unitId === this._workbook.getUnitId())).subscribe(t));
507
+ getComments() {
508
+ return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map((e) => this._injector.createInstance(i, e.root));
509
+ }
510
+ clearComments() {
511
+ const t = this.getComments().map((n) => n.deleteAsync());
512
+ return Promise.all(t).then(() => !0);
513
+ }
514
+ /**
515
+ * @deprecated
516
+ */
517
+ onThreadCommentChange(e) {
518
+ return I(this._threadCommentModel.commentUpdate$.pipe(H((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
174
519
  }
175
- onBeforeAddThreadComment(t) {
176
- return m(this._commandService.beforeCommandExecuted((e, n) => {
177
- const r = e.params;
178
- if (e.id === I.id) {
179
- if (r.unitId !== this._workbook.getUnitId())
520
+ /**
521
+ * @deprecated
522
+ */
523
+ onBeforeAddThreadComment(e) {
524
+ return I(this._commandService.beforeCommandExecuted((t, n) => {
525
+ const o = t.params;
526
+ if (t.id === b.id) {
527
+ if (o.unitId !== this._workbook.getUnitId())
180
528
  return;
181
- if (t(r, n) === !1)
529
+ if (e(o, n) === !1)
182
530
  throw new Error("Command is stopped by the hook onBeforeAddThreadComment");
183
531
  }
184
532
  }));
185
533
  }
186
- onBeforeUpdateThreadComment(t) {
187
- return m(this._commandService.beforeCommandExecuted((e, n) => {
188
- const r = e.params;
189
- if (e.id === S.id) {
190
- if (r.unitId !== this._workbook.getUnitId())
534
+ /**
535
+ * @deprecated
536
+ */
537
+ onBeforeUpdateThreadComment(e) {
538
+ return I(this._commandService.beforeCommandExecuted((t, n) => {
539
+ const o = t.params;
540
+ if (t.id === M.id) {
541
+ if (o.unitId !== this._workbook.getUnitId())
191
542
  return;
192
- if (t(r, n) === !1)
543
+ if (e(o, n) === !1)
193
544
  throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment");
194
545
  }
195
546
  }));
196
547
  }
197
- onBeforeDeleteThreadComment(t) {
198
- return m(this._commandService.beforeCommandExecuted((e, n) => {
199
- const r = e.params;
200
- if (e.id === U.id || e.id === _.id) {
201
- if (r.unitId !== this._workbook.getUnitId())
548
+ /**
549
+ * @deprecated
550
+ */
551
+ onBeforeDeleteThreadComment(e) {
552
+ return I(this._commandService.beforeCommandExecuted((t, n) => {
553
+ const o = t.params;
554
+ if (t.id === A.id || t.id === T.id) {
555
+ if (o.unitId !== this._workbook.getUnitId())
202
556
  return;
203
- if (t(r, n) === !1)
557
+ if (e(o, n) === !1)
204
558
  throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment");
205
559
  }
206
560
  }));
207
561
  }
208
562
  }
209
- f.extend(W);
210
- class O extends b {
563
+ j.extend(Q);
564
+ class X extends D {
211
565
  getComments() {
212
- return this._injector.get(c).getSubUnitAll(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((n) => this._injector.createInstance(d, n));
566
+ return this._injector.get(h).getSubUnitAll(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((n) => this._injector.createInstance(i, n));
567
+ }
568
+ clearComments() {
569
+ const t = this.getComments().map((n) => n.deleteAsync());
570
+ return Promise.all(t).then(() => !0);
213
571
  }
214
572
  /**
215
573
  * Subscribe to comment events.
216
574
  * @param callback Callback function, param contains comment info and target cell.
217
575
  */
218
- onCommented(t) {
219
- return this._injector.get(h).onCommandExecuted((n) => {
220
- if (n.id === I.id) {
221
- const r = n.params;
222
- t(r);
576
+ onCommented(e) {
577
+ return this._injector.get(p).onCommandExecuted((n) => {
578
+ if (n.id === b.id) {
579
+ const o = n.params;
580
+ e(o);
223
581
  }
224
582
  });
225
583
  }
584
+ getCommentById(e) {
585
+ const n = this._injector.get(h).getComment(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
586
+ if (n)
587
+ return this._injector.createInstance(i, n);
588
+ }
589
+ }
590
+ D.extend(X);
591
+ const d = {
592
+ CommentAdded: "CommentAdded",
593
+ BeforeCommentAdd: "BeforeCommentAdd",
594
+ CommentUpdated: "CommentUpdated",
595
+ BeforeCommentUpdate: "BeforeCommentUpdate",
596
+ CommentDeleted: "CommentDeleted",
597
+ BeforeCommentDeleted: "BeforeCommentDeleted",
598
+ CommentResolved: "CommentResolved",
599
+ BeforeCommentResolve: "BeforeCommentResolve"
600
+ };
601
+ class Y extends R {
602
+ get CommentAdded() {
603
+ return d.CommentAdded;
604
+ }
605
+ get BeforeCommentAdd() {
606
+ return d.BeforeCommentAdd;
607
+ }
608
+ get CommentUpdated() {
609
+ return d.CommentUpdated;
610
+ }
611
+ get BeforeCommentUpdate() {
612
+ return d.BeforeCommentUpdate;
613
+ }
614
+ get CommentDeleted() {
615
+ return d.CommentDeleted;
616
+ }
617
+ get BeforeCommentDeleted() {
618
+ return d.BeforeCommentDeleted;
619
+ }
620
+ get CommentResolved() {
621
+ return d.CommentResolved;
622
+ }
623
+ get BeforeCommentResolve() {
624
+ return d.BeforeCommentResolve;
625
+ }
226
626
  }
227
- b.extend(O);
627
+ R.extend(Y);
228
628
  export {
229
- d as FThreadComment
629
+ i as FThreadComment
230
630
  };