superdoc 2.0.0-next.46 → 2.0.0-next.47

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.
@@ -8588,13 +8588,19 @@ function createSuperDocUI(options) {
8588
8588
  reason: SUPERDOC_UI_REASONS.operationUnavailable
8589
8589
  };
8590
8590
  const result = safeCall(() => editSearch.next(), null);
8591
- if (isPromiseLike(result)) Promise.resolve(result).then((resolved) => applyHostSearchResult(resolved, readEditCommandCanReplace())).catch(() => {
8592
- setSearchState({
8593
- available: false,
8594
- reason: SUPERDOC_UI_REASONS.searchUnavailable
8591
+ if (isPromiseLike(result)) {
8592
+ const generation = searchRequestGeneration;
8593
+ Promise.resolve(result).then((resolved) => {
8594
+ if (generation !== searchRequestGeneration) return;
8595
+ applyHostSearchResult(resolved, readEditCommandCanReplace());
8596
+ }).catch(() => {
8597
+ if (generation !== searchRequestGeneration) return;
8598
+ setSearchState({
8599
+ available: false,
8600
+ reason: SUPERDOC_UI_REASONS.searchUnavailable
8601
+ });
8595
8602
  });
8596
- });
8597
- else applyHostSearchResult(result, readEditCommandCanReplace());
8603
+ } else applyHostSearchResult(result, readEditCommandCanReplace());
8598
8604
  applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace());
8599
8605
  return { ok: true };
8600
8606
  }
@@ -8618,13 +8624,19 @@ function createSuperDocUI(options) {
8618
8624
  reason: SUPERDOC_UI_REASONS.operationUnavailable
8619
8625
  };
8620
8626
  const result = safeCall(() => editSearch.previous(), null);
8621
- if (isPromiseLike(result)) Promise.resolve(result).then((resolved) => applyHostSearchResult(resolved, readEditCommandCanReplace())).catch(() => {
8622
- setSearchState({
8623
- available: false,
8624
- reason: SUPERDOC_UI_REASONS.searchUnavailable
8627
+ if (isPromiseLike(result)) {
8628
+ const generation = searchRequestGeneration;
8629
+ Promise.resolve(result).then((resolved) => {
8630
+ if (generation !== searchRequestGeneration) return;
8631
+ applyHostSearchResult(resolved, readEditCommandCanReplace());
8632
+ }).catch(() => {
8633
+ if (generation !== searchRequestGeneration) return;
8634
+ setSearchState({
8635
+ available: false,
8636
+ reason: SUPERDOC_UI_REASONS.searchUnavailable
8637
+ });
8625
8638
  });
8626
- });
8627
- else applyHostSearchResult(result, readEditCommandCanReplace());
8639
+ } else applyHostSearchResult(result, readEditCommandCanReplace());
8628
8640
  applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace());
8629
8641
  return { ok: true };
8630
8642
  }
@@ -8636,6 +8648,7 @@ function createSuperDocUI(options) {
8636
8648
  return { ok: true };
8637
8649
  },
8638
8650
  clear: () => {
8651
+ searchRequestGeneration += 1;
8639
8652
  const host = getHostSearch();
8640
8653
  if (host && typeof host.clear === "function") safeCall(() => host.clear(), null);
8641
8654
  if (!host || typeof host.clear !== "function") {
@@ -8663,15 +8676,19 @@ function createSuperDocUI(options) {
8663
8676
  };
8664
8677
  const result$1 = safeCall(() => editSearch.replace({ replacement: typeof replacement === "string" ? replacement : "" }), null);
8665
8678
  if (isPromiseLike(result$1)) {
8679
+ const generation = searchRequestGeneration;
8666
8680
  syncSearchStateFromHost();
8667
8681
  emitSearch();
8682
+ const isCurrent = () => generation === searchRequestGeneration;
8668
8683
  return Promise.resolve(result$1).then((resolved) => {
8669
- applyHostSearchResult(resolved, readEditCommandCanReplace());
8670
- syncSearchStateFromHost();
8671
- emitSearch();
8684
+ if (isCurrent()) {
8685
+ applyHostSearchResult(resolved, readEditCommandCanReplace());
8686
+ syncSearchStateFromHost();
8687
+ emitSearch();
8688
+ }
8672
8689
  return mapHostReplaceResult(resolved);
8673
8690
  }, () => {
8674
- setSearchState({
8691
+ if (isCurrent()) setSearchState({
8675
8692
  available: false,
8676
8693
  reason: SUPERDOC_UI_REASONS.searchUnavailable
8677
8694
  });
@@ -8708,15 +8725,19 @@ function createSuperDocUI(options) {
8708
8725
  };
8709
8726
  const result$1 = safeCall(() => editSearch.replaceAll({ replacement: typeof replacement === "string" ? replacement : "" }), null);
8710
8727
  if (isPromiseLike(result$1)) {
8728
+ const generation = searchRequestGeneration;
8711
8729
  syncSearchStateFromHost();
8712
8730
  emitSearch();
8731
+ const isCurrent = () => generation === searchRequestGeneration;
8713
8732
  return Promise.resolve(result$1).then((resolved) => {
8714
- applyHostSearchResult(resolved, readEditCommandCanReplace());
8715
- syncSearchStateFromHost();
8716
- emitSearch();
8733
+ if (isCurrent()) {
8734
+ applyHostSearchResult(resolved, readEditCommandCanReplace());
8735
+ syncSearchStateFromHost();
8736
+ emitSearch();
8737
+ }
8717
8738
  return mapHostReplaceResult(resolved);
8718
8739
  }, () => {
8719
- setSearchState({
8740
+ if (isCurrent()) setSearchState({
8720
8741
  available: false,
8721
8742
  reason: SUPERDOC_UI_REASONS.searchUnavailable
8722
8743
  });
@@ -8819,6 +8840,7 @@ function createSuperDocUI(options) {
8819
8840
  searchListeners.clear();
8820
8841
  painterCaptureEpoch += 1;
8821
8842
  painterModeListeners.clear();
8843
+ searchRequestGeneration += 1;
8822
8844
  customCommands.clear();
8823
8845
  };
8824
8846
  const controller = {
@@ -8810,13 +8810,19 @@ function createSuperDocUI(options) {
8810
8810
  reason: SUPERDOC_UI_REASONS.operationUnavailable
8811
8811
  };
8812
8812
  const result = safeCall(() => editSearch.next(), null);
8813
- if (isPromiseLike(result)) Promise.resolve(result).then((resolved) => applyHostSearchResult(resolved, readEditCommandCanReplace())).catch(() => {
8814
- setSearchState({
8815
- available: false,
8816
- reason: SUPERDOC_UI_REASONS.searchUnavailable
8813
+ if (isPromiseLike(result)) {
8814
+ const generation = searchRequestGeneration;
8815
+ Promise.resolve(result).then((resolved) => {
8816
+ if (generation !== searchRequestGeneration) return;
8817
+ applyHostSearchResult(resolved, readEditCommandCanReplace());
8818
+ }).catch(() => {
8819
+ if (generation !== searchRequestGeneration) return;
8820
+ setSearchState({
8821
+ available: false,
8822
+ reason: SUPERDOC_UI_REASONS.searchUnavailable
8823
+ });
8817
8824
  });
8818
- });
8819
- else applyHostSearchResult(result, readEditCommandCanReplace());
8825
+ } else applyHostSearchResult(result, readEditCommandCanReplace());
8820
8826
  applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace());
8821
8827
  return { ok: true };
8822
8828
  }
@@ -8840,13 +8846,19 @@ function createSuperDocUI(options) {
8840
8846
  reason: SUPERDOC_UI_REASONS.operationUnavailable
8841
8847
  };
8842
8848
  const result = safeCall(() => editSearch.previous(), null);
8843
- if (isPromiseLike(result)) Promise.resolve(result).then((resolved) => applyHostSearchResult(resolved, readEditCommandCanReplace())).catch(() => {
8844
- setSearchState({
8845
- available: false,
8846
- reason: SUPERDOC_UI_REASONS.searchUnavailable
8849
+ if (isPromiseLike(result)) {
8850
+ const generation = searchRequestGeneration;
8851
+ Promise.resolve(result).then((resolved) => {
8852
+ if (generation !== searchRequestGeneration) return;
8853
+ applyHostSearchResult(resolved, readEditCommandCanReplace());
8854
+ }).catch(() => {
8855
+ if (generation !== searchRequestGeneration) return;
8856
+ setSearchState({
8857
+ available: false,
8858
+ reason: SUPERDOC_UI_REASONS.searchUnavailable
8859
+ });
8847
8860
  });
8848
- });
8849
- else applyHostSearchResult(result, readEditCommandCanReplace());
8861
+ } else applyHostSearchResult(result, readEditCommandCanReplace());
8850
8862
  applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace());
8851
8863
  return { ok: true };
8852
8864
  }
@@ -8858,6 +8870,7 @@ function createSuperDocUI(options) {
8858
8870
  return { ok: true };
8859
8871
  },
8860
8872
  clear: () => {
8873
+ searchRequestGeneration += 1;
8861
8874
  const host = getHostSearch();
8862
8875
  if (host && typeof host.clear === "function") safeCall(() => host.clear(), null);
8863
8876
  if (!host || typeof host.clear !== "function") {
@@ -8885,15 +8898,19 @@ function createSuperDocUI(options) {
8885
8898
  };
8886
8899
  const result$1 = safeCall(() => editSearch.replace({ replacement: typeof replacement === "string" ? replacement : "" }), null);
8887
8900
  if (isPromiseLike(result$1)) {
8901
+ const generation = searchRequestGeneration;
8888
8902
  syncSearchStateFromHost();
8889
8903
  emitSearch();
8904
+ const isCurrent = () => generation === searchRequestGeneration;
8890
8905
  return Promise.resolve(result$1).then((resolved) => {
8891
- applyHostSearchResult(resolved, readEditCommandCanReplace());
8892
- syncSearchStateFromHost();
8893
- emitSearch();
8906
+ if (isCurrent()) {
8907
+ applyHostSearchResult(resolved, readEditCommandCanReplace());
8908
+ syncSearchStateFromHost();
8909
+ emitSearch();
8910
+ }
8894
8911
  return mapHostReplaceResult(resolved);
8895
8912
  }, () => {
8896
- setSearchState({
8913
+ if (isCurrent()) setSearchState({
8897
8914
  available: false,
8898
8915
  reason: SUPERDOC_UI_REASONS.searchUnavailable
8899
8916
  });
@@ -8930,15 +8947,19 @@ function createSuperDocUI(options) {
8930
8947
  };
8931
8948
  const result$1 = safeCall(() => editSearch.replaceAll({ replacement: typeof replacement === "string" ? replacement : "" }), null);
8932
8949
  if (isPromiseLike(result$1)) {
8950
+ const generation = searchRequestGeneration;
8933
8951
  syncSearchStateFromHost();
8934
8952
  emitSearch();
8953
+ const isCurrent = () => generation === searchRequestGeneration;
8935
8954
  return Promise.resolve(result$1).then((resolved) => {
8936
- applyHostSearchResult(resolved, readEditCommandCanReplace());
8937
- syncSearchStateFromHost();
8938
- emitSearch();
8955
+ if (isCurrent()) {
8956
+ applyHostSearchResult(resolved, readEditCommandCanReplace());
8957
+ syncSearchStateFromHost();
8958
+ emitSearch();
8959
+ }
8939
8960
  return mapHostReplaceResult(resolved);
8940
8961
  }, () => {
8941
- setSearchState({
8962
+ if (isCurrent()) setSearchState({
8942
8963
  available: false,
8943
8964
  reason: SUPERDOC_UI_REASONS.searchUnavailable
8944
8965
  });
@@ -9041,6 +9062,7 @@ function createSuperDocUI(options) {
9041
9062
  searchListeners.clear();
9042
9063
  painterCaptureEpoch += 1;
9043
9064
  painterModeListeners.clear();
9065
+ searchRequestGeneration += 1;
9044
9066
  customCommands.clear();
9045
9067
  };
9046
9068
  const controller = {
@@ -7,7 +7,7 @@ const COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
7
7
  var PRIVATE_ENGINE_INFO = (0, __superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
8
8
  var ENGINE_INFO = Object.freeze({
9
9
  ...PRIVATE_ENGINE_INFO,
10
- superdocVersion: "2.0.0-next.46",
10
+ superdocVersion: "2.0.0-next.47",
11
11
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
12
12
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
13
13
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -6,7 +6,7 @@ const COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
6
6
  var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
7
7
  var ENGINE_INFO = Object.freeze({
8
8
  ...PRIVATE_ENGINE_INFO,
9
- superdocVersion: "2.0.0-next.46",
9
+ superdocVersion: "2.0.0-next.47",
10
10
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
11
11
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
12
12
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("../chunks/rolldown-runtime-_dR15c8t.cjs");
3
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-6FUZ9d-y.cjs");
3
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-Dk6T01KE.cjs");
4
4
  let react = require("react");
5
5
  var SuperDocUIContext = (0, react.createContext)(null);
6
6
  function disposeOwnedUi(ref) {
@@ -1,4 +1,4 @@
1
- import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-DCFTmVRK.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-CKyCKKdl.es.js";
2
2
  import { createContext, createElement, useCallback, useContext, useEffect, useRef, useState } from "react";
3
3
  var SuperDocUIContext = createContext(null);
4
4
  function disposeOwnedUi(ref) {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-6FUZ9d-y.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-Dk6T01KE.cjs");
3
3
  exports.BUILT_IN_COMMAND_IDS = require_create_super_doc_ui.BUILT_IN_COMMAND_IDS;
4
4
  exports.createSuperDocUI = require_create_super_doc_ui.createSuperDocUI;
5
5
  exports.shallowEqual = require_create_super_doc_ui.shallowEqual;
@@ -1,2 +1,2 @@
1
- import { n as shallowEqual, r as BUILT_IN_COMMAND_IDS, t as createSuperDocUI } from "../chunks/create-super-doc-ui-DCFTmVRK.es.js";
1
+ import { n as shallowEqual, r as BUILT_IN_COMMAND_IDS, t as createSuperDocUI } from "../chunks/create-super-doc-ui-CKyCKKdl.es.js";
2
2
  export { BUILT_IN_COMMAND_IDS, createSuperDocUI, shallowEqual };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The find/replace panel's settled-replace continuation.
3
+ *
4
+ * A worker-backed replace resolves asynchronously, and the session it belongs to
5
+ * can be gone by the time it does: the search handle is reassigned when the
6
+ * active editor changes and nulled on teardown. Publishing the resolved snapshot
7
+ * anyway would repopulate the panel with matches from a document the user is no
8
+ * longer looking at.
9
+ *
10
+ * A leaf module rather than a closure inside `useFindReplace`, following
11
+ * `find-shortcut-owner.js`. The guard previously lived in two byte-identical
12
+ * inline closures, each of which needed a full composable driving a
13
+ * worker-backed host caught mid-swap to reach one branch. Nothing could, so it
14
+ * shipped with a comment admitting it was verified by inspection only. The
15
+ * duplication was the tell: logic worth stating twice is worth naming once.
16
+ */
17
+ /**
18
+ * Build the continuation that publishes a settled replace back into the panel.
19
+ *
20
+ * The session handle itself is the identity. `onSettled` always runs, including
21
+ * when the write is skipped: it clears the pending flag that gates the replace
22
+ * controls, and leaving it set would disable them with nothing left to settle.
23
+ *
24
+ * @param {{ getSnapshot: () => unknown }} session The handle captured when the replace was issued.
25
+ * @param {object} deps
26
+ * @param {() => unknown} deps.getCurrentSession Reads the live session identity.
27
+ * @param {(snapshot: unknown) => void} deps.applySlice Publishes a snapshot into the panel.
28
+ * @param {() => void} deps.onSettled Runs whether or not the write was skipped.
29
+ * @returns {() => void}
30
+ */
31
+ export function createReplaceContinuation(session: {
32
+ getSnapshot: () => unknown;
33
+ }, { getCurrentSession, applySlice, onSettled }: {
34
+ getCurrentSession: () => unknown;
35
+ applySlice: (snapshot: unknown) => void;
36
+ onSettled: () => void;
37
+ }): () => void;
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Set or clear the link item's `href` without disturbing the rest of its
3
+ * attributes. The static configuration (`ariaLabel`, and anything added later)
4
+ * lives in the same object as the transient href, so rebuilding that object
5
+ * from the keys a caller knows about silently drops the others.
6
+ *
7
+ * Exported because the built-in toolbar's `updateToolbarState()` writes the
8
+ * href on its own path, without going through this item's handlers. Both
9
+ * callers share this one rule so the two cannot drift apart.
10
+ */
11
+ export function withLinkHref(attributes: any, href: any): any;
1
12
  export function makeDefaultItems({ superToolbar, toolbarIcons, toolbarTexts, toolbarFonts, hideButtons, availableWidth, role, isDev, }?: {
2
13
  isDev?: boolean | undefined;
3
14
  }): {
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-6FUZ9d-y.cjs");
9
+ const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-Dk6T01KE.cjs");
10
10
  let vue = require("vue");
11
11
  vue = require_rolldown_runtime.__toESM(vue);
12
12
  require("y-websocket");
@@ -10554,6 +10554,14 @@ function usePasswordPrompt({ getSurfaceManager, getPasswordPromptConfig, onUnhan
10554
10554
  destroy
10555
10555
  };
10556
10556
  }
10557
+ function createReplaceContinuation(session, { getCurrentSession, applySlice, onSettled }) {
10558
+ return () => {
10559
+ if (session === getCurrentSession()) try {
10560
+ applySlice(session.getSnapshot());
10561
+ } catch {}
10562
+ onSettled();
10563
+ };
10564
+ }
10557
10565
  var DEFAULT_TEXTS = {
10558
10566
  findPlaceholder: "Find",
10559
10567
  findAriaLabel: "Find text",
@@ -10738,12 +10746,13 @@ function useFindReplace({ getSurfaceManager, getActiveEditor, activeEditorRef, g
10738
10746
  if (!canReplaceState.value) return;
10739
10747
  const search = currentV2Search;
10740
10748
  replacePending.value = true;
10741
- const finish = () => {
10742
- try {
10743
- applyV2Slice(search.getSnapshot());
10744
- } catch {}
10745
- replacePending.value = false;
10746
- };
10749
+ const finish = createReplaceContinuation(search, {
10750
+ getCurrentSession: () => currentV2Search,
10751
+ applySlice: applyV2Slice,
10752
+ onSettled: () => {
10753
+ replacePending.value = false;
10754
+ }
10755
+ });
10747
10756
  let result = null;
10748
10757
  try {
10749
10758
  result = search.replace(replaceText.value);
@@ -10767,12 +10776,13 @@ function useFindReplace({ getSurfaceManager, getActiveEditor, activeEditorRef, g
10767
10776
  if (!canReplaceState.value) return;
10768
10777
  const search = currentV2Search;
10769
10778
  replacePending.value = true;
10770
- const finish = () => {
10771
- try {
10772
- applyV2Slice(search.getSnapshot());
10773
- } catch {}
10774
- replacePending.value = false;
10775
- };
10779
+ const finish = createReplaceContinuation(search, {
10780
+ getCurrentSession: () => currentV2Search,
10781
+ applySlice: applyV2Slice,
10782
+ onSettled: () => {
10783
+ replacePending.value = false;
10784
+ }
10785
+ });
10776
10786
  let result = null;
10777
10787
  try {
10778
10788
  result = search.replaceAll(replaceText.value);
@@ -32628,6 +32638,12 @@ var check_default = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 448
32628
32638
  var closeDropdown = (dropdown) => {
32629
32639
  dropdown.expand.value = false;
32630
32640
  };
32641
+ function withLinkHref(attributes, href) {
32642
+ const next = { ...attributes ?? {} };
32643
+ if (href) next.href = href;
32644
+ else delete next.href;
32645
+ return next;
32646
+ }
32631
32647
  function selectionTargetFromTextTarget(target) {
32632
32648
  const segments = Array.isArray(target?.segments) ? target.segments : [];
32633
32649
  if (target?.kind !== "text" || !segments.length) return null;
@@ -32905,11 +32921,10 @@ const makeDefaultItems = ({ superToolbar, toolbarIcons: toolbarIcons$1, toolbarT
32905
32921
  render: () => renderLinkDropdown(link)
32906
32922
  }],
32907
32923
  onActivate: ({ href }) => {
32908
- if (href) link.attributes.value = { href };
32909
- else link.attributes.value = {};
32924
+ link.attributes.value = withLinkHref(link.attributes.value, href);
32910
32925
  },
32911
32926
  onDeactivate: () => {
32912
- link.attributes.value = {};
32927
+ link.attributes.value = withLinkHref(link.attributes.value, null);
32913
32928
  link.expand.value = false;
32914
32929
  }
32915
32930
  });
@@ -34192,7 +34207,7 @@ var BuiltInToolbar = class extends require_eventemitter3.import_eventemitter3.de
34192
34207
  },
34193
34208
  link: () => {
34194
34209
  item.active.value = Boolean(commandState?.active);
34195
- item.attributes.value = commandState?.value ? { href: commandState.value } : {};
34210
+ item.attributes.value = withLinkHref(item.attributes.value, commandState?.value ?? null);
34196
34211
  },
34197
34212
  fontFamily: () => {
34198
34213
  if (commandState?.value != null) {
@@ -34695,7 +34710,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
34695
34710
  this.config.colors = shuffleArray(this.config.colors);
34696
34711
  this.userColorMap = /* @__PURE__ */ new Map();
34697
34712
  this.colorIndex = 0;
34698
- this.version = "2.0.0-next.46";
34713
+ this.version = "2.0.0-next.47";
34699
34714
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
34700
34715
  this.superdocId = config.superdocId || require_uuid.v4_default();
34701
34716
  this.colors = this.config.colors ?? [];
@@ -5,7 +5,7 @@ import { t as v4_default } from "./chunks/uuid-B2Sqk-3p.es.js";
5
5
  import { a as init_dist, i as global, n as init_dist$1, r as process$1, t as require_jszip_min } from "./chunks/jszip-DzmwAHr3.es.js";
6
6
  import { t as __plugin_vue_export_helper_default } from "./chunks/_plugin-vue_export-helper-CInC0bKI.es.js";
7
7
  import { n as PDF_TO_CSS_UNITS } from "./chunks/constants-CY3R3_kF.es.js";
8
- import { a as createV2ReviewMutationReconciler, i as isV2EditableTextMutationEvent, o as getV2TrackedChangeMutationImpact, s as composeAuthorColorResolver, t as createSuperDocUI } from "./chunks/create-super-doc-ui-DCFTmVRK.es.js";
8
+ import { a as createV2ReviewMutationReconciler, i as isV2EditableTextMutationEvent, o as getV2TrackedChangeMutationImpact, s as composeAuthorColorResolver, t as createSuperDocUI } from "./chunks/create-super-doc-ui-CKyCKKdl.es.js";
9
9
  import * as Vue from "vue";
10
10
  import { Fragment, Teleport, Transition, computed, createApp, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, getCurrentInstance, h, inject, markRaw, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeUnmount, onDeactivated, onMounted, openBlock, reactive, ref, renderList, renderSlot, resolveDirective, resolveDynamicComponent, shallowRef, toDisplayString, toRaw, toRef, unref, useAttrs, vModelText, watch, withCtx, withDirectives, withKeys, withModifiers } from "vue";
11
11
  import "y-websocket";
@@ -10532,6 +10532,14 @@ function usePasswordPrompt({ getSurfaceManager, getPasswordPromptConfig, onUnhan
10532
10532
  destroy
10533
10533
  };
10534
10534
  }
10535
+ function createReplaceContinuation(session, { getCurrentSession, applySlice, onSettled }) {
10536
+ return () => {
10537
+ if (session === getCurrentSession()) try {
10538
+ applySlice(session.getSnapshot());
10539
+ } catch {}
10540
+ onSettled();
10541
+ };
10542
+ }
10535
10543
  var DEFAULT_TEXTS = {
10536
10544
  findPlaceholder: "Find",
10537
10545
  findAriaLabel: "Find text",
@@ -10716,12 +10724,13 @@ function useFindReplace({ getSurfaceManager, getActiveEditor, activeEditorRef, g
10716
10724
  if (!canReplaceState.value) return;
10717
10725
  const search = currentV2Search;
10718
10726
  replacePending.value = true;
10719
- const finish = () => {
10720
- try {
10721
- applyV2Slice(search.getSnapshot());
10722
- } catch {}
10723
- replacePending.value = false;
10724
- };
10727
+ const finish = createReplaceContinuation(search, {
10728
+ getCurrentSession: () => currentV2Search,
10729
+ applySlice: applyV2Slice,
10730
+ onSettled: () => {
10731
+ replacePending.value = false;
10732
+ }
10733
+ });
10725
10734
  let result = null;
10726
10735
  try {
10727
10736
  result = search.replace(replaceText.value);
@@ -10745,12 +10754,13 @@ function useFindReplace({ getSurfaceManager, getActiveEditor, activeEditorRef, g
10745
10754
  if (!canReplaceState.value) return;
10746
10755
  const search = currentV2Search;
10747
10756
  replacePending.value = true;
10748
- const finish = () => {
10749
- try {
10750
- applyV2Slice(search.getSnapshot());
10751
- } catch {}
10752
- replacePending.value = false;
10753
- };
10757
+ const finish = createReplaceContinuation(search, {
10758
+ getCurrentSession: () => currentV2Search,
10759
+ applySlice: applyV2Slice,
10760
+ onSettled: () => {
10761
+ replacePending.value = false;
10762
+ }
10763
+ });
10754
10764
  let result = null;
10755
10765
  try {
10756
10766
  result = search.replaceAll(replaceText.value);
@@ -32565,6 +32575,12 @@ var check_default = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 448
32565
32575
  var closeDropdown = (dropdown) => {
32566
32576
  dropdown.expand.value = false;
32567
32577
  };
32578
+ function withLinkHref(attributes, href) {
32579
+ const next = { ...attributes ?? {} };
32580
+ if (href) next.href = href;
32581
+ else delete next.href;
32582
+ return next;
32583
+ }
32568
32584
  function selectionTargetFromTextTarget(target) {
32569
32585
  const segments = Array.isArray(target?.segments) ? target.segments : [];
32570
32586
  if (target?.kind !== "text" || !segments.length) return null;
@@ -32842,11 +32858,10 @@ const makeDefaultItems = ({ superToolbar, toolbarIcons: toolbarIcons$1, toolbarT
32842
32858
  render: () => renderLinkDropdown(link)
32843
32859
  }],
32844
32860
  onActivate: ({ href }) => {
32845
- if (href) link.attributes.value = { href };
32846
- else link.attributes.value = {};
32861
+ link.attributes.value = withLinkHref(link.attributes.value, href);
32847
32862
  },
32848
32863
  onDeactivate: () => {
32849
- link.attributes.value = {};
32864
+ link.attributes.value = withLinkHref(link.attributes.value, null);
32850
32865
  link.expand.value = false;
32851
32866
  }
32852
32867
  });
@@ -34129,7 +34144,7 @@ var BuiltInToolbar = class extends import_eventemitter3.default {
34129
34144
  },
34130
34145
  link: () => {
34131
34146
  item.active.value = Boolean(commandState?.active);
34132
- item.attributes.value = commandState?.value ? { href: commandState.value } : {};
34147
+ item.attributes.value = withLinkHref(item.attributes.value, commandState?.value ?? null);
34133
34148
  },
34134
34149
  fontFamily: () => {
34135
34150
  if (commandState?.value != null) {
@@ -34632,7 +34647,7 @@ var SuperDoc = class extends import_eventemitter3.default {
34632
34647
  this.config.colors = shuffleArray(this.config.colors);
34633
34648
  this.userColorMap = /* @__PURE__ */ new Map();
34634
34649
  this.colorIndex = 0;
34635
- this.version = "2.0.0-next.46";
34650
+ this.version = "2.0.0-next.47";
34636
34651
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
34637
34652
  this.superdocId = config.superdocId || v4_default();
34638
34653
  this.colors = this.config.colors ?? [];