@univerjs/sheets-thread-comment 0.6.7 → 0.6.9-nightly.202504021607
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/facade.js +946 -0
- package/lib/index.js +367 -0
- package/package.json +6 -6
- package/LICENSE +0 -176
package/lib/facade.js
ADDED
|
@@ -0,0 +1,946 @@
|
|
|
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 {
|
|
17
|
+
constructor(e) {
|
|
18
|
+
M(this, "_comment", {
|
|
19
|
+
id: R(),
|
|
20
|
+
ref: "",
|
|
21
|
+
threadId: "",
|
|
22
|
+
dT: "",
|
|
23
|
+
personId: "",
|
|
24
|
+
text: J.newEmptyData().body,
|
|
25
|
+
attachments: [],
|
|
26
|
+
unitId: "",
|
|
27
|
+
subUnitId: ""
|
|
28
|
+
});
|
|
29
|
+
e && (this._comment = e);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a new FTheadCommentItem
|
|
33
|
+
* @param {IThreadComment|undefined} comment The comment
|
|
34
|
+
* @returns {FTheadCommentItem} A new instance of FTheadCommentItem
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const commentBuilder = univerAPI.newTheadComment();
|
|
38
|
+
* console.log(commentBuilder);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
static create(e) {
|
|
42
|
+
return new A(e);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the person id of the comment
|
|
46
|
+
* @returns {string} The person id of the comment
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const commentBuilder = univerAPI.newTheadComment();
|
|
50
|
+
* console.log(commentBuilder.personId);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
get personId() {
|
|
54
|
+
return this._comment.personId;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the date time of the comment
|
|
58
|
+
* @returns {string} The date time of the comment
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const commentBuilder = univerAPI.newTheadComment();
|
|
62
|
+
* console.log(commentBuilder.dateTime);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
get dateTime() {
|
|
66
|
+
return this._comment.dT;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the content of the comment
|
|
70
|
+
* @returns {RichTextValue} The content of the comment
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const commentBuilder = univerAPI.newTheadComment();
|
|
74
|
+
* console.log(commentBuilder.content);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
get content() {
|
|
78
|
+
return k.createByBody(this._comment.text);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the id of the comment
|
|
82
|
+
* @returns {string} The id of the comment
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const commentBuilder = univerAPI.newTheadComment();
|
|
86
|
+
* console.log(commentBuilder.id);
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
get id() {
|
|
90
|
+
return this._comment.id;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get the thread id of the comment
|
|
94
|
+
* @returns {string} The thread id of the comment
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const commentBuilder = univerAPI.newTheadComment();
|
|
98
|
+
* console.log(commentBuilder.threadId);
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
get threadId() {
|
|
102
|
+
return this._comment.threadId;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Copy the comment
|
|
106
|
+
* @returns {FTheadCommentBuilder} The comment builder
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const commentBuilder = univerAPI.newTheadComment();
|
|
110
|
+
* const newCommentBuilder = commentBuilder.copy();
|
|
111
|
+
* console.log(newCommentBuilder);
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
copy() {
|
|
115
|
+
return U.create(F.deepClone(this._comment));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
class U extends A {
|
|
119
|
+
static create(e) {
|
|
120
|
+
return new U(e);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Set the content of the comment
|
|
124
|
+
* @param {IDocumentBody | RichTextValue} content The content of the comment
|
|
125
|
+
* @returns {FTheadCommentBuilder} The comment builder for chaining
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* // Create a new comment
|
|
129
|
+
* const richText = univerAPI.newRichText().insertText('hello univer');
|
|
130
|
+
* const commentBuilder = univerAPI.newTheadComment()
|
|
131
|
+
* .setContent(richText);
|
|
132
|
+
* console.log(commentBuilder.content);
|
|
133
|
+
*
|
|
134
|
+
* // Add the comment to the cell A1
|
|
135
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
136
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
137
|
+
* const cell = fWorksheet.getRange('A1');
|
|
138
|
+
* const result = await cell.addCommentAsync(commentBuilder);
|
|
139
|
+
* console.log(result);
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
setContent(e) {
|
|
143
|
+
return e instanceof k ? this._comment.text = e.getData().body : this._comment.text = e, this;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Set the person id of the comment
|
|
147
|
+
* @param {string} userId The person id of the comment
|
|
148
|
+
* @returns {FTheadCommentBuilder} The comment builder for chaining
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* // Create a new comment
|
|
152
|
+
* const richText = univerAPI.newRichText().insertText('hello univer');
|
|
153
|
+
* const commentBuilder = univerAPI.newTheadComment()
|
|
154
|
+
* .setContent(richText)
|
|
155
|
+
* .setPersonId('mock-user-id');
|
|
156
|
+
* console.log(commentBuilder.personId);
|
|
157
|
+
*
|
|
158
|
+
* // Add the comment to the cell A1
|
|
159
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
160
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
161
|
+
* const cell = fWorksheet.getRange('A1');
|
|
162
|
+
* const result = await cell.addCommentAsync(commentBuilder);
|
|
163
|
+
* console.log(result);
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
setPersonId(e) {
|
|
167
|
+
return this._comment.personId = e, this;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Set the date time of the comment
|
|
171
|
+
* @param {Date} date The date time of the comment
|
|
172
|
+
* @returns {FTheadCommentBuilder} The comment builder for chaining
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* // Create a new comment
|
|
176
|
+
* const richText = univerAPI.newRichText().insertText('hello univer');
|
|
177
|
+
* const commentBuilder = univerAPI.newTheadComment()
|
|
178
|
+
* .setContent(richText)
|
|
179
|
+
* .setDateTime(new Date('2025-02-21 14:22:22'));
|
|
180
|
+
* console.log(commentBuilder.dateTime);
|
|
181
|
+
*
|
|
182
|
+
* // Add the comment to the cell A1
|
|
183
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
184
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
185
|
+
* const cell = fWorksheet.getRange('A1');
|
|
186
|
+
* const result = await cell.addCommentAsync(commentBuilder);
|
|
187
|
+
* console.log(result);
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
setDateTime(e) {
|
|
191
|
+
return this._comment.dT = B(e), this;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Set the id of the comment
|
|
195
|
+
* @param {string} id The id of the comment
|
|
196
|
+
* @returns {FTheadCommentBuilder} The comment builder for chaining
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* // Create a new comment
|
|
200
|
+
* const richText = univerAPI.newRichText().insertText('hello univer');
|
|
201
|
+
* const commentBuilder = univerAPI.newTheadComment()
|
|
202
|
+
* .setContent(richText)
|
|
203
|
+
* .setId('mock-comment-id');
|
|
204
|
+
* console.log(commentBuilder.id);
|
|
205
|
+
*
|
|
206
|
+
* // Add the comment to the cell A1
|
|
207
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
208
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
209
|
+
* const cell = fWorksheet.getRange('A1');
|
|
210
|
+
* const result = await cell.addCommentAsync(commentBuilder);
|
|
211
|
+
* console.log(result);
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
setId(e) {
|
|
215
|
+
return this._comment.id = e, this;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Set the thread id of the comment
|
|
219
|
+
* @param {string} threadId The thread id of the comment
|
|
220
|
+
* @returns {FTheadCommentBuilder} The comment builder
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* // Create a new comment
|
|
224
|
+
* const richText = univerAPI.newRichText().insertText('hello univer');
|
|
225
|
+
* const commentBuilder = univerAPI.newTheadComment()
|
|
226
|
+
* .setContent(richText)
|
|
227
|
+
* .setThreadId('mock-thread-id');
|
|
228
|
+
* console.log(commentBuilder.threadId);
|
|
229
|
+
*
|
|
230
|
+
* // Add the comment to the cell A1
|
|
231
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
232
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
233
|
+
* const cell = fWorksheet.getRange('A1');
|
|
234
|
+
* const result = await cell.addCommentAsync(commentBuilder);
|
|
235
|
+
* console.log(result);
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
setThreadId(e) {
|
|
239
|
+
return this._comment.threadId = e, this;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Build the comment
|
|
243
|
+
* @returns {IThreadComment} The comment
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* const richText = univerAPI.newRichText().insertText('hello univer');
|
|
247
|
+
* const comment = univerAPI.newTheadComment()
|
|
248
|
+
* .setContent(richText)
|
|
249
|
+
* .setPersonId('mock-user-id')
|
|
250
|
+
* .setDateTime(new Date('2025-02-21 14:22:22'))
|
|
251
|
+
* .setId('mock-comment-id')
|
|
252
|
+
* .setThreadId('mock-thread-id')
|
|
253
|
+
* .build();
|
|
254
|
+
* console.log(comment);
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
build() {
|
|
258
|
+
return this._comment;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
let I = class {
|
|
262
|
+
/**
|
|
263
|
+
* @ignore
|
|
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;
|
|
267
|
+
}
|
|
268
|
+
_getRef() {
|
|
269
|
+
var r;
|
|
270
|
+
const i = ((r = this._parent) == null ? void 0 : r.ref) || this._thread.ref;
|
|
271
|
+
return X(i).range;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Whether the comment is a root comment
|
|
275
|
+
* @returns {boolean} Whether the comment is a root comment
|
|
276
|
+
* @example
|
|
277
|
+
* ```ts
|
|
278
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
279
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
280
|
+
* const comments = fWorksheet.getComments();
|
|
281
|
+
* comments.forEach((comment) => {
|
|
282
|
+
* console.log(comment.getIsRoot());
|
|
283
|
+
* });
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
getIsRoot() {
|
|
287
|
+
return !this._parent;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Get the comment data
|
|
291
|
+
* @returns {IBaseComment} The comment data
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
295
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
296
|
+
* const comments = fWorksheet.getComments();
|
|
297
|
+
* comments.forEach((comment) => {
|
|
298
|
+
* console.log(comment.getCommentData());
|
|
299
|
+
* });
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
getCommentData() {
|
|
303
|
+
const { children: i, ...e } = this._thread;
|
|
304
|
+
return e;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Get the replies of the comment
|
|
308
|
+
* @returns {FThreadComment[]} the replies of the comment
|
|
309
|
+
* @example
|
|
310
|
+
* ```ts
|
|
311
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
312
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
313
|
+
* const comments = fWorksheet.getComments();
|
|
314
|
+
* comments.forEach((comment) => {
|
|
315
|
+
* if (comment.getIsRoot()) {
|
|
316
|
+
* const replies = comment.getReplies();
|
|
317
|
+
* replies.forEach((reply) => {
|
|
318
|
+
* console.log(reply.getCommentData());
|
|
319
|
+
* });
|
|
320
|
+
* }
|
|
321
|
+
* });
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
getReplies() {
|
|
325
|
+
var 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));
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Get the range of the comment
|
|
331
|
+
* @returns {FRange | null} The range of the comment
|
|
332
|
+
* @example
|
|
333
|
+
* ```ts
|
|
334
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
335
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
336
|
+
* const comments = fWorksheet.getComments();
|
|
337
|
+
* comments.forEach((comment) => {
|
|
338
|
+
* console.log(comment.getRange().getA1Notation());
|
|
339
|
+
* });
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
getRange() {
|
|
343
|
+
const i = this._univerInstanceService.getUnit(this._thread.unitId, G.UNIVER_SHEET);
|
|
344
|
+
if (!i)
|
|
345
|
+
return null;
|
|
346
|
+
const e = i.getSheetBySheetId(this._thread.subUnitId);
|
|
347
|
+
if (!e)
|
|
348
|
+
return null;
|
|
349
|
+
const r = this._getRef();
|
|
350
|
+
return this._injector.createInstance(j, i, e, r);
|
|
351
|
+
}
|
|
352
|
+
// eslint-disable-next-line
|
|
353
|
+
/**
|
|
354
|
+
* @deprecated use `getRichText` as instead
|
|
355
|
+
*/
|
|
356
|
+
getContent() {
|
|
357
|
+
return this._thread.text;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Get the rich text of the comment
|
|
361
|
+
* @returns {RichTextValue} The rich text of the comment
|
|
362
|
+
* @example
|
|
363
|
+
* ```ts
|
|
364
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
365
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
366
|
+
* const comments = fWorksheet.getComments();
|
|
367
|
+
* comments.forEach((comment) => {
|
|
368
|
+
* console.log(comment.getRichText());
|
|
369
|
+
* });
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
getRichText() {
|
|
373
|
+
const i = this._thread.text;
|
|
374
|
+
return k.create({ body: i, documentStyle: {}, id: "d" });
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Delete the comment and it's replies
|
|
378
|
+
* @returns {Promise<boolean>} Whether the comment is deleted successfully
|
|
379
|
+
* @example
|
|
380
|
+
* ```ts
|
|
381
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
382
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
383
|
+
* const comments = fWorksheet.getComments();
|
|
384
|
+
*
|
|
385
|
+
* // Delete the first comment
|
|
386
|
+
* const result = await comments[0]?.deleteAsync();
|
|
387
|
+
* console.log(result);
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
deleteAsync() {
|
|
391
|
+
return this._commandService.executeCommand(
|
|
392
|
+
this.getIsRoot() ? w.id : y.id,
|
|
393
|
+
{
|
|
394
|
+
commentId: this._thread.id,
|
|
395
|
+
unitId: this._thread.unitId,
|
|
396
|
+
subUnitId: this._thread.subUnitId
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
// eslint-disable-next-line
|
|
401
|
+
/**
|
|
402
|
+
* @deprecated use `deleteAsync` as instead.
|
|
403
|
+
*/
|
|
404
|
+
delete() {
|
|
405
|
+
return this.deleteAsync();
|
|
406
|
+
}
|
|
407
|
+
// eslint-disable-next-line
|
|
408
|
+
/**
|
|
409
|
+
* @deprecated use `updateAsync` as instead
|
|
410
|
+
*/
|
|
411
|
+
async update(i) {
|
|
412
|
+
return this.updateAsync(i);
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Update the comment content
|
|
416
|
+
* @param {IDocumentBody | RichTextValue} content The new content of the comment
|
|
417
|
+
* @returns {Promise<boolean>} Whether the comment is updated successfully
|
|
418
|
+
* @example
|
|
419
|
+
* ```ts
|
|
420
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
421
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
422
|
+
*
|
|
423
|
+
* // Create a new comment
|
|
424
|
+
* const richText = univerAPI.newRichText().insertText('hello univer');
|
|
425
|
+
* const commentBuilder = univerAPI.newTheadComment()
|
|
426
|
+
* .setContent(richText)
|
|
427
|
+
* .setId('mock-comment-id');
|
|
428
|
+
* const cell = fWorksheet.getRange('A1');
|
|
429
|
+
* await cell.addCommentAsync(commentBuilder);
|
|
430
|
+
*
|
|
431
|
+
* // Update the comment after 3 seconds
|
|
432
|
+
* setTimeout(async () => {
|
|
433
|
+
* const comment = fWorksheet.getCommentById('mock-comment-id');
|
|
434
|
+
* const newRichText = univerAPI.newRichText().insertText('Hello Univer AI');
|
|
435
|
+
* const result = await comment.updateAsync(newRichText);
|
|
436
|
+
* console.log(result);
|
|
437
|
+
* }, 3000);
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
async updateAsync(i) {
|
|
441
|
+
const e = i instanceof k ? i.getData().body : i, r = B();
|
|
442
|
+
return await this._commandService.executeCommand(
|
|
443
|
+
x.id,
|
|
444
|
+
{
|
|
445
|
+
unitId: this._thread.unitId,
|
|
446
|
+
subUnitId: this._thread.subUnitId,
|
|
447
|
+
payload: {
|
|
448
|
+
commentId: this._thread.id,
|
|
449
|
+
text: e,
|
|
450
|
+
updated: !0,
|
|
451
|
+
updateT: r
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
// eslint-disable-next-line
|
|
457
|
+
/**
|
|
458
|
+
* @deprecated use `resolveAsync` as instead
|
|
459
|
+
*/
|
|
460
|
+
resolve(i) {
|
|
461
|
+
return this.resolveAsync(i);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Resolve the comment
|
|
465
|
+
* @param {boolean} resolved Whether the comment is resolved
|
|
466
|
+
* @returns {Promise<boolean>} Set the comment to resolved or not operation result
|
|
467
|
+
* @example
|
|
468
|
+
* ```ts
|
|
469
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
470
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
471
|
+
*
|
|
472
|
+
* // Create a new comment
|
|
473
|
+
* const richText = univerAPI.newRichText().insertText('hello univer');
|
|
474
|
+
* const commentBuilder = univerAPI.newTheadComment()
|
|
475
|
+
* .setContent(richText)
|
|
476
|
+
* .setId('mock-comment-id');
|
|
477
|
+
* const cell = fWorksheet.getRange('A1');
|
|
478
|
+
* await cell.addCommentAsync(commentBuilder);
|
|
479
|
+
*
|
|
480
|
+
* // Resolve the comment after 3 seconds
|
|
481
|
+
* setTimeout(async () => {
|
|
482
|
+
* const comment = fWorksheet.getCommentById('mock-comment-id');
|
|
483
|
+
* const result = await comment.resolveAsync(true);
|
|
484
|
+
* console.log(result);
|
|
485
|
+
* }, 3000);
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
resolveAsync(i) {
|
|
489
|
+
return this._commandService.executeCommand(
|
|
490
|
+
D.id,
|
|
491
|
+
{
|
|
492
|
+
unitId: this._thread.unitId,
|
|
493
|
+
subUnitId: this._thread.subUnitId,
|
|
494
|
+
commentId: this._thread.id,
|
|
495
|
+
resolved: i != null ? i : !this._thread.resolved
|
|
496
|
+
}
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Reply to the comment
|
|
501
|
+
* @param {FTheadCommentBuilder} comment The comment to reply to
|
|
502
|
+
* @returns {Promise<boolean>} Whether the comment is replied successfully
|
|
503
|
+
* @example
|
|
504
|
+
* ```ts
|
|
505
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
506
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
507
|
+
*
|
|
508
|
+
* // Create a new comment
|
|
509
|
+
* const richText = univerAPI.newRichText().insertText('hello univer');
|
|
510
|
+
* const commentBuilder = univerAPI.newTheadComment()
|
|
511
|
+
* .setContent(richText)
|
|
512
|
+
* .setId('mock-comment-id');
|
|
513
|
+
* const cell = fWorksheet.getRange('A1');
|
|
514
|
+
* await cell.addCommentAsync(commentBuilder);
|
|
515
|
+
*
|
|
516
|
+
* // Reply to the comment
|
|
517
|
+
* const replyText = univerAPI.newRichText().insertText('Hello Univer AI');
|
|
518
|
+
* const reply = univerAPI.newTheadComment().setContent(replyText);
|
|
519
|
+
* const comment = fWorksheet.getCommentById('mock-comment-id');
|
|
520
|
+
* const result = await comment.replyAsync(reply);
|
|
521
|
+
* console.log(result);
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
524
|
+
replyAsync(i) {
|
|
525
|
+
var r;
|
|
526
|
+
const e = i.build();
|
|
527
|
+
return this._commandService.executeCommand(
|
|
528
|
+
f.id,
|
|
529
|
+
{
|
|
530
|
+
unitId: this._thread.unitId,
|
|
531
|
+
subUnitId: this._thread.subUnitId,
|
|
532
|
+
comment: {
|
|
533
|
+
id: R(),
|
|
534
|
+
parentId: this._thread.id,
|
|
535
|
+
threadId: this._thread.threadId,
|
|
536
|
+
ref: ((r = this._parent) == null ? void 0 : r.ref) || this._thread.ref,
|
|
537
|
+
unitId: this._thread.unitId,
|
|
538
|
+
subUnitId: this._thread.subUnitId,
|
|
539
|
+
text: e.text,
|
|
540
|
+
attachments: e.attachments,
|
|
541
|
+
dT: e.dT || B(),
|
|
542
|
+
personId: e.personId || this._userManagerService.getCurrentUser().userID
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
);
|
|
546
|
+
}
|
|
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 {
|
|
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)
|
|
559
|
+
return null;
|
|
560
|
+
const s = r.getComment(t, n, o);
|
|
561
|
+
return s ? this._injector.createInstance(I, s) : null;
|
|
562
|
+
}
|
|
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));
|
|
570
|
+
}
|
|
571
|
+
}), o;
|
|
572
|
+
}
|
|
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, {
|
|
577
|
+
unitId: s,
|
|
578
|
+
subUnitId: h,
|
|
579
|
+
comment: {
|
|
580
|
+
text: d.text,
|
|
581
|
+
dT: d.dT || B(),
|
|
582
|
+
attachments: [],
|
|
583
|
+
id: d.id || R(),
|
|
584
|
+
ref: c,
|
|
585
|
+
personId: d.personId || m.userID,
|
|
586
|
+
parentId: t == null ? void 0 : t.id,
|
|
587
|
+
unitId: s,
|
|
588
|
+
subUnitId: h,
|
|
589
|
+
threadId: (t == null ? void 0 : t.threadId) || R()
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
clearComment() {
|
|
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
|
|
601
|
+
}) : Promise.resolve(!0);
|
|
602
|
+
}
|
|
603
|
+
clearComments() {
|
|
604
|
+
const r = this.getComments().map((t) => t.deleteAsync());
|
|
605
|
+
return Promise.all(r).then(() => !0);
|
|
606
|
+
}
|
|
607
|
+
addCommentAsync(e) {
|
|
608
|
+
return this.addComment(e);
|
|
609
|
+
}
|
|
610
|
+
clearCommentAsync() {
|
|
611
|
+
return this.clearComment();
|
|
612
|
+
}
|
|
613
|
+
clearCommentsAsync() {
|
|
614
|
+
return this.clearComments();
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
j.extend(te);
|
|
618
|
+
class ne extends H {
|
|
619
|
+
/**
|
|
620
|
+
* @ignore
|
|
621
|
+
*/
|
|
622
|
+
_initialize() {
|
|
623
|
+
Object.defineProperty(this, "_threadCommentModel", {
|
|
624
|
+
get() {
|
|
625
|
+
return this._injector.get(Q);
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
getComments() {
|
|
630
|
+
return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map((e) => this._injector.createInstance(I, e.root));
|
|
631
|
+
}
|
|
632
|
+
clearComments() {
|
|
633
|
+
const r = this.getComments().map((t) => t.deleteAsync());
|
|
634
|
+
return Promise.all(r).then(() => !0);
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* @param callback
|
|
638
|
+
* @deprecated
|
|
639
|
+
*/
|
|
640
|
+
onThreadCommentChange(e) {
|
|
641
|
+
return S(this._threadCommentModel.commentUpdate$.pipe(Y((r) => r.unitId === this._workbook.getUnitId())).subscribe(e));
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* @param callback
|
|
645
|
+
* @deprecated
|
|
646
|
+
*/
|
|
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())
|
|
652
|
+
return;
|
|
653
|
+
if (e(n, t) === !1)
|
|
654
|
+
throw new Error("Command is stopped by the hook onBeforeAddThreadComment");
|
|
655
|
+
}
|
|
656
|
+
}));
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* @param callback
|
|
660
|
+
* @deprecated
|
|
661
|
+
*/
|
|
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())
|
|
667
|
+
return;
|
|
668
|
+
if (e(n, t) === !1)
|
|
669
|
+
throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment");
|
|
670
|
+
}
|
|
671
|
+
}));
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* @param callback
|
|
675
|
+
* @deprecated
|
|
676
|
+
*/
|
|
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())
|
|
682
|
+
return;
|
|
683
|
+
if (e(n, t) === !1)
|
|
684
|
+
throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment");
|
|
685
|
+
}
|
|
686
|
+
}));
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
H.extend(ne);
|
|
690
|
+
class re extends O {
|
|
691
|
+
getComments() {
|
|
692
|
+
return this._injector.get(b).getSubUnitAll(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => this._injector.createInstance(I, t));
|
|
693
|
+
}
|
|
694
|
+
clearComments() {
|
|
695
|
+
const r = this.getComments().map((t) => t.deleteAsync());
|
|
696
|
+
return Promise.all(r).then(() => !0);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Subscribe to comment events.
|
|
700
|
+
* @param callback Callback function, param contains comment info and target cell.
|
|
701
|
+
*/
|
|
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);
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
getCommentById(e) {
|
|
711
|
+
const t = this._injector.get(b).getComment(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
|
|
712
|
+
if (t)
|
|
713
|
+
return this._injector.createInstance(I, t);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
O.extend(re);
|
|
717
|
+
const l = {
|
|
718
|
+
CommentAdded: "CommentAdded",
|
|
719
|
+
BeforeCommentAdd: "BeforeCommentAdd",
|
|
720
|
+
CommentUpdated: "CommentUpdated",
|
|
721
|
+
BeforeCommentUpdate: "BeforeCommentUpdate",
|
|
722
|
+
CommentDeleted: "CommentDeleted",
|
|
723
|
+
BeforeCommentDelete: "BeforeCommentDelete",
|
|
724
|
+
CommentResolved: "CommentResolved",
|
|
725
|
+
BeforeCommentResolve: "BeforeCommentResolve"
|
|
726
|
+
};
|
|
727
|
+
class oe extends z {
|
|
728
|
+
get CommentAdded() {
|
|
729
|
+
return l.CommentAdded;
|
|
730
|
+
}
|
|
731
|
+
get BeforeCommentAdd() {
|
|
732
|
+
return l.BeforeCommentAdd;
|
|
733
|
+
}
|
|
734
|
+
get CommentUpdated() {
|
|
735
|
+
return l.CommentUpdated;
|
|
736
|
+
}
|
|
737
|
+
get BeforeCommentUpdate() {
|
|
738
|
+
return l.BeforeCommentUpdate;
|
|
739
|
+
}
|
|
740
|
+
get CommentDeleted() {
|
|
741
|
+
return l.CommentDeleted;
|
|
742
|
+
}
|
|
743
|
+
get BeforeCommentDelete() {
|
|
744
|
+
return l.BeforeCommentDelete;
|
|
745
|
+
}
|
|
746
|
+
get CommentResolved() {
|
|
747
|
+
return l.CommentResolved;
|
|
748
|
+
}
|
|
749
|
+
get BeforeCommentResolve() {
|
|
750
|
+
return l.BeforeCommentResolve;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
z.extend(oe);
|
|
754
|
+
class se extends $ {
|
|
755
|
+
// eslint-disable-next-line max-lines-per-function
|
|
756
|
+
_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,
|
|
875
|
+
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,
|
|
900
|
+
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,
|
|
903
|
+
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,
|
|
924
|
+
worksheet: s,
|
|
925
|
+
row: (u = d.getRange().getRow()) != null ? u : 0,
|
|
926
|
+
col: (g = d.getRange().getColumn()) != null ? g : 0,
|
|
927
|
+
comment: d,
|
|
928
|
+
resolved: m
|
|
929
|
+
};
|
|
930
|
+
if (this.fireEvent(this.Event.BeforeCommentResolve, C), C.cancel)
|
|
931
|
+
throw new E();
|
|
932
|
+
}
|
|
933
|
+
})
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* @ignore
|
|
938
|
+
*/
|
|
939
|
+
newTheadComment(e) {
|
|
940
|
+
return new U(e);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
$.extend(se);
|
|
944
|
+
export {
|
|
945
|
+
I as FThreadComment
|
|
946
|
+
};
|