@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/cjs/facade.js +1 -1
- package/lib/es/facade.js +309 -319
- package/lib/es/index.js +1 -1
- package/lib/facade.js +309 -319
- package/lib/index.js +1 -1
- package/lib/types/facade/f-univer.d.ts +1 -0
- package/lib/umd/facade.js +1 -1
- package/package.json +7 -7
package/lib/es/facade.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Inject as
|
|
5
|
-
import { SheetsThreadCommentModel as
|
|
6
|
-
import { FRange as
|
|
7
|
-
import { DeleteCommentTreeCommand as w, DeleteCommentCommand as
|
|
8
|
-
import { deserializeRangeWithSheet as
|
|
9
|
-
import { filter as
|
|
10
|
-
import { FEventName as
|
|
11
|
-
var
|
|
12
|
-
for (var
|
|
13
|
-
(s = i
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
class
|
|
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
|
-
|
|
19
|
-
id:
|
|
18
|
+
D(this, "_comment", {
|
|
19
|
+
id: E(),
|
|
20
20
|
ref: "",
|
|
21
21
|
threadId: "",
|
|
22
22
|
dT: "",
|
|
23
23
|
personId: "",
|
|
24
|
-
text:
|
|
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
|
|
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
|
|
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
|
|
115
|
+
return k.create(j.deepClone(this._comment));
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
class
|
|
118
|
+
class k extends S {
|
|
119
119
|
static create(e) {
|
|
120
|
-
return new
|
|
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
|
|
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 =
|
|
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
|
|
261
|
+
let l = class {
|
|
262
262
|
/**
|
|
263
263
|
* @ignore
|
|
264
264
|
*/
|
|
265
|
-
constructor(
|
|
266
|
-
this._thread =
|
|
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
|
|
270
|
-
const
|
|
271
|
-
return
|
|
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:
|
|
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
|
|
326
|
-
const
|
|
327
|
-
return (
|
|
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
|
|
344
|
-
if (!
|
|
343
|
+
const o = this._univerInstanceService.getUnit(this._thread.unitId, N.UNIVER_SHEET);
|
|
344
|
+
if (!o)
|
|
345
345
|
return null;
|
|
346
|
-
const e =
|
|
346
|
+
const e = o.getSheetBySheetId(this._thread.subUnitId);
|
|
347
347
|
if (!e)
|
|
348
348
|
return null;
|
|
349
|
-
const
|
|
350
|
-
return this._injector.createInstance(
|
|
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
|
|
374
|
-
return
|
|
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 :
|
|
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(
|
|
412
|
-
return this.updateAsync(
|
|
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(
|
|
441
|
-
const e =
|
|
440
|
+
async updateAsync(o) {
|
|
441
|
+
const e = o instanceof p ? o.getData().body : o, n = x();
|
|
442
442
|
return await this._commandService.executeCommand(
|
|
443
|
-
|
|
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:
|
|
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(
|
|
461
|
-
return this.resolveAsync(
|
|
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(
|
|
488
|
+
resolveAsync(o) {
|
|
489
489
|
return this._commandService.executeCommand(
|
|
490
|
-
|
|
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:
|
|
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(
|
|
525
|
-
var
|
|
526
|
-
const e =
|
|
524
|
+
replyAsync(o) {
|
|
525
|
+
var n;
|
|
526
|
+
const e = o.build();
|
|
527
527
|
return this._commandService.executeCommand(
|
|
528
|
-
|
|
528
|
+
_.id,
|
|
529
529
|
{
|
|
530
530
|
unitId: this._thread.unitId,
|
|
531
531
|
subUnitId: this._thread.subUnitId,
|
|
532
532
|
comment: {
|
|
533
|
-
id:
|
|
533
|
+
id: E(),
|
|
534
534
|
parentId: this._thread.id,
|
|
535
535
|
threadId: this._thread.threadId,
|
|
536
|
-
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 ||
|
|
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
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
],
|
|
555
|
-
class
|
|
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
|
|
558
|
-
if (!
|
|
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 =
|
|
561
|
-
return s ? this._injector.createInstance(
|
|
560
|
+
const s = n.getComment(t, r, i);
|
|
561
|
+
return s ? this._injector.createInstance(l, s) : null;
|
|
562
562
|
}
|
|
563
563
|
getComments() {
|
|
564
|
-
const
|
|
565
|
-
return
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
568
|
-
const
|
|
569
|
-
|
|
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
|
-
}),
|
|
571
|
+
}), i;
|
|
572
572
|
}
|
|
573
573
|
addComment(e) {
|
|
574
|
-
var
|
|
575
|
-
const
|
|
576
|
-
return
|
|
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:
|
|
578
|
+
subUnitId: a,
|
|
579
579
|
comment: {
|
|
580
|
-
text:
|
|
581
|
-
dT:
|
|
580
|
+
text: h.text,
|
|
581
|
+
dT: h.dT || x(),
|
|
582
582
|
attachments: [],
|
|
583
|
-
id:
|
|
584
|
-
ref:
|
|
585
|
-
personId:
|
|
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:
|
|
589
|
-
threadId: (t == null ? void 0 : t.threadId) ||
|
|
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,
|
|
596
|
-
return
|
|
597
|
-
unitId:
|
|
598
|
-
subUnitId:
|
|
599
|
-
threadId:
|
|
600
|
-
commentId:
|
|
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
|
|
605
|
-
return Promise.all(
|
|
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
|
-
|
|
618
|
-
class
|
|
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(
|
|
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(
|
|
630
|
+
return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map((e) => this._injector.createInstance(l, e.root));
|
|
631
631
|
}
|
|
632
632
|
clearComments() {
|
|
633
|
-
const
|
|
634
|
-
return Promise.all(
|
|
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
|
|
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
|
|
649
|
-
const
|
|
650
|
-
if (
|
|
651
|
-
if (
|
|
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(
|
|
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
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
666
|
-
if (
|
|
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(
|
|
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
|
|
679
|
-
const
|
|
680
|
-
if (
|
|
681
|
-
if (
|
|
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(
|
|
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
|
-
|
|
690
|
-
class
|
|
689
|
+
W.extend(Z);
|
|
690
|
+
class ee extends P {
|
|
691
691
|
getComments() {
|
|
692
|
-
return this._injector.get(
|
|
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
|
|
696
|
-
return Promise.all(
|
|
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(
|
|
704
|
-
if (t.id ===
|
|
705
|
-
const
|
|
706
|
-
e(
|
|
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(
|
|
711
|
+
const t = this._injector.get(v).getComment(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
|
|
712
712
|
if (t)
|
|
713
|
-
return this._injector.createInstance(
|
|
713
|
+
return this._injector.createInstance(l, t);
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
|
-
|
|
717
|
-
const
|
|
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
|
|
727
|
+
class te extends H {
|
|
728
728
|
get CommentAdded() {
|
|
729
|
-
return
|
|
729
|
+
return C.CommentAdded;
|
|
730
730
|
}
|
|
731
731
|
get BeforeCommentAdd() {
|
|
732
|
-
return
|
|
732
|
+
return C.BeforeCommentAdd;
|
|
733
733
|
}
|
|
734
734
|
get CommentUpdated() {
|
|
735
|
-
return
|
|
735
|
+
return C.CommentUpdated;
|
|
736
736
|
}
|
|
737
737
|
get BeforeCommentUpdate() {
|
|
738
|
-
return
|
|
738
|
+
return C.BeforeCommentUpdate;
|
|
739
739
|
}
|
|
740
740
|
get CommentDeleted() {
|
|
741
|
-
return
|
|
741
|
+
return C.CommentDeleted;
|
|
742
742
|
}
|
|
743
743
|
get BeforeCommentDelete() {
|
|
744
|
-
return
|
|
744
|
+
return C.BeforeCommentDelete;
|
|
745
745
|
}
|
|
746
746
|
get CommentResolved() {
|
|
747
|
-
return
|
|
747
|
+
return C.CommentResolved;
|
|
748
748
|
}
|
|
749
749
|
get BeforeCommentResolve() {
|
|
750
|
-
return
|
|
750
|
+
return C.BeforeCommentResolve;
|
|
751
751
|
}
|
|
752
752
|
}
|
|
753
|
-
|
|
754
|
-
class
|
|
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
|
|
758
|
-
this.
|
|
759
|
-
this.
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
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: (
|
|
877
|
-
col: (
|
|
878
|
-
comment:
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
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: (
|
|
902
|
-
col: (
|
|
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
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
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: (
|
|
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.
|
|
931
|
-
throw new
|
|
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
|
|
930
|
+
return new k(e);
|
|
941
931
|
}
|
|
942
932
|
}
|
|
943
|
-
|
|
933
|
+
O.extend(ne);
|
|
944
934
|
export {
|
|
945
|
-
|
|
935
|
+
l as FThreadComment
|
|
946
936
|
};
|