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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/facade.js CHANGED
@@ -1,27 +1,27 @@
1
- var L = Object.defineProperty;
2
- var N = (i, e, r) => e in i ? L(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
3
- var M = (i, e, r) => N(i, typeof e != "symbol" ? e + "" : e, r);
4
- import { Inject as T, Injector as V, ICommandService as p, IUniverInstanceService as q, UserManagerService as W, UniverInstanceType as G, RichTextValue as k, generateRandomId as R, RichTextBuilder as J, Tools as F, Range as K, toDisposable as S, CanceledError as E } from "@univerjs/core";
5
- import { SheetsThreadCommentModel as b } from "@univerjs/sheets-thread-comment";
6
- import { FRange as j, FWorkbook as H, FWorksheet as O } from "@univerjs/sheets/facade";
7
- import { DeleteCommentTreeCommand as w, DeleteCommentCommand as y, getDT as B, UpdateCommentCommand as x, ResolveCommentCommand as D, AddCommentCommand as f, ThreadCommentModel as Q } from "@univerjs/thread-comment";
8
- import { deserializeRangeWithSheet as X } from "@univerjs/engine-formula";
9
- import { filter as Y } from "rxjs";
10
- import { FEventName as z, FUniver as $ } from "@univerjs/core/facade";
11
- var Z = Object.getOwnPropertyDescriptor, ee = (i, e, r, t) => {
12
- for (var n = t > 1 ? void 0 : t ? Z(e, r) : e, o = i.length - 1, s; o >= 0; o--)
13
- (s = i[o]) && (n = s(n) || n);
14
- return n;
15
- }, _ = (i, e) => (r, t) => e(r, t, i);
16
- class A {
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, UserManagerService as M, UniverInstanceType as N, RichTextValue as p, generateRandomId as E, RichTextBuilder as V, Tools as j, ICommandService as f, IUniverInstanceService as q, 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
17
  constructor(e) {
18
- M(this, "_comment", {
19
- id: R(),
18
+ D(this, "_comment", {
19
+ id: E(),
20
20
  ref: "",
21
21
  threadId: "",
22
22
  dT: "",
23
23
  personId: "",
24
- text: J.newEmptyData().body,
24
+ text: V.newEmptyData().body,
25
25
  attachments: [],
26
26
  unitId: "",
27
27
  subUnitId: ""
@@ -39,7 +39,7 @@ class A {
39
39
  * ```
40
40
  */
41
41
  static create(e) {
42
- return new A(e);
42
+ return new S(e);
43
43
  }
44
44
  /**
45
45
  * Get the person id of the comment
@@ -75,7 +75,7 @@ class A {
75
75
  * ```
76
76
  */
77
77
  get content() {
78
- return k.createByBody(this._comment.text);
78
+ return p.createByBody(this._comment.text);
79
79
  }
80
80
  /**
81
81
  * Get the id of the comment
@@ -112,12 +112,12 @@ class A {
112
112
  * ```
113
113
  */
114
114
  copy() {
115
- return U.create(F.deepClone(this._comment));
115
+ return k.create(j.deepClone(this._comment));
116
116
  }
117
117
  }
118
- class U extends A {
118
+ class k extends S {
119
119
  static create(e) {
120
- return new U(e);
120
+ return new k(e);
121
121
  }
122
122
  /**
123
123
  * Set the content of the comment
@@ -140,7 +140,7 @@ class U extends A {
140
140
  * ```
141
141
  */
142
142
  setContent(e) {
143
- return e instanceof k ? this._comment.text = e.getData().body : this._comment.text = e, this;
143
+ return e instanceof p ? this._comment.text = e.getData().body : this._comment.text = e, this;
144
144
  }
145
145
  /**
146
146
  * Set the person id of the comment
@@ -188,7 +188,7 @@ class U extends A {
188
188
  * ```
189
189
  */
190
190
  setDateTime(e) {
191
- return this._comment.dT = B(e), this;
191
+ return this._comment.dT = x(e), this;
192
192
  }
193
193
  /**
194
194
  * Set the id of the comment
@@ -258,17 +258,17 @@ class U extends A {
258
258
  return this._comment;
259
259
  }
260
260
  }
261
- let I = class {
261
+ let l = class {
262
262
  /**
263
263
  * @ignore
264
264
  */
265
- constructor(i, e, r, t, n, o, s) {
266
- this._thread = i, this._parent = e, this._injector = r, this._commandService = t, this._univerInstanceService = n, this._threadCommentModel = o, this._userManagerService = s;
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
267
  }
268
268
  _getRef() {
269
- var r;
270
- const i = ((r = this._parent) == null ? void 0 : r.ref) || this._thread.ref;
271
- return X(i).range;
269
+ var n;
270
+ const o = ((n = this._parent) == null ? void 0 : n.ref) || this._thread.ref;
271
+ return F(o).range;
272
272
  }
273
273
  /**
274
274
  * Whether the comment is a root comment
@@ -300,7 +300,7 @@ let I = class {
300
300
  * ```
301
301
  */
302
302
  getCommentData() {
303
- const { children: i, ...e } = this._thread;
303
+ const { children: o, ...e } = this._thread;
304
304
  return e;
305
305
  }
306
306
  /**
@@ -322,9 +322,9 @@ let I = class {
322
322
  * ```
323
323
  */
324
324
  getReplies() {
325
- var r;
326
- const i = this._getRef(), e = this._threadCommentModel.getCommentWithChildren(this._thread.unitId, this._thread.subUnitId, i.startRow, i.startColumn);
327
- return (r = e == null ? void 0 : e.children) == null ? void 0 : r.map((t) => this._injector.createInstance(I, t));
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
328
  }
329
329
  /**
330
330
  * Get the range of the comment
@@ -340,14 +340,14 @@ let I = class {
340
340
  * ```
341
341
  */
342
342
  getRange() {
343
- const i = this._univerInstanceService.getUnit(this._thread.unitId, G.UNIVER_SHEET);
344
- if (!i)
343
+ const o = this._univerInstanceService.getUnit(this._thread.unitId, N.UNIVER_SHEET);
344
+ if (!o)
345
345
  return null;
346
- const e = i.getSheetBySheetId(this._thread.subUnitId);
346
+ const e = o.getSheetBySheetId(this._thread.subUnitId);
347
347
  if (!e)
348
348
  return null;
349
- const r = this._getRef();
350
- return this._injector.createInstance(j, i, e, r);
349
+ const n = this._getRef();
350
+ return this._injector.createInstance(A, o, e, n);
351
351
  }
352
352
  // eslint-disable-next-line
353
353
  /**
@@ -370,8 +370,8 @@ let I = class {
370
370
  * ```
371
371
  */
372
372
  getRichText() {
373
- const i = this._thread.text;
374
- return k.create({ body: i, documentStyle: {}, id: "d" });
373
+ const o = this._thread.text;
374
+ return p.create({ body: o, documentStyle: {}, id: "d" });
375
375
  }
376
376
  /**
377
377
  * Delete the comment and it's replies
@@ -389,7 +389,7 @@ let I = class {
389
389
  */
390
390
  deleteAsync() {
391
391
  return this._commandService.executeCommand(
392
- this.getIsRoot() ? w.id : y.id,
392
+ this.getIsRoot() ? w.id : R.id,
393
393
  {
394
394
  commentId: this._thread.id,
395
395
  unitId: this._thread.unitId,
@@ -408,8 +408,8 @@ let I = class {
408
408
  /**
409
409
  * @deprecated use `updateAsync` as instead
410
410
  */
411
- async update(i) {
412
- return this.updateAsync(i);
411
+ async update(o) {
412
+ return this.updateAsync(o);
413
413
  }
414
414
  /**
415
415
  * Update the comment content
@@ -437,10 +437,10 @@ let I = class {
437
437
  * }, 3000);
438
438
  * ```
439
439
  */
440
- async updateAsync(i) {
441
- const e = i instanceof k ? i.getData().body : i, r = B();
440
+ async updateAsync(o) {
441
+ const e = o instanceof p ? o.getData().body : o, n = x();
442
442
  return await this._commandService.executeCommand(
443
- x.id,
443
+ y.id,
444
444
  {
445
445
  unitId: this._thread.unitId,
446
446
  subUnitId: this._thread.subUnitId,
@@ -448,7 +448,7 @@ let I = class {
448
448
  commentId: this._thread.id,
449
449
  text: e,
450
450
  updated: !0,
451
- updateT: r
451
+ updateT: n
452
452
  }
453
453
  }
454
454
  );
@@ -457,8 +457,8 @@ let I = class {
457
457
  /**
458
458
  * @deprecated use `resolveAsync` as instead
459
459
  */
460
- resolve(i) {
461
- return this.resolveAsync(i);
460
+ resolve(o) {
461
+ return this.resolveAsync(o);
462
462
  }
463
463
  /**
464
464
  * Resolve the comment
@@ -485,14 +485,14 @@ let I = class {
485
485
  * }, 3000);
486
486
  * ```
487
487
  */
488
- resolveAsync(i) {
488
+ resolveAsync(o) {
489
489
  return this._commandService.executeCommand(
490
- D.id,
490
+ T.id,
491
491
  {
492
492
  unitId: this._thread.unitId,
493
493
  subUnitId: this._thread.subUnitId,
494
494
  commentId: this._thread.id,
495
- resolved: i != null ? i : !this._thread.resolved
495
+ resolved: o != null ? o : !this._thread.resolved
496
496
  }
497
497
  );
498
498
  }
@@ -521,88 +521,88 @@ let I = class {
521
521
  * console.log(result);
522
522
  * ```
523
523
  */
524
- replyAsync(i) {
525
- var r;
526
- const e = i.build();
524
+ replyAsync(o) {
525
+ var n;
526
+ const e = o.build();
527
527
  return this._commandService.executeCommand(
528
- f.id,
528
+ _.id,
529
529
  {
530
530
  unitId: this._thread.unitId,
531
531
  subUnitId: this._thread.subUnitId,
532
532
  comment: {
533
- id: R(),
533
+ id: E(),
534
534
  parentId: this._thread.id,
535
535
  threadId: this._thread.threadId,
536
- ref: ((r = this._parent) == null ? void 0 : r.ref) || this._thread.ref,
536
+ ref: ((n = this._parent) == null ? void 0 : n.ref) || this._thread.ref,
537
537
  unitId: this._thread.unitId,
538
538
  subUnitId: this._thread.subUnitId,
539
539
  text: e.text,
540
540
  attachments: e.attachments,
541
- dT: e.dT || B(),
541
+ dT: e.dT || x(),
542
542
  personId: e.personId || this._userManagerService.getCurrentUser().userID
543
543
  }
544
544
  }
545
545
  );
546
546
  }
547
547
  };
548
- I = ee([
549
- _(2, T(V)),
550
- _(3, p),
551
- _(4, q),
552
- _(5, T(b)),
553
- _(6, T(W))
554
- ], I);
555
- class te extends j {
548
+ l = X([
549
+ I(2, B(L)),
550
+ I(3, f),
551
+ I(4, q),
552
+ I(5, B(v)),
553
+ I(6, B(M))
554
+ ], l);
555
+ class Y extends A {
556
556
  getComment() {
557
- const r = this._injector.get(b), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), o = r.getByLocation(t, n, this._range.startRow, this._range.startColumn);
558
- if (!o)
557
+ 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);
558
+ if (!i)
559
559
  return null;
560
- const s = r.getComment(t, n, o);
561
- return s ? this._injector.createInstance(I, s) : null;
560
+ const s = n.getComment(t, r, i);
561
+ return s ? this._injector.createInstance(l, s) : null;
562
562
  }
563
563
  getComments() {
564
- const r = this._injector.get(b), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), o = [];
565
- return K.foreach(this._range, (s, h) => {
566
- const c = r.getByLocation(t, n, s, h);
567
- if (c) {
568
- const m = r.getComment(t, n, c);
569
- m && o.push(this._injector.createInstance(I, m));
564
+ const n = this._injector.get(v), t = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = [];
565
+ return G.foreach(this._range, (s, a) => {
566
+ const m = n.getByLocation(t, r, s, a);
567
+ if (m) {
568
+ const d = n.getComment(t, r, m);
569
+ d && i.push(this._injector.createInstance(l, d));
570
570
  }
571
- }), o;
571
+ }), i;
572
572
  }
573
573
  addComment(e) {
574
- var a;
575
- const r = this._injector, t = (a = this.getComment()) == null ? void 0 : a.getCommentData(), n = r.get(p), o = r.get(W), s = this._workbook.getUnitId(), h = this._worksheet.getSheetId(), c = `${F.chatAtABC(this._range.startColumn)}${this._range.startRow + 1}`, m = o.getCurrentUser(), d = e instanceof U ? e.build() : { text: e };
576
- return n.executeCommand(f.id, {
574
+ var c;
575
+ const n = this._injector, t = (c = this.getComment()) == null ? void 0 : c.getCommentData(), r = n.get(f), 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 };
576
+ return r.executeCommand(_.id, {
577
577
  unitId: s,
578
- subUnitId: h,
578
+ subUnitId: a,
579
579
  comment: {
580
- text: d.text,
581
- dT: d.dT || B(),
580
+ text: h.text,
581
+ dT: h.dT || x(),
582
582
  attachments: [],
583
- id: d.id || R(),
584
- ref: c,
585
- personId: d.personId || m.userID,
583
+ id: h.id || E(),
584
+ ref: m,
585
+ personId: h.personId || d.userID,
586
586
  parentId: t == null ? void 0 : t.id,
587
587
  unitId: s,
588
- subUnitId: h,
589
- threadId: (t == null ? void 0 : t.threadId) || R()
588
+ subUnitId: a,
589
+ threadId: (t == null ? void 0 : t.threadId) || E()
590
590
  }
591
591
  });
592
592
  }
593
593
  clearComment() {
594
594
  var s;
595
- const e = this._injector, r = (s = this.getComment()) == null ? void 0 : s.getCommentData(), t = e.get(p), n = this._workbook.getUnitId(), o = this._worksheet.getSheetId();
596
- return r ? t.executeCommand(w.id, {
597
- unitId: n,
598
- subUnitId: o,
599
- threadId: r.threadId,
600
- commentId: r.id
595
+ const e = this._injector, n = (s = this.getComment()) == null ? void 0 : s.getCommentData(), t = e.get(f), r = this._workbook.getUnitId(), i = this._worksheet.getSheetId();
596
+ return n ? t.executeCommand(w.id, {
597
+ unitId: r,
598
+ subUnitId: i,
599
+ threadId: n.threadId,
600
+ commentId: n.id
601
601
  }) : Promise.resolve(!0);
602
602
  }
603
603
  clearComments() {
604
- const r = this.getComments().map((t) => t.deleteAsync());
605
- return Promise.all(r).then(() => !0);
604
+ const n = this.getComments().map((t) => t.deleteAsync());
605
+ return Promise.all(n).then(() => !0);
606
606
  }
607
607
  addCommentAsync(e) {
608
608
  return this.addComment(e);
@@ -614,43 +614,43 @@ class te extends j {
614
614
  return this.clearComments();
615
615
  }
616
616
  }
617
- j.extend(te);
618
- class ne extends H {
617
+ A.extend(Y);
618
+ class Z extends W {
619
619
  /**
620
620
  * @ignore
621
621
  */
622
622
  _initialize() {
623
623
  Object.defineProperty(this, "_threadCommentModel", {
624
624
  get() {
625
- return this._injector.get(Q);
625
+ return this._injector.get(J);
626
626
  }
627
627
  });
628
628
  }
629
629
  getComments() {
630
- return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map((e) => this._injector.createInstance(I, e.root));
630
+ return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map((e) => this._injector.createInstance(l, e.root));
631
631
  }
632
632
  clearComments() {
633
- const r = this.getComments().map((t) => t.deleteAsync());
634
- return Promise.all(r).then(() => !0);
633
+ const n = this.getComments().map((t) => t.deleteAsync());
634
+ return Promise.all(n).then(() => !0);
635
635
  }
636
636
  /**
637
637
  * @param callback
638
638
  * @deprecated
639
639
  */
640
640
  onThreadCommentChange(e) {
641
- return S(this._threadCommentModel.commentUpdate$.pipe(Y((r) => r.unitId === this._workbook.getUnitId())).subscribe(e));
641
+ return b(this._threadCommentModel.commentUpdate$.pipe(K((n) => n.unitId === this._workbook.getUnitId())).subscribe(e));
642
642
  }
643
643
  /**
644
644
  * @param callback
645
645
  * @deprecated
646
646
  */
647
647
  onBeforeAddThreadComment(e) {
648
- return S(this._commandService.beforeCommandExecuted((r, t) => {
649
- const n = r.params;
650
- if (r.id === f.id) {
651
- if (n.unitId !== this._workbook.getUnitId())
648
+ return b(this._commandService.beforeCommandExecuted((n, t) => {
649
+ const r = n.params;
650
+ if (n.id === _.id) {
651
+ if (r.unitId !== this._workbook.getUnitId())
652
652
  return;
653
- if (e(n, t) === !1)
653
+ if (e(r, t) === !1)
654
654
  throw new Error("Command is stopped by the hook onBeforeAddThreadComment");
655
655
  }
656
656
  }));
@@ -660,12 +660,12 @@ class ne extends H {
660
660
  * @deprecated
661
661
  */
662
662
  onBeforeUpdateThreadComment(e) {
663
- return S(this._commandService.beforeCommandExecuted((r, t) => {
664
- const n = r.params;
665
- if (r.id === x.id) {
666
- if (n.unitId !== this._workbook.getUnitId())
663
+ return b(this._commandService.beforeCommandExecuted((n, t) => {
664
+ const r = n.params;
665
+ if (n.id === y.id) {
666
+ if (r.unitId !== this._workbook.getUnitId())
667
667
  return;
668
- if (e(n, t) === !1)
668
+ if (e(r, t) === !1)
669
669
  throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment");
670
670
  }
671
671
  }));
@@ -675,46 +675,46 @@ class ne extends H {
675
675
  * @deprecated
676
676
  */
677
677
  onBeforeDeleteThreadComment(e) {
678
- return S(this._commandService.beforeCommandExecuted((r, t) => {
679
- const n = r.params;
680
- if (r.id === y.id || r.id === w.id) {
681
- if (n.unitId !== this._workbook.getUnitId())
678
+ return b(this._commandService.beforeCommandExecuted((n, t) => {
679
+ const r = n.params;
680
+ if (n.id === R.id || n.id === w.id) {
681
+ if (r.unitId !== this._workbook.getUnitId())
682
682
  return;
683
- if (e(n, t) === !1)
683
+ if (e(r, t) === !1)
684
684
  throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment");
685
685
  }
686
686
  }));
687
687
  }
688
688
  }
689
- H.extend(ne);
690
- class re extends O {
689
+ W.extend(Z);
690
+ class ee extends P {
691
691
  getComments() {
692
- return this._injector.get(b).getSubUnitAll(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => this._injector.createInstance(I, t));
692
+ return this._injector.get(v).getSubUnitAll(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => this._injector.createInstance(l, t));
693
693
  }
694
694
  clearComments() {
695
- const r = this.getComments().map((t) => t.deleteAsync());
696
- return Promise.all(r).then(() => !0);
695
+ const n = this.getComments().map((t) => t.deleteAsync());
696
+ return Promise.all(n).then(() => !0);
697
697
  }
698
698
  /**
699
699
  * Subscribe to comment events.
700
700
  * @param callback Callback function, param contains comment info and target cell.
701
701
  */
702
702
  onCommented(e) {
703
- return this._injector.get(p).onCommandExecuted((t) => {
704
- if (t.id === f.id) {
705
- const n = t.params;
706
- e(n);
703
+ return this._injector.get(f).onCommandExecuted((t) => {
704
+ if (t.id === _.id) {
705
+ const r = t.params;
706
+ e(r);
707
707
  }
708
708
  });
709
709
  }
710
710
  getCommentById(e) {
711
- const t = this._injector.get(b).getComment(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
711
+ const t = this._injector.get(v).getComment(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
712
712
  if (t)
713
- return this._injector.createInstance(I, t);
713
+ return this._injector.createInstance(l, t);
714
714
  }
715
715
  }
716
- O.extend(re);
717
- const l = {
716
+ P.extend(ee);
717
+ const C = {
718
718
  CommentAdded: "CommentAdded",
719
719
  BeforeCommentAdd: "BeforeCommentAdd",
720
720
  CommentUpdated: "CommentUpdated",
@@ -724,223 +724,213 @@ const l = {
724
724
  CommentResolved: "CommentResolved",
725
725
  BeforeCommentResolve: "BeforeCommentResolve"
726
726
  };
727
- class oe extends z {
727
+ class te extends H {
728
728
  get CommentAdded() {
729
- return l.CommentAdded;
729
+ return C.CommentAdded;
730
730
  }
731
731
  get BeforeCommentAdd() {
732
- return l.BeforeCommentAdd;
732
+ return C.BeforeCommentAdd;
733
733
  }
734
734
  get CommentUpdated() {
735
- return l.CommentUpdated;
735
+ return C.CommentUpdated;
736
736
  }
737
737
  get BeforeCommentUpdate() {
738
- return l.BeforeCommentUpdate;
738
+ return C.BeforeCommentUpdate;
739
739
  }
740
740
  get CommentDeleted() {
741
- return l.CommentDeleted;
741
+ return C.CommentDeleted;
742
742
  }
743
743
  get BeforeCommentDelete() {
744
- return l.BeforeCommentDelete;
744
+ return C.BeforeCommentDelete;
745
745
  }
746
746
  get CommentResolved() {
747
- return l.CommentResolved;
747
+ return C.CommentResolved;
748
748
  }
749
749
  get BeforeCommentResolve() {
750
- return l.BeforeCommentResolve;
750
+ return C.BeforeCommentResolve;
751
751
  }
752
752
  }
753
- z.extend(oe);
754
- class se extends $ {
753
+ H.extend(te);
754
+ class ne extends O {
755
+ _getTargetSheet(e = {}) {
756
+ var r;
757
+ const n = e.unitId ? this.getUniverSheet(e.unitId) : (r = this.getActiveWorkbook) == null ? void 0 : r.call(this);
758
+ if (!n) return null;
759
+ const t = e.subUnitId ? n.getSheetBySheetId(e.subUnitId) : n.getActiveSheet();
760
+ return t ? {
761
+ workbook: n,
762
+ worksheet: t
763
+ } : null;
764
+ }
755
765
  // eslint-disable-next-line max-lines-per-function
756
766
  _initialize(e) {
757
- const r = e.get(p);
758
- this.registerEventHandler(
759
- this.Event.CommentAdded,
760
- () => r.onCommandExecuted((t) => {
761
- var d, a, u, g, C;
762
- if (t.id !== f.id) return;
763
- const n = t.params;
764
- if (!n) return;
765
- const o = n.unitId ? this.getUniverSheet(n.unitId) : (d = this.getActiveWorkbook) == null ? void 0 : d.call(this);
766
- if (!o) return;
767
- const s = o.getSheetBySheetId(n.subUnitId || n.sheetId) || o.getActiveSheet();
768
- if (!s) return;
769
- const h = t.params, { comment: c } = h, m = s.getRange(c.ref).getComment();
770
- m && this.fireEvent(this.Event.CommentAdded, {
771
- workbook: o,
772
- worksheet: s,
773
- row: (u = (a = m.getRange()) == null ? void 0 : a.getRow()) != null ? u : 0,
774
- col: (C = (g = m.getRange()) == null ? void 0 : g.getColumn()) != null ? C : 0,
775
- comment: m
776
- });
777
- })
778
- ), this.registerEventHandler(
779
- this.Event.CommentUpdated,
780
- () => r.onCommandExecuted((t) => {
781
- var d, a, u, g, C;
782
- if (t.id !== x.id) return;
783
- const n = t.params;
784
- if (!n) return;
785
- const o = n.unitId ? this.getUniverSheet(n.unitId) : (d = this.getActiveWorkbook) == null ? void 0 : d.call(this);
786
- if (!o) return;
787
- const s = o.getSheetBySheetId(n.subUnitId || n.sheetId) || o.getActiveSheet();
788
- if (!s) return;
789
- const h = t.params, { commentId: c } = h.payload, m = s.getCommentById(c);
790
- m && this.fireEvent(this.Event.CommentUpdated, {
791
- workbook: o,
792
- worksheet: s,
793
- row: (u = (a = m.getRange()) == null ? void 0 : a.getRow()) != null ? u : 0,
794
- col: (C = (g = m.getRange()) == null ? void 0 : g.getColumn()) != null ? C : 0,
795
- comment: m
796
- });
797
- })
798
- ), this.registerEventHandler(
799
- this.Event.CommentDeleted,
800
- () => r.onCommandExecuted((t) => {
801
- var m;
802
- if (t.id !== y.id && t.id !== w.id) return;
803
- const n = t.params;
804
- if (!n) return;
805
- const o = n.unitId ? this.getUniverSheet(n.unitId) : (m = this.getActiveWorkbook) == null ? void 0 : m.call(this);
806
- if (!o) return;
807
- const s = o.getSheetBySheetId(n.subUnitId || n.sheetId) || o.getActiveSheet();
808
- if (!s) return;
809
- const h = t.params, { commentId: c } = h;
810
- this.fireEvent(this.Event.CommentDeleted, {
811
- workbook: o,
812
- worksheet: s,
813
- commentId: c
814
- });
815
- })
816
- ), this.registerEventHandler(
817
- this.Event.CommentResolved,
818
- () => r.onCommandExecuted((t) => {
819
- var a, u, g;
820
- if (t.id !== D.id) return;
821
- const n = t.params;
822
- if (!n) return;
823
- const o = n.unitId ? this.getUniverSheet(n.unitId) : (a = this.getActiveWorkbook) == null ? void 0 : a.call(this);
824
- if (!o) return;
825
- const s = o.getSheetBySheetId(n.subUnitId || n.sheetId) || o.getActiveSheet();
826
- if (!s) return;
827
- const h = t.params, { commentId: c, resolved: m } = h, d = s.getComments().find((C) => C.getCommentData().id === c);
828
- d && this.fireEvent(this.Event.CommentResolved, {
829
- workbook: o,
830
- worksheet: s,
831
- row: (u = d.getRange().getRow()) != null ? u : 0,
832
- col: (g = d.getRange().getColumn()) != null ? g : 0,
833
- comment: d,
834
- resolved: m
835
- });
836
- })
837
- ), this.registerEventHandler(
838
- this.Event.BeforeCommentAdd,
839
- () => r.beforeCommandExecuted((t) => {
840
- var a, u, g;
841
- if (t.id !== f.id) return;
842
- const n = t.params;
843
- if (!n) return;
844
- const o = n.unitId ? this.getUniverSheet(n.unitId) : (a = this.getActiveWorkbook) == null ? void 0 : a.call(this);
845
- if (!o) return;
846
- const s = o.getSheetBySheetId(n.subUnitId || n.sheetId) || o.getActiveSheet();
847
- if (!s) return;
848
- const h = t.params, { comment: c } = h, m = s.getActiveRange();
849
- if (!m) return;
850
- const d = {
851
- workbook: o,
852
- worksheet: s,
853
- row: (u = m.getRow()) != null ? u : 0,
854
- col: (g = m.getColumn()) != null ? g : 0,
855
- comment: A.create(c)
856
- };
857
- if (this.fireEvent(this.Event.BeforeCommentAdd, d), d.cancel)
858
- throw new E();
859
- })
860
- ), this.registerEventHandler(
861
- this.Event.BeforeCommentUpdate,
862
- () => r.beforeCommandExecuted((t) => {
863
- var a, u, g, C, v;
864
- if (t.id !== x.id) return;
865
- const n = t.params;
866
- if (!n) return;
867
- const o = n.unitId ? this.getUniverSheet(n.unitId) : (a = this.getActiveWorkbook) == null ? void 0 : a.call(this);
868
- if (!o) return;
869
- const s = o.getSheetBySheetId(n.subUnitId || n.sheetId) || o.getActiveSheet();
870
- if (!s) return;
871
- const h = t.params, { commentId: c, text: m } = h.payload, d = s.getCommentById(c);
872
- if (d) {
873
- const P = {
874
- workbook: o,
767
+ const n = e.get(f);
768
+ this.disposeWithMe(
769
+ this.registerEventHandler(
770
+ this.Event.CommentAdded,
771
+ () => n.onCommandExecuted((t) => {
772
+ var d, h, c, u;
773
+ if (t.id !== _.id) return;
774
+ const r = this._getTargetSheet(t.params);
775
+ if (!r) return;
776
+ const { workbook: i, worksheet: s } = r, { comment: a } = t.params, m = s.getCommentById(a.id);
777
+ m && this.fireEvent(this.Event.CommentAdded, {
778
+ workbook: i,
875
779
  worksheet: s,
876
- row: (g = (u = d.getRange()) == null ? void 0 : u.getRow()) != null ? g : 0,
877
- col: (v = (C = d.getRange()) == null ? void 0 : C.getColumn()) != null ? v : 0,
878
- comment: d,
879
- newContent: k.createByBody(m)
880
- };
881
- if (this.fireEvent(this.Event.BeforeCommentUpdate, P), P.cancel)
882
- throw new E();
883
- }
884
- })
885
- ), this.registerEventHandler(
886
- this.Event.BeforeCommentDelete,
887
- () => r.beforeCommandExecuted((t) => {
888
- var d, a, u, g, C;
889
- if (t.id !== y.id && t.id !== w.id) return;
890
- const n = t.params;
891
- if (!n) return;
892
- const o = n.unitId ? this.getUniverSheet(n.unitId) : (d = this.getActiveWorkbook) == null ? void 0 : d.call(this);
893
- if (!o) return;
894
- const s = o.getSheetBySheetId(n.subUnitId || n.sheetId) || o.getActiveSheet();
895
- if (!s) return;
896
- const h = t.params, { commentId: c } = h, m = s.getCommentById(c);
897
- if (m) {
898
- const v = {
899
- workbook: o,
780
+ row: (h = (d = m.getRange()) == null ? void 0 : d.getRow()) != null ? h : 0,
781
+ col: (u = (c = m.getRange()) == null ? void 0 : c.getColumn()) != null ? u : 0,
782
+ comment: m
783
+ });
784
+ })
785
+ )
786
+ ), this.disposeWithMe(
787
+ this.registerEventHandler(
788
+ this.Event.CommentUpdated,
789
+ () => n.onCommandExecuted((t) => {
790
+ var d, h, c, u;
791
+ if (t.id !== y.id) return;
792
+ const r = this._getTargetSheet(t.params);
793
+ if (!r) return;
794
+ const { workbook: i, worksheet: s } = r, { payload: a } = t.params, m = s.getCommentById(a.commentId);
795
+ m && this.fireEvent(this.Event.CommentUpdated, {
796
+ workbook: i,
900
797
  worksheet: s,
901
- row: (u = (a = m.getRange()) == null ? void 0 : a.getRow()) != null ? u : 0,
902
- col: (C = (g = m.getRange()) == null ? void 0 : g.getColumn()) != null ? C : 0,
798
+ row: (h = (d = m.getRange()) == null ? void 0 : d.getRow()) != null ? h : 0,
799
+ col: (u = (c = m.getRange()) == null ? void 0 : c.getColumn()) != null ? u : 0,
903
800
  comment: m
904
- };
905
- if (this.fireEvent(this.Event.BeforeCommentDelete, v), v.cancel)
906
- throw new E();
907
- }
908
- })
909
- ), this.registerEventHandler(
910
- this.Event.BeforeCommentResolve,
911
- () => r.beforeCommandExecuted((t) => {
912
- var a, u, g;
913
- if (t.id !== D.id) return;
914
- const n = t.params;
915
- if (!n) return;
916
- const o = n.unitId ? this.getUniverSheet(n.unitId) : (a = this.getActiveWorkbook) == null ? void 0 : a.call(this);
917
- if (!o) return;
918
- const s = o.getSheetBySheetId(n.subUnitId || n.sheetId) || o.getActiveSheet();
919
- if (!s) return;
920
- const h = t.params, { commentId: c, resolved: m } = h, d = s.getComments().find((C) => C.getCommentData().id === c);
921
- if (d) {
922
- const C = {
923
- workbook: o,
801
+ });
802
+ })
803
+ )
804
+ ), this.disposeWithMe(
805
+ this.registerEventHandler(
806
+ this.Event.CommentDeleted,
807
+ () => n.onCommandExecuted((t) => {
808
+ if (t.id !== R.id && t.id !== w.id) return;
809
+ const r = this._getTargetSheet(t.params);
810
+ if (!r) return;
811
+ const { workbook: i, worksheet: s } = r, { commentId: a } = t.params;
812
+ this.fireEvent(this.Event.CommentDeleted, {
813
+ workbook: i,
814
+ worksheet: s,
815
+ commentId: a
816
+ });
817
+ })
818
+ )
819
+ ), this.disposeWithMe(
820
+ this.registerEventHandler(
821
+ this.Event.CommentResolved,
822
+ () => n.onCommandExecuted((t) => {
823
+ var h, c, u, g;
824
+ if (t.id !== T.id) return;
825
+ const r = this._getTargetSheet(t.params);
826
+ if (!r) return;
827
+ const { workbook: i, worksheet: s } = r, { commentId: a, resolved: m } = t.params, d = s.getCommentById(a);
828
+ d && this.fireEvent(this.Event.CommentResolved, {
829
+ workbook: i,
924
830
  worksheet: s,
925
- row: (u = d.getRange().getRow()) != null ? u : 0,
926
- col: (g = d.getRange().getColumn()) != null ? g : 0,
831
+ row: (c = (h = d.getRange()) == null ? void 0 : h.getRow()) != null ? c : 0,
832
+ col: (g = (u = d.getRange()) == null ? void 0 : u.getColumn()) != null ? g : 0,
927
833
  comment: d,
928
834
  resolved: m
835
+ });
836
+ })
837
+ )
838
+ ), this.disposeWithMe(
839
+ this.registerEventHandler(
840
+ this.Event.BeforeCommentAdd,
841
+ () => n.beforeCommandExecuted((t) => {
842
+ if (t.id !== _.id) return;
843
+ const r = this._getTargetSheet(t.params);
844
+ if (!r) return;
845
+ const { workbook: i, worksheet: s } = r, { comment: a } = t.params, { range: m } = F(a.ref), d = {
846
+ workbook: i,
847
+ worksheet: s,
848
+ row: m.startRow,
849
+ col: m.startColumn,
850
+ comment: S.create(a)
929
851
  };
930
- if (this.fireEvent(this.Event.BeforeCommentResolve, C), C.cancel)
931
- throw new E();
932
- }
933
- })
852
+ if (this.fireEvent(this.Event.BeforeCommentAdd, d), d.cancel)
853
+ throw new U();
854
+ })
855
+ )
856
+ ), this.disposeWithMe(
857
+ this.registerEventHandler(
858
+ this.Event.BeforeCommentUpdate,
859
+ () => n.beforeCommandExecuted((t) => {
860
+ var d, h, c, u;
861
+ if (t.id !== y.id) return;
862
+ const r = this._getTargetSheet(t.params);
863
+ if (!r) return;
864
+ const { workbook: i, worksheet: s } = r, { payload: a } = t.params, m = s.getCommentById(a.commentId);
865
+ if (m) {
866
+ const g = {
867
+ workbook: i,
868
+ worksheet: s,
869
+ row: (h = (d = m.getRange()) == null ? void 0 : d.getRow()) != null ? h : 0,
870
+ col: (u = (c = m.getRange()) == null ? void 0 : c.getColumn()) != null ? u : 0,
871
+ comment: m,
872
+ newContent: p.createByBody(a.text)
873
+ };
874
+ if (this.fireEvent(this.Event.BeforeCommentUpdate, g), g.cancel)
875
+ throw new U();
876
+ }
877
+ })
878
+ )
879
+ ), this.disposeWithMe(
880
+ this.registerEventHandler(
881
+ this.Event.BeforeCommentDelete,
882
+ () => n.beforeCommandExecuted((t) => {
883
+ var d, h, c, u;
884
+ if (t.id !== R.id && t.id !== w.id) return;
885
+ const r = this._getTargetSheet(t.params);
886
+ if (!r) return;
887
+ const { workbook: i, worksheet: s } = r, { commentId: a } = t.params, m = s.getCommentById(a);
888
+ if (m) {
889
+ const g = {
890
+ workbook: i,
891
+ worksheet: s,
892
+ row: (h = (d = m.getRange()) == null ? void 0 : d.getRow()) != null ? h : 0,
893
+ col: (u = (c = m.getRange()) == null ? void 0 : c.getColumn()) != null ? u : 0,
894
+ comment: m
895
+ };
896
+ if (this.fireEvent(this.Event.BeforeCommentDelete, g), g.cancel)
897
+ throw new U();
898
+ }
899
+ })
900
+ )
901
+ ), this.disposeWithMe(
902
+ this.registerEventHandler(
903
+ this.Event.BeforeCommentResolve,
904
+ () => n.beforeCommandExecuted((t) => {
905
+ var h, c;
906
+ if (t.id !== T.id) return;
907
+ const r = this._getTargetSheet(t.params);
908
+ if (!r) return;
909
+ const { workbook: i, worksheet: s } = r, { commentId: a, resolved: m } = t.params, d = s.getCommentById(a);
910
+ if (d) {
911
+ const u = {
912
+ workbook: i,
913
+ worksheet: s,
914
+ row: (h = d.getRange().getRow()) != null ? h : 0,
915
+ col: (c = d.getRange().getColumn()) != null ? c : 0,
916
+ comment: d,
917
+ resolved: m
918
+ };
919
+ if (this.fireEvent(this.Event.BeforeCommentResolve, u), u.cancel)
920
+ throw new U();
921
+ }
922
+ })
923
+ )
934
924
  );
935
925
  }
936
926
  /**
937
927
  * @ignore
938
928
  */
939
929
  newTheadComment(e) {
940
- return new U(e);
930
+ return new k(e);
941
931
  }
942
932
  }
943
- $.extend(se);
933
+ O.extend(ne);
944
934
  export {
945
- I as FThreadComment
935
+ l as FThreadComment
946
936
  };