superdoc 2.0.0-next.26 → 2.0.0-next.27

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/dist/superdoc.cjs CHANGED
@@ -6,7 +6,7 @@ const require_uuid = require("./chunks/uuid-CFp0WGVU.cjs");
6
6
  const require_jszip = require("./chunks/jszip-BdUBlUeG.cjs");
7
7
  const require__plugin_vue_export_helper = require("./chunks/_plugin-vue_export-helper-BTwbGDKw.cjs");
8
8
  const require_constants = require("./chunks/constants-sbCZ2O_A.cjs");
9
- const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-CHZKlLiH.cjs");
9
+ const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-pYMthdDn.cjs");
10
10
  let vue = require("vue");
11
11
  vue = require_rolldown_runtime.__toESM(vue);
12
12
  require("y-websocket");
@@ -1771,6 +1771,7 @@ function useComment(params) {
1771
1771
  const importedId = params.importedId;
1772
1772
  const parentCommentId = params.parentCommentId;
1773
1773
  const trackedChangeParentId = params.trackedChangeParentId;
1774
+ const trackedChangeThreadParentId = (0, vue.ref)(params.trackedChangeThreadParentId);
1774
1775
  const fileId = params.fileId;
1775
1776
  const fileType = params.fileType;
1776
1777
  const createdAtVersionNumber = params.createdAtVersionNumber;
@@ -1951,6 +1952,7 @@ function useComment(params) {
1951
1952
  importedId,
1952
1953
  parentCommentId,
1953
1954
  trackedChangeParentId,
1955
+ trackedChangeThreadParentId: trackedChangeThreadParentId.value,
1954
1956
  fileId,
1955
1957
  fileType,
1956
1958
  mentions: mentions.value.map((u) => {
@@ -2003,6 +2005,7 @@ function useComment(params) {
2003
2005
  importedId,
2004
2006
  parentCommentId,
2005
2007
  trackedChangeParentId,
2008
+ trackedChangeThreadParentId,
2006
2009
  fileId,
2007
2010
  fileType,
2008
2011
  mentions,
@@ -2754,6 +2757,12 @@ function withInteractionSpan(stage, branch, meta, fn) {
2754
2757
  throw error;
2755
2758
  }
2756
2759
  }
2760
+ const hasLegacyTrackedChangeThreadSignal = (comment) => Boolean(comment?.trackedChangeLink) || Boolean(comment?.trackedChangeType) || Boolean(comment?.trackedChangeDisplayType) || Boolean(comment?.trackedChangeText) || Boolean(comment?.deletedText) || comment?.trackedChange === true;
2761
+ const trackedChangeThreadParentIdForComment = (comment) => {
2762
+ if (comment?.trackedChangeThreadParentId != null) return comment.trackedChangeThreadParentId;
2763
+ if (comment?.trackedChangeParentId != null && hasLegacyTrackedChangeThreadSignal(comment)) return comment.trackedChangeParentId;
2764
+ return null;
2765
+ };
2757
2766
  var Editor = class {
2758
2767
  constructor() {
2759
2768
  throw new Error("SuperDoc v2 beta: v1 editor-backed comment import paths are not available.");
@@ -3046,9 +3055,15 @@ const useCommentsStore = defineStore("comments", () => {
3046
3055
  if (!comment?.parentCommentId) return comment;
3047
3056
  return getComment(comment.parentCommentId);
3048
3057
  };
3058
+ const trackedChangeThreadParentIdForComment$1 = (comment) => {
3059
+ if (comment?.trackedChangeThreadParentId) return comment.trackedChangeThreadParentId;
3060
+ if (isV2SyntheticTrackedChangeRow(comment) && comment?.trackedChange === true) return null;
3061
+ return trackedChangeThreadParentIdForComment(comment);
3062
+ };
3049
3063
  const shouldThreadWithTrackedChange = (comment) => {
3050
- if (!comment?.trackedChangeParentId) return false;
3051
- const trackedChange = getComment(comment.trackedChangeParentId);
3064
+ const trackedChangeParentId = trackedChangeThreadParentIdForComment$1(comment);
3065
+ if (!trackedChangeParentId) return false;
3066
+ const trackedChange = getComment(trackedChangeParentId);
3052
3067
  return Boolean(trackedChange?.trackedChange);
3053
3068
  };
3054
3069
  const getCommentPositionKey = (commentOrId) => {
@@ -3145,7 +3160,7 @@ const useCommentsStore = defineStore("comments", () => {
3145
3160
  if (source == null) return true;
3146
3161
  return source === DOCUMENT_EDITOR_SELECTION_SOURCE;
3147
3162
  };
3148
- const isTrackedChangeThread = (comment) => Boolean(comment?.trackedChange) || Boolean(comment?.trackedChangeParentId);
3163
+ const isTrackedChangeThread = (comment) => Boolean(comment?.trackedChange) || Boolean(trackedChangeThreadParentIdForComment$1(comment));
3149
3164
  const syncTrackedChangePositionsWithDocument = ({ documentId, editor } = {}) => {
3150
3165
  if (!editor?.state) return 0;
3151
3166
  if (!commentsList.value?.length) return 0;
@@ -3188,7 +3203,11 @@ const useCommentsStore = defineStore("comments", () => {
3188
3203
  commentsList.value.forEach((comment) => {
3189
3204
  const normalizedPositionKey = resolveExistingPositionKey(getCommentAliasIds(comment));
3190
3205
  if (!normalizedPositionKey) return;
3191
- if ([comment?.trackedChangeParentId, comment?.parentCommentId].map((id) => normalizeCommentId(id)).filter(Boolean).some((id) => staleRootAliasIds.has(id))) stalePositionKeys.add(normalizedPositionKey);
3206
+ if ([
3207
+ trackedChangeThreadParentIdForComment$1(comment),
3208
+ comment?.threadingParentCommentId,
3209
+ comment?.parentCommentId
3210
+ ].map((id) => normalizeCommentId(id)).filter(Boolean).some((id) => staleRootAliasIds.has(id))) stalePositionKeys.add(normalizedPositionKey);
3192
3211
  });
3193
3212
  const nextPositions = { ...currentPositions };
3194
3213
  stalePositionKeys.forEach((key) => {
@@ -3198,7 +3217,11 @@ const useCommentsStore = defineStore("comments", () => {
3198
3217
  if (activeComment.value !== void 0 && activeComment.value !== null) {
3199
3218
  const activeCommentModel = getComment(activeComment.value);
3200
3219
  const activeAliases = new Set(getCommentAliasIds(activeCommentModel ?? activeComment.value));
3201
- const activeParentKeys = [activeCommentModel?.trackedChangeParentId, activeCommentModel?.parentCommentId].map((id) => normalizeCommentId(id)).filter(Boolean);
3220
+ const activeParentKeys = [
3221
+ trackedChangeThreadParentIdForComment$1(activeCommentModel),
3222
+ activeCommentModel?.threadingParentCommentId,
3223
+ activeCommentModel?.parentCommentId
3224
+ ].map((id) => normalizeCommentId(id)).filter(Boolean);
3202
3225
  if (Array.from(activeAliases).some((id) => staleRootAliasIds.has(id)) || activeParentKeys.some((id) => staleRootAliasIds.has(id))) clearActiveCommentSelection();
3203
3226
  }
3204
3227
  return stalePositionKeys.size;
@@ -3303,7 +3326,7 @@ const useCommentsStore = defineStore("comments", () => {
3303
3326
  if (!isViewingMode.value) return true;
3304
3327
  const parent = getThreadParent(comment);
3305
3328
  if (!parent && comment?.parentCommentId) return false;
3306
- return Boolean(parent?.trackedChange) || Boolean(comment?.trackedChangeParentId) ? viewingVisibility.trackChangesVisible : viewingVisibility.commentsVisible;
3329
+ return Boolean(parent?.trackedChange) || Boolean(trackedChangeThreadParentIdForComment$1(comment)) ? viewingVisibility.trackChangesVisible : viewingVisibility.commentsVisible;
3307
3330
  };
3308
3331
  const setActiveComment = (superdoc, id) => {
3309
3332
  const activeEditor = superdoc?.activeEditor;
@@ -3671,8 +3694,8 @@ const useCommentsStore = defineStore("comments", () => {
3671
3694
  const childCommentMap = /* @__PURE__ */ new Map();
3672
3695
  commentsList.value.forEach((comment) => {
3673
3696
  if (!isThreadVisible(comment)) return;
3674
- const trackedChangeParentId = shouldThreadWithTrackedChange(comment) ? comment.trackedChangeParentId : null;
3675
- const parentId = comment.parentCommentId || trackedChangeParentId;
3697
+ const trackedChangeThreadParentId = shouldThreadWithTrackedChange(comment) ? trackedChangeThreadParentIdForComment$1(comment) : null;
3698
+ const parentId = comment.parentCommentId || trackedChangeThreadParentId;
3676
3699
  if (comment.resolvedTime) resolvedComments.push(comment);
3677
3700
  else if (!parentId && !comment.resolvedTime) parentComments.push({ ...comment });
3678
3701
  else if (parentId) {
@@ -4265,7 +4288,7 @@ const useCommentsStore = defineStore("comments", () => {
4265
4288
  };
4266
4289
  const isV2TrackedChangeSidecarCommentInput = (input) => {
4267
4290
  if (!input || input.trackedChange === true) return false;
4268
- if (!input.trackedChangeParentId || input.parentCommentId) return false;
4291
+ if (!input.trackedChangeThreadParentId || input.parentCommentId) return false;
4269
4292
  return isBlankV2CommentText(input.commentText);
4270
4293
  };
4271
4294
  const activeKey = activeComment.value != null ? String(activeComment.value) : null;
@@ -4283,12 +4306,13 @@ const useCommentsStore = defineStore("comments", () => {
4283
4306
  });
4284
4307
  if (!input) continue;
4285
4308
  if (isV2TrackedChangeSidecarCommentInput(input)) {
4286
- trackedChangeSidecarParentByCommentId.set(String(input.commentId), String(input.trackedChangeParentId));
4309
+ trackedChangeSidecarParentByCommentId.set(String(input.commentId), String(input.trackedChangeThreadParentId));
4287
4310
  tracePreviewComments("hydrate:drop-v2-sidecar-comment", {
4288
4311
  commentId: input.commentId ?? null,
4289
4312
  importedId: input.importedId ?? null,
4290
4313
  parentCommentId: input.parentCommentId ?? null,
4291
4314
  trackedChangeParentId: input.trackedChangeParentId ?? null,
4315
+ trackedChangeThreadParentId: input.trackedChangeThreadParentId ?? null,
4292
4316
  trackedChangeSide: input.trackedChangeSide ?? null,
4293
4317
  commentText: input.commentText ?? null
4294
4318
  });
@@ -4301,7 +4325,7 @@ const useCommentsStore = defineStore("comments", () => {
4301
4325
  const trackedChangeThreadId = parentId ? trackedChangeSidecarParentByCommentId.get(parentId) : null;
4302
4326
  if (trackedChangeThreadId) {
4303
4327
  input.threadingParentCommentId = trackedChangeThreadId;
4304
- if (input.trackedChangeParentId == null) input.trackedChangeParentId = trackedChangeThreadId;
4328
+ if (input.trackedChangeThreadParentId == null) input.trackedChangeThreadParentId = trackedChangeThreadId;
4305
4329
  }
4306
4330
  const cid = input.commentId != null ? String(input.commentId) : null;
4307
4331
  if (!cid) continue;
@@ -4343,6 +4367,8 @@ const useCommentsStore = defineStore("comments", () => {
4343
4367
  else delete existing.parentCommentId;
4344
4368
  if (input.trackedChangeParentId !== void 0) existing.trackedChangeParentId = input.trackedChangeParentId;
4345
4369
  else delete existing.trackedChangeParentId;
4370
+ if (input.trackedChangeThreadParentId !== void 0) existing.trackedChangeThreadParentId = input.trackedChangeThreadParentId;
4371
+ else existing.trackedChangeThreadParentId = void 0;
4346
4372
  if (input.trackedChangeSide !== void 0) existing.trackedChangeSide = input.trackedChangeSide;
4347
4373
  else delete existing.trackedChangeSide;
4348
4374
  if (input.threadingParentCommentId !== void 0) existing.threadingParentCommentId = input.threadingParentCommentId;
@@ -4554,6 +4580,7 @@ const useCommentsStore = defineStore("comments", () => {
4554
4580
  isInternal: false,
4555
4581
  parentCommentId: comment.parentCommentId,
4556
4582
  trackedChangeParentId: comment.trackedChangeParentId,
4583
+ trackedChangeThreadParentId: comment.trackedChangeThreadParentId,
4557
4584
  creatorId: null,
4558
4585
  creatorName,
4559
4586
  createdTime: comment.createdTime,
@@ -4813,8 +4840,8 @@ const useCommentsStore = defineStore("comments", () => {
4813
4840
  commentsList.value = commentsList.value.filter((comment) => {
4814
4841
  if (!belongsToTrackedChangeSyncDocument(comment, activeDocumentId)) return true;
4815
4842
  const parentCommentId = comment.parentCommentId != null ? String(comment.parentCommentId) : null;
4816
- const trackedChangeParentId = comment.trackedChangeParentId != null ? String(comment.trackedChangeParentId) : null;
4817
- if (!(parentCommentId && removedIds.has(parentCommentId) || trackedChangeParentId && removedIds.has(trackedChangeParentId))) return true;
4843
+ const trackedChangeThreadParentId = trackedChangeThreadParentIdForComment$1(comment) != null ? String(trackedChangeThreadParentIdForComment$1(comment)) : null;
4844
+ if (!(parentCommentId && removedIds.has(parentCommentId) || trackedChangeThreadParentId && removedIds.has(trackedChangeThreadParentId))) return true;
4818
4845
  if (comment.resolvedTime) return true;
4819
4846
  const commentId = comment.commentId != null ? String(comment.commentId) : null;
4820
4847
  const importedId = comment.importedId != null ? String(comment.importedId) : null;
@@ -4870,7 +4897,11 @@ const useCommentsStore = defineStore("comments", () => {
4870
4897
  commentsList.value.forEach((linkedComment) => {
4871
4898
  if (!linkedComment || linkedComment === comment) return;
4872
4899
  if (linkedComment.resolvedTime) return;
4873
- if (![linkedComment.trackedChangeParentId, linkedComment.parentCommentId].map((id) => normalizeCommentId(id)).filter(Boolean).some((id) => trackedChangeIds.has(id))) return;
4900
+ if (![
4901
+ trackedChangeThreadParentIdForComment$1(linkedComment),
4902
+ linkedComment.threadingParentCommentId,
4903
+ linkedComment.parentCommentId
4904
+ ].map((id) => normalizeCommentId(id)).filter(Boolean).some((id) => trackedChangeIds.has(id))) return;
4874
4905
  if (typeof linkedComment.resolveComment === "function") {
4875
4906
  linkedComment.resolveComment(resolveArgs);
4876
4907
  resolvedCount += 1;
@@ -4925,10 +4956,12 @@ const useCommentsStore = defineStore("comments", () => {
4925
4956
  commentsList.value.forEach((linkedComment) => {
4926
4957
  if (!linkedComment || linkedComment === comment) return;
4927
4958
  const trackedChangeParentId = normalizeCommentId(linkedComment.trackedChangeParentId);
4959
+ const trackedChangeThreadParentId = normalizeCommentId(linkedComment.trackedChangeThreadParentId);
4928
4960
  const threadingParentCommentId = normalizeCommentId(linkedComment.threadingParentCommentId);
4929
4961
  const parentCommentId = normalizeCommentId(linkedComment.parentCommentId);
4930
- if (!(trackedChangeParentId && trackedChangeIds.has(trackedChangeParentId) || threadingParentCommentId && trackedChangeIds.has(threadingParentCommentId) || parentCommentId && trackedChangeIds.has(parentCommentId))) return;
4962
+ if (!(trackedChangeParentId && trackedChangeIds.has(trackedChangeParentId) || trackedChangeThreadParentId && trackedChangeIds.has(trackedChangeThreadParentId) || threadingParentCommentId && trackedChangeIds.has(threadingParentCommentId) || parentCommentId && trackedChangeIds.has(parentCommentId))) return;
4931
4963
  delete linkedComment.trackedChangeParentId;
4964
+ linkedComment.trackedChangeThreadParentId = void 0;
4932
4965
  delete linkedComment.trackedChangeSide;
4933
4966
  delete linkedComment.threadingParentCommentId;
4934
4967
  if (parentCommentId && trackedChangeIds.has(parentCommentId)) delete linkedComment.parentCommentId;
@@ -6557,6 +6590,7 @@ var _sfc_main$34 = {
6557
6590
  return Boolean(currentName && commentName && currentName === commentName);
6558
6591
  };
6559
6592
  const isOwnComment = (0, vue.computed)(() => isCommentOwnedByCurrentUser(props.comment));
6593
+ const trackedChangeThreadParentId = (0, vue.computed)(() => trackedChangeThreadParentIdForComment(props.comment));
6560
6594
  const { uiFontFamily } = useUiFontFamily();
6561
6595
  const OVERFLOW_OPTIONS = Object.freeze({
6562
6596
  edit: {
@@ -6581,7 +6615,7 @@ var _sfc_main$34 = {
6581
6615
  if (!generallyAllowed.value) return false;
6582
6616
  if (!props.comment.trackedChange && props.config.allowResolve === false) return false;
6583
6617
  if (props.comment.parentCommentId) return false;
6584
- if (props.comment.trackedChangeParentId) return false;
6618
+ if (trackedChangeThreadParentId.value) return false;
6585
6619
  const context = {
6586
6620
  comment: props.comment,
6587
6621
  currentUser: proxy.$superdoc.config.user,
@@ -6610,7 +6644,7 @@ var _sfc_main$34 = {
6610
6644
  if (commentsStore.pendingComment) return false;
6611
6645
  if (props.isPendingInput) return false;
6612
6646
  if (props.comment.parentCommentId) return false;
6613
- if (props.comment.trackedChangeParentId) return false;
6647
+ if (trackedChangeThreadParentId.value) return false;
6614
6648
  if (props.comment.trackedChange) return false;
6615
6649
  const context = {
6616
6650
  comment: props.comment,
@@ -6732,7 +6766,7 @@ var _sfc_main$34 = {
6732
6766
  };
6733
6767
  }
6734
6768
  };
6735
- var CommentHeader_default = /* @__PURE__ */ require__plugin_vue_export_helper.__plugin_vue_export_helper_default(_sfc_main$34, [["__scopeId", "data-v-359c13bb"]]);
6769
+ var CommentHeader_default = /* @__PURE__ */ require__plugin_vue_export_helper.__plugin_vue_export_helper_default(_sfc_main$34, [["__scopeId", "data-v-ca6050aa"]]);
6736
6770
  var _hoisted_1$26 = { class: "input-section" };
6737
6771
  var TEXTAREA_MIN_HEIGHT = 28;
6738
6772
  var TEXTAREA_MAX_HEIGHT = 132;
@@ -6833,8 +6867,8 @@ const collectTrackedChangeThread = (parentComment, allComments) => {
6833
6867
  allComments.forEach((comment) => {
6834
6868
  if (comment.commentId === trackedChangeId) return;
6835
6869
  const isDirectChild = [comment.parentCommentId, comment.threadingParentCommentId].filter((id) => id != null).map((id) => String(id)).includes(trackedChangeId);
6836
- const isTrackedChangeAnchoredRoot = comment.trackedChangeParentId === trackedChangeId && !comment.parentCommentId;
6837
- if (isDirectChild || isTrackedChangeAnchoredRoot) {
6870
+ const isTrackedChangeThreadRoot = String(trackedChangeThreadParentIdForComment(comment) ?? "") === trackedChangeId && !comment.parentCommentId;
6871
+ if (isDirectChild || isTrackedChangeThreadRoot) {
6838
6872
  threadIds.add(comment.commentId);
6839
6873
  queue.push(comment.commentId);
6840
6874
  }
@@ -9679,6 +9713,38 @@ var _sfc_main$26 = {
9679
9713
  }
9680
9714
  };
9681
9715
  var HtmlViewer_default = /* @__PURE__ */ require__plugin_vue_export_helper.__plugin_vue_export_helper_default(_sfc_main$26, [["__scopeId", "data-v-da3494ba"]]);
9716
+ const collectRemovedCommentIds = (comments, targetIds, isInScope = () => true) => {
9717
+ const targets = new Set(targetIds.map(String));
9718
+ const removedIds = /* @__PURE__ */ new Set();
9719
+ comments.forEach((comment) => {
9720
+ if (!isInScope(comment)) return;
9721
+ const commentId = comment.commentId != null ? String(comment.commentId) : null;
9722
+ const importedId = comment.importedId != null ? String(comment.importedId) : null;
9723
+ if (!(commentId && targets.has(commentId)) && !(importedId && targets.has(importedId))) return;
9724
+ if (commentId) removedIds.add(commentId);
9725
+ if (importedId) removedIds.add(importedId);
9726
+ });
9727
+ let expanded = true;
9728
+ while (expanded) {
9729
+ expanded = false;
9730
+ comments.forEach((comment) => {
9731
+ if (!isInScope(comment)) return;
9732
+ const commentId = comment.commentId != null ? String(comment.commentId) : null;
9733
+ const importedId = comment.importedId != null ? String(comment.importedId) : null;
9734
+ const parentCommentId = comment.parentCommentId != null ? String(comment.parentCommentId) : null;
9735
+ const trackedChangeThreadParentIdValue = trackedChangeThreadParentIdForComment(comment);
9736
+ const trackedChangeThreadParentId = trackedChangeThreadParentIdValue != null ? String(trackedChangeThreadParentIdValue) : null;
9737
+ const isRemovedComment = commentId && removedIds.has(commentId) || importedId && removedIds.has(importedId);
9738
+ const isDescendant = parentCommentId && removedIds.has(parentCommentId) || trackedChangeThreadParentId && removedIds.has(trackedChangeThreadParentId);
9739
+ if (!isRemovedComment && !isDescendant) return;
9740
+ const sizeBefore = removedIds.size;
9741
+ if (commentId) removedIds.add(commentId);
9742
+ if (importedId) removedIds.add(importedId);
9743
+ if (removedIds.size > sizeBefore) expanded = true;
9744
+ });
9745
+ }
9746
+ return removedIds;
9747
+ };
9682
9748
  var isHighContrastMode = (0, vue.ref)(false);
9683
9749
  function useHighContrastMode() {
9684
9750
  const setHighContrastMode = (value) => {
@@ -10067,6 +10133,45 @@ function resolveV2ReviewTargetCommentId(target, getComment) {
10067
10133
  const commentId = comment?.commentId ?? comment?.importedId ?? target.entityId;
10068
10134
  return commentId != null ? String(commentId) : null;
10069
10135
  }
10136
+ function normalizeDocumentId(value) {
10137
+ return value == null ? null : String(value);
10138
+ }
10139
+ function createV2RemoteReviewHydrationScheduler({ hydrate, getActiveDocumentId, debounceMs = 250, ceilingMs = 1e3, now: now$2 = () => Date.now(), setTimer = (callback, delay) => setTimeout(callback, delay), clearTimer = (timer$1) => clearTimeout(timer$1) }) {
10140
+ let timer = null;
10141
+ let heldSinceMs = null;
10142
+ let pendingDocumentId = null;
10143
+ const matchesActiveDocument = (documentId) => {
10144
+ return normalizeDocumentId(getActiveDocumentId()) === documentId;
10145
+ };
10146
+ const clear = () => {
10147
+ if (timer != null) clearTimer(timer);
10148
+ timer = null;
10149
+ heldSinceMs = null;
10150
+ pendingDocumentId = null;
10151
+ };
10152
+ const schedule = (documentId) => {
10153
+ const normalizedDocumentId = normalizeDocumentId(documentId);
10154
+ if (!matchesActiveDocument(normalizedDocumentId)) return false;
10155
+ if (pendingDocumentId !== normalizedDocumentId) clear();
10156
+ const scheduledAtMs = now$2();
10157
+ pendingDocumentId = normalizedDocumentId;
10158
+ heldSinceMs ??= scheduledAtMs;
10159
+ if (timer != null) clearTimer(timer);
10160
+ const ceilingRemainingMs = Math.max(0, ceilingMs - (scheduledAtMs - heldSinceMs));
10161
+ timer = setTimer(() => {
10162
+ const deliveredDocumentId = pendingDocumentId;
10163
+ timer = null;
10164
+ heldSinceMs = null;
10165
+ pendingDocumentId = null;
10166
+ if (matchesActiveDocument(deliveredDocumentId)) hydrate();
10167
+ }, Math.min(debounceMs, ceilingRemainingMs));
10168
+ return true;
10169
+ };
10170
+ return {
10171
+ schedule,
10172
+ clear
10173
+ };
10174
+ }
10070
10175
  var NO_AUTHOR_SIGNAL = "no-author-configured";
10071
10176
  const V2_AUTHOR_REQUIRED_CODE = "author-required";
10072
10177
  const V2_AUTHOR_REQUIRED_MESSAGE = "This edit needs an author identity. Set `user.name` in your SuperDoc configuration and reopen the document to make tracked or revision-overlapping edits.";
@@ -14615,6 +14720,8 @@ var _sfc_main$20 = {
14615
14720
  if (latestV2MountStage && (clearedDocumentId == null || latestV2MountStage.dataset?.superdocV2DocumentId === clearedDocumentId)) latestV2MountStage = null;
14616
14721
  v2ReviewHydrationController.reset("render-cleared");
14617
14722
  v2ReviewMutationReconciler.reset();
14723
+ clearV2TypingReviewHydrationTimer();
14724
+ v2RemoteReviewHydrationScheduler.clear();
14618
14725
  commentsStore.setV2CommentsAdapter?.(null);
14619
14726
  commentsStore.setV2TrackedChangesAdapter?.(null);
14620
14727
  commentsStore.clearEditorCommentPositions?.();
@@ -14667,6 +14774,12 @@ var _sfc_main$20 = {
14667
14774
  });
14668
14775
  let v2LastTypingMutationAtMs = 0;
14669
14776
  let v2TypingReviewHydrationHeldSinceMs = 0;
14777
+ const clearV2TypingReviewHydrationTimer = () => {
14778
+ if (v2TypingReviewHydrationTimer && typeof clearTimeout === "function") clearTimeout(v2TypingReviewHydrationTimer);
14779
+ v2TypingReviewHydrationTimer = 0;
14780
+ v2LastTypingMutationAtMs = 0;
14781
+ v2TypingReviewHydrationHeldSinceMs = 0;
14782
+ };
14670
14783
  const scheduleV2TypingReviewHydration = () => {
14671
14784
  v2LastTypingMutationAtMs = Date.now();
14672
14785
  if (!v2TypingReviewHydrationHeldSinceMs) v2TypingReviewHydrationHeldSinceMs = v2LastTypingMutationAtMs;
@@ -14687,6 +14800,13 @@ var _sfc_main$20 = {
14687
14800
  const ceilingRemainingMs = Math.max(0, V2_TYPING_REVIEW_HYDRATION_CEILING_MS - (Date.now() - v2TypingReviewHydrationHeldSinceMs));
14688
14801
  v2TypingReviewHydrationTimer = setTimeout(attempt, Math.min(V2_TYPING_REVIEW_HYDRATION_IDLE_MS, ceilingRemainingMs));
14689
14802
  };
14803
+ const v2RemoteReviewHydrationScheduler = createV2RemoteReviewHydrationScheduler({
14804
+ hydrate: () => hydrateV2ReviewRowsFromHost(),
14805
+ getActiveDocumentId: () => {
14806
+ const activeEditor = proxy.$superdoc?.activeEditor ?? null;
14807
+ return activeEditor?.documentId ?? activeEditor?.options?.documentId ?? null;
14808
+ }
14809
+ });
14690
14810
  const onV2HostEvent = (document$1, event) => {
14691
14811
  if (!event) return;
14692
14812
  const documentId = document$1?.id ?? null;
@@ -14694,6 +14814,10 @@ var _sfc_main$20 = {
14694
14814
  syncSidebarActiveCommentFromV2ReviewTarget(event.next);
14695
14815
  return;
14696
14816
  }
14817
+ if (event.type === "collaboration:remote-changed") {
14818
+ v2RemoteReviewHydrationScheduler.schedule(documentId);
14819
+ return;
14820
+ }
14697
14821
  if (event.type === "source:complete") {
14698
14822
  proxy.$superdoc.broadcastSourceComplete();
14699
14823
  return;
@@ -14927,6 +15051,7 @@ var _sfc_main$20 = {
14927
15051
  "isInternal",
14928
15052
  "parentCommentId",
14929
15053
  "trackedChangeParentId",
15054
+ "trackedChangeThreadParentId",
14930
15055
  "threadingParentCommentId",
14931
15056
  "trackedChange",
14932
15057
  "trackedChangeType",
@@ -15091,34 +15216,8 @@ var _sfc_main$20 = {
15091
15216
  if (!activeDocumentId || typeof belongsToDocument !== "function") return true;
15092
15217
  return belongsToDocument(comment, activeDocumentId);
15093
15218
  };
15094
- const removedCommentIds = /* @__PURE__ */ new Set();
15095
- commentsList.value.forEach((comment) => {
15096
- if (!isInActiveDocument(comment)) return;
15097
- const commentId = comment.commentId != null ? String(comment.commentId) : null;
15098
- const importedId = comment.importedId != null ? String(comment.importedId) : null;
15099
- if (!(commentId && targetIds.includes(commentId) || importedId && targetIds.includes(importedId))) return;
15100
- if (commentId) removedCommentIds.add(commentId);
15101
- if (importedId) removedCommentIds.add(importedId);
15102
- });
15219
+ const removedCommentIds = collectRemovedCommentIds(commentsList.value, targetIds, isInActiveDocument);
15103
15220
  if (removedCommentIds.size) {
15104
- let expanded = true;
15105
- while (expanded) {
15106
- expanded = false;
15107
- commentsList.value.forEach((comment) => {
15108
- if (!isInActiveDocument(comment)) return;
15109
- const commentId = comment.commentId != null ? String(comment.commentId) : null;
15110
- const importedId = comment.importedId != null ? String(comment.importedId) : null;
15111
- const parentCommentId = comment.parentCommentId != null ? String(comment.parentCommentId) : null;
15112
- const trackedChangeParentId = comment.trackedChangeParentId != null ? String(comment.trackedChangeParentId) : null;
15113
- const isRemovedComment = commentId && removedCommentIds.has(commentId) || importedId && removedCommentIds.has(importedId);
15114
- const isDescendantOfRemovedComment = parentCommentId && removedCommentIds.has(parentCommentId) || trackedChangeParentId && removedCommentIds.has(trackedChangeParentId);
15115
- if (!isRemovedComment && !isDescendantOfRemovedComment) return;
15116
- const sizeBefore = removedCommentIds.size;
15117
- if (commentId) removedCommentIds.add(commentId);
15118
- if (importedId) removedCommentIds.add(importedId);
15119
- if (removedCommentIds.size > sizeBefore) expanded = true;
15120
- });
15121
- }
15122
15221
  const previousComments = [...commentsList.value];
15123
15222
  commentsList.value = commentsList.value.filter((comment) => {
15124
15223
  if (!isInActiveDocument(comment)) return true;
@@ -15376,11 +15475,8 @@ var _sfc_main$20 = {
15376
15475
  cancelAnimationFrame(v2GeometryRafHandle);
15377
15476
  v2GeometryRafHandle = 0;
15378
15477
  }
15379
- if (v2TypingReviewHydrationTimer && typeof clearTimeout === "function") {
15380
- clearTimeout(v2TypingReviewHydrationTimer);
15381
- v2TypingReviewHydrationTimer = 0;
15382
- }
15383
- v2TypingReviewHydrationHeldSinceMs = 0;
15478
+ clearV2TypingReviewHydrationTimer();
15479
+ v2RemoteReviewHydrationScheduler.clear();
15384
15480
  document.removeEventListener("focusin", handleRuntimeFocusIn, true);
15385
15481
  document.removeEventListener("pointerdown", handleRuntimePointerDown, true);
15386
15482
  document.removeEventListener("mousedown", handleRuntimeMouseDown, true);
@@ -15874,7 +15970,7 @@ var _sfc_main$20 = {
15874
15970
  };
15875
15971
  }
15876
15972
  };
15877
- var SuperDoc_default = /* @__PURE__ */ require__plugin_vue_export_helper.__plugin_vue_export_helper_default(_sfc_main$20, [["__scopeId", "data-v-8d8777e2"]]);
15973
+ var SuperDoc_default = /* @__PURE__ */ require__plugin_vue_export_helper.__plugin_vue_export_helper_default(_sfc_main$20, [["__scopeId", "data-v-c4ab995e"]]);
15878
15974
  var PINIA_DEVTOOLS_SETUP_EVENT = "devtools-plugin:setup";
15879
15975
  var PINIA_DEVTOOLS_PLUGIN_ID = "dev.esm.pinia";
15880
15976
  var piniaDevtoolsSuppressionState = {
@@ -34443,7 +34539,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
34443
34539
  this.config.colors = shuffleArray(this.config.colors);
34444
34540
  this.userColorMap = /* @__PURE__ */ new Map();
34445
34541
  this.colorIndex = 0;
34446
- this.version = "2.0.0-next.26";
34542
+ this.version = "2.0.0-next.27";
34447
34543
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
34448
34544
  this.superdocId = config.superdocId || require_uuid.v4_default();
34449
34545
  this.colors = this.config.colors ?? [];