@univerjs/thread-comment 1.0.0-insiders.20260813-7c9aa50 → 1.0.0

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/index.js CHANGED
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  let _univerjs_core = require("@univerjs/core");
3
3
  let rxjs = require("rxjs");
4
4
 
5
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
5
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
6
6
  function _typeof(o) {
7
7
  "@babel/helpers - typeof";
8
8
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -13,7 +13,7 @@ function _typeof(o) {
13
13
  }
14
14
 
15
15
  //#endregion
16
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
16
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
17
17
  function toPrimitive(t, r) {
18
18
  if ("object" != _typeof(t) || !t) return t;
19
19
  var e = t[Symbol.toPrimitive];
@@ -26,14 +26,14 @@ function toPrimitive(t, r) {
26
26
  }
27
27
 
28
28
  //#endregion
29
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
29
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
30
30
  function toPropertyKey(t) {
31
31
  var i = toPrimitive(t, "string");
32
32
  return "symbol" == _typeof(i) ? i : i + "";
33
33
  }
34
34
 
35
35
  //#endregion
36
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
36
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
37
37
  function _defineProperty(e, r, t) {
38
38
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
39
39
  value: t,
@@ -58,18 +58,29 @@ var ThreadCommentDataSourceService = class extends _univerjs_core.Disposable {
58
58
  constructor() {
59
59
  super();
60
60
  _defineProperty(this, "_dataSource", null);
61
+ _defineProperty(this, "_pendingAdds", /* @__PURE__ */ new Map());
61
62
  _defineProperty(this, "syncUpdateMutationToColla", true);
62
63
  }
63
64
  async getThreadComment(unitId, subUnitId, threadId) {
64
65
  if (this._dataSource) return (await this._dataSource.listComments(unitId, subUnitId, [threadId]))[0];
65
66
  return null;
66
67
  }
67
- async addComment(comment) {
68
- const savedComment = this._dataSource ? await this._dataSource.addComment(comment) : comment;
69
- return {
70
- ...savedComment,
71
- threadId: savedComment.threadId || savedComment.id
72
- };
68
+ addComment(comment) {
69
+ const key = `${comment.unitId}\0${comment.subUnitId}\0${comment.id}`;
70
+ const pending = this._pendingAdds.get(key);
71
+ if (pending) return pending;
72
+ const request = (async () => {
73
+ const savedComment = this._dataSource ? await this._dataSource.addComment(comment) : comment;
74
+ return {
75
+ ...savedComment,
76
+ threadId: savedComment.threadId || savedComment.id
77
+ };
78
+ })();
79
+ this._pendingAdds.set(key, request);
80
+ request.finally(() => {
81
+ if (this._pendingAdds.get(key) === request) this._pendingAdds.delete(key);
82
+ }).catch(() => void 0);
83
+ return request;
73
84
  }
74
85
  async updateComment(comment) {
75
86
  if (this._dataSource) return this._dataSource.updateComment(comment);
@@ -83,11 +94,16 @@ var ThreadCommentDataSourceService = class extends _univerjs_core.Disposable {
83
94
  if (this._dataSource) return this._dataSource.deleteComment(unitId, subUnitId, threadId, commentId);
84
95
  return true;
85
96
  }
97
+ async deleteThread(unitId, subUnitId, threadId) {
98
+ var _this$_dataSource;
99
+ if ((_this$_dataSource = this._dataSource) === null || _this$_dataSource === void 0 ? void 0 : _this$_dataSource.deleteThread) return this._dataSource.deleteThread(unitId, subUnitId, threadId);
100
+ return this.deleteComment(unitId, subUnitId, threadId, threadId);
101
+ }
86
102
  async listThreadComments(unitId, subUnitId, threadIds) {
87
103
  if (this.dataSource) return this.dataSource.listComments(unitId, subUnitId, threadIds);
88
104
  return false;
89
105
  }
90
- saveToSnapshot(unitComments, unitId) {
106
+ saveToSnapshot(unitComments, _unitId) {
91
107
  if (this._dataSource) {
92
108
  const map = {};
93
109
  Object.keys(unitComments).forEach((subUnitId) => {
@@ -102,7 +118,87 @@ var ThreadCommentDataSourceService = class extends _univerjs_core.Disposable {
102
118
  const IThreadCommentDataSourceService = (0, _univerjs_core.createIdentifier)("univer.thread-comment.data-source-service");
103
119
 
104
120
  //#endregion
105
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
121
+ //#region src/types/comment-anchor.ts
122
+ /**
123
+ * Copyright 2023-present DreamNum Co., Ltd.
124
+ *
125
+ * Licensed under the Apache License, Version 2.0 (the "License");
126
+ * you may not use this file except in compliance with the License.
127
+ * You may obtain a copy of the License at
128
+ *
129
+ * http://www.apache.org/licenses/LICENSE-2.0
130
+ *
131
+ * Unless required by applicable law or agreed to in writing, software
132
+ * distributed under the License is distributed on an "AS IS" BASIS,
133
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134
+ * See the License for the specific language governing permissions and
135
+ * limitations under the License.
136
+ */
137
+ let ThreadCommentAnchorKind = /* @__PURE__ */ function(ThreadCommentAnchorKind) {
138
+ /** A cell comment managed by the Sheets range Facade. */
139
+ ThreadCommentAnchorKind["SHEET_CELL"] = "sheet-cell";
140
+ /** A Sheet image, chart, Shape, or other drawing element. */
141
+ ThreadCommentAnchorKind["SHEET_DRAWING"] = "sheet-drawing";
142
+ /** A fixed text range comment managed by the Docs text range Facade. */
143
+ ThreadCommentAnchorKind["DOC_TEXT_RANGE"] = "doc-text-range";
144
+ /** A Document image, chart, Shape, or other drawing element. */
145
+ ThreadCommentAnchorKind["DOC_DRAWING"] = "doc-drawing";
146
+ /** A Slide page element identified by a stable element ID. */
147
+ ThreadCommentAnchorKind["SLIDE_ELEMENT"] = "slide-element";
148
+ /** A free position normalized to the Slide page size. */
149
+ ThreadCommentAnchorKind["SLIDE_POSITION"] = "slide-position";
150
+ /** A Board element identified by a stable element ID. */
151
+ ThreadCommentAnchorKind["BOARD_ELEMENT"] = "board-element";
152
+ /** A free position in Board world coordinates. */
153
+ ThreadCommentAnchorKind["BOARD_POSITION"] = "board-position";
154
+ /** A Base record identified by stable table and record IDs. */
155
+ ThreadCommentAnchorKind["BASE_RECORD"] = "base-record";
156
+ return ThreadCommentAnchorKind;
157
+ }({});
158
+ const THREAD_COMMENT_ANCHOR_PREFIX = "univer-comment-anchor:";
159
+ function isNonEmptyString(value) {
160
+ return typeof value === "string" && value.length > 0;
161
+ }
162
+ function isOptionalString(value) {
163
+ return value === void 0 || isNonEmptyString(value);
164
+ }
165
+ function isFiniteNumber(value) {
166
+ return typeof value === "number" && Number.isFinite(value);
167
+ }
168
+ function isThreadCommentAnchor(value) {
169
+ if (!value || typeof value !== "object") return false;
170
+ switch (Reflect.get(value, "kind")) {
171
+ case "sheet-drawing":
172
+ case "doc-drawing":
173
+ case "slide-element":
174
+ case "board-element": return isNonEmptyString(Reflect.get(value, "elementId")) && isOptionalString(Reflect.get(value, "pageId"));
175
+ case "slide-position":
176
+ case "board-position": return isFiniteNumber(Reflect.get(value, "x")) && isFiniteNumber(Reflect.get(value, "y")) && isOptionalString(Reflect.get(value, "pageId"));
177
+ case "base-record": return isNonEmptyString(Reflect.get(value, "tableId")) && isNonEmptyString(Reflect.get(value, "recordId"));
178
+ default: return false;
179
+ }
180
+ }
181
+ function serializeThreadCommentAnchor(anchor) {
182
+ if (!isThreadCommentAnchor(anchor)) throw new TypeError("Invalid thread comment anchor");
183
+ return `${THREAD_COMMENT_ANCHOR_PREFIX}${JSON.stringify({
184
+ v: 1,
185
+ anchor
186
+ })}`;
187
+ }
188
+ function deserializeThreadCommentAnchor(ref) {
189
+ if (!ref.startsWith(THREAD_COMMENT_ANCHOR_PREFIX)) return null;
190
+ try {
191
+ const value = JSON.parse(ref.slice(22));
192
+ if (!value || typeof value !== "object" || Reflect.get(value, "v") !== 1) return null;
193
+ const anchor = Reflect.get(value, "anchor");
194
+ return isThreadCommentAnchor(anchor) ? anchor : null;
195
+ } catch {
196
+ return null;
197
+ }
198
+ }
199
+
200
+ //#endregion
201
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
106
202
  function __decorateParam(paramIndex, decorator) {
107
203
  return function(target, key) {
108
204
  decorator(target, key, paramIndex);
@@ -110,7 +206,7 @@ function __decorateParam(paramIndex, decorator) {
110
206
  }
111
207
 
112
208
  //#endregion
113
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
209
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
114
210
  function __decorate(decorators, target, key, desc) {
115
211
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
116
212
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -121,12 +217,15 @@ function __decorate(decorators, target, key, desc) {
121
217
  //#endregion
122
218
  //#region src/models/thread-comment.model.ts
123
219
  let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposable {
124
- constructor(_dataSourceService, _lifecycleService) {
220
+ constructor(_dataSourceService, _lifecycleService, _univerInstanceService) {
125
221
  super();
126
222
  this._dataSourceService = _dataSourceService;
127
223
  this._lifecycleService = _lifecycleService;
224
+ this._univerInstanceService = _univerInstanceService;
128
225
  _defineProperty(this, "_commentsMap", /* @__PURE__ */ new Map());
129
226
  _defineProperty(this, "_threadMap", /* @__PURE__ */ new Map());
227
+ _defineProperty(this, "_syncVersions", /* @__PURE__ */ new Map());
228
+ _defineProperty(this, "_nextSyncVersion", 0);
130
229
  _defineProperty(this, "_commentUpdate$", new rxjs.Subject());
131
230
  _defineProperty(this, "commentUpdate$", this._commentUpdate$.asObservable());
132
231
  _defineProperty(this, "_tasks", []);
@@ -187,22 +286,47 @@ let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposa
187
286
  }
188
287
  return subUnitMap;
189
288
  }
289
+ _syncKey(unitId, subUnitId, threadId) {
290
+ return `${unitId}\0${subUnitId}\0${threadId}`;
291
+ }
292
+ _invalidateSync(unitId, subUnitId, threadId) {
293
+ this._syncVersions.delete(this._syncKey(unitId, subUnitId, threadId));
294
+ }
190
295
  _replaceComment(unitId, subUnitId, comment) {
191
296
  const commentMap = this._ensureCommentMap(unitId, subUnitId);
192
297
  const currentComment = commentMap.get(comment.id);
193
298
  if (!currentComment) {
194
- this.addComment(unitId, subUnitId, comment);
299
+ if ("ref" in comment && typeof comment.ref === "string") this.addComment(unitId, subUnitId, {
300
+ ...comment,
301
+ ref: comment.ref
302
+ });
195
303
  return;
196
304
  }
197
- const { children, ...rest } = comment;
305
+ const { children = [], ...rest } = comment;
306
+ const seenChildIds = /* @__PURE__ */ new Set([comment.id]);
307
+ const safeChildren = children.filter((child) => {
308
+ const current = commentMap.get(child.id);
309
+ if (child.threadId !== comment.threadId || seenChildIds.has(child.id) || current && current.threadId !== comment.threadId) return false;
310
+ seenChildIds.add(child.id);
311
+ return true;
312
+ });
198
313
  const newComment = {
199
314
  ...rest,
315
+ authorName: rest.authorName ?? (rest.personId === currentComment.personId ? currentComment.authorName : void 0),
200
316
  ref: currentComment.ref
201
317
  };
202
318
  commentMap.set(comment.id, newComment);
203
- children === null || children === void 0 || children.forEach((child) => {
319
+ if (!newComment.parentId) this._ensureThreadMap(unitId, subUnitId).set(newComment.threadId, newComment);
320
+ const remoteCommentIds = /* @__PURE__ */ new Set([comment.id, ...safeChildren.map((child) => child.id)]);
321
+ commentMap.forEach((localComment, commentId) => {
322
+ if (localComment.threadId === comment.threadId && !remoteCommentIds.has(commentId)) this._deleteComment(unitId, subUnitId, commentId);
323
+ });
324
+ safeChildren.forEach((child) => {
325
+ var _commentMap$get, _commentMap$get2;
204
326
  commentMap.set(child.id, {
205
327
  ...child,
328
+ authorName: child.authorName ?? (child.personId === ((_commentMap$get = commentMap.get(child.id)) === null || _commentMap$get === void 0 ? void 0 : _commentMap$get.personId) ? (_commentMap$get2 = commentMap.get(child.id)) === null || _commentMap$get2 === void 0 ? void 0 : _commentMap$get2.authorName : void 0),
329
+ parentId: comment.id,
206
330
  ref: ""
207
331
  });
208
332
  });
@@ -231,11 +355,39 @@ let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposa
231
355
  });
232
356
  return;
233
357
  }
358
+ const versions = new Map(threadIds.map((threadId) => {
359
+ const key = this._syncKey(unitId, subUnitId, threadId);
360
+ const version = ++this._nextSyncVersion;
361
+ this._syncVersions.set(key, version);
362
+ return [threadId, {
363
+ key,
364
+ version
365
+ }];
366
+ }));
367
+ const releaseVersions = () => versions.forEach(({ key, version }) => {
368
+ if (this._syncVersions.get(key) === version) this._syncVersions.delete(key);
369
+ });
370
+ let comments;
371
+ try {
372
+ comments = await this._dataSourceService.listThreadComments(unitId, subUnitId, threadIds);
373
+ } catch (error) {
374
+ releaseVersions();
375
+ throw error;
376
+ }
377
+ if (!comments) {
378
+ releaseVersions();
379
+ return;
380
+ }
381
+ const deleteThreads = new Set(threadIds.filter((threadId) => {
382
+ const request = versions.get(threadId);
383
+ return this._syncVersions.get(request.key) === request.version;
384
+ }));
385
+ if (!deleteThreads.size) {
386
+ releaseVersions();
387
+ return;
388
+ }
234
389
  const threadMap = this._ensureThreadMap(unitId, subUnitId);
235
390
  const commentMap = this._ensureCommentMap(unitId, subUnitId);
236
- const comments = await this._dataSourceService.listThreadComments(unitId, subUnitId, threadIds);
237
- if (!comments) return;
238
- const deleteThreads = new Set(threadIds);
239
391
  comments.forEach((comment) => {
240
392
  if (!deleteThreads.has(comment.threadId)) return;
241
393
  this._replaceComment(unitId, subUnitId, comment);
@@ -244,18 +396,21 @@ let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposa
244
396
  deleteThreads.forEach((id) => {
245
397
  threadMap.delete(id);
246
398
  commentMap.forEach((comment, commentId) => {
247
- if (comment.threadId === id) commentMap.delete(commentId);
399
+ if (comment.threadId === id) this._deleteComment(unitId, subUnitId, commentId);
248
400
  });
249
401
  });
402
+ releaseVersions();
250
403
  }
251
404
  addComment(unitId, subUnitId, origin, shouldSync) {
252
405
  const commentMap = this._ensureCommentMap(unitId, subUnitId);
406
+ if (commentMap.has(origin.id)) return true;
253
407
  const { parentId, children = [], ...rest } = origin;
254
408
  const comment = {
255
409
  ...rest,
256
410
  parentId: parentId === origin.id ? void 0 : parentId
257
411
  };
258
412
  if (!comment.threadId) comment.threadId = comment.parentId || comment.id;
413
+ this._invalidateSync(unitId, subUnitId, comment.threadId);
259
414
  const addCommentItem = (item) => {
260
415
  commentMap.set(item.id, item);
261
416
  this._commentUpdate$.next({
@@ -270,14 +425,22 @@ let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposa
270
425
  const threadMap = this._ensureThreadMap(unitId, subUnitId);
271
426
  if (!comment.parentId) {
272
427
  threadMap.set(comment.threadId, comment);
273
- for (const child of children) addCommentItem(child);
428
+ for (const child of children) {
429
+ if (child.id === comment.id || child.threadId !== comment.threadId || commentMap.has(child.id)) continue;
430
+ addCommentItem({
431
+ ...child,
432
+ parentId: comment.id,
433
+ ref: ""
434
+ });
435
+ }
274
436
  }
275
437
  if (shouldSync) this.syncThreadComments(unitId, subUnitId, [comment.threadId]);
276
438
  return true;
277
439
  }
278
440
  updateComment(unitId, subUnitId, payload, silent) {
279
441
  const oldComment = this._ensureCommentMap(unitId, subUnitId).get(payload.commentId);
280
- if (!oldComment) return true;
442
+ if (!oldComment) return false;
443
+ this._invalidateSync(unitId, subUnitId, oldComment.threadId);
281
444
  oldComment.updated = true;
282
445
  oldComment.text = payload.text;
283
446
  oldComment.attachments = payload.attachments;
@@ -294,6 +457,7 @@ let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposa
294
457
  updateCommentRef(unitId, subUnitId, payload, silent) {
295
458
  const oldComment = this._ensureCommentMap(unitId, subUnitId).get(payload.commentId);
296
459
  if (!oldComment) return false;
460
+ this._invalidateSync(unitId, subUnitId, oldComment.threadId);
297
461
  oldComment.ref = payload.ref;
298
462
  this._commentUpdate$.next({
299
463
  unitId,
@@ -308,6 +472,7 @@ let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposa
308
472
  resolveComment(unitId, subUnitId, commentId, resolved) {
309
473
  const oldComment = this._ensureCommentMap(unitId, subUnitId).get(commentId);
310
474
  if (!oldComment) return false;
475
+ this._invalidateSync(unitId, subUnitId, oldComment.threadId);
311
476
  oldComment.resolved = resolved;
312
477
  this._commentUpdate$.next({
313
478
  unitId,
@@ -356,6 +521,7 @@ let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposa
356
521
  const commentMap = this._ensureCommentMap(unitId, subUnitId);
357
522
  const current = commentMap.get(commentId);
358
523
  if (!current) return;
524
+ this._invalidateSync(unitId, subUnitId, current.threadId);
359
525
  commentMap.delete(commentId);
360
526
  this._commentUpdate$.next({
361
527
  unitId,
@@ -369,6 +535,7 @@ let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposa
369
535
  });
370
536
  }
371
537
  deleteThread(unitId, subUnitId, threadId) {
538
+ this._invalidateSync(unitId, subUnitId, threadId);
372
539
  this._ensureThreadMap(unitId, subUnitId).delete(threadId);
373
540
  this._ensureCommentMap(unitId, subUnitId).forEach((comment) => {
374
541
  if (comment.threadId === threadId) this._deleteComment(unitId, subUnitId, comment.id);
@@ -383,21 +550,46 @@ let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposa
383
550
  }
384
551
  deleteUnit(unitId) {
385
552
  const unitMap = this._commentsMap.get(unitId);
386
- if (!unitMap) return;
387
- unitMap.forEach((subUnitMap, subUnitId) => {
553
+ unitMap === null || unitMap === void 0 || unitMap.forEach((subUnitMap, subUnitId) => {
388
554
  subUnitMap.forEach((comment) => {
389
555
  this.deleteComment(unitId, subUnitId, comment.id);
390
556
  });
391
557
  });
558
+ this._commentsMap.delete(unitId);
559
+ this._threadMap.delete(unitId);
560
+ this._tasks = this._tasks.filter((task) => task.unitId !== unitId);
561
+ const syncPrefix = `${unitId}\0`;
562
+ this._syncVersions.forEach((_version, key) => {
563
+ if (key.startsWith(syncPrefix)) this._syncVersions.delete(key);
564
+ });
392
565
  }
393
566
  getUnit(unitId) {
394
- const unitMap = this._threadMap.get(unitId);
567
+ const unitMap = this._commentsMap.get(unitId);
395
568
  if (!unitMap) return [];
396
569
  const threads = [];
397
- unitMap.forEach((subUnitSet, subUnitId) => {
398
- subUnitSet.forEach((threadComment, threadId) => {
399
- const thread = this.getThread(unitId, subUnitId, threadId);
400
- if (thread) threads.push(thread);
570
+ unitMap.forEach((commentMap, subUnitId) => {
571
+ const threadInfos = /* @__PURE__ */ new Map();
572
+ commentMap.forEach((comment) => {
573
+ let thread = threadInfos.get(comment.threadId);
574
+ if (!thread) {
575
+ thread = {
576
+ unitId,
577
+ subUnitId,
578
+ threadId: comment.threadId,
579
+ children: [],
580
+ relativeUsers: /* @__PURE__ */ new Set()
581
+ };
582
+ threadInfos.set(comment.threadId, thread);
583
+ }
584
+ if (comment.parentId) thread.children.push(comment);
585
+ else thread.root = comment;
586
+ thread.relativeUsers.add(comment.personId);
587
+ });
588
+ threadInfos.forEach((thread) => {
589
+ if (thread.root) threads.push({
590
+ ...thread,
591
+ root: thread.root
592
+ });
401
593
  });
402
594
  });
403
595
  return threads;
@@ -412,8 +604,40 @@ let ThreadCommentModel = class ThreadCommentModel extends _univerjs_core.Disposa
412
604
  });
413
605
  return all;
414
606
  }
607
+ getAnchorKind(unitId, ref) {
608
+ const anchor = deserializeThreadCommentAnchor(ref);
609
+ if (anchor) return anchor.kind;
610
+ switch (this._univerInstanceService.getUnitType(unitId)) {
611
+ case _univerjs_core.UniverInstanceType.UNIVER_SHEET: return "sheet-cell";
612
+ case _univerjs_core.UniverInstanceType.UNIVER_DOC: return "doc-text-range";
613
+ default: return null;
614
+ }
615
+ }
616
+ query(query = {}) {
617
+ const unitIds = query.unitIds ? new Set(query.unitIds) : null;
618
+ const subUnitIds = query.subUnitIds ? new Set(query.subUnitIds) : null;
619
+ const anchorKinds = query.anchorKinds ? new Set(query.anchorKinds) : null;
620
+ const authorIds = query.authorIds ? new Set(query.authorIds) : null;
621
+ return this.getAll().flatMap(({ unitId, threads }) => {
622
+ if (unitIds && !unitIds.has(unitId)) return [];
623
+ return threads.filter((thread) => {
624
+ if (subUnitIds && !subUnitIds.has(thread.subUnitId)) return false;
625
+ if (query.resolved !== void 0 && Boolean(thread.root.resolved) !== query.resolved) return false;
626
+ if (anchorKinds) {
627
+ const anchorKind = this.getAnchorKind(unitId, thread.root.ref);
628
+ if (!anchorKind || !anchorKinds.has(anchorKind)) return false;
629
+ }
630
+ if (authorIds && ![thread.root, ...thread.children].some((comment) => authorIds.has(comment.personId))) return false;
631
+ return true;
632
+ });
633
+ });
634
+ }
415
635
  };
416
- ThreadCommentModel = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(IThreadCommentDataSourceService)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.LifecycleService))], ThreadCommentModel);
636
+ ThreadCommentModel = __decorate([
637
+ __decorateParam(0, (0, _univerjs_core.Inject)(IThreadCommentDataSourceService)),
638
+ __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.LifecycleService)),
639
+ __decorateParam(2, _univerjs_core.IUniverInstanceService)
640
+ ], ThreadCommentModel);
417
641
 
418
642
  //#endregion
419
643
  //#region src/commands/mutations/comment.mutation.ts
@@ -471,17 +695,48 @@ const DeleteCommentMutation = {
471
695
 
472
696
  //#endregion
473
697
  //#region src/commands/commands/comment.command.ts
698
+ const latestWriteVersions = /* @__PURE__ */ new WeakMap();
699
+ function startCommentWrite(comment, kind) {
700
+ const versions = latestWriteVersions.get(comment) ?? {
701
+ resolve: 0,
702
+ update: 0
703
+ };
704
+ const version = versions[kind] + 1;
705
+ versions[kind] = version;
706
+ latestWriteVersions.set(comment, versions);
707
+ return version;
708
+ }
709
+ function isLatestCommentWrite(comment, kind, version) {
710
+ var _latestWriteVersions$;
711
+ return ((_latestWriteVersions$ = latestWriteVersions.get(comment)) === null || _latestWriteVersions$ === void 0 ? void 0 : _latestWriteVersions$[kind]) === version;
712
+ }
474
713
  const AddCommentCommand = {
475
714
  id: "thread-comment.command.add-comment",
476
715
  type: _univerjs_core.CommandType.COMMAND,
477
716
  async handler(accessor, params) {
717
+ var _threadCommentModel$g, _threadCommentModel$g2;
478
718
  if (!params) return false;
479
719
  const commandService = accessor.get(_univerjs_core.ICommandService);
480
720
  const dataSourceService = accessor.get(IThreadCommentDataSourceService);
721
+ const threadCommentModel = accessor.get(ThreadCommentModel);
481
722
  const { comment: originComment } = params;
482
- const comment = await dataSourceService.addComment(originComment);
483
- const syncUpdateMutationToColla = dataSourceService.syncUpdateMutationToColla;
484
723
  const isRoot = !originComment.parentId;
724
+ if (!isRoot && ((_threadCommentModel$g = threadCommentModel.getRootComment(params.unitId, params.subUnitId, originComment.threadId)) === null || _threadCommentModel$g === void 0 ? void 0 : _threadCommentModel$g.id) !== originComment.parentId) return false;
725
+ const comment = {
726
+ ...await dataSourceService.addComment(originComment),
727
+ unitId: params.unitId,
728
+ subUnitId: params.subUnitId,
729
+ ref: originComment.ref,
730
+ parentId: originComment.parentId,
731
+ ...!isRoot ? { threadId: originComment.threadId } : {}
732
+ };
733
+ const syncUpdateMutationToColla = dataSourceService.syncUpdateMutationToColla;
734
+ if (!isRoot && ((_threadCommentModel$g2 = threadCommentModel.getRootComment(params.unitId, params.subUnitId, originComment.threadId)) === null || _threadCommentModel$g2 === void 0 ? void 0 : _threadCommentModel$g2.id) !== originComment.parentId) {
735
+ try {
736
+ await dataSourceService.deleteComment(params.unitId, params.subUnitId, comment.threadId, comment.id);
737
+ } catch {}
738
+ return false;
739
+ }
485
740
  const redo = {
486
741
  id: AddCommentMutation.id,
487
742
  params: {
@@ -506,16 +761,16 @@ const UpdateCommentCommand = {
506
761
  const current = threadCommentModel.getComment(unitId, subUnitId, payload.commentId);
507
762
  if (!current) return false;
508
763
  const { children, ...currentComment } = current;
764
+ const writeVersion = startCommentWrite(current, "update");
509
765
  if (!await dataSourceService.updateComment({
510
766
  ...currentComment,
511
767
  ...payload
512
- })) return false;
768
+ }) || threadCommentModel.getComment(unitId, subUnitId, payload.commentId) !== current || !isLatestCommentWrite(current, "update", writeVersion)) return false;
513
769
  const redo = {
514
770
  id: UpdateCommentMutation.id,
515
771
  params
516
772
  };
517
- commandService.executeCommand(redo.id, redo.params, { onlyLocal: !syncUpdateMutationToColla });
518
- return true;
773
+ return commandService.executeCommand(redo.id, redo.params, { onlyLocal: !syncUpdateMutationToColla });
519
774
  }
520
775
  };
521
776
  const ResolveCommentCommand = {
@@ -525,13 +780,15 @@ const ResolveCommentCommand = {
525
780
  if (!params) return false;
526
781
  const { unitId, subUnitId, resolved, commentId } = params;
527
782
  const dataSourceService = accessor.get(IThreadCommentDataSourceService);
528
- const currentComment = accessor.get(ThreadCommentModel).getComment(unitId, subUnitId, commentId);
783
+ const threadCommentModel = accessor.get(ThreadCommentModel);
784
+ const currentComment = threadCommentModel.getComment(unitId, subUnitId, commentId);
529
785
  const syncUpdateMutationToColla = dataSourceService.syncUpdateMutationToColla;
530
786
  if (!currentComment) return false;
787
+ const writeVersion = startCommentWrite(currentComment, "resolve");
531
788
  if (!await dataSourceService.resolveComment({
532
789
  ...currentComment,
533
790
  resolved
534
- })) return false;
791
+ }) || threadCommentModel.getComment(unitId, subUnitId, commentId) !== currentComment || !isLatestCommentWrite(currentComment, "resolve", writeVersion)) return false;
535
792
  return accessor.get(_univerjs_core.ICommandService).executeCommand(ResolveCommentMutation.id, params, { onlyLocal: !syncUpdateMutationToColla });
536
793
  }
537
794
  };
@@ -569,7 +826,7 @@ const DeleteCommentTreeCommand = {
569
826
  const { unitId, subUnitId, commentId } = params;
570
827
  const commentWithChildren = threadCommentModel.getCommentWithChildren(unitId, subUnitId, commentId);
571
828
  if (!commentWithChildren) return false;
572
- if (!await dataSourceService.deleteComment(unitId, subUnitId, commentWithChildren.root.threadId, commentId)) return false;
829
+ if (!(dataSourceService.deleteThread ? await dataSourceService.deleteThread(unitId, subUnitId, commentWithChildren.root.threadId) : await dataSourceService.deleteComment(unitId, subUnitId, commentWithChildren.root.threadId, commentWithChildren.root.id))) return false;
573
830
  return await commandService.executeCommand(DeleteCommentMutation.id, {
574
831
  unitId,
575
832
  subUnitId,
@@ -600,90 +857,226 @@ function getDT(date) {
600
857
  }
601
858
 
602
859
  //#endregion
603
- //#region src/types/const/index.ts
604
- /**
605
- * Copyright 2023-present DreamNum Co., Ltd.
606
- *
607
- * Licensed under the Apache License, Version 2.0 (the "License");
608
- * you may not use this file except in compliance with the License.
609
- * You may obtain a copy of the License at
610
- *
611
- * http://www.apache.org/licenses/LICENSE-2.0
612
- *
613
- * Unless required by applicable law or agreed to in writing, software
614
- * distributed under the License is distributed on an "AS IS" BASIS,
615
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
616
- * See the License for the specific language governing permissions and
617
- * limitations under the License.
618
- */
619
- const TC_PLUGIN_NAME = "UNIVER_THREAD_COMMENT_PLUGIN";
860
+ //#region src/services/thread-comment-api.service.ts
861
+ const DOCUMENT_BODY_ARRAY_FIELDS = [
862
+ "renderedPageBreaks",
863
+ "textRuns",
864
+ "paragraphs",
865
+ "sectionBreaks",
866
+ "customBlocks",
867
+ "tables",
868
+ "columnGroups",
869
+ "blockRanges",
870
+ "customRanges",
871
+ "customDecorations"
872
+ ];
873
+ function isThreadCommentDocumentBody(value) {
874
+ if (!value || typeof value !== "object") return false;
875
+ if (typeof Reflect.get(value, "dataStream") !== "string") return false;
876
+ if (DOCUMENT_BODY_ARRAY_FIELDS.some((field) => {
877
+ const fieldValue = Reflect.get(value, field);
878
+ return fieldValue !== void 0 && !Array.isArray(fieldValue);
879
+ })) return false;
880
+ const payloads = Reflect.get(value, "payloads");
881
+ return payloads === void 0 || payloads !== null && typeof payloads === "object" && !Array.isArray(payloads) && Object.values(payloads).every((item) => typeof item === "string");
882
+ }
883
+ function normalizeThreadCommentContent(content) {
884
+ if (typeof content !== "string") {
885
+ if (!isThreadCommentDocumentBody(content)) throw new TypeError("Invalid thread comment content");
886
+ if (!content.dataStream.replace(/[\r\n]/g, "").trim()) throw new TypeError("Thread comment content cannot be empty");
887
+ return content;
888
+ }
889
+ if (!content.trim()) throw new TypeError("Thread comment content cannot be empty");
890
+ return { dataStream: content.replace(/\r\n?|\n/g, "\r").replace(/\r*$/, "\r\n") };
891
+ }
892
+ function toFacadeInfo(thread, anchorKind) {
893
+ return {
894
+ unitId: thread.unitId,
895
+ subUnitId: thread.subUnitId,
896
+ threadId: thread.threadId,
897
+ root: thread.root,
898
+ children: thread.children,
899
+ anchorKind,
900
+ anchor: deserializeThreadCommentAnchor(thread.root.ref),
901
+ relativeUserIds: Array.from(thread.relativeUsers)
902
+ };
903
+ }
904
+ let ThreadCommentFacadeService = class ThreadCommentFacadeService {
905
+ constructor(_commandService, _model, _userManagerService) {
906
+ this._commandService = _commandService;
907
+ this._model = _model;
908
+ this._userManagerService = _userManagerService;
909
+ }
910
+ createCommentAsync(options) {
911
+ const id = options.id ?? (0, _univerjs_core.generateRandomId)();
912
+ const threadId = options.threadId ?? id;
913
+ const personId = options.personId ?? this._userManagerService.getCurrentUser().userID;
914
+ return this._commandService.executeCommand(AddCommentCommand.id, {
915
+ unitId: options.unitId,
916
+ subUnitId: options.subUnitId,
917
+ comment: {
918
+ id,
919
+ threadId,
920
+ unitId: options.unitId,
921
+ subUnitId: options.subUnitId,
922
+ ref: serializeThreadCommentAnchor(options.anchor),
923
+ text: normalizeThreadCommentContent(options.content),
924
+ attachments: options.attachments ?? [],
925
+ dT: getDT(options.dateTime),
926
+ authorName: options.authorName,
927
+ personId
928
+ }
929
+ });
930
+ }
931
+ replyCommentAsync(options) {
932
+ const root = this._model.getRootComment(options.unitId, options.subUnitId, options.threadId);
933
+ if (!root) return Promise.resolve(false);
934
+ return this._commandService.executeCommand(AddCommentCommand.id, {
935
+ unitId: options.unitId,
936
+ subUnitId: options.subUnitId,
937
+ comment: {
938
+ id: options.id ?? (0, _univerjs_core.generateRandomId)(),
939
+ threadId: options.threadId,
940
+ parentId: root.id,
941
+ unitId: options.unitId,
942
+ subUnitId: options.subUnitId,
943
+ ref: root.ref,
944
+ text: normalizeThreadCommentContent(options.content),
945
+ attachments: options.attachments ?? [],
946
+ dT: getDT(options.dateTime),
947
+ authorName: options.authorName,
948
+ personId: options.personId ?? this._userManagerService.getCurrentUser().userID
949
+ }
950
+ });
951
+ }
952
+ updateCommentAsync(options) {
953
+ return this._commandService.executeCommand(UpdateCommentCommand.id, {
954
+ unitId: options.unitId,
955
+ subUnitId: options.subUnitId,
956
+ payload: {
957
+ commentId: options.commentId,
958
+ text: normalizeThreadCommentContent(options.content),
959
+ attachments: options.attachments,
960
+ updateT: getDT(options.dateTime)
961
+ }
962
+ });
963
+ }
964
+ deleteCommentAsync(options) {
965
+ return this._commandService.executeCommand(options.deleteThread ? DeleteCommentTreeCommand.id : DeleteCommentCommand.id, {
966
+ unitId: options.unitId,
967
+ subUnitId: options.subUnitId,
968
+ commentId: options.commentId
969
+ });
970
+ }
971
+ resolveCommentAsync(options) {
972
+ return this._commandService.executeCommand(ResolveCommentCommand.id, {
973
+ unitId: options.unitId,
974
+ subUnitId: options.subUnitId,
975
+ commentId: options.commentId,
976
+ resolved: options.resolved ?? true
977
+ });
978
+ }
979
+ getComments(query = {}) {
980
+ return this._model.query(query).map((thread) => toFacadeInfo(thread, this._model.getAnchorKind(thread.unitId, thread.root.ref)));
981
+ }
982
+ async listCommentsAsync(query = {}) {
983
+ const knownThreads = this._model.query({
984
+ unitIds: query.unitIds,
985
+ subUnitIds: query.subUnitIds
986
+ });
987
+ const groups = /* @__PURE__ */ new Map();
988
+ knownThreads.forEach((thread) => {
989
+ const key = `${thread.unitId}\0${thread.subUnitId}`;
990
+ const group = groups.get(key) ?? {
991
+ unitId: thread.unitId,
992
+ subUnitId: thread.subUnitId,
993
+ threadIds: []
994
+ };
995
+ group.threadIds.push(thread.threadId);
996
+ groups.set(key, group);
997
+ });
998
+ await Promise.all(Array.from(groups.values()).map((group) => this._model.syncThreadComments(group.unitId, group.subUnitId, group.threadIds)));
999
+ return this._model.query(query).map((thread) => toFacadeInfo(thread, this._model.getAnchorKind(thread.unitId, thread.root.ref)));
1000
+ }
1001
+ };
1002
+ ThreadCommentFacadeService = __decorate([
1003
+ __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService)),
1004
+ __decorateParam(1, (0, _univerjs_core.Inject)(ThreadCommentModel)),
1005
+ __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.UserManagerService))
1006
+ ], ThreadCommentFacadeService);
620
1007
 
621
1008
  //#endregion
622
- //#region src/controllers/tc-resource.controller.ts
623
- const SHEET_UNIVER_THREAD_COMMENT_PLUGIN = `SHEET_${TC_PLUGIN_NAME}`;
624
- let ThreadCommentResourceController = class ThreadCommentResourceController extends _univerjs_core.Disposable {
625
- constructor(_resourceManagerService, _threadCommentModel, _threadCommentDataSourceService) {
626
- super();
627
- this._resourceManagerService = _resourceManagerService;
628
- this._threadCommentModel = _threadCommentModel;
629
- this._threadCommentDataSourceService = _threadCommentDataSourceService;
630
- this._initSnapshot();
631
- }
632
- _initSnapshot() {
633
- const toJson = (unitID) => {
634
- const map = this._threadCommentModel.getUnit(unitID);
1009
+ //#region src/common/tc-resource.ts
1010
+ function isStringArray(value) {
1011
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
1012
+ }
1013
+ function isSnapshotComment(value, allowChildren = true) {
1014
+ if (!value || typeof value !== "object") return false;
1015
+ const comment = value;
1016
+ return typeof comment.id === "string" && comment.id.length > 0 && typeof comment.threadId === "string" && comment.threadId.length > 0 && (typeof comment.ref === "string" || !allowChildren && comment.ref === void 0) && (comment.authorName === void 0 || typeof comment.authorName === "string") && (comment.text === void 0 || isThreadCommentDocumentBody(comment.text)) && (comment.attachments === void 0 || isStringArray(comment.attachments)) && (comment.mentions === void 0 || isStringArray(comment.mentions)) && (!allowChildren || comment.children === void 0 || Array.isArray(comment.children) && comment.children.every((child) => isSnapshotComment(child, false)));
1017
+ }
1018
+ function createThreadCommentResourceHook(threadCommentModel, threadCommentDataSourceService, pluginName, businesses) {
1019
+ return {
1020
+ pluginName,
1021
+ businesses,
1022
+ toJson: (unitID) => {
1023
+ const map = threadCommentModel.getUnit(unitID);
635
1024
  const resultMap = {};
636
- if (map) {
637
- map.forEach((info) => {
638
- const subUnitComments = resultMap[info.subUnitId] ?? [];
639
- subUnitComments.push({
640
- ...info.root,
641
- children: info.children
642
- });
643
- resultMap[info.subUnitId] = subUnitComments;
1025
+ map.forEach((info) => {
1026
+ const subUnitComments = resultMap[info.subUnitId] ?? [];
1027
+ subUnitComments.push({
1028
+ ...info.root,
1029
+ children: info.children
644
1030
  });
645
- return JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(resultMap, unitID));
646
- }
647
- return "";
648
- };
649
- const parseJson = (json) => {
1031
+ resultMap[info.subUnitId] = subUnitComments;
1032
+ });
1033
+ return JSON.stringify(threadCommentDataSourceService.saveToSnapshot(resultMap, unitID));
1034
+ },
1035
+ parseJson: (json) => {
650
1036
  if (!json) return {};
651
1037
  try {
652
- return JSON.parse(json);
653
- } catch (err) {
1038
+ const value = JSON.parse(json);
1039
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
1040
+ return Object.fromEntries(Object.entries(value).flatMap(([subUnitId, comments]) => Array.isArray(comments) ? [[subUnitId, comments.filter((comment) => isSnapshotComment(comment))]] : []));
1041
+ } catch {
654
1042
  return {};
655
1043
  }
656
- };
657
- this.disposeWithMe(this._resourceManagerService.registerPluginResource({
658
- pluginName: SHEET_UNIVER_THREAD_COMMENT_PLUGIN,
659
- businesses: [_univerjs_core.UniverInstanceType.UNIVER_SHEET, _univerjs_core.UniverInstanceType.UNIVER_DOC],
660
- toJson: (unitID) => toJson(unitID),
661
- parseJson: (json) => parseJson(json),
662
- onUnLoad: (unitID) => {
663
- this._threadCommentModel.deleteUnit(unitID);
664
- },
665
- onLoad: async (unitID, value) => {
666
- Object.keys(value).forEach((subunitId) => {
667
- const commentList = value[subunitId];
668
- commentList.forEach((comment) => {
669
- this._threadCommentModel.addComment(unitID, subunitId, comment);
1044
+ },
1045
+ onUnLoad: (unitID) => {
1046
+ threadCommentModel.deleteUnit(unitID);
1047
+ },
1048
+ onLoad: (unitID, value) => {
1049
+ Object.keys(value).forEach((subunitId) => {
1050
+ const commentList = value[subunitId];
1051
+ commentList.forEach((comment) => {
1052
+ var _comment$children;
1053
+ const seenIds = /* @__PURE__ */ new Set([comment.id]);
1054
+ const children = (_comment$children = comment.children) === null || _comment$children === void 0 ? void 0 : _comment$children.filter((child) => {
1055
+ if (child.threadId !== comment.threadId || seenIds.has(child.id)) return false;
1056
+ seenIds.add(child.id);
1057
+ return true;
1058
+ }).map((child) => ({
1059
+ ...child,
1060
+ unitId: unitID,
1061
+ subUnitId: subunitId
1062
+ }));
1063
+ threadCommentModel.addComment(unitID, subunitId, {
1064
+ ...comment,
1065
+ unitId: unitID,
1066
+ subUnitId: subunitId,
1067
+ children
670
1068
  });
671
- this._threadCommentModel.syncThreadComments(unitID, subunitId, commentList.map((i) => i.threadId));
672
1069
  });
673
- }
674
- }));
675
- }
676
- };
677
- ThreadCommentResourceController = __decorate([
678
- __decorateParam(0, _univerjs_core.IResourceManagerService),
679
- __decorateParam(1, (0, _univerjs_core.Inject)(ThreadCommentModel)),
680
- __decorateParam(2, IThreadCommentDataSourceService)
681
- ], ThreadCommentResourceController);
1070
+ threadCommentModel.syncThreadComments(unitID, subunitId, commentList.map((i) => i.threadId));
1071
+ });
1072
+ }
1073
+ };
1074
+ }
682
1075
 
683
1076
  //#endregion
684
1077
  //#region package.json
685
1078
  var name = "@univerjs/thread-comment";
686
- var version = "1.0.0-insiders.20260813-7c9aa50";
1079
+ var version = "1.0.0";
687
1080
 
688
1081
  //#endregion
689
1082
  //#region src/config/config.ts
@@ -691,6 +1084,25 @@ const THREAD_COMMENT_PLUGIN_CONFIG_KEY = "thread-comment.config";
691
1084
  const configSymbol = Symbol(THREAD_COMMENT_PLUGIN_CONFIG_KEY);
692
1085
  const defaultPluginConfig = {};
693
1086
 
1087
+ //#endregion
1088
+ //#region src/types/const/index.ts
1089
+ /**
1090
+ * Copyright 2023-present DreamNum Co., Ltd.
1091
+ *
1092
+ * Licensed under the Apache License, Version 2.0 (the "License");
1093
+ * you may not use this file except in compliance with the License.
1094
+ * You may obtain a copy of the License at
1095
+ *
1096
+ * http://www.apache.org/licenses/LICENSE-2.0
1097
+ *
1098
+ * Unless required by applicable law or agreed to in writing, software
1099
+ * distributed under the License is distributed on an "AS IS" BASIS,
1100
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1101
+ * See the License for the specific language governing permissions and
1102
+ * limitations under the License.
1103
+ */
1104
+ const TC_PLUGIN_NAME = "UNIVER_THREAD_COMMENT_PLUGIN";
1105
+
694
1106
  //#endregion
695
1107
  //#region src/plugin.ts
696
1108
  let UniverThreadCommentPlugin = class UniverThreadCommentPlugin extends _univerjs_core.Plugin {
@@ -708,7 +1120,7 @@ let UniverThreadCommentPlugin = class UniverThreadCommentPlugin extends _univerj
708
1120
  (0, _univerjs_core.mergeOverrideWithDependencies)([
709
1121
  [IThreadCommentDataSourceService, { useClass: ThreadCommentDataSourceService }],
710
1122
  [ThreadCommentModel],
711
- [ThreadCommentResourceController]
1123
+ [ThreadCommentFacadeService]
712
1124
  ], (_this$_config = this._config) === null || _this$_config === void 0 ? void 0 : _this$_config.overrides).forEach((d) => {
713
1125
  this._injector.add(d);
714
1126
  });
@@ -726,7 +1138,6 @@ let UniverThreadCommentPlugin = class UniverThreadCommentPlugin extends _univerj
726
1138
  ].forEach((command) => {
727
1139
  this._commandService.registerCommand(command);
728
1140
  });
729
- this._injector.get(ThreadCommentResourceController);
730
1141
  }
731
1142
  };
732
1143
  _defineProperty(UniverThreadCommentPlugin, "pluginName", TC_PLUGIN_NAME);
@@ -748,19 +1159,19 @@ exports.DeleteCommentTreeCommand = DeleteCommentTreeCommand;
748
1159
  exports.IThreadCommentDataSourceService = IThreadCommentDataSourceService;
749
1160
  exports.ResolveCommentCommand = ResolveCommentCommand;
750
1161
  exports.ResolveCommentMutation = ResolveCommentMutation;
751
- exports.SHEET_UNIVER_THREAD_COMMENT_PLUGIN = SHEET_UNIVER_THREAD_COMMENT_PLUGIN;
752
1162
  exports.TC_PLUGIN_NAME = TC_PLUGIN_NAME;
1163
+ exports.ThreadCommentAnchorKind = ThreadCommentAnchorKind;
753
1164
  exports.ThreadCommentDataSourceService = ThreadCommentDataSourceService;
754
- Object.defineProperty(exports, 'ThreadCommentModel', {
1165
+ Object.defineProperty(exports, 'ThreadCommentFacadeService', {
755
1166
  enumerable: true,
756
1167
  get: function () {
757
- return ThreadCommentModel;
1168
+ return ThreadCommentFacadeService;
758
1169
  }
759
1170
  });
760
- Object.defineProperty(exports, 'ThreadCommentResourceController', {
1171
+ Object.defineProperty(exports, 'ThreadCommentModel', {
761
1172
  enumerable: true,
762
1173
  get: function () {
763
- return ThreadCommentResourceController;
1174
+ return ThreadCommentModel;
764
1175
  }
765
1176
  });
766
1177
  Object.defineProperty(exports, 'UniverThreadCommentPlugin', {
@@ -772,4 +1183,10 @@ Object.defineProperty(exports, 'UniverThreadCommentPlugin', {
772
1183
  exports.UpdateCommentCommand = UpdateCommentCommand;
773
1184
  exports.UpdateCommentMutation = UpdateCommentMutation;
774
1185
  exports.UpdateCommentRefMutation = UpdateCommentRefMutation;
775
- exports.getDT = getDT;
1186
+ exports.createThreadCommentResourceHook = createThreadCommentResourceHook;
1187
+ exports.deserializeThreadCommentAnchor = deserializeThreadCommentAnchor;
1188
+ exports.getDT = getDT;
1189
+ exports.isThreadCommentAnchor = isThreadCommentAnchor;
1190
+ exports.isThreadCommentDocumentBody = isThreadCommentDocumentBody;
1191
+ exports.normalizeThreadCommentContent = normalizeThreadCommentContent;
1192
+ exports.serializeThreadCommentAnchor = serializeThreadCommentAnchor;