@univerjs/sheets-thread-comment 0.5.3 → 0.5.4
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 +502 -102
- package/lib/es/index.js +117 -117
- package/lib/types/facade/f-event.d.ts +247 -0
- package/lib/types/facade/f-range.d.ts +15 -3
- package/lib/types/facade/f-thread-comment.d.ts +255 -8
- package/lib/types/facade/f-univer.d.ts +41 -0
- package/lib/types/facade/f-workbook.d.ts +28 -12
- package/lib/types/facade/f-worksheet.d.ts +26 -0
- package/lib/types/facade/index.d.ts +4 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
package/lib/es/facade.js
CHANGED
|
@@ -1,26 +1,231 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var P = (r, e, t) => e in r ? E(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var y = (r, e, t) => P(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Inject as v, Injector as F, UserManagerService as S, UniverInstanceType as W, RichTextValue as l, generateRandomId as g, ICommandService as p, IUniverInstanceService as O, RichTextBuilder as $, Tools as B, Range as z, toDisposable as I, FEventName as R } from "@univerjs/core";
|
|
5
|
+
import { SheetsThreadCommentModel as h } from "@univerjs/sheets-thread-comment";
|
|
6
|
+
import { FRange as x, FWorkbook as j, FWorksheet as D } from "@univerjs/sheets/facade";
|
|
7
|
+
import { DeleteCommentTreeCommand as T, DeleteCommentCommand as A, getDT as f, UpdateCommentCommand as M, ResolveCommentCommand as L, AddCommentCommand as b, ThreadCommentModel as N } from "@univerjs/thread-comment";
|
|
8
|
+
import { deserializeRangeWithSheet as V } from "@univerjs/engine-formula";
|
|
9
|
+
import { filter as H } from "rxjs";
|
|
10
|
+
var q = Object.defineProperty, G = Object.getOwnPropertyDescriptor, J = (r, e, t, n) => {
|
|
11
|
+
for (var o = n > 1 ? void 0 : n ? G(e, t) : e, m = r.length - 1, s; m >= 0; m--)
|
|
12
|
+
(s = r[m]) && (o = (n ? s(e, t, o) : s(o)) || o);
|
|
13
|
+
return n && o && q(e, t, o), o;
|
|
14
|
+
}, a = (r, e) => (t, n) => e(t, n, r);
|
|
15
|
+
class k {
|
|
16
|
+
constructor(e) {
|
|
17
|
+
y(this, "_comment", {
|
|
18
|
+
id: g(),
|
|
19
|
+
ref: "",
|
|
20
|
+
threadId: "",
|
|
21
|
+
dT: "",
|
|
22
|
+
personId: "",
|
|
23
|
+
text: $.newEmptyData().body,
|
|
24
|
+
attachments: [],
|
|
25
|
+
unitId: "",
|
|
26
|
+
subUnitId: ""
|
|
27
|
+
});
|
|
28
|
+
e && (this._comment = e);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a new FTheadCommentItem
|
|
32
|
+
* @param {IThreadComment|undefined} comment The comment
|
|
33
|
+
* @returns {FTheadCommentItem} A new instance of FTheadCommentItem
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const comment = univerAPI.newTheadComment();
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
static create(e) {
|
|
40
|
+
return new k(e);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the person id of the comment
|
|
44
|
+
* @returns {string} The person id of the comment
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
48
|
+
* .getSheetById(sheetId)
|
|
49
|
+
* .getCommentById(commentId);
|
|
50
|
+
* const personId = comment.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 comment = univerAPI.getActiveWorkbook()
|
|
62
|
+
* .getSheetById(sheetId)
|
|
63
|
+
* .getCommentById(commentId);
|
|
64
|
+
* const dateTime = comment.dateTime;
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
get dateTime() {
|
|
68
|
+
return this._comment.dT;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get the content of the comment
|
|
72
|
+
* @returns {RichTextValue} The content of the comment
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
76
|
+
* .getSheetById(sheetId)
|
|
77
|
+
* .getCommentById(commentId);
|
|
78
|
+
* const content = comment.content;
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
get content() {
|
|
82
|
+
return l.createByBody(this._comment.text);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get the id of the comment
|
|
86
|
+
* @returns {string} The id of the comment
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
90
|
+
* .getSheetById(sheetId)
|
|
91
|
+
* .getCommentById(commentId);
|
|
92
|
+
* const id = comment.id;
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
get id() {
|
|
96
|
+
return this._comment.id;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get the thread id of the comment
|
|
100
|
+
* @returns {string} The thread id of the comment
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
104
|
+
* .getSheetById(sheetId)
|
|
105
|
+
* .getCommentById(commentId);
|
|
106
|
+
* const threadId = comment.threadId;
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
get threadId() {
|
|
110
|
+
return this._comment.threadId;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Copy the comment
|
|
114
|
+
* @returns {FTheadCommentBuilder} The comment builder
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
118
|
+
* .getSheetById(sheetId)
|
|
119
|
+
* .getCommentById(commentId);
|
|
120
|
+
* const newComment = comment.copy();
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
copy() {
|
|
124
|
+
return U.create(B.deepClone(this._comment));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
class U extends k {
|
|
128
|
+
static create(e) {
|
|
129
|
+
return new U(e);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Set the content of the comment
|
|
133
|
+
* @param {IDocumentBody | RichTextValue} content The content of the comment
|
|
134
|
+
* @returns {FTheadCommentBuilder} The comment builder
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* const comment = univerAPI.newTheadComment()
|
|
138
|
+
* .setContent(univerAPI.newRichText().insertText('hello zhangsan'));
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
setContent(e) {
|
|
142
|
+
return e instanceof l ? this._comment.text = e.getData().body : this._comment.text = e, this;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Set the person id of the comment
|
|
146
|
+
* @param {string} userId The person id of the comment
|
|
147
|
+
* @returns {FTheadCommentBuilder} The comment builder
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* const comment = univerAPI.newTheadComment()
|
|
151
|
+
* .setPersonId('123');
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
setPersonId(e) {
|
|
155
|
+
return this._comment.personId = e, this;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Set the date time of the comment
|
|
159
|
+
* @param {Date} date The date time of the comment
|
|
160
|
+
* @returns {FTheadCommentBuilder} The comment builder
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const comment = univerAPI.newTheadComment()
|
|
164
|
+
* .setDateTime(new Date());
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
setDateTime(e) {
|
|
168
|
+
return this._comment.dT = f(e), this;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Set the id of the comment
|
|
172
|
+
* @param {string} id The id of the comment
|
|
173
|
+
* @returns {FTheadCommentBuilder} The comment builder
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* const comment = univerAPI.newTheadComment()
|
|
177
|
+
* .setId('123');
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
setId(e) {
|
|
181
|
+
return this._comment.id = e, this;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Set the thread id of the comment
|
|
185
|
+
* @param {string} threadId The thread id of the comment
|
|
186
|
+
* @returns {FTheadCommentBuilder} The comment builder
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* const comment = univerAPI.newTheadComment()
|
|
190
|
+
* .setThreadId('123');
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
setThreadId(e) {
|
|
194
|
+
return this._comment.threadId = e, this;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Build the comment
|
|
198
|
+
* @returns {IThreadComment} The comment
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const comment = univerAPI.newTheadComment()
|
|
202
|
+
* .setContent(univerAPI.newRichText().insertText('hello zhangsan'))
|
|
203
|
+
* .build();
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
build() {
|
|
207
|
+
return this._comment;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
let i = class {
|
|
211
|
+
constructor(r, e, t, n, o, m, s) {
|
|
212
|
+
this._thread = r, this._parent = e, this._injector = t, this._commandService = n, this._univerInstanceService = o, this._threadCommentModel = m, this._userManagerService = s;
|
|
15
213
|
}
|
|
16
214
|
_getRef() {
|
|
17
|
-
var
|
|
18
|
-
const
|
|
19
|
-
return
|
|
215
|
+
var t;
|
|
216
|
+
const r = ((t = this._parent) == null ? void 0 : t.ref) || this._thread.ref;
|
|
217
|
+
return V(r).range;
|
|
20
218
|
}
|
|
21
219
|
/**
|
|
22
220
|
* Whether the comment is a root comment
|
|
23
221
|
* @returns Whether the comment is a root comment
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
225
|
+
* .getSheetById(sheetId)
|
|
226
|
+
* .getCommentById(commentId);
|
|
227
|
+
* const isRoot = comment.getIsRoot();
|
|
228
|
+
* ```
|
|
24
229
|
*/
|
|
25
230
|
getIsRoot() {
|
|
26
231
|
return !this._parent;
|
|
@@ -28,48 +233,90 @@ let d = class {
|
|
|
28
233
|
/**
|
|
29
234
|
* Get the comment data
|
|
30
235
|
* @returns The comment data
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
239
|
+
* .getSheetById(sheetId)
|
|
240
|
+
* .getCommentById(commentId);
|
|
241
|
+
* const commentData = comment.getCommentData();
|
|
242
|
+
* ```
|
|
31
243
|
*/
|
|
32
244
|
getCommentData() {
|
|
33
|
-
const { children:
|
|
34
|
-
return
|
|
245
|
+
const { children: r, ...e } = this._thread;
|
|
246
|
+
return e;
|
|
35
247
|
}
|
|
36
248
|
/**
|
|
37
249
|
* Get the replies of the comment
|
|
38
250
|
* @returns the replies of the comment
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
254
|
+
* .getSheetById(sheetId)
|
|
255
|
+
* .getCommentById(commentId);
|
|
256
|
+
* const replies = comment.getReplies();
|
|
257
|
+
* ```
|
|
39
258
|
*/
|
|
40
259
|
getReplies() {
|
|
41
|
-
var
|
|
42
|
-
const
|
|
43
|
-
return (
|
|
260
|
+
var t;
|
|
261
|
+
const r = this._getRef(), e = this._threadCommentModel.getCommentWithChildren(this._thread.unitId, this._thread.subUnitId, r.startRow, r.startColumn);
|
|
262
|
+
return (t = e == null ? void 0 : e.children) == null ? void 0 : t.map((n) => this._injector.createInstance(i, n));
|
|
44
263
|
}
|
|
45
264
|
/**
|
|
46
265
|
* Get the range of the comment
|
|
47
266
|
* @returns The range of the comment
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
270
|
+
* .getSheetById(sheetId)
|
|
271
|
+
* .getCommentById(commentId);
|
|
272
|
+
* const range = comment.getRange();
|
|
273
|
+
* ```
|
|
48
274
|
*/
|
|
49
275
|
getRange() {
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
276
|
+
const r = this._univerInstanceService.getUnit(this._thread.unitId, W.UNIVER_SHEET);
|
|
277
|
+
if (!r)
|
|
52
278
|
return null;
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
279
|
+
const e = r.getSheetBySheetId(this._thread.subUnitId);
|
|
280
|
+
if (!e)
|
|
55
281
|
return null;
|
|
56
|
-
const
|
|
57
|
-
return this._injector.createInstance(
|
|
282
|
+
const t = this._getRef();
|
|
283
|
+
return this._injector.createInstance(x, r, e, t);
|
|
58
284
|
}
|
|
59
285
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @returns The content of the comment
|
|
286
|
+
* @deprecated use `getRichText` as instead
|
|
62
287
|
*/
|
|
63
288
|
getContent() {
|
|
64
289
|
return this._thread.text;
|
|
65
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Get the rich text of the comment
|
|
293
|
+
* @returns {RichTextValue} The rich text of the comment
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
297
|
+
* .getSheetById(sheetId)
|
|
298
|
+
* .getCommentById(commentId);
|
|
299
|
+
* const richText = comment.getRichText();
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
getRichText() {
|
|
303
|
+
const r = this._thread.text;
|
|
304
|
+
return l.create({ body: r, documentStyle: {}, id: "d" });
|
|
305
|
+
}
|
|
66
306
|
/**
|
|
67
307
|
* Delete the comment and it's replies
|
|
68
|
-
* @returns success or not
|
|
308
|
+
* @returns {Promise<boolean>} success or not
|
|
309
|
+
* @example
|
|
310
|
+
* ```ts
|
|
311
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
312
|
+
* .getSheetById(sheetId)
|
|
313
|
+
* .getCommentById(commentId);
|
|
314
|
+
* const success = await comment.deleteAsync();
|
|
315
|
+
* ```
|
|
69
316
|
*/
|
|
70
|
-
|
|
317
|
+
deleteAsync() {
|
|
71
318
|
return this._commandService.executeCommand(
|
|
72
|
-
this.getIsRoot() ?
|
|
319
|
+
this.getIsRoot() ? T.id : A.id,
|
|
73
320
|
{
|
|
74
321
|
commentId: this._thread.id,
|
|
75
322
|
unitId: this._thread.unitId,
|
|
@@ -77,154 +324,307 @@ let d = class {
|
|
|
77
324
|
}
|
|
78
325
|
);
|
|
79
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* @deprecated use `deleteAsync` as instead.
|
|
329
|
+
*/
|
|
330
|
+
delete() {
|
|
331
|
+
return this.deleteAsync();
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* @param content
|
|
335
|
+
* @deprecated use `updateAsync` as instead
|
|
336
|
+
*/
|
|
337
|
+
async update(r) {
|
|
338
|
+
return this.updateAsync(r);
|
|
339
|
+
}
|
|
80
340
|
/**
|
|
81
341
|
* Update the comment content
|
|
82
342
|
* @param content The new content of the comment
|
|
83
343
|
* @returns success or not
|
|
344
|
+
* @example
|
|
345
|
+
* ```ts
|
|
346
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
347
|
+
* .getSheetById(sheetId)
|
|
348
|
+
* .getCommentById(commentId);
|
|
349
|
+
* const success = await comment.updateAsync(univerAPI.newRichText().insertText('hello zhangsan'));
|
|
350
|
+
* ```
|
|
84
351
|
*/
|
|
85
|
-
async
|
|
86
|
-
const t =
|
|
352
|
+
async updateAsync(r) {
|
|
353
|
+
const e = r instanceof l ? r.getData().body : r, t = f();
|
|
87
354
|
return await this._commandService.executeCommand(
|
|
88
|
-
|
|
355
|
+
M.id,
|
|
89
356
|
{
|
|
90
357
|
unitId: this._thread.unitId,
|
|
91
358
|
subUnitId: this._thread.subUnitId,
|
|
92
359
|
payload: {
|
|
93
360
|
commentId: this._thread.id,
|
|
94
|
-
text:
|
|
361
|
+
text: e,
|
|
95
362
|
updated: !0,
|
|
96
363
|
updateT: t
|
|
97
364
|
}
|
|
98
365
|
}
|
|
99
366
|
);
|
|
100
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* @param resolved
|
|
370
|
+
* @deprecated use `resolveAsync` as instead
|
|
371
|
+
*/
|
|
372
|
+
resolve(r) {
|
|
373
|
+
return this.resolveAsync(r);
|
|
374
|
+
}
|
|
101
375
|
/**
|
|
102
376
|
* Resolve the comment
|
|
103
377
|
* @param resolved Whether the comment is resolved
|
|
104
378
|
* @returns success or not
|
|
379
|
+
* @example
|
|
380
|
+
* ```ts
|
|
381
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
382
|
+
* .getSheetById(sheetId)
|
|
383
|
+
* .getCommentById(commentId);
|
|
384
|
+
* const success = await comment.resolveAsync(true);
|
|
385
|
+
* ```
|
|
105
386
|
*/
|
|
106
|
-
|
|
387
|
+
resolveAsync(r) {
|
|
107
388
|
return this._commandService.executeCommand(
|
|
108
|
-
|
|
389
|
+
L.id,
|
|
109
390
|
{
|
|
110
391
|
unitId: this._thread.unitId,
|
|
111
392
|
subUnitId: this._thread.subUnitId,
|
|
112
393
|
commentId: this._thread.id,
|
|
113
|
-
resolved:
|
|
394
|
+
resolved: r != null ? r : !this._thread.resolved
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Reply to the comment
|
|
400
|
+
* @param comment The comment to reply to
|
|
401
|
+
* @returns success or not
|
|
402
|
+
* @example
|
|
403
|
+
* ```ts
|
|
404
|
+
* const comment = univerAPI.getActiveWorkbook()
|
|
405
|
+
* .getSheetById(sheetId)
|
|
406
|
+
* .getCommentById(commentId);
|
|
407
|
+
*
|
|
408
|
+
* const reply = univerAPI.newTheadComment()
|
|
409
|
+
* .setContent(univerAPI.newRichText().insertText('hello zhangsan'));
|
|
410
|
+
*
|
|
411
|
+
* const success = await comment.replyAsync(reply);
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
async replyAsync(r) {
|
|
415
|
+
var t;
|
|
416
|
+
const e = r.build();
|
|
417
|
+
return this._commandService.executeCommand(
|
|
418
|
+
b.id,
|
|
419
|
+
{
|
|
420
|
+
unitId: this._thread.unitId,
|
|
421
|
+
subUnitId: this._thread.subUnitId,
|
|
422
|
+
comment: {
|
|
423
|
+
id: g(),
|
|
424
|
+
parentId: this._thread.id,
|
|
425
|
+
threadId: this._thread.threadId,
|
|
426
|
+
ref: (t = this._parent) == null ? void 0 : t.ref,
|
|
427
|
+
unitId: this._thread.unitId,
|
|
428
|
+
subUnitId: this._thread.subUnitId,
|
|
429
|
+
text: e.text,
|
|
430
|
+
attachments: e.attachments,
|
|
431
|
+
dT: e.dT || f(),
|
|
432
|
+
personId: e.personId || this._userManagerService.getCurrentUser().userID
|
|
433
|
+
}
|
|
114
434
|
}
|
|
115
435
|
);
|
|
116
436
|
}
|
|
117
437
|
};
|
|
118
|
-
|
|
119
|
-
a(2,
|
|
120
|
-
a(3,
|
|
121
|
-
a(4,
|
|
122
|
-
a(5,
|
|
123
|
-
|
|
124
|
-
|
|
438
|
+
i = J([
|
|
439
|
+
a(2, v(F)),
|
|
440
|
+
a(3, p),
|
|
441
|
+
a(4, O),
|
|
442
|
+
a(5, v(h)),
|
|
443
|
+
a(6, v(S))
|
|
444
|
+
], i);
|
|
445
|
+
class K extends x {
|
|
125
446
|
getComment() {
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
447
|
+
const t = this._injector.get(h), n = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), m = t.getByLocation(n, o, this._range.startRow, this._range.startColumn);
|
|
448
|
+
if (!m)
|
|
128
449
|
return null;
|
|
129
|
-
const s =
|
|
130
|
-
return s ? this._injector.createInstance(
|
|
450
|
+
const s = t.getComment(n, o, m);
|
|
451
|
+
return s ? this._injector.createInstance(i, s) : null;
|
|
452
|
+
}
|
|
453
|
+
getComments() {
|
|
454
|
+
const t = this._injector.get(h), n = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), m = [];
|
|
455
|
+
return z.foreach(this._range, (s, c) => {
|
|
456
|
+
const u = t.getByLocation(n, o, s, c);
|
|
457
|
+
if (u) {
|
|
458
|
+
const C = t.getComment(n, o, u);
|
|
459
|
+
C && m.push(this._injector.createInstance(i, C));
|
|
460
|
+
}
|
|
461
|
+
}), m;
|
|
131
462
|
}
|
|
132
|
-
addComment(
|
|
133
|
-
var
|
|
134
|
-
const
|
|
135
|
-
return
|
|
463
|
+
addComment(e) {
|
|
464
|
+
var w;
|
|
465
|
+
const t = this._injector, n = (w = this.getComment()) == null ? void 0 : w.getCommentData(), o = t.get(p), m = t.get(S), s = this._workbook.getUnitId(), c = this._worksheet.getSheetId(), u = `${B.chatAtABC(this._range.startColumn)}${this._range.startRow + 1}`, C = m.getCurrentUser(), _ = e instanceof U ? e.build() : { text: e };
|
|
466
|
+
return o.executeCommand(b.id, {
|
|
136
467
|
unitId: s,
|
|
137
|
-
subUnitId:
|
|
468
|
+
subUnitId: c,
|
|
138
469
|
comment: {
|
|
139
|
-
text:
|
|
470
|
+
text: _.text,
|
|
471
|
+
dT: _.dT || f(),
|
|
140
472
|
attachments: [],
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
personId: w.userID,
|
|
473
|
+
id: _.id || g(),
|
|
474
|
+
ref: u,
|
|
475
|
+
personId: _.personId || C.userID,
|
|
145
476
|
parentId: n == null ? void 0 : n.id,
|
|
146
477
|
unitId: s,
|
|
147
|
-
subUnitId:
|
|
148
|
-
threadId: n == null ? void 0 : n.threadId
|
|
478
|
+
subUnitId: c,
|
|
479
|
+
threadId: (n == null ? void 0 : n.threadId) || g()
|
|
149
480
|
}
|
|
150
481
|
});
|
|
151
482
|
}
|
|
152
483
|
clearComment() {
|
|
153
484
|
var s;
|
|
154
|
-
const
|
|
155
|
-
return
|
|
156
|
-
unitId:
|
|
157
|
-
subUnitId:
|
|
158
|
-
threadId:
|
|
159
|
-
commentId:
|
|
485
|
+
const e = this._injector, t = (s = this.getComment()) == null ? void 0 : s.getCommentData(), n = e.get(p), o = this._workbook.getUnitId(), m = this._worksheet.getSheetId();
|
|
486
|
+
return t ? n.executeCommand(T.id, {
|
|
487
|
+
unitId: o,
|
|
488
|
+
subUnitId: m,
|
|
489
|
+
threadId: t.threadId,
|
|
490
|
+
commentId: t.id
|
|
160
491
|
}) : Promise.resolve(!0);
|
|
161
492
|
}
|
|
493
|
+
clearComments() {
|
|
494
|
+
const t = this.getComments().map((n) => n.deleteAsync());
|
|
495
|
+
return Promise.all(t).then(() => !0);
|
|
496
|
+
}
|
|
162
497
|
}
|
|
163
|
-
|
|
164
|
-
class
|
|
498
|
+
x.extend(K);
|
|
499
|
+
class Q extends j {
|
|
165
500
|
_initialize() {
|
|
166
501
|
Object.defineProperty(this, "_threadCommentModel", {
|
|
167
502
|
get() {
|
|
168
|
-
return this._injector.get(
|
|
503
|
+
return this._injector.get(N);
|
|
169
504
|
}
|
|
170
505
|
});
|
|
171
506
|
}
|
|
172
|
-
|
|
173
|
-
return
|
|
507
|
+
getComments() {
|
|
508
|
+
return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map((e) => this._injector.createInstance(i, e.root));
|
|
509
|
+
}
|
|
510
|
+
clearComments() {
|
|
511
|
+
const t = this.getComments().map((n) => n.deleteAsync());
|
|
512
|
+
return Promise.all(t).then(() => !0);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* @deprecated
|
|
516
|
+
*/
|
|
517
|
+
onThreadCommentChange(e) {
|
|
518
|
+
return I(this._threadCommentModel.commentUpdate$.pipe(H((t) => t.unitId === this._workbook.getUnitId())).subscribe(e));
|
|
174
519
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
520
|
+
/**
|
|
521
|
+
* @deprecated
|
|
522
|
+
*/
|
|
523
|
+
onBeforeAddThreadComment(e) {
|
|
524
|
+
return I(this._commandService.beforeCommandExecuted((t, n) => {
|
|
525
|
+
const o = t.params;
|
|
526
|
+
if (t.id === b.id) {
|
|
527
|
+
if (o.unitId !== this._workbook.getUnitId())
|
|
180
528
|
return;
|
|
181
|
-
if (
|
|
529
|
+
if (e(o, n) === !1)
|
|
182
530
|
throw new Error("Command is stopped by the hook onBeforeAddThreadComment");
|
|
183
531
|
}
|
|
184
532
|
}));
|
|
185
533
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
534
|
+
/**
|
|
535
|
+
* @deprecated
|
|
536
|
+
*/
|
|
537
|
+
onBeforeUpdateThreadComment(e) {
|
|
538
|
+
return I(this._commandService.beforeCommandExecuted((t, n) => {
|
|
539
|
+
const o = t.params;
|
|
540
|
+
if (t.id === M.id) {
|
|
541
|
+
if (o.unitId !== this._workbook.getUnitId())
|
|
191
542
|
return;
|
|
192
|
-
if (
|
|
543
|
+
if (e(o, n) === !1)
|
|
193
544
|
throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment");
|
|
194
545
|
}
|
|
195
546
|
}));
|
|
196
547
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
548
|
+
/**
|
|
549
|
+
* @deprecated
|
|
550
|
+
*/
|
|
551
|
+
onBeforeDeleteThreadComment(e) {
|
|
552
|
+
return I(this._commandService.beforeCommandExecuted((t, n) => {
|
|
553
|
+
const o = t.params;
|
|
554
|
+
if (t.id === A.id || t.id === T.id) {
|
|
555
|
+
if (o.unitId !== this._workbook.getUnitId())
|
|
202
556
|
return;
|
|
203
|
-
if (
|
|
557
|
+
if (e(o, n) === !1)
|
|
204
558
|
throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment");
|
|
205
559
|
}
|
|
206
560
|
}));
|
|
207
561
|
}
|
|
208
562
|
}
|
|
209
|
-
|
|
210
|
-
class
|
|
563
|
+
j.extend(Q);
|
|
564
|
+
class X extends D {
|
|
211
565
|
getComments() {
|
|
212
|
-
return this._injector.get(
|
|
566
|
+
return this._injector.get(h).getSubUnitAll(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((n) => this._injector.createInstance(i, n));
|
|
567
|
+
}
|
|
568
|
+
clearComments() {
|
|
569
|
+
const t = this.getComments().map((n) => n.deleteAsync());
|
|
570
|
+
return Promise.all(t).then(() => !0);
|
|
213
571
|
}
|
|
214
572
|
/**
|
|
215
573
|
* Subscribe to comment events.
|
|
216
574
|
* @param callback Callback function, param contains comment info and target cell.
|
|
217
575
|
*/
|
|
218
|
-
onCommented(
|
|
219
|
-
return this._injector.get(
|
|
220
|
-
if (n.id ===
|
|
221
|
-
const
|
|
222
|
-
|
|
576
|
+
onCommented(e) {
|
|
577
|
+
return this._injector.get(p).onCommandExecuted((n) => {
|
|
578
|
+
if (n.id === b.id) {
|
|
579
|
+
const o = n.params;
|
|
580
|
+
e(o);
|
|
223
581
|
}
|
|
224
582
|
});
|
|
225
583
|
}
|
|
584
|
+
getCommentById(e) {
|
|
585
|
+
const n = this._injector.get(h).getComment(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
|
|
586
|
+
if (n)
|
|
587
|
+
return this._injector.createInstance(i, n);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
D.extend(X);
|
|
591
|
+
const d = {
|
|
592
|
+
CommentAdded: "CommentAdded",
|
|
593
|
+
BeforeCommentAdd: "BeforeCommentAdd",
|
|
594
|
+
CommentUpdated: "CommentUpdated",
|
|
595
|
+
BeforeCommentUpdate: "BeforeCommentUpdate",
|
|
596
|
+
CommentDeleted: "CommentDeleted",
|
|
597
|
+
BeforeCommentDeleted: "BeforeCommentDeleted",
|
|
598
|
+
CommentResolved: "CommentResolved",
|
|
599
|
+
BeforeCommentResolve: "BeforeCommentResolve"
|
|
600
|
+
};
|
|
601
|
+
class Y extends R {
|
|
602
|
+
get CommentAdded() {
|
|
603
|
+
return d.CommentAdded;
|
|
604
|
+
}
|
|
605
|
+
get BeforeCommentAdd() {
|
|
606
|
+
return d.BeforeCommentAdd;
|
|
607
|
+
}
|
|
608
|
+
get CommentUpdated() {
|
|
609
|
+
return d.CommentUpdated;
|
|
610
|
+
}
|
|
611
|
+
get BeforeCommentUpdate() {
|
|
612
|
+
return d.BeforeCommentUpdate;
|
|
613
|
+
}
|
|
614
|
+
get CommentDeleted() {
|
|
615
|
+
return d.CommentDeleted;
|
|
616
|
+
}
|
|
617
|
+
get BeforeCommentDeleted() {
|
|
618
|
+
return d.BeforeCommentDeleted;
|
|
619
|
+
}
|
|
620
|
+
get CommentResolved() {
|
|
621
|
+
return d.CommentResolved;
|
|
622
|
+
}
|
|
623
|
+
get BeforeCommentResolve() {
|
|
624
|
+
return d.BeforeCommentResolve;
|
|
625
|
+
}
|
|
226
626
|
}
|
|
227
|
-
|
|
627
|
+
R.extend(Y);
|
|
228
628
|
export {
|
|
229
|
-
|
|
629
|
+
i as FThreadComment
|
|
230
630
|
};
|