superdoc 2.24.0-next.1 → 2.24.0-next.10

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.
Files changed (52) hide show
  1. package/dist/chunks/{create-super-doc-ui-DFNXiKvQ.es.js → create-super-doc-ui-8UTu16Lw.es.js} +229 -82
  2. package/dist/chunks/{create-super-doc-ui-D_FbXpOQ.cjs → create-super-doc-ui-bTFGKVRb.cjs} +229 -82
  3. package/dist/collaboration-upgrade-engine.cjs +1 -1
  4. package/dist/collaboration-upgrade-engine.es.js +1 -1
  5. package/dist/document-api/src/authorities/authorities.types.d.ts +2 -0
  6. package/dist/document-api/src/bookmarks/bookmarks.types.d.ts +1 -0
  7. package/dist/document-api/src/capabilities/html-markdown-support.d.ts +2 -4
  8. package/dist/document-api/src/captions/captions.types.d.ts +1 -0
  9. package/dist/document-api/src/citations/citations.types.d.ts +2 -0
  10. package/dist/document-api/src/content-controls/content-controls.types.d.ts +1 -0
  11. package/dist/document-api/src/contract/command-catalog.d.ts +1 -1
  12. package/dist/document-api/src/contract/operation-definitions.d.ts +15 -5
  13. package/dist/document-api/src/cross-refs/cross-refs.types.d.ts +1 -0
  14. package/dist/document-api/src/fields/fields.types.d.ts +1 -0
  15. package/dist/document-api/src/footnotes/footnotes.types.d.ts +2 -0
  16. package/dist/document-api/src/hyperlinks/hyperlinks.types.d.ts +1 -0
  17. package/dist/document-api/src/images/images.types.d.ts +2 -0
  18. package/dist/document-api/src/index/index.types.d.ts +2 -0
  19. package/dist/document-api/src/index.d.ts +6 -6
  20. package/dist/document-api/src/insert/insert.d.ts +7 -1
  21. package/dist/document-api/src/lists/lists.types.d.ts +10 -0
  22. package/dist/document-api/src/paragraphs/paragraphs.types.d.ts +3 -0
  23. package/dist/document-api/src/receipt-bridge.d.ts +1 -0
  24. package/dist/document-api/src/replace/replace.d.ts +31 -4
  25. package/dist/document-api/src/sections/sections.types.d.ts +4 -1
  26. package/dist/document-api/src/selection/selection.d.ts +9 -2
  27. package/dist/document-api/src/selection/selection.types.d.ts +57 -8
  28. package/dist/document-api/src/toc/toc.types.d.ts +3 -0
  29. package/dist/document-api/src/types/blocks.types.d.ts +6 -1
  30. package/dist/document-api/src/types/create.types.d.ts +3 -1
  31. package/dist/document-api/src/types/mutation-plan.types.d.ts +4 -0
  32. package/dist/document-api/src/types/receipt.d.ts +8 -0
  33. package/dist/document-api/src/types/sd-contract.d.ts +2 -0
  34. package/dist/document-api/src/types/table-operations.types.d.ts +2 -0
  35. package/dist/document-api/src/write/write.d.ts +4 -2
  36. package/dist/public/ui-react.cjs +1 -1
  37. package/dist/public/ui-react.es.js +1 -1
  38. package/dist/public/ui-vue.cjs +1 -1
  39. package/dist/public/ui-vue.es.js +1 -1
  40. package/dist/public/ui.cjs +1 -1
  41. package/dist/public/ui.es.js +1 -1
  42. package/dist/style.css +65 -65
  43. package/dist/style.layered.css +65 -65
  44. package/dist/superdoc/src/public/ui/types.d.ts +22 -0
  45. package/dist/superdoc/src/public/ui.d.cts +4 -0
  46. package/dist/superdoc/src/public/ui.d.ts +1 -1
  47. package/dist/superdoc.cjs +101 -43
  48. package/dist/superdoc.es.js +101 -43
  49. package/dist-cdn/style.layered.css +1 -1
  50. package/dist-cdn/superdoc.min.css +1 -1
  51. package/dist-cdn/superdoc.min.js +42 -42
  52. package/package.json +2 -2
package/dist/superdoc.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./chunks/rolldown-runtime-74VwNCz7.cjs");
3
3
  const require_blank_docx = require("./chunks/blank-docx-BuFAbRjs.cjs");
4
- const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-D_FbXpOQ.cjs");
4
+ const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-bTFGKVRb.cjs");
5
5
  const require_eventemitter3 = require("./chunks/eventemitter3-C_TAnXOl.cjs");
6
6
  const require_uuid = require("./chunks/uuid-BhG0ngwk.cjs");
7
7
  const require__plugin_vue_export_helper = require("./chunks/_plugin-vue_export-helper-CYxINHh_.cjs");
@@ -304,7 +304,7 @@ var awarenessStatesToArray = (context, states) => {
304
304
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
305
305
  function getSuperdocVersion() {
306
306
  try {
307
- return "2.24.0-next.1";
307
+ return "2.24.0-next.10";
308
308
  } catch {
309
309
  return "unknown";
310
310
  }
@@ -13932,10 +13932,35 @@ var _sfc_main$34 = {
13932
13932
  require__plugin_vue_export_helper.nextTick(() => emit("resize"));
13933
13933
  });
13934
13934
  };
13935
- const isV2Mode = require__plugin_vue_export_helper.computed(() => proxy.$superdoc?.activeEditor?.editorVersion === 2);
13936
- const v2CommentsAdapter = require__plugin_vue_export_helper.computed(() => isV2Mode.value ? proxy.$superdoc?.activeEditor?.v2Comments ?? null : null);
13937
- const v2TrackedChangesAdapter = require__plugin_vue_export_helper.computed(() => isV2Mode.value ? proxy.$superdoc?.activeEditor?.v2TrackedChanges ?? null : null);
13935
+ const activeEditorRevision = require__plugin_vue_export_helper.ref(0);
13936
+ const v2CapabilityRevision = require__plugin_vue_export_helper.ref(0);
13937
+ const refreshActiveEditor = () => {
13938
+ activeEditorRevision.value += 1;
13939
+ };
13940
+ const isV2Mode = require__plugin_vue_export_helper.computed(() => {
13941
+ activeEditorRevision.value;
13942
+ return proxy.$superdoc?.activeEditor?.editorVersion === 2;
13943
+ });
13944
+ const v2CommentsAdapter = require__plugin_vue_export_helper.computed(() => {
13945
+ activeEditorRevision.value;
13946
+ return isV2Mode.value ? proxy.$superdoc?.activeEditor?.v2Comments ?? null : null;
13947
+ });
13948
+ const v2TrackedChangesAdapter = require__plugin_vue_export_helper.computed(() => {
13949
+ activeEditorRevision.value;
13950
+ return isV2Mode.value ? proxy.$superdoc?.activeEditor?.v2TrackedChanges ?? null : null;
13951
+ });
13952
+ require__plugin_vue_export_helper.watch(() => {
13953
+ activeEditorRevision.value;
13954
+ return isV2Mode.value ? proxy.$superdoc?.activeEditor?.host ?? null : null;
13955
+ }, (host, _previous, onCleanup) => {
13956
+ v2CapabilityRevision.value += 1;
13957
+ const unsubscribe = host?.subscribe?.(() => {
13958
+ v2CapabilityRevision.value += 1;
13959
+ });
13960
+ onCleanup(() => unsubscribe?.());
13961
+ }, { immediate: true });
13938
13962
  const v2WriteCapability = require__plugin_vue_export_helper.computed(() => {
13963
+ v2CapabilityRevision.value;
13939
13964
  if (!v2CommentsAdapter.value) return null;
13940
13965
  const documentMode = commentsStore.viewingVisibility.documentMode;
13941
13966
  const command = isPendingNewComment.value ? "comments.createFromSelection" : null;
@@ -13959,6 +13984,7 @@ var _sfc_main$34 = {
13959
13984
  return v2WriteCapability.value?.reason ?? "v2-write-unavailable";
13960
13985
  });
13961
13986
  const v2TrackedChangeCapability = require__plugin_vue_export_helper.computed(() => {
13987
+ v2CapabilityRevision.value;
13962
13988
  if (!v2TrackedChangesAdapter.value) return null;
13963
13989
  const documentMode = commentsStore.viewingVisibility.documentMode;
13964
13990
  const capability = v2TrackedChangesAdapter.value.getCapabilityState?.() ?? null;
@@ -14243,6 +14269,7 @@ var _sfc_main$34 = {
14243
14269
  return users;
14244
14270
  });
14245
14271
  require__plugin_vue_export_helper.onMounted(() => {
14272
+ proxy.$superdoc?.on?.("active-editor-change", refreshActiveEditor);
14246
14273
  if (props.autoFocus) require__plugin_vue_export_helper.nextTick(() => setFocus());
14247
14274
  if (isPendingNewComment.value) require__plugin_vue_export_helper.nextTick(() => {
14248
14275
  commentInput.value?.focus?.({ preventScroll: true });
@@ -14256,6 +14283,9 @@ var _sfc_main$34 = {
14256
14283
  checkOverflow();
14257
14284
  });
14258
14285
  });
14286
+ require__plugin_vue_export_helper.onBeforeUnmount(() => {
14287
+ proxy.$superdoc?.off?.("active-editor-change", refreshActiveEditor);
14288
+ });
14259
14289
  require__plugin_vue_export_helper.watch(showInputSection, (isVisible) => {
14260
14290
  if (!isVisible) return;
14261
14291
  require__plugin_vue_export_helper.nextTick(() => {
@@ -14503,7 +14533,7 @@ var _sfc_main$34 = {
14503
14533
  };
14504
14534
  }
14505
14535
  };
14506
- var CommentDialog_default = /*#__PURE__*/ require__plugin_vue_export_helper._plugin_vue_export_helper_default(_sfc_main$34, [["__scopeId", "data-v-c189ab35"]]);
14536
+ var CommentDialog_default = /*#__PURE__*/ require__plugin_vue_export_helper._plugin_vue_export_helper_default(_sfc_main$34, [["__scopeId", "data-v-5ace8cef"]]);
14507
14537
  //#endregion
14508
14538
  //#region src/components/CommentsLayer/commentsList/ReviewDirectoryListItem.vue
14509
14539
  var _hoisted_1$25 = [
@@ -19735,6 +19765,11 @@ function textTargetFromQueryMatch(doc, text, blockId) {
19735
19765
  function isTocEntryLinkElement(element) {
19736
19766
  return Boolean(element && typeof element.closest === "function" && element.closest(".superdoc-toc-entry"));
19737
19767
  }
19768
+ /** @param {Element | null | undefined} element */
19769
+ function isNoteCrossReferenceLinkElement(element) {
19770
+ const kind = element?.getAttribute("data-sd-note-cross-reference");
19771
+ return (kind === "ref" || kind === "noteRef") && Boolean(element?.closest("[data-sd-note-role=\"body\"]"));
19772
+ }
19738
19773
  /**
19739
19774
  * @param {Object} options
19740
19775
  * @param {() => SurfaceManager | null | undefined} options.getSurfaceManager
@@ -19878,9 +19913,9 @@ function useLinkPopover({ getSurfaceManager, getActiveEditor, getUi, getActivati
19878
19913
  * Navigate to a body bookmark through its model address. A mounted-anchor
19879
19914
  * fallback is reserved for runtimes without a callable bookmark model.
19880
19915
  * @param {string | null | undefined} anchorUrl
19881
- * @param {{ placeCaret?: boolean }} [options]
19916
+ * @param {{ placeCaret?: boolean, revalidateCaretAfterReveal?: boolean }} [options]
19882
19917
  */
19883
- async function navigateToAnchor(anchorUrl, { placeCaret = false } = {}) {
19918
+ async function navigateToAnchor(anchorUrl, { placeCaret = false, revalidateCaretAfterReveal = false } = {}) {
19884
19919
  if (typeof anchorUrl !== "string" || !anchorUrl.startsWith("#")) return false;
19885
19920
  const anchorName = decodeAnchorFragment(anchorUrl.slice(1));
19886
19921
  const editor = getActiveEditor();
@@ -19897,48 +19932,65 @@ function useLinkPopover({ getSurfaceManager, getActiveEditor, getUi, getActivati
19897
19932
  });
19898
19933
  return true;
19899
19934
  }
19900
- /** @type {BookmarkGetResult | null} */
19901
- let bookmark = null;
19902
- try {
19903
- const list = doc?.bookmarks?.list;
19904
- if (typeof list === "function") {
19905
- if ((await Promise.resolve(list.call(doc.bookmarks)))?.items?.filter((item) => item.name === anchorName).length !== 1) return false;
19935
+ async function readBodyBookmark() {
19936
+ try {
19937
+ const list = doc?.bookmarks?.list;
19938
+ if (typeof list === "function") {
19939
+ if ((await Promise.resolve(list.call(doc.bookmarks)))?.items?.filter((item) => item.name === anchorName).length !== 1) return null;
19940
+ }
19941
+ const bookmark = await Promise.resolve(bookmarkGet.call(doc.bookmarks, { target: {
19942
+ kind: "entity",
19943
+ entityType: "bookmark",
19944
+ name: anchorName
19945
+ } }));
19946
+ if (editor !== getActiveEditor() || generation !== openGeneration) return null;
19947
+ const story = bookmark?.address?.story;
19948
+ if (story && story.storyType !== "body" || bookmark?.tableColumn) return null;
19949
+ const blockId = bookmark?.range?.from?.blockId;
19950
+ const offset = bookmark?.range?.from?.offset ?? 0;
19951
+ if (typeof blockId !== "string" || !Number.isInteger(offset) || offset < 0) return null;
19952
+ return {
19953
+ blockId,
19954
+ offset
19955
+ };
19956
+ } catch {
19957
+ return null;
19906
19958
  }
19907
- bookmark = await Promise.resolve(bookmarkGet.call(doc.bookmarks, { target: {
19908
- kind: "entity",
19909
- entityType: "bookmark",
19910
- name: anchorName
19911
- } }));
19912
- bookmark ??= null;
19913
- } catch {
19914
- return false;
19915
19959
  }
19916
- if (editor !== getActiveEditor() || generation !== openGeneration) return false;
19917
- const story = bookmark?.address?.story;
19918
- if (story && story.storyType !== "body" || bookmark?.tableColumn) return false;
19919
- const blockId = bookmark?.range?.from?.blockId;
19920
- const offset = bookmark?.range?.from?.offset ?? 0;
19921
- if (typeof blockId !== "string" || !Number.isInteger(offset) || offset < 0) return false;
19922
- if (placeCaret) await placeCaretAtBookmark(blockId, offset);
19960
+ let position = await readBodyBookmark();
19961
+ if (!position) return false;
19962
+ if (placeCaret && !revalidateCaretAfterReveal) await placeCaretAtBookmark(position.blockId, position.offset);
19923
19963
  const viewport = getUi()?.viewport;
19924
19964
  const scrollIntoView = viewport?.scrollIntoView;
19925
19965
  if (typeof scrollIntoView !== "function") return false;
19926
- const target = {
19927
- kind: "text",
19928
- blockId,
19929
- range: {
19930
- start: offset,
19931
- end: offset
19932
- }
19933
- };
19934
19966
  for (let step = 0; step < MAX_ANCHOR_NAVIGATION_STEPS; step += 1) try {
19967
+ const target = {
19968
+ kind: "text",
19969
+ blockId: position.blockId,
19970
+ range: {
19971
+ start: position.offset,
19972
+ end: position.offset
19973
+ }
19974
+ };
19935
19975
  const result = await Promise.resolve(scrollIntoView.call(viewport, {
19936
19976
  target,
19937
19977
  block: "start",
19938
19978
  behavior: "instant"
19939
19979
  }));
19940
19980
  if (editor !== getActiveEditor() || generation !== openGeneration) return false;
19941
- if (result?.success !== false) return true;
19981
+ if (result?.success !== false) {
19982
+ if (revalidateCaretAfterReveal) {
19983
+ const current = await readBodyBookmark();
19984
+ if (!current) return false;
19985
+ if (current.blockId !== position.blockId || current.offset !== position.offset) {
19986
+ position = current;
19987
+ continue;
19988
+ }
19989
+ if (placeCaret) await placeCaretAtBookmark(current.blockId, current.offset);
19990
+ if (editor !== getActiveEditor() || generation !== openGeneration) return false;
19991
+ }
19992
+ return true;
19993
+ }
19942
19994
  } catch {
19943
19995
  return false;
19944
19996
  }
@@ -20064,8 +20116,13 @@ function useLinkPopover({ getSurfaceManager, getActiveEditor, getUi, getActivati
20064
20116
  return;
20065
20117
  }
20066
20118
  if (ctx.defaultAction === "navigate") {
20067
- if (ctx.isAnchorLink) navigateToAnchor(ctx.href);
20068
- else if (ctx.href) {
20119
+ if (ctx.isAnchorLink) {
20120
+ const noteReference = isNoteCrossReferenceLinkElement(ctx.element);
20121
+ navigateToAnchor(ctx.href, {
20122
+ placeCaret: noteReference && ctx.documentMode !== "viewing",
20123
+ revalidateCaretAfterReveal: noteReference && ctx.documentMode !== "viewing"
20124
+ });
20125
+ } else if (ctx.href) {
20069
20126
  const target = ctx.target || "_self";
20070
20127
  const features = linkOpenFeaturesForTarget(ctx.rel, target);
20071
20128
  if (features) window.open(ctx.href, target, features);
@@ -46564,7 +46621,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
46564
46621
  }
46565
46622
  this.userColorMap = /* @__PURE__ */ new Map();
46566
46623
  this.colorIndex = 0;
46567
- this.version = "2.24.0-next.1";
46624
+ this.version = "2.24.0-next.10";
46568
46625
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
46569
46626
  this.superdocId = config.superdocId || require_uuid.v4();
46570
46627
  this.colors = this.config.colors ?? [];
@@ -48742,11 +48799,12 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
48742
48799
  async #replaceActiveDocument(source) {
48743
48800
  const activeEditor = this.activeEditor;
48744
48801
  if (isV2ActiveEditorFacade(activeEditor) && typeof activeEditor.replaceFile === "function") {
48745
- const result = await activeEditor.replaceFile(source);
48802
+ const replacementSource = this.#savedDocxToBlob(source);
48803
+ const result = await activeEditor.replaceFile(replacementSource);
48746
48804
  const state = result && typeof result === "object" ? result.state : null;
48747
48805
  const confirmed = state === null || state === "review-ready" || state === "editing-ready";
48748
48806
  if (confirmed) {
48749
- this.#replaceActiveDocumentData(activeEditor, source);
48807
+ this.#replaceActiveDocumentData(activeEditor, replacementSource);
48750
48808
  this.emit("document-replaced", {
48751
48809
  editor: activeEditor,
48752
48810
  host: activeEditor?.host
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM$2 } from "./chunks/rolldown-runtime-0pSA04fp.es.js";
2
2
  import { t as blank_default } from "./chunks/blank-docx-DzQccOlW.es.js";
3
- import { c as createImageFilePicker, d as DOM_CLASS_NAMES, f as closeInteractionHistory, g as recordInteraction, h as isWorkflowRecordingEnabled, i as registerFirstPartyCommandMutation, l as resolveImageSrc, m as getWorkflowRecording, n as executeFirstPartyCommandAsync, o as applyV2CommentInvalidationFromMutation, p as createInteractionHistory, r as readFirstPartyPageNumbers, s as getV2TrackedChangeMutationImpact, t as createSuperDocUI } from "./chunks/create-super-doc-ui-DFNXiKvQ.es.js";
3
+ import { c as createImageFilePicker, d as DOM_CLASS_NAMES, f as closeInteractionHistory, g as recordInteraction, h as isWorkflowRecordingEnabled, i as registerFirstPartyCommandMutation, l as resolveImageSrc, m as getWorkflowRecording, n as executeFirstPartyCommandAsync, o as applyV2CommentInvalidationFromMutation, p as createInteractionHistory, r as readFirstPartyPageNumbers, s as getV2TrackedChangeMutationImpact, t as createSuperDocUI } from "./chunks/create-super-doc-ui-8UTu16Lw.es.js";
4
4
  import { t as import_eventemitter3 } from "./chunks/eventemitter3-DEIiXiH2.es.js";
5
5
  import { t as v4 } from "./chunks/uuid-H0Xcmmhy.es.js";
6
6
  import { $ as watch$1, A as onActivated, B as resolveDirective, C as isRef$1, D as normalizeClass, E as nextTick, F as openBlock, G as toRef, H as shallowRef$1, I as reactive, J as useAttrs, K as toRefs, L as ref, M as onDeactivated, N as onMounted, O as normalizeProps, P as onScopeDispose$1, Q as vModelText, R as renderList, S as isReactive$1, T as mergeProps, U as toDisplayString, V as resolveDynamicComponent, W as toRaw$2, X as vModelCheckbox, Y as useSlots, Z as vModelSelect, _ as getCurrentInstance, a as computed$1, b as hasInjectionContext, c as createCommentVNode, d as createStaticVNode, et as withCtx, f as createTextVNode, g as effectScope, h as defineComponent, i as Transition, j as onBeforeUnmount, k as normalizeStyle, l as createElementBlock, m as defineAsyncComponent, n as Fragment, nt as withKeys, o as createApp, p as createVNode, q as unref, r as Teleport, rt as withModifiers, s as createBlock, t as _plugin_vue_export_helper_default, tt as withDirectives, u as createElementVNode, v as getCurrentScope, w as markRaw, x as inject$1, y as h, z as renderSlot } from "./chunks/_plugin-vue_export-helper-DHiJKCsy.es.js";
@@ -302,7 +302,7 @@ var awarenessStatesToArray = (context, states) => {
302
302
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
303
303
  function getSuperdocVersion() {
304
304
  try {
305
- return "2.24.0-next.1";
305
+ return "2.24.0-next.10";
306
306
  } catch {
307
307
  return "unknown";
308
308
  }
@@ -13925,10 +13925,35 @@ var CommentDialog_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
13925
13925
  nextTick(() => emit("resize"));
13926
13926
  });
13927
13927
  };
13928
- const isV2Mode = computed$1(() => proxy.$superdoc?.activeEditor?.editorVersion === 2);
13929
- const v2CommentsAdapter = computed$1(() => isV2Mode.value ? proxy.$superdoc?.activeEditor?.v2Comments ?? null : null);
13930
- const v2TrackedChangesAdapter = computed$1(() => isV2Mode.value ? proxy.$superdoc?.activeEditor?.v2TrackedChanges ?? null : null);
13928
+ const activeEditorRevision = ref(0);
13929
+ const v2CapabilityRevision = ref(0);
13930
+ const refreshActiveEditor = () => {
13931
+ activeEditorRevision.value += 1;
13932
+ };
13933
+ const isV2Mode = computed$1(() => {
13934
+ activeEditorRevision.value;
13935
+ return proxy.$superdoc?.activeEditor?.editorVersion === 2;
13936
+ });
13937
+ const v2CommentsAdapter = computed$1(() => {
13938
+ activeEditorRevision.value;
13939
+ return isV2Mode.value ? proxy.$superdoc?.activeEditor?.v2Comments ?? null : null;
13940
+ });
13941
+ const v2TrackedChangesAdapter = computed$1(() => {
13942
+ activeEditorRevision.value;
13943
+ return isV2Mode.value ? proxy.$superdoc?.activeEditor?.v2TrackedChanges ?? null : null;
13944
+ });
13945
+ watch$1(() => {
13946
+ activeEditorRevision.value;
13947
+ return isV2Mode.value ? proxy.$superdoc?.activeEditor?.host ?? null : null;
13948
+ }, (host, _previous, onCleanup) => {
13949
+ v2CapabilityRevision.value += 1;
13950
+ const unsubscribe = host?.subscribe?.(() => {
13951
+ v2CapabilityRevision.value += 1;
13952
+ });
13953
+ onCleanup(() => unsubscribe?.());
13954
+ }, { immediate: true });
13931
13955
  const v2WriteCapability = computed$1(() => {
13956
+ v2CapabilityRevision.value;
13932
13957
  if (!v2CommentsAdapter.value) return null;
13933
13958
  const documentMode = commentsStore.viewingVisibility.documentMode;
13934
13959
  const command = isPendingNewComment.value ? "comments.createFromSelection" : null;
@@ -13952,6 +13977,7 @@ var CommentDialog_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
13952
13977
  return v2WriteCapability.value?.reason ?? "v2-write-unavailable";
13953
13978
  });
13954
13979
  const v2TrackedChangeCapability = computed$1(() => {
13980
+ v2CapabilityRevision.value;
13955
13981
  if (!v2TrackedChangesAdapter.value) return null;
13956
13982
  const documentMode = commentsStore.viewingVisibility.documentMode;
13957
13983
  const capability = v2TrackedChangesAdapter.value.getCapabilityState?.() ?? null;
@@ -14236,6 +14262,7 @@ var CommentDialog_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
14236
14262
  return users;
14237
14263
  });
14238
14264
  onMounted(() => {
14265
+ proxy.$superdoc?.on?.("active-editor-change", refreshActiveEditor);
14239
14266
  if (props.autoFocus) nextTick(() => setFocus());
14240
14267
  if (isPendingNewComment.value) nextTick(() => {
14241
14268
  commentInput.value?.focus?.({ preventScroll: true });
@@ -14249,6 +14276,9 @@ var CommentDialog_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
14249
14276
  checkOverflow();
14250
14277
  });
14251
14278
  });
14279
+ onBeforeUnmount(() => {
14280
+ proxy.$superdoc?.off?.("active-editor-change", refreshActiveEditor);
14281
+ });
14252
14282
  watch$1(showInputSection, (isVisible) => {
14253
14283
  if (!isVisible) return;
14254
14284
  nextTick(() => {
@@ -14495,7 +14525,7 @@ var CommentDialog_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
14495
14525
  ], 64))], 14, _hoisted_1$26)), [[_directive_click_outside, handleClickOutside]]);
14496
14526
  };
14497
14527
  }
14498
- }, [["__scopeId", "data-v-c189ab35"]]);
14528
+ }, [["__scopeId", "data-v-5ace8cef"]]);
14499
14529
  //#endregion
14500
14530
  //#region src/components/CommentsLayer/commentsList/ReviewDirectoryListItem.vue
14501
14531
  var _hoisted_1$25 = [
@@ -19702,6 +19732,11 @@ function textTargetFromQueryMatch(doc, text, blockId) {
19702
19732
  function isTocEntryLinkElement(element) {
19703
19733
  return Boolean(element && typeof element.closest === "function" && element.closest(".superdoc-toc-entry"));
19704
19734
  }
19735
+ /** @param {Element | null | undefined} element */
19736
+ function isNoteCrossReferenceLinkElement(element) {
19737
+ const kind = element?.getAttribute("data-sd-note-cross-reference");
19738
+ return (kind === "ref" || kind === "noteRef") && Boolean(element?.closest("[data-sd-note-role=\"body\"]"));
19739
+ }
19705
19740
  /**
19706
19741
  * @param {Object} options
19707
19742
  * @param {() => SurfaceManager | null | undefined} options.getSurfaceManager
@@ -19845,9 +19880,9 @@ function useLinkPopover({ getSurfaceManager, getActiveEditor, getUi, getActivati
19845
19880
  * Navigate to a body bookmark through its model address. A mounted-anchor
19846
19881
  * fallback is reserved for runtimes without a callable bookmark model.
19847
19882
  * @param {string | null | undefined} anchorUrl
19848
- * @param {{ placeCaret?: boolean }} [options]
19883
+ * @param {{ placeCaret?: boolean, revalidateCaretAfterReveal?: boolean }} [options]
19849
19884
  */
19850
- async function navigateToAnchor(anchorUrl, { placeCaret = false } = {}) {
19885
+ async function navigateToAnchor(anchorUrl, { placeCaret = false, revalidateCaretAfterReveal = false } = {}) {
19851
19886
  if (typeof anchorUrl !== "string" || !anchorUrl.startsWith("#")) return false;
19852
19887
  const anchorName = decodeAnchorFragment(anchorUrl.slice(1));
19853
19888
  const editor = getActiveEditor();
@@ -19864,48 +19899,65 @@ function useLinkPopover({ getSurfaceManager, getActiveEditor, getUi, getActivati
19864
19899
  });
19865
19900
  return true;
19866
19901
  }
19867
- /** @type {BookmarkGetResult | null} */
19868
- let bookmark = null;
19869
- try {
19870
- const list = doc?.bookmarks?.list;
19871
- if (typeof list === "function") {
19872
- if ((await Promise.resolve(list.call(doc.bookmarks)))?.items?.filter((item) => item.name === anchorName).length !== 1) return false;
19902
+ async function readBodyBookmark() {
19903
+ try {
19904
+ const list = doc?.bookmarks?.list;
19905
+ if (typeof list === "function") {
19906
+ if ((await Promise.resolve(list.call(doc.bookmarks)))?.items?.filter((item) => item.name === anchorName).length !== 1) return null;
19907
+ }
19908
+ const bookmark = await Promise.resolve(bookmarkGet.call(doc.bookmarks, { target: {
19909
+ kind: "entity",
19910
+ entityType: "bookmark",
19911
+ name: anchorName
19912
+ } }));
19913
+ if (editor !== getActiveEditor() || generation !== openGeneration) return null;
19914
+ const story = bookmark?.address?.story;
19915
+ if (story && story.storyType !== "body" || bookmark?.tableColumn) return null;
19916
+ const blockId = bookmark?.range?.from?.blockId;
19917
+ const offset = bookmark?.range?.from?.offset ?? 0;
19918
+ if (typeof blockId !== "string" || !Number.isInteger(offset) || offset < 0) return null;
19919
+ return {
19920
+ blockId,
19921
+ offset
19922
+ };
19923
+ } catch {
19924
+ return null;
19873
19925
  }
19874
- bookmark = await Promise.resolve(bookmarkGet.call(doc.bookmarks, { target: {
19875
- kind: "entity",
19876
- entityType: "bookmark",
19877
- name: anchorName
19878
- } }));
19879
- bookmark ??= null;
19880
- } catch {
19881
- return false;
19882
19926
  }
19883
- if (editor !== getActiveEditor() || generation !== openGeneration) return false;
19884
- const story = bookmark?.address?.story;
19885
- if (story && story.storyType !== "body" || bookmark?.tableColumn) return false;
19886
- const blockId = bookmark?.range?.from?.blockId;
19887
- const offset = bookmark?.range?.from?.offset ?? 0;
19888
- if (typeof blockId !== "string" || !Number.isInteger(offset) || offset < 0) return false;
19889
- if (placeCaret) await placeCaretAtBookmark(blockId, offset);
19927
+ let position = await readBodyBookmark();
19928
+ if (!position) return false;
19929
+ if (placeCaret && !revalidateCaretAfterReveal) await placeCaretAtBookmark(position.blockId, position.offset);
19890
19930
  const viewport = getUi()?.viewport;
19891
19931
  const scrollIntoView = viewport?.scrollIntoView;
19892
19932
  if (typeof scrollIntoView !== "function") return false;
19893
- const target = {
19894
- kind: "text",
19895
- blockId,
19896
- range: {
19897
- start: offset,
19898
- end: offset
19899
- }
19900
- };
19901
19933
  for (let step = 0; step < MAX_ANCHOR_NAVIGATION_STEPS; step += 1) try {
19934
+ const target = {
19935
+ kind: "text",
19936
+ blockId: position.blockId,
19937
+ range: {
19938
+ start: position.offset,
19939
+ end: position.offset
19940
+ }
19941
+ };
19902
19942
  const result = await Promise.resolve(scrollIntoView.call(viewport, {
19903
19943
  target,
19904
19944
  block: "start",
19905
19945
  behavior: "instant"
19906
19946
  }));
19907
19947
  if (editor !== getActiveEditor() || generation !== openGeneration) return false;
19908
- if (result?.success !== false) return true;
19948
+ if (result?.success !== false) {
19949
+ if (revalidateCaretAfterReveal) {
19950
+ const current = await readBodyBookmark();
19951
+ if (!current) return false;
19952
+ if (current.blockId !== position.blockId || current.offset !== position.offset) {
19953
+ position = current;
19954
+ continue;
19955
+ }
19956
+ if (placeCaret) await placeCaretAtBookmark(current.blockId, current.offset);
19957
+ if (editor !== getActiveEditor() || generation !== openGeneration) return false;
19958
+ }
19959
+ return true;
19960
+ }
19909
19961
  } catch {
19910
19962
  return false;
19911
19963
  }
@@ -20031,8 +20083,13 @@ function useLinkPopover({ getSurfaceManager, getActiveEditor, getUi, getActivati
20031
20083
  return;
20032
20084
  }
20033
20085
  if (ctx.defaultAction === "navigate") {
20034
- if (ctx.isAnchorLink) navigateToAnchor(ctx.href);
20035
- else if (ctx.href) {
20086
+ if (ctx.isAnchorLink) {
20087
+ const noteReference = isNoteCrossReferenceLinkElement(ctx.element);
20088
+ navigateToAnchor(ctx.href, {
20089
+ placeCaret: noteReference && ctx.documentMode !== "viewing",
20090
+ revalidateCaretAfterReveal: noteReference && ctx.documentMode !== "viewing"
20091
+ });
20092
+ } else if (ctx.href) {
20036
20093
  const target = ctx.target || "_self";
20037
20094
  const features = linkOpenFeaturesForTarget(ctx.rel, target);
20038
20095
  if (features) window.open(ctx.href, target, features);
@@ -46493,7 +46550,7 @@ var SuperDoc = class extends import_eventemitter3.default {
46493
46550
  }
46494
46551
  this.userColorMap = /* @__PURE__ */ new Map();
46495
46552
  this.colorIndex = 0;
46496
- this.version = "2.24.0-next.1";
46553
+ this.version = "2.24.0-next.10";
46497
46554
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
46498
46555
  this.superdocId = config.superdocId || v4();
46499
46556
  this.colors = this.config.colors ?? [];
@@ -48671,11 +48728,12 @@ var SuperDoc = class extends import_eventemitter3.default {
48671
48728
  async #replaceActiveDocument(source) {
48672
48729
  const activeEditor = this.activeEditor;
48673
48730
  if (isV2ActiveEditorFacade(activeEditor) && typeof activeEditor.replaceFile === "function") {
48674
- const result = await activeEditor.replaceFile(source);
48731
+ const replacementSource = this.#savedDocxToBlob(source);
48732
+ const result = await activeEditor.replaceFile(replacementSource);
48675
48733
  const state = result && typeof result === "object" ? result.state : null;
48676
48734
  const confirmed = state === null || state === "review-ready" || state === "editing-ready";
48677
48735
  if (confirmed) {
48678
- this.#replaceActiveDocumentData(activeEditor, source);
48736
+ this.#replaceActiveDocumentData(activeEditor, replacementSource);
48679
48737
  this.emit("document-replaced", {
48680
48738
  editor: activeEditor,
48681
48739
  host: activeEditor?.host