@univerjs/sheets-thread-comment 0.5.4 → 0.5.5-experimental.20250122-3362a4a

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,31 +1,32 @@
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(),
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
+ import { Inject, Injector, UserManagerService, UniverInstanceType, RichTextValue, generateRandomId, ICommandService, IUniverInstanceService, RichTextBuilder, Tools, Range, toDisposable, FEventName } from "@univerjs/core";
6
+ import { SheetsThreadCommentModel } from "@univerjs/sheets-thread-comment";
7
+ import { FRange, FWorkbook, FWorksheet } from "@univerjs/sheets/facade";
8
+ import { DeleteCommentTreeCommand, DeleteCommentCommand, getDT, UpdateCommentCommand, ResolveCommentCommand, AddCommentCommand, ThreadCommentModel } from "@univerjs/thread-comment";
9
+ import { deserializeRangeWithSheet } from "@univerjs/engine-formula";
10
+ import { filter } from "rxjs";
11
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
12
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
13
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
14
+ return kind && result && __defProp2(target, key, result), result;
15
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
16
+ const _FTheadCommentItem = class _FTheadCommentItem {
17
+ constructor(comment) {
18
+ __publicField(this, "_comment", {
19
+ id: generateRandomId(),
19
20
  ref: "",
20
21
  threadId: "",
21
22
  dT: "",
22
23
  personId: "",
23
- text: $.newEmptyData().body,
24
+ text: RichTextBuilder.newEmptyData().body,
24
25
  attachments: [],
25
26
  unitId: "",
26
27
  subUnitId: ""
27
28
  });
28
- e && (this._comment = e);
29
+ comment && (this._comment = comment);
29
30
  }
30
31
  /**
31
32
  * Create a new FTheadCommentItem
@@ -36,8 +37,8 @@ class k {
36
37
  * const comment = univerAPI.newTheadComment();
37
38
  * ```
38
39
  */
39
- static create(e) {
40
- return new k(e);
40
+ static create(comment) {
41
+ return new _FTheadCommentItem(comment);
41
42
  }
42
43
  /**
43
44
  * Get the person id of the comment
@@ -79,7 +80,7 @@ class k {
79
80
  * ```
80
81
  */
81
82
  get content() {
82
- return l.createByBody(this._comment.text);
83
+ return RichTextValue.createByBody(this._comment.text);
83
84
  }
84
85
  /**
85
86
  * Get the id of the comment
@@ -121,12 +122,14 @@ class k {
121
122
  * ```
122
123
  */
123
124
  copy() {
124
- return U.create(B.deepClone(this._comment));
125
+ return FTheadCommentBuilder.create(Tools.deepClone(this._comment));
125
126
  }
126
- }
127
- class U extends k {
128
- static create(e) {
129
- return new U(e);
127
+ };
128
+ __name(_FTheadCommentItem, "FTheadCommentItem");
129
+ let FTheadCommentItem = _FTheadCommentItem;
130
+ const _FTheadCommentBuilder = class _FTheadCommentBuilder extends FTheadCommentItem {
131
+ static create(comment) {
132
+ return new _FTheadCommentBuilder(comment);
130
133
  }
131
134
  /**
132
135
  * Set the content of the comment
@@ -138,8 +141,8 @@ class U extends k {
138
141
  * .setContent(univerAPI.newRichText().insertText('hello zhangsan'));
139
142
  * ```
140
143
  */
141
- setContent(e) {
142
- return e instanceof l ? this._comment.text = e.getData().body : this._comment.text = e, this;
144
+ setContent(content) {
145
+ return content instanceof RichTextValue ? this._comment.text = content.getData().body : this._comment.text = content, this;
143
146
  }
144
147
  /**
145
148
  * Set the person id of the comment
@@ -151,8 +154,8 @@ class U extends k {
151
154
  * .setPersonId('123');
152
155
  * ```
153
156
  */
154
- setPersonId(e) {
155
- return this._comment.personId = e, this;
157
+ setPersonId(userId) {
158
+ return this._comment.personId = userId, this;
156
159
  }
157
160
  /**
158
161
  * Set the date time of the comment
@@ -164,8 +167,8 @@ class U extends k {
164
167
  * .setDateTime(new Date());
165
168
  * ```
166
169
  */
167
- setDateTime(e) {
168
- return this._comment.dT = f(e), this;
170
+ setDateTime(date) {
171
+ return this._comment.dT = getDT(date), this;
169
172
  }
170
173
  /**
171
174
  * Set the id of the comment
@@ -177,8 +180,8 @@ class U extends k {
177
180
  * .setId('123');
178
181
  * ```
179
182
  */
180
- setId(e) {
181
- return this._comment.id = e, this;
183
+ setId(id) {
184
+ return this._comment.id = id, this;
182
185
  }
183
186
  /**
184
187
  * Set the thread id of the comment
@@ -190,8 +193,8 @@ class U extends k {
190
193
  * .setThreadId('123');
191
194
  * ```
192
195
  */
193
- setThreadId(e) {
194
- return this._comment.threadId = e, this;
196
+ setThreadId(threadId) {
197
+ return this._comment.threadId = threadId, this;
195
198
  }
196
199
  /**
197
200
  * Build the comment
@@ -206,15 +209,18 @@ class U extends k {
206
209
  build() {
207
210
  return this._comment;
208
211
  }
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;
212
+ };
213
+ __name(_FTheadCommentBuilder, "FTheadCommentBuilder");
214
+ let FTheadCommentBuilder = _FTheadCommentBuilder;
215
+ var _a;
216
+ let FThreadComment = (_a = class {
217
+ constructor(_thread, _parent, _injector, _commandService, _univerInstanceService, _threadCommentModel, _userManagerService) {
218
+ this._thread = _thread, this._parent = _parent, this._injector = _injector, this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._threadCommentModel = _threadCommentModel, this._userManagerService = _userManagerService;
213
219
  }
214
220
  _getRef() {
215
- var t;
216
- const r = ((t = this._parent) == null ? void 0 : t.ref) || this._thread.ref;
217
- return V(r).range;
221
+ var _a2;
222
+ const ref = ((_a2 = this._parent) == null ? void 0 : _a2.ref) || this._thread.ref;
223
+ return deserializeRangeWithSheet(ref).range;
218
224
  }
219
225
  /**
220
226
  * Whether the comment is a root comment
@@ -242,8 +248,8 @@ let i = class {
242
248
  * ```
243
249
  */
244
250
  getCommentData() {
245
- const { children: r, ...e } = this._thread;
246
- return e;
251
+ const { children, ...comment } = this._thread;
252
+ return comment;
247
253
  }
248
254
  /**
249
255
  * Get the replies of the comment
@@ -257,9 +263,9 @@ let i = class {
257
263
  * ```
258
264
  */
259
265
  getReplies() {
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));
266
+ var _a2;
267
+ const range = this._getRef(), comments = this._threadCommentModel.getCommentWithChildren(this._thread.unitId, this._thread.subUnitId, range.startRow, range.startColumn);
268
+ return (_a2 = comments == null ? void 0 : comments.children) == null ? void 0 : _a2.map((child) => this._injector.createInstance(FThreadComment, child));
263
269
  }
264
270
  /**
265
271
  * Get the range of the comment
@@ -273,14 +279,14 @@ let i = class {
273
279
  * ```
274
280
  */
275
281
  getRange() {
276
- const r = this._univerInstanceService.getUnit(this._thread.unitId, W.UNIVER_SHEET);
277
- if (!r)
282
+ const workbook = this._univerInstanceService.getUnit(this._thread.unitId, UniverInstanceType.UNIVER_SHEET);
283
+ if (!workbook)
278
284
  return null;
279
- const e = r.getSheetBySheetId(this._thread.subUnitId);
280
- if (!e)
285
+ const worksheet = workbook.getSheetBySheetId(this._thread.subUnitId);
286
+ if (!worksheet)
281
287
  return null;
282
- const t = this._getRef();
283
- return this._injector.createInstance(x, r, e, t);
288
+ const range = this._getRef();
289
+ return this._injector.createInstance(FRange, workbook, worksheet, range);
284
290
  }
285
291
  /**
286
292
  * @deprecated use `getRichText` as instead
@@ -300,8 +306,8 @@ let i = class {
300
306
  * ```
301
307
  */
302
308
  getRichText() {
303
- const r = this._thread.text;
304
- return l.create({ body: r, documentStyle: {}, id: "d" });
309
+ const body = this._thread.text;
310
+ return RichTextValue.create({ body, documentStyle: {}, id: "d" });
305
311
  }
306
312
  /**
307
313
  * Delete the comment and it's replies
@@ -316,7 +322,7 @@ let i = class {
316
322
  */
317
323
  deleteAsync() {
318
324
  return this._commandService.executeCommand(
319
- this.getIsRoot() ? T.id : A.id,
325
+ this.getIsRoot() ? DeleteCommentTreeCommand.id : DeleteCommentCommand.id,
320
326
  {
321
327
  commentId: this._thread.id,
322
328
  unitId: this._thread.unitId,
@@ -334,8 +340,8 @@ let i = class {
334
340
  * @param content
335
341
  * @deprecated use `updateAsync` as instead
336
342
  */
337
- async update(r) {
338
- return this.updateAsync(r);
343
+ async update(content) {
344
+ return this.updateAsync(content);
339
345
  }
340
346
  /**
341
347
  * Update the comment content
@@ -349,18 +355,18 @@ let i = class {
349
355
  * const success = await comment.updateAsync(univerAPI.newRichText().insertText('hello zhangsan'));
350
356
  * ```
351
357
  */
352
- async updateAsync(r) {
353
- const e = r instanceof l ? r.getData().body : r, t = f();
358
+ async updateAsync(content) {
359
+ const body = content instanceof RichTextValue ? content.getData().body : content, dt = getDT();
354
360
  return await this._commandService.executeCommand(
355
- M.id,
361
+ UpdateCommentCommand.id,
356
362
  {
357
363
  unitId: this._thread.unitId,
358
364
  subUnitId: this._thread.subUnitId,
359
365
  payload: {
360
366
  commentId: this._thread.id,
361
- text: e,
367
+ text: body,
362
368
  updated: !0,
363
- updateT: t
369
+ updateT: dt
364
370
  }
365
371
  }
366
372
  );
@@ -369,8 +375,8 @@ let i = class {
369
375
  * @param resolved
370
376
  * @deprecated use `resolveAsync` as instead
371
377
  */
372
- resolve(r) {
373
- return this.resolveAsync(r);
378
+ resolve(resolved) {
379
+ return this.resolveAsync(resolved);
374
380
  }
375
381
  /**
376
382
  * Resolve the comment
@@ -384,14 +390,14 @@ let i = class {
384
390
  * const success = await comment.resolveAsync(true);
385
391
  * ```
386
392
  */
387
- resolveAsync(r) {
393
+ resolveAsync(resolved) {
388
394
  return this._commandService.executeCommand(
389
- L.id,
395
+ ResolveCommentCommand.id,
390
396
  {
391
397
  unitId: this._thread.unitId,
392
398
  subUnitId: this._thread.subUnitId,
393
399
  commentId: this._thread.id,
394
- resolved: r != null ? r : !this._thread.resolved
400
+ resolved: resolved != null ? resolved : !this._thread.resolved
395
401
  }
396
402
  );
397
403
  }
@@ -411,184 +417,206 @@ let i = class {
411
417
  * const success = await comment.replyAsync(reply);
412
418
  * ```
413
419
  */
414
- async replyAsync(r) {
415
- var t;
416
- const e = r.build();
420
+ async replyAsync(comment) {
421
+ var _a2;
422
+ const commentData = comment.build();
417
423
  return this._commandService.executeCommand(
418
- b.id,
424
+ AddCommentCommand.id,
419
425
  {
420
426
  unitId: this._thread.unitId,
421
427
  subUnitId: this._thread.subUnitId,
422
428
  comment: {
423
- id: g(),
429
+ id: generateRandomId(),
424
430
  parentId: this._thread.id,
425
431
  threadId: this._thread.threadId,
426
- ref: (t = this._parent) == null ? void 0 : t.ref,
432
+ ref: (_a2 = this._parent) == null ? void 0 : _a2.ref,
427
433
  unitId: this._thread.unitId,
428
434
  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
435
+ text: commentData.text,
436
+ attachments: commentData.attachments,
437
+ dT: commentData.dT || getDT(),
438
+ personId: commentData.personId || this._userManagerService.getCurrentUser().userID
433
439
  }
434
440
  }
435
441
  );
436
442
  }
437
- };
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 {
443
+ }, __name(_a, "FThreadComment"), _a);
444
+ FThreadComment = __decorateClass([
445
+ __decorateParam(2, Inject(Injector)),
446
+ __decorateParam(3, ICommandService),
447
+ __decorateParam(4, IUniverInstanceService),
448
+ __decorateParam(5, Inject(SheetsThreadCommentModel)),
449
+ __decorateParam(6, Inject(UserManagerService))
450
+ ], FThreadComment);
451
+ const _FRangeCommentMixin = class _FRangeCommentMixin extends FRange {
446
452
  getComment() {
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)
453
+ const sheetsTheadCommentModel = this._injector.get(SheetsThreadCommentModel), unitId = this._workbook.getUnitId(), sheetId = this._worksheet.getSheetId(), commentId = sheetsTheadCommentModel.getByLocation(unitId, sheetId, this._range.startRow, this._range.startColumn);
454
+ if (!commentId)
449
455
  return null;
450
- const s = t.getComment(n, o, m);
451
- return s ? this._injector.createInstance(i, s) : null;
456
+ const comment = sheetsTheadCommentModel.getComment(unitId, sheetId, commentId);
457
+ return comment ? this._injector.createInstance(FThreadComment, comment) : null;
452
458
  }
453
459
  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
+ const sheetsTheadCommentModel = this._injector.get(SheetsThreadCommentModel), unitId = this._workbook.getUnitId(), sheetId = this._worksheet.getSheetId(), comments = [];
461
+ return Range.foreach(this._range, (row, col) => {
462
+ const commentId = sheetsTheadCommentModel.getByLocation(unitId, sheetId, row, col);
463
+ if (commentId) {
464
+ const comment = sheetsTheadCommentModel.getComment(unitId, sheetId, commentId);
465
+ comment && comments.push(this._injector.createInstance(FThreadComment, comment));
460
466
  }
461
- }), m;
462
- }
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, {
467
- unitId: s,
468
- subUnitId: c,
467
+ }), comments;
468
+ }
469
+ addComment(content) {
470
+ var _a2;
471
+ const injector = this._injector, currentComment = (_a2 = this.getComment()) == null ? void 0 : _a2.getCommentData(), commentService = injector.get(ICommandService), userService = injector.get(UserManagerService), unitId = this._workbook.getUnitId(), sheetId = this._worksheet.getSheetId(), refStr = `${Tools.chatAtABC(this._range.startColumn)}${this._range.startRow + 1}`, currentUser = userService.getCurrentUser(), commentData = content instanceof FTheadCommentBuilder ? content.build() : { text: content };
472
+ return commentService.executeCommand(AddCommentCommand.id, {
473
+ unitId,
474
+ subUnitId: sheetId,
469
475
  comment: {
470
- text: _.text,
471
- dT: _.dT || f(),
476
+ text: commentData.text,
477
+ dT: commentData.dT || getDT(),
472
478
  attachments: [],
473
- id: _.id || g(),
474
- ref: u,
475
- personId: _.personId || C.userID,
476
- parentId: n == null ? void 0 : n.id,
477
- unitId: s,
478
- subUnitId: c,
479
- threadId: (n == null ? void 0 : n.threadId) || g()
479
+ id: commentData.id || generateRandomId(),
480
+ ref: refStr,
481
+ personId: commentData.personId || currentUser.userID,
482
+ parentId: currentComment == null ? void 0 : currentComment.id,
483
+ unitId,
484
+ subUnitId: sheetId,
485
+ threadId: (currentComment == null ? void 0 : currentComment.threadId) || generateRandomId()
480
486
  }
481
487
  });
482
488
  }
483
489
  clearComment() {
484
- var s;
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
490
+ var _a2;
491
+ const injector = this._injector, currentComment = (_a2 = this.getComment()) == null ? void 0 : _a2.getCommentData(), commentService = injector.get(ICommandService), unitId = this._workbook.getUnitId(), sheetId = this._worksheet.getSheetId();
492
+ return currentComment ? commentService.executeCommand(DeleteCommentTreeCommand.id, {
493
+ unitId,
494
+ subUnitId: sheetId,
495
+ threadId: currentComment.threadId,
496
+ commentId: currentComment.id
491
497
  }) : Promise.resolve(!0);
492
498
  }
493
499
  clearComments() {
494
- const t = this.getComments().map((n) => n.deleteAsync());
495
- return Promise.all(t).then(() => !0);
500
+ const promises = this.getComments().map((comment) => comment.deleteAsync());
501
+ return Promise.all(promises).then(() => !0);
502
+ }
503
+ addCommentAsync(content) {
504
+ return this.addComment(content);
496
505
  }
497
- }
498
- x.extend(K);
499
- class Q extends j {
506
+ clearCommentAsync() {
507
+ return this.clearComment();
508
+ }
509
+ clearCommentsAsync() {
510
+ return this.clearComments();
511
+ }
512
+ };
513
+ __name(_FRangeCommentMixin, "FRangeCommentMixin");
514
+ let FRangeCommentMixin = _FRangeCommentMixin;
515
+ FRange.extend(FRangeCommentMixin);
516
+ const _FWorkbookThreadCommentMixin = class _FWorkbookThreadCommentMixin extends FWorkbook {
517
+ /**
518
+ * @ignore
519
+ */
500
520
  _initialize() {
501
521
  Object.defineProperty(this, "_threadCommentModel", {
502
522
  get() {
503
- return this._injector.get(N);
523
+ return this._injector.get(ThreadCommentModel);
504
524
  }
505
525
  });
506
526
  }
507
527
  getComments() {
508
- return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map((e) => this._injector.createInstance(i, e.root));
528
+ return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map((i) => this._injector.createInstance(FThreadComment, i.root));
509
529
  }
510
530
  clearComments() {
511
- const t = this.getComments().map((n) => n.deleteAsync());
512
- return Promise.all(t).then(() => !0);
531
+ const promises = this.getComments().map((comment) => comment.deleteAsync());
532
+ return Promise.all(promises).then(() => !0);
513
533
  }
514
534
  /**
535
+ * @param callback
515
536
  * @deprecated
516
537
  */
517
- onThreadCommentChange(e) {
518
- return I(this._threadCommentModel.commentUpdate$.pipe(H((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
538
+ onThreadCommentChange(callback) {
539
+ return toDisposable(this._threadCommentModel.commentUpdate$.pipe(filter((change) => change.unitId === this._workbook.getUnitId())).subscribe(callback));
519
540
  }
520
541
  /**
542
+ * @param callback
521
543
  * @deprecated
522
544
  */
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())
545
+ onBeforeAddThreadComment(callback) {
546
+ return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
547
+ const params = commandInfo.params;
548
+ if (commandInfo.id === AddCommentCommand.id) {
549
+ if (params.unitId !== this._workbook.getUnitId())
528
550
  return;
529
- if (e(o, n) === !1)
551
+ if (callback(params, options) === !1)
530
552
  throw new Error("Command is stopped by the hook onBeforeAddThreadComment");
531
553
  }
532
554
  }));
533
555
  }
534
556
  /**
557
+ * @param callback
535
558
  * @deprecated
536
559
  */
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())
560
+ onBeforeUpdateThreadComment(callback) {
561
+ return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
562
+ const params = commandInfo.params;
563
+ if (commandInfo.id === UpdateCommentCommand.id) {
564
+ if (params.unitId !== this._workbook.getUnitId())
542
565
  return;
543
- if (e(o, n) === !1)
566
+ if (callback(params, options) === !1)
544
567
  throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment");
545
568
  }
546
569
  }));
547
570
  }
548
571
  /**
572
+ * @param callback
549
573
  * @deprecated
550
574
  */
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())
575
+ onBeforeDeleteThreadComment(callback) {
576
+ return toDisposable(this._commandService.beforeCommandExecuted((commandInfo, options) => {
577
+ const params = commandInfo.params;
578
+ if (commandInfo.id === DeleteCommentCommand.id || commandInfo.id === DeleteCommentTreeCommand.id) {
579
+ if (params.unitId !== this._workbook.getUnitId())
556
580
  return;
557
- if (e(o, n) === !1)
581
+ if (callback(params, options) === !1)
558
582
  throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment");
559
583
  }
560
584
  }));
561
585
  }
562
- }
563
- j.extend(Q);
564
- class X extends D {
586
+ };
587
+ __name(_FWorkbookThreadCommentMixin, "FWorkbookThreadCommentMixin");
588
+ let FWorkbookThreadCommentMixin = _FWorkbookThreadCommentMixin;
589
+ FWorkbook.extend(FWorkbookThreadCommentMixin);
590
+ const _FWorksheetCommentMixin = class _FWorksheetCommentMixin extends FWorksheet {
565
591
  getComments() {
566
- return this._injector.get(h).getSubUnitAll(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((n) => this._injector.createInstance(i, n));
592
+ return this._injector.get(SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((comment) => this._injector.createInstance(FThreadComment, comment));
567
593
  }
568
594
  clearComments() {
569
- const t = this.getComments().map((n) => n.deleteAsync());
570
- return Promise.all(t).then(() => !0);
595
+ const promises = this.getComments().map((comment) => comment.deleteAsync());
596
+ return Promise.all(promises).then(() => !0);
571
597
  }
572
598
  /**
573
599
  * Subscribe to comment events.
574
600
  * @param callback Callback function, param contains comment info and target cell.
575
601
  */
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);
602
+ onCommented(callback) {
603
+ return this._injector.get(ICommandService).onCommandExecuted((command) => {
604
+ if (command.id === AddCommentCommand.id) {
605
+ const params = command.params;
606
+ callback(params);
581
607
  }
582
608
  });
583
609
  }
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);
610
+ getCommentById(commentId) {
611
+ const comment = this._injector.get(SheetsThreadCommentModel).getComment(this._workbook.getUnitId(), this._worksheet.getSheetId(), commentId);
612
+ if (comment)
613
+ return this._injector.createInstance(FThreadComment, comment);
588
614
  }
589
- }
590
- D.extend(X);
591
- const d = {
615
+ };
616
+ __name(_FWorksheetCommentMixin, "FWorksheetCommentMixin");
617
+ let FWorksheetCommentMixin = _FWorksheetCommentMixin;
618
+ FWorksheet.extend(FWorksheetCommentMixin);
619
+ const CommentEvent = {
592
620
  CommentAdded: "CommentAdded",
593
621
  BeforeCommentAdd: "BeforeCommentAdd",
594
622
  CommentUpdated: "CommentUpdated",
@@ -597,34 +625,35 @@ const d = {
597
625
  BeforeCommentDeleted: "BeforeCommentDeleted",
598
626
  CommentResolved: "CommentResolved",
599
627
  BeforeCommentResolve: "BeforeCommentResolve"
600
- };
601
- class Y extends R {
628
+ }, _FCommentEvent = class _FCommentEvent extends FEventName {
602
629
  get CommentAdded() {
603
- return d.CommentAdded;
630
+ return CommentEvent.CommentAdded;
604
631
  }
605
632
  get BeforeCommentAdd() {
606
- return d.BeforeCommentAdd;
633
+ return CommentEvent.BeforeCommentAdd;
607
634
  }
608
635
  get CommentUpdated() {
609
- return d.CommentUpdated;
636
+ return CommentEvent.CommentUpdated;
610
637
  }
611
638
  get BeforeCommentUpdate() {
612
- return d.BeforeCommentUpdate;
639
+ return CommentEvent.BeforeCommentUpdate;
613
640
  }
614
641
  get CommentDeleted() {
615
- return d.CommentDeleted;
642
+ return CommentEvent.CommentDeleted;
616
643
  }
617
644
  get BeforeCommentDeleted() {
618
- return d.BeforeCommentDeleted;
645
+ return CommentEvent.BeforeCommentDeleted;
619
646
  }
620
647
  get CommentResolved() {
621
- return d.CommentResolved;
648
+ return CommentEvent.CommentResolved;
622
649
  }
623
650
  get BeforeCommentResolve() {
624
- return d.BeforeCommentResolve;
651
+ return CommentEvent.BeforeCommentResolve;
625
652
  }
626
- }
627
- R.extend(Y);
653
+ };
654
+ __name(_FCommentEvent, "FCommentEvent");
655
+ let FCommentEvent = _FCommentEvent;
656
+ FEventName.extend(FCommentEvent);
628
657
  export {
629
- i as FThreadComment
658
+ FThreadComment
630
659
  };