superdoc 2.12.0-next.15 → 2.12.0-next.17

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 (34) hide show
  1. package/dist/chunks/{FindReplaceSurface-40AnrqWk.es.js → FindReplaceSurface-CVKgivXi.es.js} +8 -2
  2. package/dist/chunks/{FindReplaceSurface-0p7EtMZh.cjs → FindReplaceSurface-qi9OhbwN.cjs} +8 -2
  3. package/dist/chunks/{create-super-doc-ui-BkDVQgqj.cjs → create-super-doc-ui-BWWWNPP8.cjs} +114 -60
  4. package/dist/chunks/{create-super-doc-ui-Biwv0tas.es.js → create-super-doc-ui-FnwgTkUv.es.js} +114 -60
  5. package/dist/collaboration-upgrade-engine.cjs +1 -1
  6. package/dist/collaboration-upgrade-engine.es.js +1 -1
  7. package/dist/layout-engine/contracts/src/column-layout.d.ts +58 -1
  8. package/dist/layout-engine/contracts/src/graphic-placement.d.ts +3 -0
  9. package/dist/layout-engine/contracts/src/index.d.ts +16 -2
  10. package/dist/layout-engine/layout-engine/src/column-balancing.d.ts +11 -7
  11. package/dist/layout-engine/layout-engine/src/layout-paragraph.d.ts +2 -6
  12. package/dist/layout-engine/painters/dom/src/renderer.d.ts +6 -16
  13. package/dist/public/ui-react.cjs +18 -1
  14. package/dist/public/ui-react.es.js +18 -2
  15. package/dist/public/ui-vue.cjs +18 -1
  16. package/dist/public/ui-vue.es.js +18 -2
  17. package/dist/public/ui.cjs +1 -1
  18. package/dist/public/ui.es.js +1 -1
  19. package/dist/style.css +40 -40
  20. package/dist/style.layered.css +40 -40
  21. package/dist/superdoc/src/core/types/index.d.ts +20 -12
  22. package/dist/superdoc/src/public/ui/react.d.ts +3 -1
  23. package/dist/superdoc/src/public/ui/types.d.ts +26 -5
  24. package/dist/superdoc/src/public/ui/vue.d.ts +3 -1
  25. package/dist/superdoc/src/public/ui-react.d.cts +1 -0
  26. package/dist/superdoc/src/public/ui-react.d.ts +1 -1
  27. package/dist/superdoc/src/public/ui-vue.d.cts +1 -0
  28. package/dist/superdoc/src/public/ui-vue.d.ts +1 -1
  29. package/dist/superdoc.cjs +18 -6
  30. package/dist/superdoc.es.js +18 -6
  31. package/dist-cdn/style.layered.css +1 -1
  32. package/dist-cdn/superdoc.min.css +1 -1
  33. package/dist-cdn/superdoc.min.js +37 -37
  34. package/package.json +2 -2
@@ -106,6 +106,12 @@ var FindReplaceSurface_default = /*#__PURE__*/ _plugin_vue_export_helper_default
106
106
  if (fr.canReplace && fr.canReplace.value === false) return true;
107
107
  return false;
108
108
  });
109
+ const replaceAllDisabled = computed(() => {
110
+ if (replaceDisabled.value) return true;
111
+ const fr = props.findReplace;
112
+ if (fr.canReplaceAll && fr.canReplaceAll.value === false) return true;
113
+ return false;
114
+ });
109
115
  const showIgnoreDiacritics = computed(() => props.findReplace.ignoreDiacriticsSupported?.value !== false);
110
116
  const showReplaceControls = computed(() => props.findReplace.replaceEnabled && props.findReplace.replaceCanMutate?.value !== false);
111
117
  const showRegexToggle = computed(() => props.findReplace.regexSupported?.value === true);
@@ -331,7 +337,7 @@ var FindReplaceSurface_default = /*#__PURE__*/ _plugin_vue_export_helper_default
331
337
  }, toDisplayString(__props.findReplace.texts.replaceLabel), 9, _hoisted_17), createElementVNode("button", {
332
338
  type: "button",
333
339
  class: "sd-find-replace__btn sd-find-replace__btn--action",
334
- disabled: replaceDisabled.value,
340
+ disabled: replaceAllDisabled.value,
335
341
  title: __props.findReplace.texts.replaceAllLabel,
336
342
  onClick: _cache[13] || (_cache[13] = ($event) => __props.findReplace.replaceAll())
337
343
  }, toDisplayString(__props.findReplace.texts.replaceAllLabel), 9, _hoisted_18)])
@@ -340,6 +346,6 @@ var FindReplaceSurface_default = /*#__PURE__*/ _plugin_vue_export_helper_default
340
346
  ], 40, _hoisted_1);
341
347
  };
342
348
  }
343
- }, [["__scopeId", "data-v-41f37c29"]]);
349
+ }, [["__scopeId", "data-v-5dba4c36"]]);
344
350
  //#endregion
345
351
  export { FindReplaceSurface_default as default };
@@ -106,6 +106,12 @@ var _sfc_main = {
106
106
  if (fr.canReplace && fr.canReplace.value === false) return true;
107
107
  return false;
108
108
  });
109
+ const replaceAllDisabled = (0, vue.computed)(() => {
110
+ if (replaceDisabled.value) return true;
111
+ const fr = props.findReplace;
112
+ if (fr.canReplaceAll && fr.canReplaceAll.value === false) return true;
113
+ return false;
114
+ });
109
115
  const showIgnoreDiacritics = (0, vue.computed)(() => props.findReplace.ignoreDiacriticsSupported?.value !== false);
110
116
  const showReplaceControls = (0, vue.computed)(() => props.findReplace.replaceEnabled && props.findReplace.replaceCanMutate?.value !== false);
111
117
  const showRegexToggle = (0, vue.computed)(() => props.findReplace.regexSupported?.value === true);
@@ -331,7 +337,7 @@ var _sfc_main = {
331
337
  }, (0, vue.toDisplayString)(__props.findReplace.texts.replaceLabel), 9, _hoisted_17), (0, vue.createElementVNode)("button", {
332
338
  type: "button",
333
339
  class: "sd-find-replace__btn sd-find-replace__btn--action",
334
- disabled: replaceDisabled.value,
340
+ disabled: replaceAllDisabled.value,
335
341
  title: __props.findReplace.texts.replaceAllLabel,
336
342
  onClick: _cache[13] || (_cache[13] = ($event) => __props.findReplace.replaceAll())
337
343
  }, (0, vue.toDisplayString)(__props.findReplace.texts.replaceAllLabel), 9, _hoisted_18)])
@@ -341,6 +347,6 @@ var _sfc_main = {
341
347
  };
342
348
  }
343
349
  };
344
- var FindReplaceSurface_default = /*#__PURE__*/ require__plugin_vue_export_helper._plugin_vue_export_helper_default(_sfc_main, [["__scopeId", "data-v-41f37c29"]]);
350
+ var FindReplaceSurface_default = /*#__PURE__*/ require__plugin_vue_export_helper._plugin_vue_export_helper_default(_sfc_main, [["__scopeId", "data-v-5dba4c36"]]);
345
351
  //#endregion
346
352
  exports.default = FindReplaceSurface_default;
@@ -3553,7 +3553,8 @@ function createSuperDocUI(options) {
3553
3553
  try {
3554
3554
  surface.close();
3555
3555
  } catch {}
3556
- }
3556
+ },
3557
+ contextAt
3557
3558
  };
3558
3559
  /** Read the live browser Document API facade (or null). */
3559
3560
  const getDoc = () => {
@@ -7243,6 +7244,12 @@ function createSuperDocUI(options) {
7243
7244
  * reports the previous document's match count.
7244
7245
  */
7245
7246
  const documentResetHooks = [];
7247
+ /**
7248
+ * Slices that publish through their own listener set rather than the
7249
+ * aggregate `listeners`. `recompute()` never reaches them, so a mode change
7250
+ * that alters what the host reports must republish them explicitly.
7251
+ */
7252
+ const documentModeChangeHooks = [];
7246
7253
  const runHooks = (hooks) => {
7247
7254
  for (const reset of hooks) try {
7248
7255
  reset();
@@ -7250,6 +7257,7 @@ function createSuperDocUI(options) {
7250
7257
  };
7251
7258
  const runActiveEditorResetHooks = () => runHooks(activeEditorResetHooks);
7252
7259
  const runDocumentResetHooks = () => runHooks(documentResetHooks);
7260
+ const runDocumentModeChangeHooks = () => runHooks(documentModeChangeHooks);
7253
7261
  const detachers = [];
7254
7262
  const attach = (source, events) => {
7255
7263
  if (!source || typeof source.on !== "function") return;
@@ -7269,6 +7277,9 @@ function createSuperDocUI(options) {
7269
7277
  asyncReads.clear();
7270
7278
  invalidateDocumentContent();
7271
7279
  recompute();
7280
+ } : event === "document-mode-change" ? () => {
7281
+ recompute();
7282
+ runDocumentModeChangeHooks();
7272
7283
  } : () => recompute();
7273
7284
  try {
7274
7285
  source.on(event, handler);
@@ -10001,6 +10012,23 @@ function createSuperDocUI(options) {
10001
10012
  if (typeof xOrInput === "object") return pointEntityHits(xOrInput?.x, xOrInput?.y);
10002
10013
  return null;
10003
10014
  }
10015
+ function contextAt(input) {
10016
+ const validInput = !!input && typeof input.x === "number" && typeof input.y === "number";
10017
+ const point = validInput ? {
10018
+ x: input.x,
10019
+ y: input.y
10020
+ } : {
10021
+ x: 0,
10022
+ y: 0
10023
+ };
10024
+ return {
10025
+ point,
10026
+ entities: validInput ? entityAt(point) : [],
10027
+ selection: state.selection,
10028
+ position: null,
10029
+ insideSelection: false
10030
+ };
10031
+ }
10004
10032
  const geometryObservers = /* @__PURE__ */ new Set();
10005
10033
  let geometryReleaseScheduled = false;
10006
10034
  const bindGeometryObserver = (entry) => {
@@ -10120,24 +10148,7 @@ function createSuperDocUI(options) {
10120
10148
  },
10121
10149
  getHost: () => resolveVisibleHost(),
10122
10150
  entityAt,
10123
- contextAt: (input) => {
10124
- const validInput = !!input && typeof input.x === "number" && typeof input.y === "number";
10125
- const x = validInput ? input.x : 0;
10126
- const y = validInput ? input.y : 0;
10127
- return {
10128
- point: {
10129
- x,
10130
- y
10131
- },
10132
- entities: validInput ? entityAt({
10133
- x,
10134
- y
10135
- }) : [],
10136
- selection: state.selection,
10137
- position: null,
10138
- insideSelection: false
10139
- };
10140
- },
10151
+ contextAt,
10141
10152
  scrollIntoView: async (input) => {
10142
10153
  const rawTarget = input?.target;
10143
10154
  if (!rawTarget) return { success: false };
@@ -10255,6 +10266,7 @@ function createSuperDocUI(options) {
10255
10266
  includeDeletedText: false,
10256
10267
  regex: false,
10257
10268
  canReplace: false,
10269
+ canReplaceAll: false,
10258
10270
  reason: SUPERDOC_UI_REASONS.searchUnavailable
10259
10271
  };
10260
10272
  let searchState = { ...SEARCH_UNAVAILABLE_SLICE };
@@ -10292,6 +10304,7 @@ function createSuperDocUI(options) {
10292
10304
  return searchState;
10293
10305
  };
10294
10306
  let searchRequestGeneration = 0;
10307
+ let pendingFallbackGeneration = null;
10295
10308
  /**
10296
10309
  * How to tear down the session that is currently open, captured when it was
10297
10310
  * opened.
@@ -10335,6 +10348,8 @@ function createSuperDocUI(options) {
10335
10348
  */
10336
10349
  const resetSearchForActiveEditorChange = () => {
10337
10350
  searchRequestGeneration += 1;
10351
+ pendingFallbackGeneration = null;
10352
+ shellFallbackOutstanding = false;
10338
10353
  releaseSearchSession();
10339
10354
  const available = searchIsAvailable();
10340
10355
  searchState = {
@@ -10345,6 +10360,12 @@ function createSuperDocUI(options) {
10345
10360
  emitSearch();
10346
10361
  };
10347
10362
  documentResetHooks.push(resetSearchForActiveEditorChange);
10363
+ documentModeChangeHooks.push(() => {
10364
+ if (pendingFallbackGeneration === searchRequestGeneration) return;
10365
+ const before = searchState;
10366
+ const after = syncSearchStateFromHost();
10367
+ if (after.canReplace !== before.canReplace || after.canReplaceAll !== before.canReplaceAll || after.available !== before.available || after.reason !== before.reason) emitSearch();
10368
+ });
10348
10369
  const readSearchQueryError = (record) => {
10349
10370
  if (!record) return false;
10350
10371
  const queryError = record.queryError;
@@ -10352,34 +10373,42 @@ function createSuperDocUI(options) {
10352
10373
  const rejection = record.rejection;
10353
10374
  return record.status === "rejected" && Boolean(rejection) && typeof rejection === "object" && rejection.code === "invalid-pattern";
10354
10375
  };
10355
- const normalizeHostSearchResult = (result, fallbackCanReplace = false) => {
10376
+ const normalizeHostSearchResult = (result, fallbackCanReplace = false, fallbackCanReplaceAll = fallbackCanReplace) => {
10356
10377
  const record = result && typeof result === "object" ? result : null;
10357
10378
  if (!record) return null;
10358
10379
  const matches = Array.isArray(record.matches) ? record.matches : [];
10359
10380
  const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : matches.length;
10360
10381
  const activeIndex = typeof record.activeMatchIndex === "number" ? record.activeMatchIndex : typeof record.activeIndex === "number" ? record.activeIndex : -1;
10382
+ const canReplace = record.canReplace === true || fallbackCanReplace;
10361
10383
  return {
10362
10384
  ...typeof record.query === "string" ? { query: record.query } : {},
10363
10385
  total,
10364
10386
  activeIndex,
10365
- canReplace: record.canReplace === true || fallbackCanReplace,
10387
+ canReplace,
10388
+ canReplaceAll: canReplace && total > 0 && record.truncated !== true && (record.canReplace === true || fallbackCanReplaceAll),
10389
+ ...typeof record.caseSensitive === "boolean" ? { caseSensitive: record.caseSensitive } : {},
10366
10390
  ...typeof record.includeDeletedText === "boolean" ? { includeDeletedText: record.includeDeletedText } : {},
10367
10391
  ...record.regex === true ? { regex: true } : {},
10368
10392
  ...readSearchQueryError(record) ? { invalidPattern: true } : {}
10369
10393
  };
10370
10394
  };
10371
- const readEditCommandCanReplace = () => {
10372
- const replaceEntry = readEditCommandStateEntry("find.replace");
10373
- const replaceAllEntry = readEditCommandStateEntry("find.replaceAll");
10374
- return replaceEntry?.enabled === true || replaceAllEntry?.enabled === true;
10395
+ let shellFallbackOutstanding = false;
10396
+ const cancelOutstandingShellFallback = () => {
10397
+ if (!shellFallbackOutstanding) return;
10398
+ shellFallbackOutstanding = false;
10399
+ const editSearch = getEditCommandSearch();
10400
+ if (editSearch && typeof editSearch.query === "function") safeCall(() => editSearch.query({ query: "" }), null);
10375
10401
  };
10376
- const applyHostSearchResult = (result, fallbackCanReplace = false) => {
10377
- const snapshot = normalizeHostSearchResult(result, fallbackCanReplace);
10402
+ const readEditCommandCanReplace = () => readEditCommandStateEntry("find.replace")?.enabled === true;
10403
+ const readEditCommandCanReplaceAll = () => readEditCommandStateEntry("find.replaceAll")?.enabled === true;
10404
+ const applyHostSearchResult = (result, fallbackCanReplace = false, fallbackCanReplaceAll = fallbackCanReplace) => {
10405
+ const snapshot = normalizeHostSearchResult(result, fallbackCanReplace, fallbackCanReplaceAll);
10378
10406
  if (!snapshot) {
10379
10407
  setSearchState({
10380
10408
  total: 0,
10381
10409
  activeIndex: -1,
10382
10410
  canReplace: false,
10411
+ canReplaceAll: false,
10383
10412
  reason: void 0
10384
10413
  });
10385
10414
  return;
@@ -10389,6 +10418,7 @@ function createSuperDocUI(options) {
10389
10418
  total: snapshot.total,
10390
10419
  activeIndex: snapshot.activeIndex,
10391
10420
  canReplace: snapshot.canReplace,
10421
+ canReplaceAll: snapshot.canReplaceAll,
10392
10422
  ...snapshot.includeDeletedText !== void 0 ? { includeDeletedText: snapshot.includeDeletedText } : {},
10393
10423
  ...snapshot.regex !== void 0 ? { regex: snapshot.regex } : {},
10394
10424
  reason: snapshot.invalidPattern ? SUPERDOC_UI_REASONS.searchInvalidPattern : void 0
@@ -10407,7 +10437,8 @@ function createSuperDocUI(options) {
10407
10437
  if (!host) {
10408
10438
  const editSearch = getEditCommandSearch();
10409
10439
  if (editSearch && typeof editSearch.getState === "function") {
10410
- const editSnapshot = normalizeHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace());
10440
+ const editSnapshot = normalizeHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10441
+ if (pendingFallbackGeneration === searchRequestGeneration) return searchState;
10411
10442
  if (editSnapshot) {
10412
10443
  searchState = {
10413
10444
  ...searchState,
@@ -10415,6 +10446,7 @@ function createSuperDocUI(options) {
10415
10446
  total: editSnapshot.total,
10416
10447
  activeIndex: editSnapshot.activeIndex,
10417
10448
  canReplace: editSnapshot.canReplace,
10449
+ canReplaceAll: editSnapshot.canReplaceAll,
10418
10450
  available: true,
10419
10451
  reason: editSnapshot.invalidPattern ? SUPERDOC_UI_REASONS.searchInvalidPattern : void 0,
10420
10452
  open: searchState.open || Boolean(editSnapshot.query)
@@ -10439,6 +10471,7 @@ function createSuperDocUI(options) {
10439
10471
  total: snapshot.total,
10440
10472
  activeIndex: snapshot.activeIndex,
10441
10473
  canReplace: snapshot.canReplace,
10474
+ canReplaceAll: snapshot.canReplaceAll,
10442
10475
  ...snapshot.includeDeletedText !== void 0 ? { includeDeletedText: snapshot.includeDeletedText } : {},
10443
10476
  ...snapshot.includeDeletedText !== void 0 ? { includeTrackedDeletions: snapshot.includeDeletedText } : {},
10444
10477
  ...snapshot.regex !== void 0 ? { regex: snapshot.regex } : {},
@@ -10521,14 +10554,20 @@ function createSuperDocUI(options) {
10521
10554
  const includeDeletedText = (options?.includeTrackedDeletions ?? options?.includeDeletedText) === true;
10522
10555
  const regex = options?.regex === true;
10523
10556
  const generation = ++searchRequestGeneration;
10557
+ cancelOutstandingShellFallback();
10524
10558
  if (!host || typeof host.setSession !== "function") {
10525
10559
  const editSearch = getEditCommandSearch();
10526
10560
  if (editSearch && typeof editSearch.query === "function" && typeof editSearch.getState === "function") {
10561
+ pendingFallbackGeneration = generation;
10527
10562
  setSearchState({
10528
10563
  query,
10529
10564
  caseSensitive,
10530
10565
  includeDeletedText,
10531
10566
  regex,
10567
+ total: 0,
10568
+ activeIndex: -1,
10569
+ canReplace: false,
10570
+ canReplaceAll: false,
10532
10571
  available: true,
10533
10572
  open: true,
10534
10573
  reason: void 0
@@ -10542,18 +10581,26 @@ function createSuperDocUI(options) {
10542
10581
  includeDeletedText,
10543
10582
  regex
10544
10583
  }), null);
10545
- if (isPromiseLike(result)) Promise.resolve(result).then((resolved) => {
10546
- if (generation !== searchRequestGeneration) return;
10547
- applyHostSearchResult(resolved, readEditCommandCanReplace());
10548
- }, () => {
10549
- if (generation !== searchRequestGeneration) return;
10550
- setSearchState({
10551
- available: false,
10552
- reason: SUPERDOC_UI_REASONS.searchUnavailable
10584
+ if (isPromiseLike(result)) {
10585
+ shellFallbackOutstanding = true;
10586
+ Promise.resolve(result).then((resolved) => {
10587
+ if (generation !== searchRequestGeneration) return;
10588
+ shellFallbackOutstanding = false;
10589
+ pendingFallbackGeneration = null;
10590
+ applyHostSearchResult(resolved, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10591
+ }, () => {
10592
+ if (generation !== searchRequestGeneration) return;
10593
+ shellFallbackOutstanding = false;
10594
+ setSearchState({
10595
+ available: false,
10596
+ reason: SUPERDOC_UI_REASONS.searchUnavailable
10597
+ });
10553
10598
  });
10554
- });
10555
- else applyHostSearchResult(result, readEditCommandCanReplace());
10556
- applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace());
10599
+ return searchState;
10600
+ }
10601
+ pendingFallbackGeneration = null;
10602
+ applyHostSearchResult(result, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10603
+ applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10557
10604
  return searchState;
10558
10605
  }
10559
10606
  return setSearchState({
@@ -10600,18 +10647,22 @@ function createSuperDocUI(options) {
10600
10647
  includeDeletedText,
10601
10648
  regex
10602
10649
  }), null);
10603
- if (isPromiseLike(commandResult)) Promise.resolve(commandResult).then((resolved) => {
10604
- if (generation !== searchRequestGeneration) return;
10605
- applyHostSearchResult(resolved, readEditCommandCanReplace());
10606
- }, () => {
10607
- if (generation !== searchRequestGeneration) return;
10608
- setSearchState({
10609
- available: false,
10610
- reason: SUPERDOC_UI_REASONS.searchUnavailable
10650
+ if (isPromiseLike(commandResult)) {
10651
+ shellFallbackOutstanding = true;
10652
+ Promise.resolve(commandResult).then((resolved) => {
10653
+ if (generation !== searchRequestGeneration) return;
10654
+ shellFallbackOutstanding = false;
10655
+ applyHostSearchResult(resolved, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10656
+ }, () => {
10657
+ if (generation !== searchRequestGeneration) return;
10658
+ shellFallbackOutstanding = false;
10659
+ setSearchState({
10660
+ available: false,
10661
+ reason: SUPERDOC_UI_REASONS.searchUnavailable
10662
+ });
10611
10663
  });
10612
- });
10613
- else applyHostSearchResult(commandResult, readEditCommandCanReplace());
10614
- applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace());
10664
+ } else applyHostSearchResult(commandResult, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10665
+ applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10615
10666
  }
10616
10667
  }
10617
10668
  return searchState;
@@ -10634,7 +10685,7 @@ function createSuperDocUI(options) {
10634
10685
  const generation = searchRequestGeneration;
10635
10686
  Promise.resolve(result).then((resolved) => {
10636
10687
  if (generation !== searchRequestGeneration) return;
10637
- applyHostSearchResult(resolved, readEditCommandCanReplace());
10688
+ applyHostSearchResult(resolved, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10638
10689
  }).catch(() => {
10639
10690
  if (generation !== searchRequestGeneration) return;
10640
10691
  setSearchState({
@@ -10642,8 +10693,8 @@ function createSuperDocUI(options) {
10642
10693
  reason: SUPERDOC_UI_REASONS.searchUnavailable
10643
10694
  });
10644
10695
  });
10645
- } else applyHostSearchResult(result, readEditCommandCanReplace());
10646
- applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace());
10696
+ } else applyHostSearchResult(result, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10697
+ applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10647
10698
  return { ok: true };
10648
10699
  }
10649
10700
  if (searchState.total === 0) return {
@@ -10670,7 +10721,7 @@ function createSuperDocUI(options) {
10670
10721
  const generation = searchRequestGeneration;
10671
10722
  Promise.resolve(result).then((resolved) => {
10672
10723
  if (generation !== searchRequestGeneration) return;
10673
- applyHostSearchResult(resolved, readEditCommandCanReplace());
10724
+ applyHostSearchResult(resolved, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10674
10725
  }).catch(() => {
10675
10726
  if (generation !== searchRequestGeneration) return;
10676
10727
  setSearchState({
@@ -10678,8 +10729,8 @@ function createSuperDocUI(options) {
10678
10729
  reason: SUPERDOC_UI_REASONS.searchUnavailable
10679
10730
  });
10680
10731
  });
10681
- } else applyHostSearchResult(result, readEditCommandCanReplace());
10682
- applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace());
10732
+ } else applyHostSearchResult(result, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10733
+ applyHostSearchResult(safeCall(() => editSearch.getState(), null), readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10683
10734
  return { ok: true };
10684
10735
  }
10685
10736
  if (searchState.total === 0) return {
@@ -10691,6 +10742,7 @@ function createSuperDocUI(options) {
10691
10742
  },
10692
10743
  clear: () => {
10693
10744
  searchRequestGeneration += 1;
10745
+ cancelOutstandingShellFallback();
10694
10746
  const host = getHostSearch();
10695
10747
  if (host && typeof host.clear === "function") safeCall(() => host.clear(), null);
10696
10748
  if (!host || typeof host.clear !== "function") {
@@ -10701,7 +10753,9 @@ function createSuperDocUI(options) {
10701
10753
  query: "",
10702
10754
  total: 0,
10703
10755
  activeIndex: -1,
10704
- canReplace: false
10756
+ canReplace: false,
10757
+ canReplaceAll: false,
10758
+ reason: void 0
10705
10759
  });
10706
10760
  },
10707
10761
  replace: (replacement) => {
@@ -10724,7 +10778,7 @@ function createSuperDocUI(options) {
10724
10778
  const isCurrent = () => generation === searchRequestGeneration;
10725
10779
  return Promise.resolve(result).then((resolved) => {
10726
10780
  if (isCurrent()) {
10727
- applyHostSearchResult(resolved, readEditCommandCanReplace());
10781
+ applyHostSearchResult(resolved, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10728
10782
  syncSearchStateFromHost();
10729
10783
  emitSearch();
10730
10784
  }
@@ -10761,7 +10815,7 @@ function createSuperDocUI(options) {
10761
10815
  ok: false,
10762
10816
  reason: SUPERDOC_UI_REASONS.searchUnavailable
10763
10817
  };
10764
- if (!readEditCommandCanReplace()) return {
10818
+ if (!readEditCommandCanReplaceAll()) return {
10765
10819
  ok: false,
10766
10820
  reason: SUPERDOC_UI_REASONS.operationUnavailable
10767
10821
  };
@@ -10773,7 +10827,7 @@ function createSuperDocUI(options) {
10773
10827
  const isCurrent = () => generation === searchRequestGeneration;
10774
10828
  return Promise.resolve(result).then((resolved) => {
10775
10829
  if (isCurrent()) {
10776
- applyHostSearchResult(resolved, readEditCommandCanReplace());
10830
+ applyHostSearchResult(resolved, readEditCommandCanReplace(), readEditCommandCanReplaceAll());
10777
10831
  syncSearchStateFromHost();
10778
10832
  emitSearch();
10779
10833
  }