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