@stll/folio-react 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,7 +31,6 @@ import { executeEditorCommand, executeFirstEditorCommand } from "@stll/folio-cor
31
31
  import { insertPageBreak } from "@stll/folio-core/prosemirror/commands/pageBreak";
32
32
  import { clearTrackedChanges, getChangedParagraphIds, hasStructuralChanges, hasUntrackedChanges, repackWithEditorSectionRemovals } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
33
33
  import { createStarterKit } from "@stll/folio-core/prosemirror/extensions/StarterKit";
34
- import { findInMarkupView, resolveFindMatchRange } from "@stll/folio-core/prosemirror/findReplaceSelection";
35
34
  import { createAICitationDecorationsPlugin } from "@stll/folio-core/prosemirror/plugins/aiCitationDecorations";
36
35
  import { AI_SUGGESTION_SEVERITY_CLASS, aiSuggestionDecorationsKey, createAISuggestionDecorationsPlugin } from "@stll/folio-core/prosemirror/plugins/aiSuggestionDecorations";
37
36
  import { anonymizationDecorationsKey, createAnonymizationDecorationsPlugin, slugAnonymizationLabel } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations";
@@ -107,7 +106,7 @@ import { getFolioParaIdFromBlockId } from "@stll/folio-core/types/block-id";
107
106
  import { getPageTextFromLayout } from "@stll/folio-core/paged-layout/pageText";
108
107
  import { allocateCommentId, seedCommentIdAbove } from "@stll/folio-core/prosemirror/commentIdAllocator";
109
108
  import { ContentControlWidgetController } from "@stll/folio-core/controller/contentControlWidgetController";
110
- import { createDefaultFindOptions, findInDocument } from "@stll/folio-core/utils/findReplace";
109
+ import { createDefaultFindOptions, replaceEligibility } from "@stll/folio-core/utils/findReplace";
111
110
  import { PANEL_METRICS, computePanelLayout } from "@stll/folio-core/panel-layout";
112
111
  import { ErrorManager } from "@stll/folio-core/managers/ErrorManager";
113
112
  import { ContextMenuManager } from "@stll/folio-core/managers/ContextMenuManager";
@@ -116,6 +115,9 @@ import { getDocumentLoadSource } from "@stll/folio-core/utils/documentLoaderBeha
116
115
  import { DISPLAY_MODES, EditorModeManager, getEditorReadOnlyReason, getReviewViewReadOnlyReason, isTrackChangesMode, toggledTrackChangesMode } from "@stll/folio-core/managers/EditorModeManager";
117
116
  import { reviewDisplayModeToDisplayMode } from "@stll/folio-core/managers/reviewDisplayMode";
118
117
  import { FindReplaceManager } from "@stll/folio-core/managers/FindReplaceManager";
118
+ import { findInDisplayedDocument } from "@stll/folio-core/prosemirror/findReplaceSelection";
119
+ import { createFindQueryKey, createFindSearchKey, sameFindBodyVersion, sameFindSearchKey } from "@stll/folio-core/utils/findSearchKey";
120
+ import { createFindMatchView, getRenderedSearchStories } from "@stll/folio-core/utils/findMatchView";
119
121
  import { createEmptyHeaderFooter, pickActiveHeaderFooterRId, removeHeaderFooter, resolveEffectiveSectionProperties, resolveHeaderFooterContent, saveHeaderFooterContent } from "@stll/folio-core/utils/headerFooter";
120
122
  import { createCanonicalHeaderFooterOperation, removeCanonicalHeaderFooterOperations } from "@stll/folio-core/controller/canonicalOperations";
121
123
  import { editHyperlinkAtCursor, removeHyperlinkAtCursor } from "@stll/folio-core/prosemirror/commands/hyperlink";
@@ -7529,12 +7531,6 @@ const readFindSelectionSeed = () => {
7529
7531
  return selection && !selection.isCollapsed ? selection.toString() : "";
7530
7532
  };
7531
7533
  //#endregion
7532
- //#region src/components/dialogs/findReplaceUtils.ts
7533
- const scrollToMatch = (containerElement, match) => {
7534
- if (!containerElement) return;
7535
- scrollEditorElementIntoView(containerElement.querySelector(`[data-paragraph-index="${match.paragraphIndex}"]`) ?? containerElement.querySelector(`.layout-paragraph[data-block-id="block-${match.paragraphIndex + 1}"]`) ?? containerElement.querySelectorAll(".layout-paragraph").item(match.paragraphIndex));
7536
- };
7537
- //#endregion
7538
7534
  //#region src/components/dialogs/useFindReplace.ts
7539
7535
  /**
7540
7536
  * useFindReplace Hook
@@ -8348,7 +8344,7 @@ function _temp$10(heading) {
8348
8344
  }
8349
8345
  //#endregion
8350
8346
  //#region src/components/DocxEditorDialogs.tsx
8351
- const FindReplaceDialog = lazy(() => import("./FindReplaceDialog-CUd8xdgd.js").then((n) => n.n).then((m) => ({ default: m.FindReplaceDialog })));
8347
+ const FindReplaceDialog = lazy(() => import("./FindReplaceDialog-C3njN6OI.js").then((n) => n.n).then((m) => ({ default: m.FindReplaceDialog })));
8352
8348
  const TablePropertiesDialog = lazy(() => import("./TablePropertiesDialog-uSTmyEcu.js").then((n) => n.n).then((m) => ({ default: m.TablePropertiesDialog })));
8353
8349
  const ImagePositionDialog = lazy(() => import("./ImagePositionDialog-Oap9knQ-.js").then((n) => n.n).then((m) => ({ default: m.ImagePositionDialog })));
8354
8350
  const ImagePropertiesDialog = lazy(() => import("./ImagePropertiesDialog-lLMKHv0u.js").then((n) => n.n).then((m) => ({ default: m.ImagePropertiesDialog })));
@@ -8357,88 +8353,94 @@ const PageSetupDialog = lazy(() => import("./PageSetupDialog-DTWCdPkX.js").then(
8357
8353
  const SetNumberingValueDialog = lazy(() => import("./SetNumberingValueDialog-twVIZMLc.js").then((m) => ({ default: m.SetNumberingValueDialog })));
8358
8354
  const InsertSymbolDialog = lazy(() => import("./InsertSymbolDialog-Drm40-9j.js").then((n) => n.n).then((m) => ({ default: m.InsertSymbolDialog })));
8359
8355
  function DocxEditorDialogs(t0) {
8360
- const $ = c(52);
8356
+ const $ = c(55);
8361
8357
  const { findReplace, tableProperties, imagePosition, imageProperties, pageSetup, footnoteProperties, insertSymbol, setNumberingValue } = t0;
8362
8358
  let t1;
8363
- if ($[0] !== findReplace.currentResult || $[1] !== findReplace.onClose || $[2] !== findReplace.onFind || $[3] !== findReplace.onFindNext || $[4] !== findReplace.onFindPrevious || $[5] !== findReplace.onReplace || $[6] !== findReplace.onReplaceAll || $[7] !== findReplace.state.dialog.status || $[8] !== findReplace.state.searchText) {
8359
+ if ($[0] !== findReplace.currentSearch || $[1] !== findReplace.onClose || $[2] !== findReplace.onFind || $[3] !== findReplace.onFindNext || $[4] !== findReplace.onFindPrevious || $[5] !== findReplace.onQueryChange || $[6] !== findReplace.onReplace || $[7] !== findReplace.onReplaceAll || $[8] !== findReplace.readOnly || $[9] !== findReplace.state.dialog.mode || $[10] !== findReplace.state.dialog.status || $[11] !== findReplace.state.searchText) {
8364
8360
  t1 = findReplace.state.dialog.status === "open" && /* @__PURE__ */ jsx(FindReplaceDialog, {
8365
8361
  isOpen: true,
8366
8362
  onClose: findReplace.onClose,
8367
8363
  onFind: findReplace.onFind,
8364
+ onQueryChange: findReplace.onQueryChange,
8368
8365
  onFindNext: findReplace.onFindNext,
8369
8366
  onFindPrevious: findReplace.onFindPrevious,
8370
8367
  onReplace: findReplace.onReplace,
8371
8368
  onReplaceAll: findReplace.onReplaceAll,
8372
8369
  initialSearchText: findReplace.state.searchText,
8373
- currentResult: findReplace.currentResult
8370
+ currentSearch: findReplace.currentSearch,
8371
+ readOnly: findReplace.readOnly,
8372
+ replaceMode: findReplace.state.dialog.mode === "replace"
8374
8373
  });
8375
- $[0] = findReplace.currentResult;
8374
+ $[0] = findReplace.currentSearch;
8376
8375
  $[1] = findReplace.onClose;
8377
8376
  $[2] = findReplace.onFind;
8378
8377
  $[3] = findReplace.onFindNext;
8379
8378
  $[4] = findReplace.onFindPrevious;
8380
- $[5] = findReplace.onReplace;
8381
- $[6] = findReplace.onReplaceAll;
8382
- $[7] = findReplace.state.dialog.status;
8383
- $[8] = findReplace.state.searchText;
8384
- $[9] = t1;
8385
- } else t1 = $[9];
8379
+ $[5] = findReplace.onQueryChange;
8380
+ $[6] = findReplace.onReplace;
8381
+ $[7] = findReplace.onReplaceAll;
8382
+ $[8] = findReplace.readOnly;
8383
+ $[9] = findReplace.state.dialog.mode;
8384
+ $[10] = findReplace.state.dialog.status;
8385
+ $[11] = findReplace.state.searchText;
8386
+ $[12] = t1;
8387
+ } else t1 = $[12];
8386
8388
  let t2;
8387
- if ($[10] !== tableProperties.currentProps || $[11] !== tableProperties.isOpen || $[12] !== tableProperties.onApply || $[13] !== tableProperties.onClose) {
8389
+ if ($[13] !== tableProperties.currentProps || $[14] !== tableProperties.isOpen || $[15] !== tableProperties.onApply || $[16] !== tableProperties.onClose) {
8388
8390
  t2 = tableProperties.isOpen && /* @__PURE__ */ jsx(TablePropertiesDialog, {
8389
8391
  isOpen: tableProperties.isOpen,
8390
8392
  onClose: tableProperties.onClose,
8391
8393
  onApply: tableProperties.onApply,
8392
8394
  ...tableProperties.currentProps ? { currentProps: tableProperties.currentProps } : {}
8393
8395
  });
8394
- $[10] = tableProperties.currentProps;
8395
- $[11] = tableProperties.isOpen;
8396
- $[12] = tableProperties.onApply;
8397
- $[13] = tableProperties.onClose;
8398
- $[14] = t2;
8399
- } else t2 = $[14];
8396
+ $[13] = tableProperties.currentProps;
8397
+ $[14] = tableProperties.isOpen;
8398
+ $[15] = tableProperties.onApply;
8399
+ $[16] = tableProperties.onClose;
8400
+ $[17] = t2;
8401
+ } else t2 = $[17];
8400
8402
  let t3;
8401
- if ($[15] !== imagePosition.isOpen || $[16] !== imagePosition.onApply || $[17] !== imagePosition.onClose) {
8403
+ if ($[18] !== imagePosition.isOpen || $[19] !== imagePosition.onApply || $[20] !== imagePosition.onClose) {
8402
8404
  t3 = imagePosition.isOpen && /* @__PURE__ */ jsx(ImagePositionDialog, {
8403
8405
  isOpen: imagePosition.isOpen,
8404
8406
  onClose: imagePosition.onClose,
8405
8407
  onApply: imagePosition.onApply
8406
8408
  });
8407
- $[15] = imagePosition.isOpen;
8408
- $[16] = imagePosition.onApply;
8409
- $[17] = imagePosition.onClose;
8410
- $[18] = t3;
8411
- } else t3 = $[18];
8409
+ $[18] = imagePosition.isOpen;
8410
+ $[19] = imagePosition.onApply;
8411
+ $[20] = imagePosition.onClose;
8412
+ $[21] = t3;
8413
+ } else t3 = $[21];
8412
8414
  let t4;
8413
- if ($[19] !== imageProperties.currentData || $[20] !== imageProperties.isOpen || $[21] !== imageProperties.onApply || $[22] !== imageProperties.onClose) {
8415
+ if ($[22] !== imageProperties.currentData || $[23] !== imageProperties.isOpen || $[24] !== imageProperties.onApply || $[25] !== imageProperties.onClose) {
8414
8416
  t4 = imageProperties.isOpen && /* @__PURE__ */ jsx(ImagePropertiesDialog, {
8415
8417
  isOpen: imageProperties.isOpen,
8416
8418
  onClose: imageProperties.onClose,
8417
8419
  onApply: imageProperties.onApply,
8418
8420
  ...imageProperties.currentData ? { currentData: imageProperties.currentData } : {}
8419
8421
  });
8420
- $[19] = imageProperties.currentData;
8421
- $[20] = imageProperties.isOpen;
8422
- $[21] = imageProperties.onApply;
8423
- $[22] = imageProperties.onClose;
8424
- $[23] = t4;
8425
- } else t4 = $[23];
8422
+ $[22] = imageProperties.currentData;
8423
+ $[23] = imageProperties.isOpen;
8424
+ $[24] = imageProperties.onApply;
8425
+ $[25] = imageProperties.onClose;
8426
+ $[26] = t4;
8427
+ } else t4 = $[26];
8426
8428
  let t5;
8427
- if ($[24] !== pageSetup.currentProps || $[25] !== pageSetup.isOpen || $[26] !== pageSetup.onApply || $[27] !== pageSetup.onClose) {
8429
+ if ($[27] !== pageSetup.currentProps || $[28] !== pageSetup.isOpen || $[29] !== pageSetup.onApply || $[30] !== pageSetup.onClose) {
8428
8430
  t5 = pageSetup.isOpen && /* @__PURE__ */ jsx(PageSetupDialog, {
8429
8431
  isOpen: pageSetup.isOpen,
8430
8432
  onClose: pageSetup.onClose,
8431
8433
  onApply: pageSetup.onApply,
8432
8434
  ...pageSetup.currentProps ? { currentProps: pageSetup.currentProps } : {}
8433
8435
  });
8434
- $[24] = pageSetup.currentProps;
8435
- $[25] = pageSetup.isOpen;
8436
- $[26] = pageSetup.onApply;
8437
- $[27] = pageSetup.onClose;
8438
- $[28] = t5;
8439
- } else t5 = $[28];
8436
+ $[27] = pageSetup.currentProps;
8437
+ $[28] = pageSetup.isOpen;
8438
+ $[29] = pageSetup.onApply;
8439
+ $[30] = pageSetup.onClose;
8440
+ $[31] = t5;
8441
+ } else t5 = $[31];
8440
8442
  let t6;
8441
- if ($[29] !== footnoteProperties.endnotePr || $[30] !== footnoteProperties.footnotePr || $[31] !== footnoteProperties.isOpen || $[32] !== footnoteProperties.onApply || $[33] !== footnoteProperties.onClose) {
8443
+ if ($[32] !== footnoteProperties.endnotePr || $[33] !== footnoteProperties.footnotePr || $[34] !== footnoteProperties.isOpen || $[35] !== footnoteProperties.onApply || $[36] !== footnoteProperties.onClose) {
8442
8444
  t6 = footnoteProperties.isOpen && /* @__PURE__ */ jsx(FootnotePropertiesDialog, {
8443
8445
  isOpen: footnoteProperties.isOpen,
8444
8446
  onClose: footnoteProperties.onClose,
@@ -8446,39 +8448,39 @@ function DocxEditorDialogs(t0) {
8446
8448
  ...footnoteProperties.footnotePr ? { footnotePr: footnoteProperties.footnotePr } : {},
8447
8449
  ...footnoteProperties.endnotePr ? { endnotePr: footnoteProperties.endnotePr } : {}
8448
8450
  });
8449
- $[29] = footnoteProperties.endnotePr;
8450
- $[30] = footnoteProperties.footnotePr;
8451
- $[31] = footnoteProperties.isOpen;
8452
- $[32] = footnoteProperties.onApply;
8453
- $[33] = footnoteProperties.onClose;
8454
- $[34] = t6;
8455
- } else t6 = $[34];
8451
+ $[32] = footnoteProperties.endnotePr;
8452
+ $[33] = footnoteProperties.footnotePr;
8453
+ $[34] = footnoteProperties.isOpen;
8454
+ $[35] = footnoteProperties.onApply;
8455
+ $[36] = footnoteProperties.onClose;
8456
+ $[37] = t6;
8457
+ } else t6 = $[37];
8456
8458
  let t7;
8457
- if ($[35] !== insertSymbol.isOpen || $[36] !== insertSymbol.onClose || $[37] !== insertSymbol.onInsert) {
8459
+ if ($[38] !== insertSymbol.isOpen || $[39] !== insertSymbol.onClose || $[40] !== insertSymbol.onInsert) {
8458
8460
  t7 = insertSymbol.isOpen && /* @__PURE__ */ jsx(InsertSymbolDialog, {
8459
8461
  isOpen: insertSymbol.isOpen,
8460
8462
  onClose: insertSymbol.onClose,
8461
8463
  onInsert: insertSymbol.onInsert
8462
8464
  });
8463
- $[35] = insertSymbol.isOpen;
8464
- $[36] = insertSymbol.onClose;
8465
- $[37] = insertSymbol.onInsert;
8466
- $[38] = t7;
8467
- } else t7 = $[38];
8465
+ $[38] = insertSymbol.isOpen;
8466
+ $[39] = insertSymbol.onClose;
8467
+ $[40] = insertSymbol.onInsert;
8468
+ $[41] = t7;
8469
+ } else t7 = $[41];
8468
8470
  let t8;
8469
- if ($[39] !== setNumberingValue.isOpen || $[40] !== setNumberingValue.onApply || $[41] !== setNumberingValue.onClose) {
8471
+ if ($[42] !== setNumberingValue.isOpen || $[43] !== setNumberingValue.onApply || $[44] !== setNumberingValue.onClose) {
8470
8472
  t8 = setNumberingValue.isOpen && /* @__PURE__ */ jsx(SetNumberingValueDialog, {
8471
8473
  isOpen: setNumberingValue.isOpen,
8472
8474
  onClose: setNumberingValue.onClose,
8473
8475
  onApply: setNumberingValue.onApply
8474
8476
  });
8475
- $[39] = setNumberingValue.isOpen;
8476
- $[40] = setNumberingValue.onApply;
8477
- $[41] = setNumberingValue.onClose;
8478
- $[42] = t8;
8479
- } else t8 = $[42];
8477
+ $[42] = setNumberingValue.isOpen;
8478
+ $[43] = setNumberingValue.onApply;
8479
+ $[44] = setNumberingValue.onClose;
8480
+ $[45] = t8;
8481
+ } else t8 = $[45];
8480
8482
  let t9;
8481
- if ($[43] !== t1 || $[44] !== t2 || $[45] !== t3 || $[46] !== t4 || $[47] !== t5 || $[48] !== t6 || $[49] !== t7 || $[50] !== t8) {
8483
+ if ($[46] !== t1 || $[47] !== t2 || $[48] !== t3 || $[49] !== t4 || $[50] !== t5 || $[51] !== t6 || $[52] !== t7 || $[53] !== t8) {
8482
8484
  t9 = /* @__PURE__ */ jsxs(Suspense, {
8483
8485
  fallback: null,
8484
8486
  children: [
@@ -8492,16 +8494,16 @@ function DocxEditorDialogs(t0) {
8492
8494
  t8
8493
8495
  ]
8494
8496
  });
8495
- $[43] = t1;
8496
- $[44] = t2;
8497
- $[45] = t3;
8498
- $[46] = t4;
8499
- $[47] = t5;
8500
- $[48] = t6;
8501
- $[49] = t7;
8502
- $[50] = t8;
8503
- $[51] = t9;
8504
- } else t9 = $[51];
8497
+ $[46] = t1;
8498
+ $[47] = t2;
8499
+ $[48] = t3;
8500
+ $[49] = t4;
8501
+ $[50] = t5;
8502
+ $[51] = t6;
8503
+ $[52] = t7;
8504
+ $[53] = t8;
8505
+ $[54] = t9;
8506
+ } else t9 = $[54];
8505
8507
  return t9;
8506
8508
  }
8507
8509
  //#endregion
@@ -10904,22 +10906,13 @@ function useEditorMode(t0) {
10904
10906
  * from `dialogs/useFindReplace.ts`; this hook layers the document-aware
10905
10907
  * operations (find, replace, scroll-to-match) on top.
10906
10908
  */
10907
- const toEditorFindMatch = ({ from, to, ...match }) => ({
10908
- ...match,
10909
- contentIndex: 0,
10910
- authoredRange: {
10911
- from,
10912
- to
10913
- }
10914
- });
10915
10909
  function useFindReplace(t0) {
10916
- const $ = c(49);
10917
- const { documentState, getDocumentState, getEditorState, markupView: markupViewProp, containerRef, handleDocumentChange, findReplace, selectMatch, readOnlyReason, onReadonlyEditAttempt } = t0;
10918
- const markupView = markupViewProp ?? "all-markup";
10910
+ const $ = c(89);
10911
+ const { documentState, getDocumentState, getEditorState, containerRef, handleDocumentChange, findReplace, selectMatch, getBodyDoc, getLayout, displayMode, onFindResultChange, readOnlyReason, onReadonlyEditAttempt } = t0;
10919
10912
  let t1;
10920
- if ($[0] !== markupView || $[1] !== readOnlyReason) {
10921
- t1 = getReviewViewReadOnlyReason(markupView) ?? readOnlyReason ?? null;
10922
- $[0] = markupView;
10913
+ if ($[0] !== displayMode || $[1] !== readOnlyReason) {
10914
+ t1 = getReviewViewReadOnlyReason(displayMode ?? "all-markup") ?? readOnlyReason ?? null;
10915
+ $[0] = displayMode;
10923
10916
  $[1] = readOnlyReason;
10924
10917
  $[2] = t1;
10925
10918
  } else t1 = $[2];
@@ -10930,208 +10923,476 @@ function useFindReplace(t0) {
10930
10923
  $[3] = t2;
10931
10924
  } else t2 = $[3];
10932
10925
  const manager = t2;
10933
- const [currentResult, setCurrentResult] = useState(null);
10934
- const activeSearch = useRef(null);
10935
- const { setMatches, goToMatch } = findReplace;
10936
10926
  let t3;
10937
- if ($[4] !== setMatches) {
10938
- t3 = () => {
10939
- activeSearch.current = null;
10927
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
10928
+ t3 = { status: "cleared" };
10929
+ $[4] = t3;
10930
+ } else t3 = $[4];
10931
+ const [publishedResult, setPublishedResult] = useState(t3);
10932
+ const { setMatches, goToMatch } = findReplace;
10933
+ const matchView = useRef(null);
10934
+ const query = useRef(null);
10935
+ const searchSource = useRef(null);
10936
+ let t4;
10937
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
10938
+ t4 = { status: "ready" };
10939
+ $[5] = t4;
10940
+ } else t4 = $[5];
10941
+ const replacementGate = useRef(t4);
10942
+ const resultCallback = useRef(onFindResultChange);
10943
+ let t5;
10944
+ let t6;
10945
+ if ($[6] !== onFindResultChange) {
10946
+ t5 = () => {
10947
+ resultCallback.current = onFindResultChange;
10948
+ };
10949
+ t6 = [onFindResultChange];
10950
+ $[6] = onFindResultChange;
10951
+ $[7] = t5;
10952
+ $[8] = t6;
10953
+ } else {
10954
+ t5 = $[7];
10955
+ t6 = $[8];
10956
+ }
10957
+ useEffect(t5, t6);
10958
+ let t7;
10959
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
10960
+ t7 = (result) => {
10961
+ if (result) {
10962
+ const source = searchSource.current;
10963
+ if (!source) panic("Find result published without a search key");
10964
+ setPublishedResult({
10965
+ status: "ready",
10966
+ queryKey: source.intentKey,
10967
+ result
10968
+ });
10969
+ } else setPublishedResult({ status: "cleared" });
10970
+ resultCallback.current?.(result);
10971
+ };
10972
+ $[9] = t7;
10973
+ } else t7 = $[9];
10974
+ const publish = t7;
10975
+ let t8;
10976
+ let t9;
10977
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
10978
+ t8 = () => () => matchView.current?.destroy();
10979
+ t9 = [];
10980
+ $[10] = t8;
10981
+ $[11] = t9;
10982
+ } else {
10983
+ t8 = $[10];
10984
+ t9 = $[11];
10985
+ }
10986
+ useEffect(t8, t9);
10987
+ let t10;
10988
+ if ($[12] !== setMatches) {
10989
+ t10 = () => {
10940
10990
  manager.clear();
10941
- setCurrentResult(null);
10991
+ searchSource.current = null;
10992
+ matchView.current?.destroy();
10993
+ matchView.current = null;
10994
+ publish(null);
10942
10995
  setMatches([], 0);
10943
10996
  };
10944
- $[4] = setMatches;
10945
- $[5] = t3;
10946
- } else t3 = $[5];
10947
- const resetFindResult = t3;
10948
- let t4;
10949
- if ($[6] !== documentState || $[7] !== getDocumentState) {
10950
- t4 = () => getDocumentState?.() ?? documentState ?? null;
10951
- $[6] = documentState;
10952
- $[7] = getDocumentState;
10953
- $[8] = t4;
10954
- } else t4 = $[8];
10955
- const readDocumentState = t4;
10956
- let t5;
10957
- if ($[9] !== containerRef || $[10] !== selectMatch) {
10958
- t5 = (match) => {
10959
- if (!selectMatch?.(match) && containerRef.current) scrollToMatch(containerRef.current, match);
10997
+ $[12] = setMatches;
10998
+ $[13] = t10;
10999
+ } else t10 = $[13];
11000
+ const clearFindResult = t10;
11001
+ let t11;
11002
+ if ($[14] !== clearFindResult) {
11003
+ t11 = () => {
11004
+ query.current = null;
11005
+ clearFindResult();
10960
11006
  };
10961
- $[9] = containerRef;
10962
- $[10] = selectMatch;
10963
- $[11] = t5;
10964
- } else t5 = $[11];
10965
- const revealMatch = t5;
10966
- let t6;
10967
- if ($[12] !== getEditorState || $[13] !== markupView || $[14] !== readDocumentState || $[15] !== resetFindResult || $[16] !== revealMatch || $[17] !== setMatches) {
10968
- t6 = (searchText, options) => {
10969
- const currentDocument = readDocumentState();
10970
- if (!currentDocument || !searchText.trim()) {
11007
+ $[14] = clearFindResult;
11008
+ $[15] = t11;
11009
+ } else t11 = $[15];
11010
+ const resetFindResult = t11;
11011
+ let t12;
11012
+ if ($[16] !== documentState || $[17] !== getDocumentState) {
11013
+ t12 = () => getDocumentState?.() ?? documentState ?? null;
11014
+ $[16] = documentState;
11015
+ $[17] = getDocumentState;
11016
+ $[18] = t12;
11017
+ } else t12 = $[18];
11018
+ const readDocumentState = t12;
11019
+ let t13;
11020
+ if ($[19] !== getEditorState) {
11021
+ t13 = (currentDocument, searchText, options, context) => findInDisplayedDocument({
11022
+ document: currentDocument,
11023
+ ...getEditorState && { state: getEditorState() },
11024
+ searchText,
11025
+ options,
11026
+ context
11027
+ });
11028
+ $[19] = getEditorState;
11029
+ $[20] = t13;
11030
+ } else t13 = $[20];
11031
+ const findDisplayedMatches = t13;
11032
+ let t14;
11033
+ if ($[21] !== selectMatch) {
11034
+ t14 = (match) => {
11035
+ const index = manager.getResult()?.currentIndex ?? 0;
11036
+ matchView.current?.navigate(index, () => selectMatch?.(match));
11037
+ };
11038
+ $[21] = selectMatch;
11039
+ $[22] = t14;
11040
+ } else t14 = $[22];
11041
+ const revealMatch = t14;
11042
+ let t15;
11043
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
11044
+ t15 = (text, options_0) => {
11045
+ query.current = {
11046
+ text,
11047
+ options: options_0
11048
+ };
11049
+ };
11050
+ $[23] = t15;
11051
+ } else t15 = $[23];
11052
+ const handleQueryChange = t15;
11053
+ let t16;
11054
+ if ($[24] !== clearFindResult || $[25] !== containerRef || $[26] !== displayMode || $[27] !== findDisplayedMatches || $[28] !== getBodyDoc || $[29] !== getLayout || $[30] !== readDocumentState || $[31] !== resetFindResult || $[32] !== revealMatch || $[33] !== setMatches) {
11055
+ t16 = (searchText_0, options_1) => {
11056
+ const currentDocument_0 = readDocumentState();
11057
+ if (!currentDocument_0 || !searchText_0.trim()) {
10971
11058
  resetFindResult();
10972
11059
  return null;
10973
11060
  }
10974
- const editorState = getEditorState?.();
10975
- let matches;
10976
- if (markupView === "all-markup") matches = findInDocument(currentDocument, searchText, options);
10977
- else {
10978
- if (!editorState) {
10979
- resetFindResult();
10980
- return null;
10981
- }
10982
- matches = findInMarkupView({
10983
- state: editorState,
10984
- markupView,
10985
- searchText,
10986
- options
10987
- }).map(toEditorFindMatch);
11061
+ const bodyDoc = getBodyDoc?.();
11062
+ const effectiveOptions = {
11063
+ ...options_1,
11064
+ includeComments: true,
11065
+ ...displayMode && { displayMode }
11066
+ };
11067
+ const context_0 = getLayout ? { renderedStories: getRenderedSearchStories(getLayout()) } : void 0;
11068
+ const matches = findDisplayedMatches(currentDocument_0, searchText_0, effectiveOptions, context_0);
11069
+ if (matches === null) {
11070
+ query.current = {
11071
+ text: searchText_0,
11072
+ options: options_1
11073
+ };
11074
+ clearFindResult();
11075
+ return null;
10988
11076
  }
10989
- activeSearch.current = {
10990
- searchText,
10991
- options
11077
+ const nextSource = createFindSearchKey({
11078
+ query: searchText_0,
11079
+ options: effectiveOptions,
11080
+ document: currentDocument_0,
11081
+ ...bodyDoc && { bodyVersion: bodyDoc },
11082
+ ...context_0 && { context: context_0 }
11083
+ });
11084
+ const refresh = searchSource.current?.query === nextSource.query;
11085
+ const currentIndex = refresh ? manager.getResult()?.currentIndex ?? 0 : 0;
11086
+ query.current = {
11087
+ text: searchText_0,
11088
+ options: options_1
10992
11089
  };
10993
- const result = manager.setMatches(matches);
10994
- setCurrentResult(result);
10995
- setMatches(matches, 0);
10996
- if (matches.length > 0) revealMatch(matches[0]);
10997
- return result;
11090
+ searchSource.current = {
11091
+ ...nextSource,
11092
+ intentKey: createFindQueryKey(searchText_0, options_1)
11093
+ };
11094
+ const result_0 = manager.setMatches(matches, currentIndex);
11095
+ matchView.current?.destroy();
11096
+ const container = containerRef.current;
11097
+ matchView.current = container ? createFindMatchView({
11098
+ container,
11099
+ document: currentDocument_0,
11100
+ bodyDoc,
11101
+ matches,
11102
+ layout: getLayout?.()
11103
+ }) : null;
11104
+ publish(result_0);
11105
+ setMatches(matches, result_0.currentIndex);
11106
+ matchView.current?.paint(result_0.currentIndex);
11107
+ if (matches.length > 0 && !refresh) revealMatch(matches[0]);
11108
+ return result_0;
10998
11109
  };
10999
- $[12] = getEditorState;
11000
- $[13] = markupView;
11001
- $[14] = readDocumentState;
11002
- $[15] = resetFindResult;
11003
- $[16] = revealMatch;
11004
- $[17] = setMatches;
11005
- $[18] = t6;
11006
- } else t6 = $[18];
11007
- const handleFind = t6;
11008
- const previousMarkupView = useRef(markupView);
11009
- let t7;
11010
- let t8;
11011
- if ($[19] !== handleFind || $[20] !== markupView) {
11012
- t7 = () => {
11013
- if (previousMarkupView.current === markupView) return;
11014
- previousMarkupView.current = markupView;
11015
- const search = activeSearch.current;
11016
- if (search) handleFind(search.searchText, search.options);
11110
+ $[24] = clearFindResult;
11111
+ $[25] = containerRef;
11112
+ $[26] = displayMode;
11113
+ $[27] = findDisplayedMatches;
11114
+ $[28] = getBodyDoc;
11115
+ $[29] = getLayout;
11116
+ $[30] = readDocumentState;
11117
+ $[31] = resetFindResult;
11118
+ $[32] = revealMatch;
11119
+ $[33] = setMatches;
11120
+ $[34] = t16;
11121
+ } else t16 = $[34];
11122
+ const handleFind = t16;
11123
+ let t17;
11124
+ let t18;
11125
+ if ($[35] !== handleFind) {
11126
+ t17 = () => {
11127
+ if (!query.current) return;
11128
+ const timer = setTimeout(() => {
11129
+ const active = query.current;
11130
+ if (active) handleFind(active.text, active.options);
11131
+ }, 200);
11132
+ return () => clearTimeout(timer);
11017
11133
  };
11018
- t8 = [markupView, handleFind];
11019
- $[19] = handleFind;
11020
- $[20] = markupView;
11021
- $[21] = t7;
11022
- $[22] = t8;
11134
+ t18 = [handleFind];
11135
+ $[35] = handleFind;
11136
+ $[36] = t17;
11137
+ $[37] = t18;
11023
11138
  } else {
11024
- t7 = $[21];
11025
- t8 = $[22];
11139
+ t17 = $[36];
11140
+ t18 = $[37];
11026
11141
  }
11027
- useEffect(t7, t8);
11028
- let t9;
11029
- if ($[23] !== goToMatch || $[24] !== revealMatch) {
11030
- t9 = () => {
11142
+ useEffect(t17, t18);
11143
+ const previousDisplayMode = useRef(displayMode);
11144
+ let t19;
11145
+ let t20;
11146
+ if ($[38] !== displayMode || $[39] !== handleFind) {
11147
+ t19 = () => {
11148
+ if (previousDisplayMode.current === displayMode) return;
11149
+ previousDisplayMode.current = displayMode;
11150
+ const active_0 = query.current;
11151
+ if (active_0) handleFind(active_0.text, active_0.options);
11152
+ };
11153
+ t20 = [displayMode, handleFind];
11154
+ $[38] = displayMode;
11155
+ $[39] = handleFind;
11156
+ $[40] = t19;
11157
+ $[41] = t20;
11158
+ } else {
11159
+ t19 = $[40];
11160
+ t20 = $[41];
11161
+ }
11162
+ useEffect(t19, t20);
11163
+ let t21;
11164
+ if ($[42] !== goToMatch || $[43] !== revealMatch) {
11165
+ t21 = () => {
11031
11166
  const stepped = manager.navigate("next");
11032
11167
  if (!stepped) return null;
11033
- setCurrentResult(manager.getResult());
11168
+ publish(manager.getResult());
11034
11169
  goToMatch(stepped.index);
11035
11170
  revealMatch(stepped.match);
11036
11171
  return stepped.match;
11037
11172
  };
11038
- $[23] = goToMatch;
11039
- $[24] = revealMatch;
11040
- $[25] = t9;
11041
- } else t9 = $[25];
11042
- const handleFindNext = t9;
11043
- let t10;
11044
- if ($[26] !== goToMatch || $[27] !== revealMatch) {
11045
- t10 = () => {
11173
+ $[42] = goToMatch;
11174
+ $[43] = revealMatch;
11175
+ $[44] = t21;
11176
+ } else t21 = $[44];
11177
+ const handleFindNext = t21;
11178
+ let t22;
11179
+ if ($[45] !== goToMatch || $[46] !== revealMatch) {
11180
+ t22 = () => {
11046
11181
  const stepped_0 = manager.navigate("previous");
11047
11182
  if (!stepped_0) return null;
11048
- setCurrentResult(manager.getResult());
11183
+ publish(manager.getResult());
11049
11184
  goToMatch(stepped_0.index);
11050
11185
  revealMatch(stepped_0.match);
11051
11186
  return stepped_0.match;
11052
11187
  };
11053
- $[26] = goToMatch;
11054
- $[27] = revealMatch;
11055
- $[28] = t10;
11056
- } else t10 = $[28];
11057
- const handleFindPrevious = t10;
11058
- let t11;
11059
- if ($[29] !== handleDocumentChange || $[30] !== readDocumentState) {
11060
- t11 = (replaceText) => {
11061
- const currentDocument_0 = readDocumentState();
11062
- if (!currentDocument_0) return false;
11063
- const newDoc = manager.replaceCurrent(currentDocument_0, replaceText);
11188
+ $[45] = goToMatch;
11189
+ $[46] = revealMatch;
11190
+ $[47] = t22;
11191
+ } else t22 = $[47];
11192
+ const handleFindPrevious = t22;
11193
+ let t23;
11194
+ if ($[48] !== displayMode || $[49] !== getBodyDoc || $[50] !== getLayout || $[51] !== handleFind) {
11195
+ t23 = (currentDocument_1) => {
11196
+ const active_1 = query.current;
11197
+ if (!active_1) return false;
11198
+ const bodyDoc_0 = getBodyDoc?.();
11199
+ const context_1 = getLayout ? { renderedStories: getRenderedSearchStories(getLayout()) } : void 0;
11200
+ const currentSource = createFindSearchKey({
11201
+ query: active_1.text,
11202
+ options: {
11203
+ ...active_1.options,
11204
+ includeComments: true,
11205
+ ...displayMode && { displayMode }
11206
+ },
11207
+ document: currentDocument_1,
11208
+ ...bodyDoc_0 && { bodyVersion: bodyDoc_0 },
11209
+ ...context_1 && { context: context_1 }
11210
+ });
11211
+ bb215: switch (replacementGate.current.status) {
11212
+ case "awaiting-document":
11213
+ if (sameFindBodyVersion(replacementGate.current.source, currentSource)) return true;
11214
+ replacementGate.current = { status: "ready" };
11215
+ break bb215;
11216
+ case "ready": break bb215;
11217
+ default: return replacementGate.current;
11218
+ }
11219
+ if (sameFindSearchKey(searchSource.current, currentSource)) return false;
11220
+ handleFind(active_1.text, active_1.options);
11221
+ return true;
11222
+ };
11223
+ $[48] = displayMode;
11224
+ $[49] = getBodyDoc;
11225
+ $[50] = getLayout;
11226
+ $[51] = handleFind;
11227
+ $[52] = t23;
11228
+ } else t23 = $[52];
11229
+ const refreshChangedSource = t23;
11230
+ let t24;
11231
+ if ($[53] !== clearFindResult || $[54] !== handleDocumentChange) {
11232
+ t24 = (nextDocument) => {
11233
+ const source_0 = searchSource.current;
11234
+ if (!source_0) panic("Replacement accepted without a search key");
11235
+ replacementGate.current = {
11236
+ status: "awaiting-document",
11237
+ source: source_0
11238
+ };
11239
+ clearFindResult();
11240
+ handleDocumentChange(nextDocument);
11241
+ };
11242
+ $[53] = clearFindResult;
11243
+ $[54] = handleDocumentChange;
11244
+ $[55] = t24;
11245
+ } else t24 = $[55];
11246
+ const acceptReplacement = t24;
11247
+ let t25;
11248
+ if ($[56] !== acceptReplacement || $[57] !== readDocumentState || $[58] !== refreshChangedSource) {
11249
+ t25 = (replaceText) => {
11250
+ const currentDocument_2 = readDocumentState();
11251
+ if (!currentDocument_2) return false;
11252
+ if (refreshChangedSource(currentDocument_2)) return false;
11253
+ const result_1 = manager.getResult();
11254
+ const match_0 = result_1?.matches.at(result_1.currentIndex);
11255
+ if (!match_0 || replaceEligibility(match_0).status === "blocked") return false;
11256
+ if (match_0.text === replaceText) return true;
11257
+ const newDoc = manager.replaceCurrent(currentDocument_2, replaceText);
11064
11258
  if (!newDoc) return false;
11065
- handleDocumentChange(newDoc);
11259
+ acceptReplacement(newDoc);
11066
11260
  return true;
11067
11261
  };
11068
- $[29] = handleDocumentChange;
11069
- $[30] = readDocumentState;
11070
- $[31] = t11;
11071
- } else t11 = $[31];
11072
- const handleReplace = t11;
11073
- let t12;
11074
- if ($[32] !== handleDocumentChange || $[33] !== readDocumentState || $[34] !== resetFindResult) {
11075
- t12 = (searchText_0, replaceText_0, options_0) => {
11076
- const currentDocument_1 = readDocumentState();
11077
- if (!currentDocument_1 || !searchText_0.trim()) return 0;
11078
- const matches_0 = findInDocument(currentDocument_1, searchText_0, options_0);
11079
- const outcome = manager.replaceAll(currentDocument_1, matches_0, replaceText_0);
11080
- if (!outcome) return 0;
11081
- handleDocumentChange(outcome.document);
11082
- resetFindResult();
11083
- return outcome.replacedCount;
11262
+ $[56] = acceptReplacement;
11263
+ $[57] = readDocumentState;
11264
+ $[58] = refreshChangedSource;
11265
+ $[59] = t25;
11266
+ } else t25 = $[59];
11267
+ const handleReplace = t25;
11268
+ let t26;
11269
+ if ($[60] !== acceptReplacement || $[61] !== displayMode || $[62] !== findDisplayedMatches || $[63] !== getLayout || $[64] !== readDocumentState || $[65] !== refreshChangedSource) {
11270
+ t26 = (searchText_1, replaceText_0, options_2) => {
11271
+ const currentDocument_3 = readDocumentState();
11272
+ if (!currentDocument_3 || !searchText_1.trim()) return {
11273
+ replacedCount: 0,
11274
+ skippedCount: 0
11275
+ };
11276
+ const previousCount = manager.getResult()?.matches.length ?? 0;
11277
+ handleQueryChange(searchText_1, options_2);
11278
+ if (refreshChangedSource(currentDocument_3)) return {
11279
+ replacedCount: 0,
11280
+ skippedCount: previousCount
11281
+ };
11282
+ const matches_0 = findDisplayedMatches(currentDocument_3, searchText_1, {
11283
+ ...options_2,
11284
+ includeComments: true,
11285
+ ...displayMode && { displayMode }
11286
+ }, getLayout ? { renderedStories: getRenderedSearchStories(getLayout()) } : void 0);
11287
+ if (matches_0 === null) return {
11288
+ replacedCount: 0,
11289
+ skippedCount: previousCount
11290
+ };
11291
+ const mutationMatches = matches_0.filter((match_1) => replaceEligibility(match_1).status === "blocked" || match_1.text !== replaceText_0);
11292
+ const unchangedCount = matches_0.length - mutationMatches.length;
11293
+ if (mutationMatches.length === 0) return {
11294
+ replacedCount: unchangedCount,
11295
+ skippedCount: 0
11296
+ };
11297
+ const outcome = manager.replaceAll(currentDocument_3, mutationMatches, replaceText_0);
11298
+ if (!outcome) return {
11299
+ replacedCount: 0,
11300
+ skippedCount: 0
11301
+ };
11302
+ if (outcome.replacedCount > 0) acceptReplacement(outcome.document);
11303
+ return {
11304
+ replacedCount: outcome.replacedCount + unchangedCount,
11305
+ skippedCount: outcome.skippedCount
11306
+ };
11084
11307
  };
11085
- $[32] = handleDocumentChange;
11086
- $[33] = readDocumentState;
11087
- $[34] = resetFindResult;
11088
- $[35] = t12;
11089
- } else t12 = $[35];
11090
- const handleReplaceAll = t12;
11091
- let t13;
11092
- if ($[36] !== onReadonlyEditAttempt || $[37] !== replacementRefusal) {
11093
- t13 = () => {
11308
+ $[60] = acceptReplacement;
11309
+ $[61] = displayMode;
11310
+ $[62] = findDisplayedMatches;
11311
+ $[63] = getLayout;
11312
+ $[64] = readDocumentState;
11313
+ $[65] = refreshChangedSource;
11314
+ $[66] = t26;
11315
+ } else t26 = $[66];
11316
+ const handleReplaceAll = t26;
11317
+ let t27;
11318
+ if ($[67] !== onReadonlyEditAttempt || $[68] !== replacementRefusal) {
11319
+ t27 = () => {
11094
11320
  if (replacementRefusal) onReadonlyEditAttempt?.(replacementRefusal);
11095
11321
  return false;
11096
11322
  };
11097
- $[36] = onReadonlyEditAttempt;
11098
- $[37] = replacementRefusal;
11099
- $[38] = t13;
11100
- } else t13 = $[38];
11101
- const refuseReplace = t13;
11102
- let t14;
11103
- if ($[39] !== refuseReplace) {
11104
- t14 = () => {
11323
+ $[67] = onReadonlyEditAttempt;
11324
+ $[68] = replacementRefusal;
11325
+ $[69] = t27;
11326
+ } else t27 = $[69];
11327
+ const refuseReplace = t27;
11328
+ let t28;
11329
+ if ($[70] !== refuseReplace) {
11330
+ t28 = () => {
11105
11331
  refuseReplace();
11106
- return 0;
11332
+ return {
11333
+ replacedCount: 0,
11334
+ skippedCount: manager.getResult()?.totalCount ?? 0
11335
+ };
11107
11336
  };
11108
- $[39] = refuseReplace;
11109
- $[40] = t14;
11110
- } else t14 = $[40];
11111
- const refuseReplaceAll = t14;
11112
- const t15 = replacementRefusal ? refuseReplace : handleReplace;
11113
- const t16 = replacementRefusal ? refuseReplaceAll : handleReplaceAll;
11114
- let t17;
11115
- if ($[41] !== currentResult || $[42] !== handleFind || $[43] !== handleFindNext || $[44] !== handleFindPrevious || $[45] !== resetFindResult || $[46] !== t15 || $[47] !== t16) {
11116
- t17 = {
11117
- currentResult,
11337
+ $[70] = refuseReplace;
11338
+ $[71] = t28;
11339
+ } else t28 = $[71];
11340
+ const refuseReplaceAll = t28;
11341
+ const t29 = publishedResult.status === "ready" ? publishedResult.result : null;
11342
+ let t30;
11343
+ if ($[72] !== publishedResult.queryKey || $[73] !== publishedResult.result || $[74] !== publishedResult.status) {
11344
+ t30 = publishedResult.status === "ready" ? {
11345
+ queryKey: publishedResult.queryKey,
11346
+ result: publishedResult.result
11347
+ } : null;
11348
+ $[72] = publishedResult.queryKey;
11349
+ $[73] = publishedResult.result;
11350
+ $[74] = publishedResult.status;
11351
+ $[75] = t30;
11352
+ } else t30 = $[75];
11353
+ const t31 = replacementRefusal ? refuseReplace : handleReplace;
11354
+ const t32 = replacementRefusal ? refuseReplaceAll : handleReplaceAll;
11355
+ let t33;
11356
+ if ($[76] === Symbol.for("react.memo_cache_sentinel")) {
11357
+ t33 = () => manager.getResult();
11358
+ $[76] = t33;
11359
+ } else t33 = $[76];
11360
+ let t34;
11361
+ if ($[77] !== handleFind) {
11362
+ t34 = () => {
11363
+ const active_2 = query.current;
11364
+ if (active_2) handleFind(active_2.text, active_2.options);
11365
+ };
11366
+ $[77] = handleFind;
11367
+ $[78] = t34;
11368
+ } else t34 = $[78];
11369
+ let t35;
11370
+ if ($[79] !== handleFind || $[80] !== handleFindNext || $[81] !== handleFindPrevious || $[82] !== resetFindResult || $[83] !== t29 || $[84] !== t30 || $[85] !== t31 || $[86] !== t32 || $[87] !== t34) {
11371
+ t35 = {
11372
+ currentResult: t29,
11373
+ currentSearch: t30,
11118
11374
  resetFindResult,
11119
11375
  handleFind,
11376
+ handleQueryChange,
11120
11377
  handleFindNext,
11121
11378
  handleFindPrevious,
11122
- handleReplace: t15,
11123
- handleReplaceAll: t16
11379
+ handleReplace: t31,
11380
+ handleReplaceAll: t32,
11381
+ getFindResult: t33,
11382
+ refreshFind: t34
11124
11383
  };
11125
- $[41] = currentResult;
11126
- $[42] = handleFind;
11127
- $[43] = handleFindNext;
11128
- $[44] = handleFindPrevious;
11129
- $[45] = resetFindResult;
11130
- $[46] = t15;
11131
- $[47] = t16;
11132
- $[48] = t17;
11133
- } else t17 = $[48];
11134
- return t17;
11384
+ $[79] = handleFind;
11385
+ $[80] = handleFindNext;
11386
+ $[81] = handleFindPrevious;
11387
+ $[82] = resetFindResult;
11388
+ $[83] = t29;
11389
+ $[84] = t30;
11390
+ $[85] = t31;
11391
+ $[86] = t32;
11392
+ $[87] = t34;
11393
+ $[88] = t35;
11394
+ } else t35 = $[88];
11395
+ return t35;
11135
11396
  }
11136
11397
  //#endregion
11137
11398
  //#region src/components/hooks/useHeaderFooterEditor.ts
@@ -13925,7 +14186,7 @@ function _temp(id_4) {
13925
14186
  */
13926
14187
  /** No headings to track while the outline is not shown. */
13927
14188
  const NO_HEADINGS = [];
13928
- const CommentsSidebar = lazy(() => import("./CommentsSidebar-D7eTgHpL.js").then((m) => ({ default: m.CommentsSidebar })));
14189
+ const CommentsSidebar = lazy(() => import("./CommentsSidebar-6K9GbqAA.js").then((m) => ({ default: m.CommentsSidebar })));
13929
14190
  const TextContextMenu = lazy(() => import("./TextContextMenu-DZ3AUFKh.js").then((m) => ({ default: m.TextContextMenu })));
13930
14191
  const loadAttemptSelectiveSave = async () => {
13931
14192
  const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
@@ -14027,7 +14288,7 @@ const createPagedEditorBinding = () => {
14027
14288
  /**
14028
14289
  * DocxEditor - Complete DOCX editor component
14029
14290
  */
14030
- const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, document: initialDocument, onSave, author = "User", onChange, onSelectionChange, onSelectionTextChange, onError, onFontsLoaded: onFontsLoadedCallback, fontFamilies, fonts, theme, showToolbar = true, showZoomControl = true, showReviewControls = true, showHeaderFooterEditing = true, pageRenderer, showMarginGuides = false, marginGuideColor, showRuler: showRulerProp = false, rulerUnit = "inch", initialZoom = 1, enableWheelZoom = true, keyboardShortcuts = DEFAULT_KEYBOARD_SHORTCUT_SCOPE, hostShortcuts: hostShortcutsProp, readOnly: readOnlyProp = false, reviewDisplayMode, showCommentHighlights = true, autoOpenReviewSidebar = true, components, toolbarExtra, className = "", style, placeholder, loadingIndicator, preserveDocumentWhileLoading = false, initialScrollTop, onScrollTopChange, showOutline: showOutlineProp = true, outlineDepth: outlineDepthProp, onOutlineDepthChange, onPrint, onInsertImage, onInsertTable, showTableInsert = true, onInsertPageBreak, onInsertTOC, onCopy, onCut, onPaste, mode: modeProp, onModeChange, onReadonlyEditAttempt, onCompatibilityChange, onEditorViewReady, onAnonymizationMatchesChange, onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq, showTemplateDirectives = false, onSlashMenuChange, onSlashMenuKeyAction, customContextMenuItems, onCustomContextAction, comments: commentsProp, onCommentsChange, collaboration, plugins, featureFlags, experimentalSession, onSelectiveSaveTripwire }, ref) {
14291
+ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, document: initialDocument, onSave, author = "User", onChange, onFindResultChange, onSelectionChange, onSelectionTextChange, onError, onFontsLoaded: onFontsLoadedCallback, fontFamilies, fonts, theme, showToolbar = true, showZoomControl = true, showReviewControls = true, showHeaderFooterEditing = true, pageRenderer, showMarginGuides = false, marginGuideColor, showRuler: showRulerProp = false, rulerUnit = "inch", initialZoom = 1, enableWheelZoom = true, keyboardShortcuts = DEFAULT_KEYBOARD_SHORTCUT_SCOPE, hostShortcuts: hostShortcutsProp, readOnly: readOnlyProp = false, reviewDisplayMode, showCommentHighlights = true, autoOpenReviewSidebar = true, components, toolbarExtra, className = "", style, placeholder, loadingIndicator, preserveDocumentWhileLoading = false, initialScrollTop, onScrollTopChange, showOutline: showOutlineProp = true, outlineDepth: outlineDepthProp, onOutlineDepthChange, onPrint, onInsertImage, onInsertTable, showTableInsert = true, onInsertPageBreak, onInsertTOC, onCopy, onCut, onPaste, mode: modeProp, onModeChange, onReadonlyEditAttempt, onCompatibilityChange, onEditorViewReady, onAnonymizationMatchesChange, onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq, showTemplateDirectives = false, onSlashMenuChange, onSlashMenuKeyAction, customContextMenuItems, onCustomContextAction, comments: commentsProp, onCommentsChange, collaboration, plugins, featureFlags, experimentalSession, onSelectiveSaveTripwire }, ref) {
14031
14292
  const pagedEditorRef = useRef(null);
14032
14293
  const [pagedEditorBinding] = useState(createPagedEditorBinding);
14033
14294
  const scrollContainerRef = useRef(null);
@@ -14786,46 +15047,86 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14786
15047
  onCommentsChange
14787
15048
  ]);
14788
15049
  const selectFindMatch = useCallback((match) => {
14789
- const editor_1 = pagedEditorRef.current;
14790
- const view_8 = editor_1?.getView();
14791
- if (!editor_1 || !view_8) return false;
14792
- const range = match.authoredRange ?? resolveFindMatchRange(view_8.state.doc, match);
14793
- if (!range) return false;
14794
- editor_1.setSelection(range.from, range.to);
14795
- requestAnimationFrame(() => {
14796
- editor_1.scrollToPosition(range.from);
14797
- });
14798
- return true;
15050
+ if (match.commentId !== void 0) {
15051
+ setVisibleCommentAuthors(null);
15052
+ setShowCommentsSidebar(true);
15053
+ setActiveCommentId(commentsRef.current.find(({ id }) => id === match.commentId)?.parentId ?? match.commentId);
15054
+ return true;
15055
+ }
15056
+ return false;
15057
+ }, [
15058
+ setActiveCommentId,
15059
+ setVisibleCommentAuthors,
15060
+ setShowCommentsSidebar,
15061
+ commentsRef
15062
+ ]);
15063
+ const getFindEditorState = useCallback(() => {
15064
+ pagedEditorRef.current?.ensureView({ focus: false });
15065
+ return pagedEditorRef.current?.getView()?.state ?? null;
14799
15066
  }, []);
15067
+ const getFindBodyDoc = useCallback(() => getFindEditorState()?.doc, [getFindEditorState]);
15068
+ const getFindLayout = useCallback(() => pagedEditorRef.current?.getLayout() ?? null, []);
14800
15069
  const notifyReadonlyEditAttempt = useCallback(() => {
14801
15070
  if (readOnlyReason) onReadonlyEditAttempt?.(readOnlyReason);
14802
15071
  }, [readOnlyReason, onReadonlyEditAttempt]);
14803
- const { currentResult: currentFindResult, resetFindResult, handleFind, handleFindNext, handleFindPrevious, handleReplace, handleReplaceAll } = useFindReplace({
15072
+ const { currentSearch: currentFindSearch, resetFindResult, handleFind, handleQueryChange, handleFindNext, handleFindPrevious, handleReplace, handleReplaceAll, getFindResult, refreshFind } = useFindReplace({
15073
+ documentState: history.state,
14804
15074
  getDocumentState: buildCurrentDocument,
14805
- getEditorState: () => pagedEditorRef.current?.getView()?.state ?? null,
14806
- markupView: displayMode,
15075
+ getEditorState: getFindEditorState,
14807
15076
  containerRef,
14808
15077
  handleDocumentChange,
14809
15078
  findReplace,
14810
15079
  selectMatch: selectFindMatch,
15080
+ getBodyDoc: getFindBodyDoc,
15081
+ getLayout: getFindLayout,
15082
+ displayMode,
15083
+ onFindResultChange,
14811
15084
  readOnlyReason,
14812
15085
  onReadonlyEditAttempt
14813
15086
  });
15087
+ const refreshFindRef = useRef(refreshFind);
15088
+ useLayoutEffect(() => {
15089
+ refreshFindRef.current = refreshFind;
15090
+ }, [refreshFind]);
15091
+ useEffect(() => {
15092
+ if (bodyViewEpoch === 0) return;
15093
+ const editor_1 = pagedEditorRef.current?.getEditor();
15094
+ if (!editor_1) return;
15095
+ let timer_1 = null;
15096
+ const schedule = () => {
15097
+ if (timer_1 !== null) clearTimeout(timer_1);
15098
+ timer_1 = setTimeout(() => refreshFindRef.current(), 200);
15099
+ };
15100
+ const unsubscribe = editor_1.on("docChange", schedule);
15101
+ const unsubscribeLayout = editor_1.on("layoutComplete", schedule);
15102
+ return () => {
15103
+ unsubscribe();
15104
+ unsubscribeLayout();
15105
+ if (timer_1 !== null) clearTimeout(timer_1);
15106
+ };
15107
+ }, [bodyViewEpoch]);
15108
+ useEffect(() => {
15109
+ const snapshot = comments;
15110
+ const timer_2 = setTimeout(() => {
15111
+ if (commentsRef.current === snapshot) refreshFindRef.current();
15112
+ }, 200);
15113
+ return () => clearTimeout(timer_2);
15114
+ }, [comments, commentsRef]);
14814
15115
  useLayoutEffect(() => {
14815
15116
  resetFindResultRef.current = resetFindResult;
14816
15117
  }, [resetFindResult]);
14817
15118
  const handleSelectionChange = useCallback((selectionState) => {
14818
- const view_9 = getActiveEditorView();
14819
- if (view_9) {
14820
- const { from, to } = view_9.state.selection;
15119
+ const view_8 = getActiveEditorView();
15120
+ if (view_8) {
15121
+ const { from, to } = view_8.state.selection;
14821
15122
  lastSelectionRef.current = {
14822
15123
  from,
14823
15124
  to
14824
15125
  };
14825
15126
  }
14826
15127
  let pmTableCtx = null;
14827
- if (view_9) {
14828
- pmTableCtx = getTableContext(view_9.state);
15128
+ if (view_8) {
15129
+ pmTableCtx = getTableContext(view_8.state);
14829
15130
  if (!pmTableCtx.isInTable) pmTableCtx = null;
14830
15131
  }
14831
15132
  if (pmTableCtx?.cellBorderColor) {
@@ -14837,8 +15138,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14837
15138
  color: { rgb }
14838
15139
  };
14839
15140
  }
14840
- const pmImageCtx = view_9 ? detectImageContext(view_9.state) : null;
14841
- const trackedChange = view_9 ? detectActiveTrackedChange(view_9.state) : null;
15141
+ const pmImageCtx = view_8 ? detectImageContext(view_8.state) : null;
15142
+ const trackedChange = view_8 ? detectActiveTrackedChange(view_8.state) : null;
14842
15143
  if (!selectionState) {
14843
15144
  setFloatingCommentBtn(null);
14844
15145
  setState((prev_1) => {
@@ -14901,10 +15202,10 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14901
15202
  activeTrackedChange: activeTrackedChange_0
14902
15203
  };
14903
15204
  });
14904
- if (view_9 && selectionState.hasSelection && !isAddingComment && !readOnly) {
15205
+ if (view_8 && selectionState.hasSelection && !isAddingComment && !readOnly) {
14905
15206
  const container = scrollContainerRef.current;
14906
15207
  const parentEl = editorContentRef.current;
14907
- const { from: selFrom } = view_9.state.selection;
15208
+ const { from: selFrom } = view_8.state.selection;
14908
15209
  const top = findSelectionYPosition(container, parentEl, selFrom);
14909
15210
  if (top !== null && container && parentEl) {
14910
15211
  const pagesEl = container.querySelector(".paged-editor__pages");
@@ -14912,7 +15213,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14912
15213
  const parentRect = parentEl.getBoundingClientRect();
14913
15214
  const rawLeft = pageEl ? pageEl.getBoundingClientRect().right - parentRect.left + 12 : parentRect.width / 2 + 408;
14914
15215
  const left = Math.max(16, Math.min(rawLeft, parentRect.width - 16));
14915
- const { from: from_0, to: to_0 } = view_9.state.selection;
15216
+ const { from: from_0, to: to_0 } = view_8.state.selection;
14916
15217
  if (from_0 !== to_0) setFloatingCommentBtn({
14917
15218
  top,
14918
15219
  left,
@@ -15075,98 +15376,98 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15075
15376
  refuseCanonicalModelEdit
15076
15377
  ]);
15077
15378
  const handleTableAction = useCallback((action_0) => {
15078
- const view_10 = getActiveEditorView();
15079
- if (!view_10) return;
15379
+ const view_9 = getActiveEditorView();
15380
+ if (!view_9) return;
15080
15381
  switch (action_0) {
15081
15382
  case "addRowAbove":
15082
- addRowAbove(view_10.state, view_10.dispatch);
15383
+ addRowAbove(view_9.state, view_9.dispatch);
15083
15384
  break;
15084
15385
  case "addRowBelow":
15085
- addRowBelow(view_10.state, view_10.dispatch);
15386
+ addRowBelow(view_9.state, view_9.dispatch);
15086
15387
  break;
15087
15388
  case "addColumnLeft":
15088
- addColumnLeft(view_10.state, view_10.dispatch);
15389
+ addColumnLeft(view_9.state, view_9.dispatch);
15089
15390
  break;
15090
15391
  case "addColumnRight":
15091
- addColumnRight(view_10.state, view_10.dispatch);
15392
+ addColumnRight(view_9.state, view_9.dispatch);
15092
15393
  break;
15093
15394
  case "deleteRow":
15094
- deleteRow(view_10.state, view_10.dispatch);
15395
+ deleteRow(view_9.state, view_9.dispatch);
15095
15396
  break;
15096
15397
  case "deleteColumn":
15097
- deleteColumn(view_10.state, view_10.dispatch);
15398
+ deleteColumn(view_9.state, view_9.dispatch);
15098
15399
  break;
15099
15400
  case "deleteTable":
15100
- deleteTable(view_10.state, view_10.dispatch);
15401
+ deleteTable(view_9.state, view_9.dispatch);
15101
15402
  break;
15102
15403
  case "selectTable":
15103
- selectTable(view_10.state, view_10.dispatch);
15404
+ selectTable(view_9.state, view_9.dispatch);
15104
15405
  break;
15105
15406
  case "selectRow":
15106
- selectRow(view_10.state, view_10.dispatch);
15407
+ selectRow(view_9.state, view_9.dispatch);
15107
15408
  break;
15108
15409
  case "selectColumn":
15109
- selectColumn(view_10.state, view_10.dispatch);
15410
+ selectColumn(view_9.state, view_9.dispatch);
15110
15411
  break;
15111
15412
  case "mergeCells":
15112
- mergeCells(view_10.state, view_10.dispatch);
15413
+ mergeCells(view_9.state, view_9.dispatch);
15113
15414
  break;
15114
15415
  case "splitCell":
15115
- splitCell(view_10.state, view_10.dispatch);
15416
+ splitCell(view_9.state, view_9.dispatch);
15116
15417
  break;
15117
15418
  case "borderAll":
15118
- setAllTableBorders(view_10.state, view_10.dispatch, borderSpecRef.current);
15419
+ setAllTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
15119
15420
  break;
15120
15421
  case "borderOutside":
15121
- setOutsideTableBorders(view_10.state, view_10.dispatch, borderSpecRef.current);
15422
+ setOutsideTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
15122
15423
  break;
15123
15424
  case "borderInside":
15124
- setInsideTableBorders(view_10.state, view_10.dispatch, borderSpecRef.current);
15425
+ setInsideTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
15125
15426
  break;
15126
15427
  case "borderNone":
15127
- removeTableBorders(view_10.state, view_10.dispatch);
15428
+ removeTableBorders(view_9.state, view_9.dispatch);
15128
15429
  break;
15129
15430
  case "borderTop":
15130
- setCellBorder("top", borderSpecRef.current, true)(view_10.state, view_10.dispatch);
15431
+ setCellBorder("top", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
15131
15432
  break;
15132
15433
  case "borderBottom":
15133
- setCellBorder("bottom", borderSpecRef.current, true)(view_10.state, view_10.dispatch);
15434
+ setCellBorder("bottom", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
15134
15435
  break;
15135
15436
  case "borderLeft":
15136
- setCellBorder("left", borderSpecRef.current, true)(view_10.state, view_10.dispatch);
15437
+ setCellBorder("left", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
15137
15438
  break;
15138
15439
  case "borderRight":
15139
- setCellBorder("right", borderSpecRef.current, true)(view_10.state, view_10.dispatch);
15440
+ setCellBorder("right", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
15140
15441
  break;
15141
- default: if (typeof action_0 === "object") if (action_0.type === "cellFillColor") setCellFillColor(action_0.color)(view_10.state, view_10.dispatch);
15442
+ default: if (typeof action_0 === "object") if (action_0.type === "cellFillColor") setCellFillColor(action_0.color)(view_9.state, view_9.dispatch);
15142
15443
  else if (action_0.type === "borderColor") {
15143
15444
  const rgb_0 = action_0.color.replace(/^#/u, "");
15144
15445
  borderSpecRef.current = {
15145
15446
  ...borderSpecRef.current,
15146
15447
  color: { rgb: rgb_0 }
15147
15448
  };
15148
- setTableBorderColor(action_0.color)(view_10.state, view_10.dispatch);
15449
+ setTableBorderColor(action_0.color)(view_9.state, view_9.dispatch);
15149
15450
  } else if (action_0.type === "borderWidth") {
15150
15451
  borderSpecRef.current = {
15151
15452
  ...borderSpecRef.current,
15152
15453
  size: action_0.size
15153
15454
  };
15154
- setTableBorderWidth(action_0.size)(view_10.state, view_10.dispatch);
15455
+ setTableBorderWidth(action_0.size)(view_9.state, view_9.dispatch);
15155
15456
  } else if (action_0.type === "cellBorder") setCellBorder(action_0.side, {
15156
15457
  style: action_0.style,
15157
15458
  size: action_0.size,
15158
15459
  color: { rgb: action_0.color.replace(/^#/u, "") }
15159
- })(view_10.state, view_10.dispatch);
15160
- else if (action_0.type === "cellVerticalAlign") setCellVerticalAlign(action_0.align)(view_10.state, view_10.dispatch);
15161
- else if (action_0.type === "cellMargins") setCellMargins(action_0.margins)(view_10.state, view_10.dispatch);
15162
- else if (action_0.type === "cellTextDirection") setCellTextDirection(action_0.direction)(view_10.state, view_10.dispatch);
15163
- else if (action_0.type === "toggleNoWrap") toggleNoWrap()(view_10.state, view_10.dispatch);
15164
- else if (action_0.type === "rowHeight") setRowHeight(action_0.height, action_0.rule)(view_10.state, view_10.dispatch);
15165
- else if (action_0.type === "toggleHeaderRow") toggleHeaderRow()(view_10.state, view_10.dispatch);
15166
- else if (action_0.type === "distributeColumns") distributeColumns()(view_10.state, view_10.dispatch);
15167
- else if (action_0.type === "autoFitContents") autoFitContents()(view_10.state, view_10.dispatch);
15460
+ })(view_9.state, view_9.dispatch);
15461
+ else if (action_0.type === "cellVerticalAlign") setCellVerticalAlign(action_0.align)(view_9.state, view_9.dispatch);
15462
+ else if (action_0.type === "cellMargins") setCellMargins(action_0.margins)(view_9.state, view_9.dispatch);
15463
+ else if (action_0.type === "cellTextDirection") setCellTextDirection(action_0.direction)(view_9.state, view_9.dispatch);
15464
+ else if (action_0.type === "toggleNoWrap") toggleNoWrap()(view_9.state, view_9.dispatch);
15465
+ else if (action_0.type === "rowHeight") setRowHeight(action_0.height, action_0.rule)(view_9.state, view_9.dispatch);
15466
+ else if (action_0.type === "toggleHeaderRow") toggleHeaderRow()(view_9.state, view_9.dispatch);
15467
+ else if (action_0.type === "distributeColumns") distributeColumns()(view_9.state, view_9.dispatch);
15468
+ else if (action_0.type === "autoFitContents") autoFitContents()(view_9.state, view_9.dispatch);
15168
15469
  else if (action_0.type === "openTableProperties") setTablePropsOpen(true);
15169
- else if (action_0.type === "tableProperties") setTableProperties(action_0.props)(view_10.state, view_10.dispatch);
15470
+ else if (action_0.type === "tableProperties") setTableProperties(action_0.props)(view_9.state, view_9.dispatch);
15170
15471
  else {
15171
15472
  let preset = getBuiltinTableStyle(action_0.styleId);
15172
15473
  const currentDocForTable = historyStateRef.current;
@@ -15237,7 +15538,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15237
15538
  if (preset.tableBorders) styleArg.tableBorders = preset.tableBorders;
15238
15539
  if (preset.conditionals) styleArg.conditionals = preset.conditionals;
15239
15540
  if (preset.look) styleArg.look = preset.look;
15240
- applyTableStyle(styleArg)(view_10.state, view_10.dispatch);
15541
+ applyTableStyle(styleArg)(view_9.state, view_9.dispatch);
15241
15542
  }
15242
15543
  }
15243
15544
  else tableSelection.handleAction(action_0);
@@ -15258,86 +15559,86 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15258
15559
  });
15259
15560
  }, [openContextMenu]);
15260
15561
  const handleFormat = useCallback((action_1) => {
15261
- const view_11 = getActiveEditorView();
15262
- if (!view_11) return;
15263
- view_11.focus();
15264
- const isBodyEditor = view_11 === pagedEditorRef.current?.getView();
15265
- const { from: from_1, to: to_1 } = view_11.state.selection;
15562
+ const view_10 = getActiveEditorView();
15563
+ if (!view_10) return;
15564
+ view_10.focus();
15565
+ const isBodyEditor = view_10 === pagedEditorRef.current?.getView();
15566
+ const { from: from_1, to: to_1 } = view_10.state.selection;
15266
15567
  const savedSelection = lastSelectionRef.current;
15267
15568
  if (isBodyEditor && savedSelection && (from_1 !== savedSelection.from || to_1 !== savedSelection.to)) try {
15268
- const tr = view_11.state.tr.setSelection(TextSelection.create(view_11.state.doc, savedSelection.from, savedSelection.to));
15269
- view_11.dispatch(tr);
15569
+ const tr = view_10.state.tr.setSelection(TextSelection.create(view_10.state.doc, savedSelection.from, savedSelection.to));
15570
+ view_10.dispatch(tr);
15270
15571
  } catch {}
15271
15572
  if (action_1 === "bold") {
15272
- executeEditorCommand(view_11, toggleBold);
15573
+ executeEditorCommand(view_10, toggleBold);
15273
15574
  return;
15274
15575
  }
15275
15576
  if (action_1 === "italic") {
15276
- executeEditorCommand(view_11, toggleItalic);
15577
+ executeEditorCommand(view_10, toggleItalic);
15277
15578
  return;
15278
15579
  }
15279
15580
  if (action_1 === "underline") {
15280
- executeEditorCommand(view_11, toggleUnderline);
15581
+ executeEditorCommand(view_10, toggleUnderline);
15281
15582
  return;
15282
15583
  }
15283
15584
  if (action_1 === "strikethrough") {
15284
- executeEditorCommand(view_11, toggleStrike);
15585
+ executeEditorCommand(view_10, toggleStrike);
15285
15586
  return;
15286
15587
  }
15287
15588
  if (action_1 === "superscript") {
15288
- executeEditorCommand(view_11, toggleSuperscript);
15589
+ executeEditorCommand(view_10, toggleSuperscript);
15289
15590
  return;
15290
15591
  }
15291
15592
  if (action_1 === "subscript") {
15292
- executeEditorCommand(view_11, toggleSubscript);
15593
+ executeEditorCommand(view_10, toggleSubscript);
15293
15594
  return;
15294
15595
  }
15295
15596
  if (action_1 === "bulletList") {
15296
- executeEditorCommand(view_11, toggleBulletList);
15597
+ executeEditorCommand(view_10, toggleBulletList);
15297
15598
  return;
15298
15599
  }
15299
15600
  if (action_1 === "numberedList") {
15300
- executeEditorCommand(view_11, toggleNumberedList);
15601
+ executeEditorCommand(view_10, toggleNumberedList);
15301
15602
  return;
15302
15603
  }
15303
15604
  if (action_1 === "indent") {
15304
- executeFirstEditorCommand(view_11, [increaseListLevel, increaseIndent()]);
15605
+ executeFirstEditorCommand(view_10, [increaseListLevel, increaseIndent()]);
15305
15606
  return;
15306
15607
  }
15307
15608
  if (action_1 === "outdent") {
15308
- executeFirstEditorCommand(view_11, [decreaseListLevel, decreaseIndent()]);
15609
+ executeFirstEditorCommand(view_10, [decreaseListLevel, decreaseIndent()]);
15309
15610
  return;
15310
15611
  }
15311
15612
  if (action_1 === "clearFormatting") {
15312
- executeEditorCommand(view_11, clearFormatting);
15613
+ executeEditorCommand(view_10, clearFormatting);
15313
15614
  return;
15314
15615
  }
15315
15616
  if (action_1 === "setRtl") {
15316
- executeEditorCommand(view_11, setRtl);
15617
+ executeEditorCommand(view_10, setRtl);
15317
15618
  return;
15318
15619
  }
15319
15620
  if (action_1 === "setLtr") {
15320
- executeEditorCommand(view_11, setLtr);
15621
+ executeEditorCommand(view_10, setLtr);
15321
15622
  return;
15322
15623
  }
15323
15624
  if (action_1 === "insertPageBreak") {
15324
- executeEditorCommand(view_11, insertPageBreak);
15625
+ executeEditorCommand(view_10, insertPageBreak);
15325
15626
  return;
15326
15627
  }
15327
15628
  if (typeof action_1 === "object") switch (action_1.type) {
15328
15629
  case "alignment":
15329
- executeEditorCommand(view_11, setAlignment(action_1.value));
15630
+ executeEditorCommand(view_10, setAlignment(action_1.value));
15330
15631
  break;
15331
15632
  case "toggleDirection":
15332
- executeEditorCommand(view_11, toggleBidi);
15633
+ executeEditorCommand(view_10, toggleBidi);
15333
15634
  break;
15334
15635
  case "textColor": {
15335
15636
  const colorVal_0 = action_1.value;
15336
- if (typeof colorVal_0 === "string") executeEditorCommand(view_11, setTextColor({ rgb: colorVal_0.replace("#", "") }));
15337
- else if (colorVal_0.auto) executeEditorCommand(view_11, clearTextColor);
15637
+ if (typeof colorVal_0 === "string") executeEditorCommand(view_10, setTextColor({ rgb: colorVal_0.replace("#", "") }));
15638
+ else if (colorVal_0.auto) executeEditorCommand(view_10, clearTextColor);
15338
15639
  else {
15339
15640
  const themeColor = typeof colorVal_0.themeColor === "string" ? colorVal_0.themeColor : void 0;
15340
- executeEditorCommand(view_11, setTextColor({
15641
+ executeEditorCommand(view_10, setTextColor({
15341
15642
  ...colorVal_0.rgb === void 0 ? {} : { rgb: colorVal_0.rgb },
15342
15643
  ...themeColor ? { themeColor } : {},
15343
15644
  ...colorVal_0.themeTint === void 0 ? {} : { themeTint: colorVal_0.themeTint },
@@ -15347,16 +15648,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15347
15648
  break;
15348
15649
  }
15349
15650
  case "highlightColor":
15350
- executeEditorCommand(view_11, setHighlight((action_1.value ? mapHexToHighlightName(action_1.value) : "") || action_1.value));
15651
+ executeEditorCommand(view_10, setHighlight((action_1.value ? mapHexToHighlightName(action_1.value) : "") || action_1.value));
15351
15652
  break;
15352
15653
  case "fontSize":
15353
- executeEditorCommand(view_11, setFontSize(pointsToHalfPoints(action_1.value)));
15654
+ executeEditorCommand(view_10, setFontSize(pointsToHalfPoints(action_1.value)));
15354
15655
  break;
15355
15656
  case "fontFamily":
15356
- executeEditorCommand(view_11, setFontFamily(action_1.value));
15657
+ executeEditorCommand(view_10, setFontFamily(action_1.value));
15357
15658
  break;
15358
15659
  case "lineSpacing":
15359
- executeEditorCommand(view_11, setLineSpacing(action_1.value));
15660
+ executeEditorCommand(view_10, setLineSpacing(action_1.value));
15360
15661
  break;
15361
15662
  case "applyStyle": {
15362
15663
  const currentDoc_0 = historyStateRef.current;
@@ -15369,22 +15670,22 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15369
15670
  const styleName = styleResolver_0.getStyle(action_1.value)?.name;
15370
15671
  if (styleName) styleAttrs.styleName = styleName;
15371
15672
  styleAttrs.numbering = currentDoc_0?.package.numbering ? getCachedNumberingMap(currentDoc_0.package.numbering) : null;
15372
- executeEditorCommand(view_11, applyStyle(action_1.value, styleAttrs));
15373
- } else executeEditorCommand(view_11, applyStyle(action_1.value));
15673
+ executeEditorCommand(view_10, applyStyle(action_1.value, styleAttrs));
15674
+ } else executeEditorCommand(view_10, applyStyle(action_1.value));
15374
15675
  break;
15375
15676
  }
15376
15677
  default: break;
15377
15678
  }
15378
15679
  }, [getActiveEditorView, getCachedStyleResolver]);
15379
15680
  const captureFormatPainter = useCallback(() => {
15380
- const view_12 = getActiveEditorView();
15381
- capturedFormatMarksRef.current = view_12 ? captureFormatMarks(view_12.state) : null;
15681
+ const view_11 = getActiveEditorView();
15682
+ capturedFormatMarksRef.current = view_11 ? captureFormatMarks(view_11.state) : null;
15382
15683
  }, [getActiveEditorView]);
15383
15684
  const paintFormatToSelection = useCallback(() => {
15384
- const view_13 = getActiveEditorView();
15385
- if (!view_13) return false;
15386
- const applied = applyFormatMarks(capturedFormatMarksRef.current)(view_13.state, view_13.dispatch);
15387
- if (applied) requestAnimationFrame(() => view_13.focus());
15685
+ const view_12 = getActiveEditorView();
15686
+ if (!view_12) return false;
15687
+ const applied = applyFormatMarks(capturedFormatMarksRef.current)(view_12.state, view_12.dispatch);
15688
+ if (applied) requestAnimationFrame(() => view_12.focus());
15388
15689
  return applied;
15389
15690
  }, [getActiveEditorView]);
15390
15691
  const handleFormatPainter = useCallback((sticky) => {
@@ -15563,15 +15864,15 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15563
15864
  ]);
15564
15865
  const { from: contextSelectionFrom, to: contextSelectionTo } = contextMenu.selectionRange;
15565
15866
  const handleContextMenuAction = useCallback(async (action_2) => {
15566
- const view_14 = getActiveEditorView();
15567
- if (!view_14) return;
15867
+ const view_13 = getActiveEditorView();
15868
+ if (!view_13) return;
15568
15869
  focusActiveEditor();
15569
15870
  if (readOnly && action_2 !== "copy" && action_2 !== "selectAll") return;
15570
15871
  if (action_2.startsWith("custom:")) {
15571
15872
  const { from: from_2, to: to_2 } = contextSelectionFrom !== contextSelectionTo ? {
15572
15873
  from: contextSelectionFrom,
15573
15874
  to: contextSelectionTo
15574
- } : view_14.state.selection;
15875
+ } : view_13.state.selection;
15575
15876
  onCustomContextAction?.(action_2.slice(7), {
15576
15877
  from: from_2,
15577
15878
  to: to_2
@@ -15581,16 +15882,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15581
15882
  switch (action_2) {
15582
15883
  case "cut": {
15583
15884
  if (readOnly) return;
15584
- const { from: from_7, to: to_7 } = view_14.state.selection;
15585
- const text_2 = view_14.state.doc.textBetween(from_7, to_7, "\n");
15885
+ const { from: from_7, to: to_7 } = view_13.state.selection;
15886
+ const text_2 = view_13.state.doc.textBetween(from_7, to_7, "\n");
15586
15887
  navigator.clipboard.writeText(text_2).catch(() => void 0);
15587
- if (!deleteSelectionAsSuggestion(view_14.state, view_14.dispatch)) view_14.dispatch(view_14.state.tr.deleteSelection());
15888
+ if (!deleteSelectionAsSuggestion(view_13.state, view_13.dispatch)) view_13.dispatch(view_13.state.tr.deleteSelection());
15588
15889
  onCut?.();
15589
15890
  break;
15590
15891
  }
15591
15892
  case "copy": {
15592
- const { from: cf, to: ct } = view_14.state.selection;
15593
- const copied = view_14.state.doc.textBetween(cf, ct, "\n");
15893
+ const { from: cf, to: ct } = view_13.state.selection;
15894
+ const copied = view_13.state.doc.textBetween(cf, ct, "\n");
15594
15895
  navigator.clipboard.writeText(copied).catch(() => void 0);
15595
15896
  onCopy?.();
15596
15897
  break;
@@ -15613,12 +15914,12 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15613
15914
  bubbles: true,
15614
15915
  cancelable: true
15615
15916
  });
15616
- view_14.dom.dispatchEvent(pasteEvent);
15917
+ view_13.dom.dispatchEvent(pasteEvent);
15617
15918
  } catch {
15618
15919
  try {
15619
15920
  const text_0 = await navigator.clipboard.readText();
15620
15921
  if (text_0) {
15621
- view_14.dispatch(view_14.state.tr.insertText(text_0));
15922
+ view_13.dispatch(view_13.state.tr.insertText(text_0));
15622
15923
  onPaste?.();
15623
15924
  }
15624
15925
  } catch {}
@@ -15627,9 +15928,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15627
15928
  case "pasteAsPlainText":
15628
15929
  try {
15629
15930
  const text = await navigator.clipboard.readText();
15630
- if (text && !view_14.isDestroyed) {
15631
- const slice = buildPlainTextSlice(text, view_14.state.schema);
15632
- view_14.dispatch(view_14.state.tr.replaceSelection(slice).scrollIntoView());
15931
+ if (text && !view_13.isDestroyed) {
15932
+ const slice = buildPlainTextSlice(text, view_13.state.schema);
15933
+ view_13.dispatch(view_13.state.tr.replaceSelection(slice).scrollIntoView());
15633
15934
  onPaste?.();
15634
15935
  }
15635
15936
  } catch {
@@ -15637,42 +15938,42 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15637
15938
  }
15638
15939
  break;
15639
15940
  case "delete": {
15640
- const { from: from_6, to: to_6 } = view_14.state.selection;
15641
- if (from_6 !== to_6) view_14.dispatch(view_14.state.tr.deleteRange(from_6, to_6));
15941
+ const { from: from_6, to: to_6 } = view_13.state.selection;
15942
+ if (from_6 !== to_6) view_13.dispatch(view_13.state.tr.deleteRange(from_6, to_6));
15642
15943
  break;
15643
15944
  }
15644
15945
  case "selectAll":
15645
- view_14.dispatch(view_14.state.tr.setSelection(TextSelection.create(view_14.state.doc, 0, view_14.state.doc.content.size)));
15946
+ view_13.dispatch(view_13.state.tr.setSelection(TextSelection.create(view_13.state.doc, 0, view_13.state.doc.content.size)));
15646
15947
  break;
15647
15948
  case "addRowAbove":
15648
- addRowAbove(view_14.state, view_14.dispatch);
15949
+ addRowAbove(view_13.state, view_13.dispatch);
15649
15950
  break;
15650
15951
  case "addRowBelow":
15651
- addRowBelow(view_14.state, view_14.dispatch);
15952
+ addRowBelow(view_13.state, view_13.dispatch);
15652
15953
  break;
15653
15954
  case "deleteRow":
15654
- deleteRow(view_14.state, view_14.dispatch);
15955
+ deleteRow(view_13.state, view_13.dispatch);
15655
15956
  break;
15656
15957
  case "addColumnLeft":
15657
- addColumnLeft(view_14.state, view_14.dispatch);
15958
+ addColumnLeft(view_13.state, view_13.dispatch);
15658
15959
  break;
15659
15960
  case "addColumnRight":
15660
- addColumnRight(view_14.state, view_14.dispatch);
15961
+ addColumnRight(view_13.state, view_13.dispatch);
15661
15962
  break;
15662
15963
  case "deleteColumn":
15663
- deleteColumn(view_14.state, view_14.dispatch);
15964
+ deleteColumn(view_13.state, view_13.dispatch);
15664
15965
  break;
15665
15966
  case "tableBordersAll":
15666
- setTableBorderPreset("all")(view_14.state, view_14.dispatch);
15967
+ setTableBorderPreset("all")(view_13.state, view_13.dispatch);
15667
15968
  break;
15668
15969
  case "tableBordersNone":
15669
- setTableBorderPreset("none")(view_14.state, view_14.dispatch);
15970
+ setTableBorderPreset("none")(view_13.state, view_13.dispatch);
15670
15971
  break;
15671
15972
  case "addComment": {
15672
15973
  const { from: from_5, to: to_5 } = contextSelectionFrom !== contextSelectionTo ? {
15673
15974
  from: contextSelectionFrom,
15674
15975
  to: contextSelectionTo
15675
- } : view_14.state.selection;
15976
+ } : view_13.state.selection;
15676
15977
  if (from_5 === to_5) break;
15677
15978
  const commentY = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, from_5) ?? getFallbackCommentYPosition(scrollContainerRef.current);
15678
15979
  setCommentSelectionRange({
@@ -15680,7 +15981,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15680
15981
  to: to_5
15681
15982
  });
15682
15983
  if (commentDraftMode === "prosemirror") {
15683
- if (!applyCommentMarkRange(view_14, {
15984
+ if (!applyCommentMarkRange(view_13, {
15684
15985
  from: from_5,
15685
15986
  to: to_5
15686
15987
  }, -1, { selectEnd: true })) break;
@@ -15692,30 +15993,30 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15692
15993
  break;
15693
15994
  }
15694
15995
  case "acceptChange": {
15695
- const { from: from_4, to: to_4 } = view_14.state.selection;
15696
- const range_1 = findChangeAtPosition(view_14.state, from_4, to_4);
15996
+ const { from: from_4, to: to_4 } = view_13.state.selection;
15997
+ const range_0 = findChangeAtPosition(view_13.state, from_4, to_4);
15697
15998
  if (resolveCanonicalReviewRange({
15698
15999
  editor: pagedEditorRef.current?.getEditor(),
15699
- ...range_1,
16000
+ ...range_0,
15700
16001
  resolution: "accept"
15701
- }) === null) acceptChange(range_1.from, range_1.to)(view_14.state, view_14.dispatch);
16002
+ }) === null) acceptChange(range_0.from, range_0.to)(view_13.state, view_13.dispatch);
15702
16003
  break;
15703
16004
  }
15704
16005
  case "rejectChange": {
15705
- const { from: from_3, to: to_3 } = view_14.state.selection;
15706
- const range_0 = findChangeAtPosition(view_14.state, from_3, to_3);
16006
+ const { from: from_3, to: to_3 } = view_13.state.selection;
16007
+ const range = findChangeAtPosition(view_13.state, from_3, to_3);
15707
16008
  if (resolveCanonicalReviewRange({
15708
16009
  editor: pagedEditorRef.current?.getEditor(),
15709
- ...range_0,
16010
+ ...range,
15710
16011
  resolution: "reject"
15711
- }) === null) rejectChange(range_0.from, range_0.to)(view_14.state, view_14.dispatch);
16012
+ }) === null) rejectChange(range.from, range.to)(view_13.state, view_13.dispatch);
15712
16013
  break;
15713
16014
  }
15714
16015
  case "restartNumbering":
15715
- restartNumbering(view_14.state, view_14.dispatch);
16016
+ restartNumbering(view_13.state, view_13.dispatch);
15716
16017
  break;
15717
16018
  case "continueNumbering":
15718
- continueNumbering(view_14.state, view_14.dispatch);
16019
+ continueNumbering(view_13.state, view_13.dispatch);
15719
16020
  break;
15720
16021
  case "setNumberingValue":
15721
16022
  setNumberingValueDialogOpen(true);
@@ -15775,37 +16076,37 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15775
16076
  const handleTopMarginChange = useCallback((twips_1) => handlePageSetupApply({ marginTop: twips_1 }), [handlePageSetupApply]);
15776
16077
  const handleBottomMarginChange = useCallback((twips_2) => handlePageSetupApply({ marginBottom: twips_2 }), [handlePageSetupApply]);
15777
16078
  const handleIndentLeftChange = useCallback((twips_3) => {
16079
+ const view_14 = getActiveEditorView();
16080
+ if (!view_14) return;
16081
+ setIndentLeft(twips_3)(view_14.state, view_14.dispatch);
16082
+ }, [getActiveEditorView]);
16083
+ const handleIndentRightChange = useCallback((twips_4) => {
15778
16084
  const view_15 = getActiveEditorView();
15779
16085
  if (!view_15) return;
15780
- setIndentLeft(twips_3)(view_15.state, view_15.dispatch);
16086
+ setIndentRight(twips_4)(view_15.state, view_15.dispatch);
15781
16087
  }, [getActiveEditorView]);
15782
- const handleIndentRightChange = useCallback((twips_4) => {
16088
+ const handleFirstLineIndentChange = useCallback((twips_5) => {
15783
16089
  const view_16 = getActiveEditorView();
15784
16090
  if (!view_16) return;
15785
- setIndentRight(twips_4)(view_16.state, view_16.dispatch);
16091
+ if (twips_5 < 0) setIndentFirstLine(-twips_5, true)(view_16.state, view_16.dispatch);
16092
+ else setIndentFirstLine(twips_5, false)(view_16.state, view_16.dispatch);
15786
16093
  }, [getActiveEditorView]);
15787
- const handleFirstLineIndentChange = useCallback((twips_5) => {
16094
+ const handleTabStopRemove = useCallback((positionTwips) => {
15788
16095
  const view_17 = getActiveEditorView();
15789
16096
  if (!view_17) return;
15790
- if (twips_5 < 0) setIndentFirstLine(-twips_5, true)(view_17.state, view_17.dispatch);
15791
- else setIndentFirstLine(twips_5, false)(view_17.state, view_17.dispatch);
15792
- }, [getActiveEditorView]);
15793
- const handleTabStopRemove = useCallback((positionTwips) => {
15794
- const view_18 = getActiveEditorView();
15795
- if (!view_18) return;
15796
- removeTabStop(positionTwips)(view_18.state, view_18.dispatch);
16097
+ removeTabStop(positionTwips)(view_17.state, view_17.dispatch);
15797
16098
  }, [getActiveEditorView]);
15798
16099
  const serializeCurrentDocx = useCallback(async (options) => {
15799
16100
  let tripwireResult = null;
15800
16101
  let savedBuffer = null;
15801
16102
  try {
15802
16103
  const editor_2 = pagedEditorRef.current?.getEditor();
15803
- const snapshot = editor_2?.captureCanonicalSave();
15804
- if (snapshot && editor_2) {
15805
- const view_19 = editor_2.getView();
15806
- const editorState = view_19?.state;
16104
+ const snapshot_0 = editor_2?.captureCanonicalSave();
16105
+ if (snapshot_0 && editor_2) {
16106
+ const view_18 = editor_2.getView();
16107
+ const editorState = view_18?.state;
15807
16108
  const result_2 = await serializeCanonicalSave({
15808
- snapshot,
16109
+ snapshot: snapshot_0,
15809
16110
  options,
15810
16111
  featureFlags
15811
16112
  });
@@ -15815,12 +16116,12 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15815
16116
  message: `Canonical save used a fidelity fallback: ${diagnostic.type} (${diagnostic.part}).`
15816
16117
  }));
15817
16118
  tripwireResult = result_2.tripwireResult;
15818
- if (view_19 && pagedEditorRef.current?.getEditor() === editor_2 && editor_2.getView() === view_19 && view_19.state.doc === editorState?.doc && editor_2.isCanonicalSaveCurrent(snapshot.version)) view_19.dispatch(clearTrackedChanges(view_19.state));
16119
+ if (view_18 && pagedEditorRef.current?.getEditor() === editor_2 && editor_2.getView() === view_18 && view_18.state.doc === editorState?.doc && editor_2.isCanonicalSaveCurrent(snapshot_0.version)) view_18.dispatch(clearTrackedChanges(view_18.state));
15819
16120
  savedBuffer = result_2.buffer;
15820
16121
  } else {
15821
16122
  if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.save)) return null;
15822
- const view_20 = pagedEditorRef.current?.getView();
15823
- const editorState_0 = view_20?.state;
16123
+ const view_19 = pagedEditorRef.current?.getView();
16124
+ const editorState_0 = view_19?.state;
15824
16125
  const baselineBuffer = originalBufferRef.current;
15825
16126
  const current = buildCurrentDocument();
15826
16127
  const doc_1 = current ? withoutUnreferencedNotes(current) : null;
@@ -15861,9 +16162,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15861
16162
  const { compareSelectiveVsFull } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
15862
16163
  tripwireResult = await compareSelectiveVsFull(selectiveBuffer, fullBuffer);
15863
16164
  } catch {}
15864
- if (view_20 && pagedEditorRef.current?.getView() === view_20 && view_20.state.doc === editorState_0?.doc) {
16165
+ if (view_19 && pagedEditorRef.current?.getView() === view_19 && view_19.state.doc === editorState_0?.doc) {
15865
16166
  originalBufferRef.current = buffer;
15866
- view_20.dispatch(clearTrackedChanges(view_20.state));
16167
+ view_19.dispatch(clearTrackedChanges(view_19.state));
15867
16168
  }
15868
16169
  savedBuffer = buffer;
15869
16170
  }
@@ -15910,10 +16211,18 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15910
16211
  useImperativeHandle(ref, () => ({
15911
16212
  getReadOnlyReason: () => readOnlyReason,
15912
16213
  getDocument: () => buildCurrentDocument(),
16214
+ find: (searchText, options_1) => handleFind(searchText, {
16215
+ ...createDefaultFindOptions(),
16216
+ ...options_1
16217
+ }),
16218
+ findNext: handleFindNext,
16219
+ findPrevious: handleFindPrevious,
16220
+ getFindResult,
16221
+ clearFind: resetFindResult,
15913
16222
  hasPendingChanges: () => {
15914
- const view_21 = pagedEditorRef.current?.getView();
15915
- if (!view_21) return false;
15916
- return getCommentsDirty() || getChangedParagraphIds(view_21.state).size > 0 || hasStructuralChanges(view_21.state) || hasUntrackedChanges(view_21.state);
16223
+ const view_20 = pagedEditorRef.current?.getView();
16224
+ if (!view_20) return false;
16225
+ return getCommentsDirty() || getChangedParagraphIds(view_20.state).size > 0 || hasStructuralChanges(view_20.state) || hasUntrackedChanges(view_20.state);
15917
16226
  },
15918
16227
  getEditorRef: () => pagedEditorRef.current,
15919
16228
  getEditor: () => pagedEditorRef.current?.getEditor() ?? null,
@@ -15928,7 +16237,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15928
16237
  scrollToPage: (pageNumber_0) => {
15929
16238
  pagedEditorRef.current?.scrollToPage(pageNumber_0);
15930
16239
  },
15931
- scrollToParaId: (paraId, options_1) => pagedEditorRef.current?.scrollToParaId(paraId, options_1) ?? false,
16240
+ scrollToParaId: (paraId, options_2) => pagedEditorRef.current?.scrollToParaId(paraId, options_2) ?? false,
15932
16241
  openPrintPreview: handleDirectPrint,
15933
16242
  print: handleDirectPrint,
15934
16243
  openFind: () => {
@@ -15954,17 +16263,17 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15954
16263
  pendingSuggestionRegistryRef.current.clear();
15955
16264
  return pagedEditorRef.current?.getEditor().loadDocx(buffer_1) ?? loadBuffer(buffer_1);
15956
16265
  },
15957
- ensureEditorView: (options_2) => {
15958
- pagedEditorRef.current?.ensureView(options_2);
16266
+ ensureEditorView: (options_3) => {
16267
+ pagedEditorRef.current?.ensureView(options_3);
15959
16268
  },
15960
16269
  createAIEditSnapshot: () => {
15961
- const view_22 = pagedEditorRef.current?.getView();
15962
- return view_22 ? createFolioAIEditSnapshot(view_22.state.doc) : null;
16270
+ const view_21 = pagedEditorRef.current?.getView();
16271
+ return view_21 ? createFolioAIEditSnapshot(view_21.state.doc) : null;
15963
16272
  },
15964
- applyDocumentOperations: ({ undefinedReferences, snapshot: snapshot_0, batch, author: operationAuthor = author }) => {
16273
+ applyDocumentOperations: ({ undefinedReferences, snapshot: snapshot_1, batch, author: operationAuthor = author }) => {
15965
16274
  assertSupportedFolioDocumentOperationVersion(batch.version);
15966
- const view_23 = pagedEditorRef.current?.getView();
15967
- if (!view_23) {
16275
+ const view_22 = pagedEditorRef.current?.getView();
16276
+ if (!view_22) {
15968
16277
  let status = "committed";
15969
16278
  if (batch.dryRun === true) status = "previewed";
15970
16279
  else if (batch.atomic === true) status = "rejected";
@@ -15984,27 +16293,27 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15984
16293
  }
15985
16294
  const canonical_1 = getCanonicalApi()?.applyCanonicalDocumentOperations({
15986
16295
  undefinedReferences,
15987
- snapshot: snapshot_0,
16296
+ snapshot: snapshot_1,
15988
16297
  batch,
15989
16298
  author: operationAuthor
15990
16299
  });
15991
16300
  if (canonical_1) return canonical_1;
15992
16301
  const existingUndoEntry = documentOperationUndoEntriesRef.current.at(-1);
15993
- if (existingUndoEntry && (!view_23.state.doc.eq(existingUndoEntry.afterState.doc) || canonicalJson(commentsRef.current) !== existingUndoEntry.commentsAfterJson)) documentOperationUndoEntriesRef.current.length = 0;
16302
+ if (existingUndoEntry && (!view_22.state.doc.eq(existingUndoEntry.afterState.doc) || canonicalJson(commentsRef.current) !== existingUndoEntry.commentsAfterJson)) documentOperationUndoEntriesRef.current.length = 0;
15994
16303
  const commentsBefore = commentsRef.current;
15995
16304
  const createdComments = [];
15996
16305
  const operationView = {
15997
- state: view_23.state,
16306
+ state: view_22.state,
15998
16307
  dispatch: (transaction) => {
15999
- view_23.dispatch(closeHistory(transaction));
16000
- operationView.state = view_23.state;
16308
+ view_22.dispatch(closeHistory(transaction));
16309
+ operationView.state = view_22.state;
16001
16310
  }
16002
16311
  };
16003
- const activeSuggestionIds = new Set(getSuggestions(view_23.state).map((s_0) => s_0.suggestionId));
16312
+ const activeSuggestionIds = new Set(getSuggestions(view_22.state).map((s_0) => s_0.suggestionId));
16004
16313
  const result_3 = applyFolioDocumentOperations({
16005
16314
  undefinedReferences,
16006
16315
  view: operationView,
16007
- snapshot: snapshot_0,
16316
+ snapshot: snapshot_1,
16008
16317
  batch,
16009
16318
  author: operationAuthor,
16010
16319
  createCommentId: (text_3) => {
@@ -16018,7 +16327,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16018
16327
  })
16019
16328
  });
16020
16329
  if (batch.mode === "suggested" && result_3.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
16021
- snapshot: snapshot_0,
16330
+ snapshot: snapshot_1,
16022
16331
  story: { type: "main" },
16023
16332
  operations: batch.operations,
16024
16333
  applied: result_3.applied,
@@ -16030,7 +16339,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16030
16339
  if (batchComments.length > 0) replaceComments(commentsAfter);
16031
16340
  if (result_3.undoHandle !== null) documentOperationUndoEntriesRef.current.push({
16032
16341
  undoHandle: result_3.undoHandle,
16033
- afterState: view_23.state,
16342
+ afterState: view_22.state,
16034
16343
  commentsBefore,
16035
16344
  commentsAfterJson: canonicalJson(commentsAfter)
16036
16345
  });
@@ -16052,18 +16361,18 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16052
16361
  reason: "notLatest"
16053
16362
  };
16054
16363
  const entry_3 = entries_0.at(-1);
16055
- const view_24 = pagedEditorRef.current?.getView();
16056
- if (!entry_3 || !view_24) return {
16364
+ const view_23 = pagedEditorRef.current?.getView();
16365
+ if (!entry_3 || !view_23) return {
16057
16366
  status: "rejected",
16058
16367
  undoHandle,
16059
16368
  reason: "unknownHandle"
16060
16369
  };
16061
- if (!view_24.state.doc.eq(entry_3.afterState.doc) || canonicalJson(commentsRef.current) !== entry_3.commentsAfterJson) return {
16370
+ if (!view_23.state.doc.eq(entry_3.afterState.doc) || canonicalJson(commentsRef.current) !== entry_3.commentsAfterJson) return {
16062
16371
  status: "rejected",
16063
16372
  undoHandle,
16064
16373
  reason: "documentChanged"
16065
16374
  };
16066
- if (!undo(view_24.state, view_24.dispatch)) return {
16375
+ if (!undo(view_23.state, view_23.dispatch)) return {
16067
16376
  status: "rejected",
16068
16377
  undoHandle,
16069
16378
  reason: "documentChanged"
@@ -16076,9 +16385,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16076
16385
  undoHandle
16077
16386
  };
16078
16387
  },
16079
- applyAIEditOperations: ({ undefinedReferences: undefinedReferences_0, snapshot: snapshot_1, operations, mode = "tracked-changes", author: operationAuthor_0 = author }) => {
16080
- const view_25 = pagedEditorRef.current?.getView();
16081
- if (!view_25) return {
16388
+ applyAIEditOperations: ({ undefinedReferences: undefinedReferences_0, snapshot: snapshot_2, operations, mode = "tracked-changes", author: operationAuthor_0 = author }) => {
16389
+ const view_24 = pagedEditorRef.current?.getView();
16390
+ if (!view_24) return {
16082
16391
  applied: [],
16083
16392
  skipped: operations.map((operation_0) => ({
16084
16393
  id: operation_0.id,
@@ -16087,7 +16396,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16087
16396
  };
16088
16397
  const canonical_3 = getCanonicalApi()?.applyCanonicalDocumentOperations({
16089
16398
  undefinedReferences: undefinedReferences_0,
16090
- snapshot: snapshot_1,
16399
+ snapshot: snapshot_2,
16091
16400
  batch: {
16092
16401
  version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
16093
16402
  operations,
@@ -16097,11 +16406,11 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16097
16406
  });
16098
16407
  if (canonical_3) return canonical_3;
16099
16408
  const createdComments_0 = [];
16100
- const activeSuggestionIds_0 = new Set(getSuggestions(view_25.state).map((s_1) => s_1.suggestionId));
16409
+ const activeSuggestionIds_0 = new Set(getSuggestions(view_24.state).map((s_1) => s_1.suggestionId));
16101
16410
  const { applied: applied_0, skipped: skipped_0 } = applyFolioDocumentOperations({
16102
16411
  undefinedReferences: undefinedReferences_0,
16103
- view: view_25,
16104
- snapshot: snapshot_1,
16412
+ view: view_24,
16413
+ snapshot: snapshot_2,
16105
16414
  batch: {
16106
16415
  version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
16107
16416
  operations,
@@ -16117,7 +16426,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16117
16426
  const batchComments_0 = appliedOperationComments(createdComments_0, applied_0);
16118
16427
  if (batchComments_0.length > 0) updateComments((currentComments_0) => [...currentComments_0, ...batchComments_0]);
16119
16428
  if (mode === "suggested") pendingSuggestionRegistryRef.current.recordApplied({
16120
- snapshot: snapshot_1,
16429
+ snapshot: snapshot_2,
16121
16430
  story: { type: "main" },
16122
16431
  operations,
16123
16432
  applied: applied_0,
@@ -16130,18 +16439,18 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16130
16439
  };
16131
16440
  },
16132
16441
  acceptAIEditOperation: (revisionId) => {
16133
- const view_26 = pagedEditorRef.current?.getView();
16134
- if (!view_26) return false;
16442
+ const view_25 = pagedEditorRef.current?.getView();
16443
+ if (!view_25) return false;
16135
16444
  const editor_5 = pagedEditorRef.current?.getEditor();
16136
16445
  if (editor_5?.getCanonicalDocument()) return editor_5.resolveCanonicalRevisions(typeof revisionId === "number" ? [revisionId] : revisionId, "accept");
16137
- return acceptAIEditRevision(revisionId)(view_26.state, view_26.dispatch);
16446
+ return acceptAIEditRevision(revisionId)(view_25.state, view_25.dispatch);
16138
16447
  },
16139
16448
  rejectAIEditOperation: (revisionId_0) => {
16140
- const view_27 = pagedEditorRef.current?.getView();
16141
- if (!view_27) return false;
16449
+ const view_26 = pagedEditorRef.current?.getView();
16450
+ if (!view_26) return false;
16142
16451
  const editor_6 = pagedEditorRef.current?.getEditor();
16143
16452
  if (editor_6?.getCanonicalDocument()) return editor_6.resolveCanonicalRevisions(typeof revisionId_0 === "number" ? [revisionId_0] : revisionId_0, "reject");
16144
- return rejectAIEditRevision(revisionId_0)(view_27.state, view_27.dispatch);
16453
+ return rejectAIEditRevision(revisionId_0)(view_26.state, view_26.dispatch);
16145
16454
  },
16146
16455
  undo: () => {
16147
16456
  if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.undo();
@@ -16156,45 +16465,45 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16156
16465
  return redone;
16157
16466
  },
16158
16467
  scrollToAIEditOperation: (revisionId_1) => {
16159
- const view_28 = pagedEditorRef.current?.getView();
16160
- if (!view_28) return false;
16161
- const range_2 = findAIEditRevisionRange(view_28.state, revisionId_1);
16162
- if (!range_2) return false;
16163
- const { from: from_8, to: to_8 } = clampRangeToDocSize(view_28.state.doc.content.size, range_2);
16164
- const $from = view_28.state.doc.resolve(from_8);
16165
- const $to = view_28.state.doc.resolve(to_8);
16166
- view_28.dispatch(view_28.state.tr.setSelection(TextSelection.between($from, $to)));
16468
+ const view_27 = pagedEditorRef.current?.getView();
16469
+ if (!view_27) return false;
16470
+ const range_1 = findAIEditRevisionRange(view_27.state, revisionId_1);
16471
+ if (!range_1) return false;
16472
+ const { from: from_8, to: to_8 } = clampRangeToDocSize(view_27.state.doc.content.size, range_1);
16473
+ const $from = view_27.state.doc.resolve(from_8);
16474
+ const $to = view_27.state.doc.resolve(to_8);
16475
+ view_27.dispatch(view_27.state.tr.setSelection(TextSelection.between($from, $to)));
16167
16476
  requestAnimationFrame(() => {
16168
16477
  pagedEditorRef.current?.scrollToPosition(from_8);
16169
16478
  });
16170
16479
  return true;
16171
16480
  },
16172
- scrollToBlock: (blockId, snapshot_2) => {
16173
- const view_29 = pagedEditorRef.current?.getView();
16174
- if (!view_29) return false;
16175
- const range_3 = resolveFolioAIBlockRange({
16481
+ scrollToBlock: (blockId, snapshot_3) => {
16482
+ const view_28 = pagedEditorRef.current?.getView();
16483
+ if (!view_28) return false;
16484
+ const range_2 = resolveFolioAIBlockRange({
16176
16485
  blockId,
16177
- doc: view_29.state.doc,
16178
- snapshot: snapshot_2
16486
+ doc: view_28.state.doc,
16487
+ snapshot: snapshot_3
16179
16488
  });
16180
- if (range_3 === null) return false;
16181
- const { from: from_9, to: to_9 } = range_3;
16182
- const $from_0 = view_29.state.doc.resolve(from_9);
16183
- const $to_0 = view_29.state.doc.resolve(to_9);
16184
- view_29.dispatch(view_29.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
16489
+ if (range_2 === null) return false;
16490
+ const { from: from_9, to: to_9 } = range_2;
16491
+ const $from_0 = view_28.state.doc.resolve(from_9);
16492
+ const $to_0 = view_28.state.doc.resolve(to_9);
16493
+ view_28.dispatch(view_28.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
16185
16494
  requestAnimationFrame(() => {
16186
16495
  pagedEditorRef.current?.scrollToPosition(from_9);
16187
16496
  });
16188
16497
  return true;
16189
16498
  },
16190
- highlightPassage: ({ blockId: blockId_0, text: text_5, snapshot: snapshot_3 }) => {
16191
- const view_30 = pagedEditorRef.current?.getView();
16192
- if (!view_30) return "none";
16499
+ highlightPassage: ({ blockId: blockId_0, text: text_5, snapshot: snapshot_4 }) => {
16500
+ const view_29 = pagedEditorRef.current?.getView();
16501
+ if (!view_29) return "none";
16193
16502
  const passageRange = resolvePassageRange({
16194
16503
  blockId: blockId_0,
16195
16504
  text: text_5,
16196
- doc: view_30.state.doc,
16197
- snapshot: snapshot_3
16505
+ doc: view_29.state.doc,
16506
+ snapshot: snapshot_4
16198
16507
  });
16199
16508
  if (passageRange !== null) {
16200
16509
  pagedEditorRef.current?.setPassageHighlight(passageRange);
@@ -16206,16 +16515,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16206
16515
  pagedEditorRef.current?.setPassageHighlight(null);
16207
16516
  const blockRange = resolveFolioAIBlockRange({
16208
16517
  blockId: blockId_0,
16209
- doc: view_30.state.doc,
16210
- snapshot: snapshot_3
16518
+ doc: view_29.state.doc,
16519
+ snapshot: snapshot_4
16211
16520
  });
16212
16521
  if (blockRange === null) return "none";
16213
16522
  const paraId_0 = getFolioParaIdFromBlockId(blockId_0);
16214
16523
  if (paraId_0 !== null && pagedEditorRef.current?.scrollToParaId(paraId_0, { highlight: {} })) return "block";
16215
16524
  const { from: from_10, to: to_10 } = blockRange;
16216
- const $from_1 = view_30.state.doc.resolve(from_10);
16217
- const $to_1 = view_30.state.doc.resolve(to_10);
16218
- view_30.dispatch(view_30.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
16525
+ const $from_1 = view_29.state.doc.resolve(from_10);
16526
+ const $to_1 = view_29.state.doc.resolve(to_10);
16527
+ view_29.dispatch(view_29.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
16219
16528
  requestAnimationFrame(() => {
16220
16529
  pagedEditorRef.current?.scrollToPosition(from_10);
16221
16530
  });
@@ -16224,59 +16533,59 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16224
16533
  clearPassageHighlight: () => {
16225
16534
  pagedEditorRef.current?.setPassageHighlight(null);
16226
16535
  },
16227
- showInDocument: (target_1, snapshot_4) => {
16228
- const view_31 = pagedEditorRef.current?.getView();
16229
- if (!view_31) return false;
16230
- const range_4 = target_1.type === "textRange" ? resolveFolioAITextRange({
16536
+ showInDocument: (target_1, snapshot_5) => {
16537
+ const view_30 = pagedEditorRef.current?.getView();
16538
+ if (!view_30) return false;
16539
+ const range_3 = target_1.type === "textRange" ? resolveFolioAITextRange({
16231
16540
  range: target_1,
16232
- doc: view_31.state.doc,
16233
- snapshot: snapshot_4
16541
+ doc: view_30.state.doc,
16542
+ snapshot: snapshot_5
16234
16543
  }) : resolveFolioAIBlockRange({
16235
16544
  blockId: target_1.blockId,
16236
- doc: view_31.state.doc,
16237
- snapshot: snapshot_4
16545
+ doc: view_30.state.doc,
16546
+ snapshot: snapshot_5
16238
16547
  });
16239
- if (range_4 === null) return false;
16240
- const { from: from_11, to: to_11 } = range_4;
16241
- const $from_2 = view_31.state.doc.resolve(from_11);
16242
- const $to_2 = view_31.state.doc.resolve(to_11);
16243
- view_31.dispatch(view_31.state.tr.setSelection(TextSelection.between($from_2, $to_2)));
16548
+ if (range_3 === null) return false;
16549
+ const { from: from_11, to: to_11 } = range_3;
16550
+ const $from_2 = view_30.state.doc.resolve(from_11);
16551
+ const $to_2 = view_30.state.doc.resolve(to_11);
16552
+ view_30.dispatch(view_30.state.tr.setSelection(TextSelection.between($from_2, $to_2)));
16244
16553
  requestAnimationFrame(() => {
16245
16554
  pagedEditorRef.current?.scrollToPosition(from_11);
16246
16555
  });
16247
16556
  return true;
16248
16557
  },
16249
16558
  getSuggestions: () => {
16250
- const view_32 = pagedEditorRef.current?.getView();
16251
- return view_32 ? getSuggestions(view_32.state) : [];
16559
+ const view_31 = pagedEditorRef.current?.getView();
16560
+ return view_31 ? getSuggestions(view_31.state) : [];
16252
16561
  },
16253
16562
  exportPendingSuggestions: () => {
16254
- const view_33 = pagedEditorRef.current?.getView();
16255
- const activeIds = new Set(view_33 ? getSuggestions(view_33.state).map((s_2) => s_2.suggestionId) : []);
16563
+ const view_32 = pagedEditorRef.current?.getView();
16564
+ const activeIds = new Set(view_32 ? getSuggestions(view_32.state).map((s_2) => s_2.suggestionId) : []);
16256
16565
  return pendingSuggestionRegistryRef.current.exportPendingSuggestions({
16257
16566
  activeSuggestionIds: activeIds,
16258
- snapshotForStory: (story_0, commentIds) => story_0.type === "main" && view_33 ? createPendingSuggestionSourceSnapshot(view_33.state, commentIds) : null
16567
+ snapshotForStory: (story_0, commentIds) => story_0.type === "main" && view_32 ? createPendingSuggestionSourceSnapshot(view_32.state, commentIds) : null
16259
16568
  });
16260
16569
  },
16261
16570
  loadPendingSuggestions: (records) => pendingSuggestionRegistryRef.current.loadPendingSuggestions({
16262
16571
  records,
16263
16572
  snapshotForStory: (story_1) => {
16264
- const view_34 = pagedEditorRef.current?.getView();
16265
- return story_1.type === "main" && view_34 ? createFolioAIEditSnapshot(view_34.state.doc) : null;
16573
+ const view_33 = pagedEditorRef.current?.getView();
16574
+ return story_1.type === "main" && view_33 ? createFolioAIEditSnapshot(view_33.state.doc) : null;
16266
16575
  },
16267
16576
  sourceSnapshotForStory: (story_2, commentIds_0) => {
16268
- const view_35 = pagedEditorRef.current?.getView();
16269
- return story_2.type === "main" && view_35 ? createPendingSuggestionSourceSnapshot(view_35.state, commentIds_0) : null;
16577
+ const view_34 = pagedEditorRef.current?.getView();
16578
+ return story_2.type === "main" && view_34 ? createPendingSuggestionSourceSnapshot(view_34.state, commentIds_0) : null;
16270
16579
  },
16271
- apply: (record, snapshot_5) => {
16272
- const view_36 = pagedEditorRef.current?.getView();
16273
- if (!view_36) return {
16580
+ apply: (record, snapshot_6) => {
16581
+ const view_35 = pagedEditorRef.current?.getView();
16582
+ if (!view_35) return {
16274
16583
  applied: [],
16275
16584
  skipped: []
16276
16585
  };
16277
16586
  const canonical_4 = getCanonicalApi()?.applyCanonicalDocumentOperations({
16278
16587
  undefinedReferences: "refuse",
16279
- snapshot: snapshot_5,
16588
+ snapshot: snapshot_6,
16280
16589
  batch: {
16281
16590
  version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
16282
16591
  operations: [record.operation],
@@ -16288,8 +16597,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16288
16597
  const createdComments_1 = [];
16289
16598
  const result_4 = applyFolioDocumentOperations({
16290
16599
  undefinedReferences: "refuse",
16291
- view: view_36,
16292
- snapshot: snapshot_5,
16600
+ view: view_35,
16601
+ snapshot: snapshot_6,
16293
16602
  batch: {
16294
16603
  version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
16295
16604
  operations: [record.operation],
@@ -16310,127 +16619,127 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16310
16619
  };
16311
16620
  },
16312
16621
  activeSuggestionIds: () => {
16313
- const view_37 = pagedEditorRef.current?.getView();
16314
- return new Set(view_37 ? getSuggestions(view_37.state).map((s_3) => s_3.suggestionId) : []);
16622
+ const view_36 = pagedEditorRef.current?.getView();
16623
+ return new Set(view_36 ? getSuggestions(view_36.state).map((s_3) => s_3.suggestionId) : []);
16315
16624
  }
16316
16625
  }),
16317
- acceptSuggestion: (suggestionId, options_3) => {
16318
- const view_38 = pagedEditorRef.current?.getView();
16319
- if (!view_38) return {
16626
+ acceptSuggestion: (suggestionId, options_4) => {
16627
+ const view_37 = pagedEditorRef.current?.getView();
16628
+ if (!view_37) return {
16320
16629
  accepted: false,
16321
16630
  appliedAs: null
16322
16631
  };
16323
- const appliedAs = getSuggestions(view_38.state).find((s_4) => s_4.suggestionId === suggestionId)?.appliedAs ?? null;
16324
- const accepted = acceptSuggestion(suggestionId, { author: options_3?.author ?? author })(view_38.state, view_38.dispatch);
16632
+ const appliedAs = getSuggestions(view_37.state).find((s_4) => s_4.suggestionId === suggestionId)?.appliedAs ?? null;
16633
+ const accepted = acceptSuggestion(suggestionId, { author: options_4?.author ?? author })(view_37.state, view_37.dispatch);
16325
16634
  return {
16326
16635
  accepted,
16327
16636
  appliedAs: accepted ? appliedAs : null
16328
16637
  };
16329
16638
  },
16330
16639
  rejectSuggestion: (suggestionId_0) => {
16331
- const view_39 = pagedEditorRef.current?.getView();
16332
- if (!view_39) return false;
16333
- return rejectSuggestion(suggestionId_0)(view_39.state, view_39.dispatch);
16640
+ const view_38 = pagedEditorRef.current?.getView();
16641
+ if (!view_38) return false;
16642
+ return rejectSuggestion(suggestionId_0)(view_38.state, view_38.dispatch);
16334
16643
  },
16335
16644
  scrollToSuggestion: (suggestionId_1) => {
16336
- const view_40 = pagedEditorRef.current?.getView();
16337
- if (!view_40) return false;
16338
- const range_5 = findSuggestionRange(view_40.state, suggestionId_1);
16339
- if (!range_5) return false;
16340
- const { from: from_12, to: to_12 } = clampRangeToDocSize(view_40.state.doc.content.size, range_5);
16341
- const $from_3 = view_40.state.doc.resolve(from_12);
16342
- const $to_3 = view_40.state.doc.resolve(to_12);
16343
- view_40.dispatch(view_40.state.tr.setSelection(TextSelection.between($from_3, $to_3)));
16645
+ const view_39 = pagedEditorRef.current?.getView();
16646
+ if (!view_39) return false;
16647
+ const range_4 = findSuggestionRange(view_39.state, suggestionId_1);
16648
+ if (!range_4) return false;
16649
+ const { from: from_12, to: to_12 } = clampRangeToDocSize(view_39.state.doc.content.size, range_4);
16650
+ const $from_3 = view_39.state.doc.resolve(from_12);
16651
+ const $to_3 = view_39.state.doc.resolve(to_12);
16652
+ view_39.dispatch(view_39.state.tr.setSelection(TextSelection.between($from_3, $to_3)));
16344
16653
  requestAnimationFrame(() => {
16345
16654
  pagedEditorRef.current?.scrollToPosition(from_12);
16346
16655
  });
16347
16656
  return true;
16348
16657
  },
16349
16658
  getTrackedChanges: () => {
16350
- const view_41 = pagedEditorRef.current?.getView();
16351
- return view_41 ? getTrackedChangesFromDoc(view_41.state.doc) : [];
16659
+ const view_40 = pagedEditorRef.current?.getView();
16660
+ return view_40 ? getTrackedChangesFromDoc(view_40.state.doc) : [];
16352
16661
  },
16353
16662
  getCommentAnchors: () => {
16354
- const view_42 = pagedEditorRef.current?.getView();
16355
- return view_42 ? getCommentAnchorsFromDoc(view_42.state.doc) : [];
16663
+ const view_41 = pagedEditorRef.current?.getView();
16664
+ return view_41 ? getCommentAnchorsFromDoc(view_41.state.doc) : [];
16356
16665
  },
16357
16666
  getSelectionText: () => {
16358
- const view_43 = pagedEditorRef.current?.getView();
16359
- return view_43 ? getSelectedText(view_43.state) : "";
16667
+ const view_42 = pagedEditorRef.current?.getView();
16668
+ return view_42 ? getSelectedText(view_42.state) : "";
16360
16669
  },
16361
16670
  getPageText: (page_1) => {
16362
- const view_44 = pagedEditorRef.current?.getView();
16363
- if (!view_44) return null;
16671
+ const view_43 = pagedEditorRef.current?.getView();
16672
+ if (!view_43) return null;
16364
16673
  return getPageTextFromLayout({
16365
16674
  layout: pagedEditorRef.current?.getEditor()?.getLayout() ?? null,
16366
- doc: view_44.state.doc,
16675
+ doc: view_43.state.doc,
16367
16676
  page: page_1,
16368
- projection: projectMarkupView(view_44.state, displayMode)
16677
+ projection: projectMarkupView(view_43.state, displayMode)
16369
16678
  });
16370
16679
  },
16371
- getTargetPage: (target_2, snapshot_6) => {
16372
- const view_45 = pagedEditorRef.current?.getView();
16373
- if (!view_45) return null;
16374
- const range_6 = target_2.type === "textRange" ? resolveFolioAITextRange({
16680
+ getTargetPage: (target_2, snapshot_7) => {
16681
+ const view_44 = pagedEditorRef.current?.getView();
16682
+ if (!view_44) return null;
16683
+ const range_5 = target_2.type === "textRange" ? resolveFolioAITextRange({
16375
16684
  range: target_2,
16376
- doc: view_45.state.doc,
16377
- snapshot: snapshot_6
16685
+ doc: view_44.state.doc,
16686
+ snapshot: snapshot_7
16378
16687
  }) : resolveFolioAIBlockRange({
16379
16688
  blockId: target_2.blockId,
16380
- doc: view_45.state.doc,
16381
- snapshot: snapshot_6
16689
+ doc: view_44.state.doc,
16690
+ snapshot: snapshot_7
16382
16691
  });
16383
- if (range_6 === null) return null;
16384
- return pagedEditorRef.current?.getPageNumberForPmPos(range_6.from) ?? null;
16692
+ if (range_5 === null) return null;
16693
+ return pagedEditorRef.current?.getPageNumberForPmPos(range_5.from) ?? null;
16385
16694
  },
16386
16695
  getBlockRect: (blockId_1) => pagedEditorRef.current?.getBlockRect(blockId_1) ?? null,
16387
16696
  getBlockRects: (blockIds) => pagedEditorRef.current?.getBlockRects(blockIds) ?? /* @__PURE__ */ new Map(),
16388
16697
  getScrollRoot: () => pagedEditorRef.current?.getScrollRoot() ?? null,
16389
16698
  onLayoutChange: (listener) => pagedEditorRef.current?.onLayoutChange(listener) ?? (() => {}),
16390
16699
  getContentControls: (filter = {}) => {
16391
- const view_46 = pagedEditorRef.current?.getView();
16392
- if (!view_46) return [];
16393
- return findBlockSdtMatches(view_46.state.doc, filter).map((match_0) => ({
16700
+ const view_45 = pagedEditorRef.current?.getView();
16701
+ if (!view_45) return [];
16702
+ return findBlockSdtMatches(view_45.state.doc, filter).map((match_0) => ({
16394
16703
  properties: blockSdtAttrsToSdtProperties(match_0.node),
16395
16704
  path: match_0.path,
16396
16705
  pmPos: match_0.pos
16397
16706
  }));
16398
16707
  },
16399
16708
  scrollToContentControl: (filter_0) => {
16400
- const view_47 = pagedEditorRef.current?.getView();
16401
- if (!view_47) return false;
16402
- const match_1 = findBlockSdtMatch(view_47.state.doc, filter_0);
16709
+ const view_46 = pagedEditorRef.current?.getView();
16710
+ if (!view_46) return false;
16711
+ const match_1 = findBlockSdtMatch(view_46.state.doc, filter_0);
16403
16712
  if (!match_1) return false;
16404
16713
  const inside = match_1.pos + 1;
16405
- const $pos = view_47.state.doc.resolve(inside);
16406
- view_47.dispatch(view_47.state.tr.setSelection(TextSelection.near($pos)));
16714
+ const $pos = view_46.state.doc.resolve(inside);
16715
+ view_46.dispatch(view_46.state.tr.setSelection(TextSelection.near($pos)));
16407
16716
  requestAnimationFrame(() => {
16408
16717
  pagedEditorRef.current?.scrollToPosition(inside);
16409
16718
  });
16410
16719
  return true;
16411
16720
  },
16412
- setContentControlContent: (filter_1, input, options_4 = {}) => {
16413
- const view_48 = pagedEditorRef.current?.getView();
16414
- if (!view_48) return false;
16415
- const tr_0 = typeof input === "string" ? setContentControlContentTr(view_48.state, filter_1, input, options_4) : setContentControlContentBlocksTr(view_48.state, filter_1, input, options_4);
16721
+ setContentControlContent: (filter_1, input, options_5 = {}) => {
16722
+ const view_47 = pagedEditorRef.current?.getView();
16723
+ if (!view_47) return false;
16724
+ const tr_0 = typeof input === "string" ? setContentControlContentTr(view_47.state, filter_1, input, options_5) : setContentControlContentBlocksTr(view_47.state, filter_1, input, options_5);
16416
16725
  if (!tr_0) return false;
16417
- view_48.dispatch(tr_0);
16726
+ view_47.dispatch(tr_0);
16418
16727
  return true;
16419
16728
  },
16420
- setContentControlValue: (filter_2, input_0, options_5 = {}) => {
16421
- const view_49 = pagedEditorRef.current?.getView();
16422
- if (!view_49) return false;
16423
- const tr_1 = setContentControlValueTr(view_49.state, filter_2, input_0, options_5);
16729
+ setContentControlValue: (filter_2, input_0, options_6 = {}) => {
16730
+ const view_48 = pagedEditorRef.current?.getView();
16731
+ if (!view_48) return false;
16732
+ const tr_1 = setContentControlValueTr(view_48.state, filter_2, input_0, options_6);
16424
16733
  if (!tr_1) return false;
16425
- view_49.dispatch(tr_1);
16734
+ view_48.dispatch(tr_1);
16426
16735
  return true;
16427
16736
  },
16428
- removeContentControl: (filter_3, options_6 = {}) => {
16429
- const view_50 = pagedEditorRef.current?.getView();
16430
- if (!view_50) return false;
16431
- const tr_2 = removeContentControlTr(view_50.state, filter_3, options_6);
16737
+ removeContentControl: (filter_3, options_7 = {}) => {
16738
+ const view_49 = pagedEditorRef.current?.getView();
16739
+ if (!view_49) return false;
16740
+ const tr_2 = removeContentControlTr(view_49.state, filter_3, options_7);
16432
16741
  if (!tr_2) return false;
16433
- view_50.dispatch(tr_2);
16742
+ view_49.dispatch(tr_2);
16434
16743
  return true;
16435
16744
  }
16436
16745
  }), [
@@ -16440,6 +16749,11 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16440
16749
  readOnlyReason,
16441
16750
  notifyReadonlyEditAttempt,
16442
16751
  scrollPageInfo,
16752
+ handleFind,
16753
+ handleFindNext,
16754
+ handleFindPrevious,
16755
+ getFindResult,
16756
+ resetFindResult,
16443
16757
  handleSave,
16444
16758
  setZoomWithViewportAnchor,
16445
16759
  zoomRef,
@@ -16518,47 +16832,47 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16518
16832
  if (isDisplayMode(value)) setDisplayMode(value);
16519
16833
  }, [setDisplayMode]);
16520
16834
  const handleAcceptActiveChange = useCallback(() => {
16521
- const view_51 = pagedEditorRef.current?.getView();
16522
- if (!view_51) return;
16523
- const { from: from_13, to: to_13 } = view_51.state.selection;
16524
- const range_7 = findChangeAtPosition(view_51.state, from_13, to_13);
16835
+ const view_50 = pagedEditorRef.current?.getView();
16836
+ if (!view_50) return;
16837
+ const { from: from_13, to: to_13 } = view_50.state.selection;
16838
+ const range_6 = findChangeAtPosition(view_50.state, from_13, to_13);
16525
16839
  if (resolveCanonicalReviewRange({
16526
16840
  editor: pagedEditorRef.current?.getEditor(),
16527
- ...range_7,
16841
+ ...range_6,
16528
16842
  resolution: "accept"
16529
- }) === null) acceptChange(range_7.from, range_7.to)(view_51.state, view_51.dispatch);
16843
+ }) === null) acceptChange(range_6.from, range_6.to)(view_50.state, view_50.dispatch);
16530
16844
  }, []);
16531
16845
  const handleRejectActiveChange = useCallback(() => {
16532
- const view_52 = pagedEditorRef.current?.getView();
16533
- if (!view_52) return;
16534
- const { from: from_14, to: to_14 } = view_52.state.selection;
16535
- const range_8 = findChangeAtPosition(view_52.state, from_14, to_14);
16846
+ const view_51 = pagedEditorRef.current?.getView();
16847
+ if (!view_51) return;
16848
+ const { from: from_14, to: to_14 } = view_51.state.selection;
16849
+ const range_7 = findChangeAtPosition(view_51.state, from_14, to_14);
16536
16850
  if (resolveCanonicalReviewRange({
16537
16851
  editor: pagedEditorRef.current?.getEditor(),
16538
- ...range_8,
16852
+ ...range_7,
16539
16853
  resolution: "reject"
16540
- }) === null) rejectChange(range_8.from, range_8.to)(view_52.state, view_52.dispatch);
16854
+ }) === null) rejectChange(range_7.from, range_7.to)(view_51.state, view_51.dispatch);
16541
16855
  }, []);
16542
16856
  const handlePreviousChange = useCallback(() => {
16543
- const view_53 = pagedEditorRef.current?.getView();
16544
- if (!view_53) return;
16545
- const { from: from_15 } = view_53.state.selection;
16546
- const change = findPreviousChange(view_53.state, from_15);
16857
+ const view_52 = pagedEditorRef.current?.getView();
16858
+ if (!view_52) return;
16859
+ const { from: from_15 } = view_52.state.selection;
16860
+ const change = findPreviousChange(view_52.state, from_15);
16547
16861
  if (!change) return;
16548
- view_53.dispatch(view_53.state.tr.setSelection(TextSelection.create(view_53.state.doc, change.from, change.to)));
16549
- view_53.focus();
16862
+ view_52.dispatch(view_52.state.tr.setSelection(TextSelection.create(view_52.state.doc, change.from, change.to)));
16863
+ view_52.focus();
16550
16864
  requestAnimationFrame(() => {
16551
16865
  pagedEditorRef.current?.scrollToPosition(change.from);
16552
16866
  });
16553
16867
  }, []);
16554
16868
  const handleNextChange = useCallback(() => {
16555
- const view_54 = pagedEditorRef.current?.getView();
16556
- if (!view_54) return;
16557
- const { to: to_15 } = view_54.state.selection;
16558
- const change_0 = findNextChange(view_54.state, to_15);
16869
+ const view_53 = pagedEditorRef.current?.getView();
16870
+ if (!view_53) return;
16871
+ const { to: to_15 } = view_53.state.selection;
16872
+ const change_0 = findNextChange(view_53.state, to_15);
16559
16873
  if (!change_0) return;
16560
- view_54.dispatch(view_54.state.tr.setSelection(TextSelection.create(view_54.state.doc, change_0.from, change_0.to)));
16561
- view_54.focus();
16874
+ view_53.dispatch(view_53.state.tr.setSelection(TextSelection.create(view_53.state.doc, change_0.from, change_0.to)));
16875
+ view_53.focus();
16562
16876
  requestAnimationFrame(() => {
16563
16877
  pagedEditorRef.current?.scrollToPosition(change_0.from);
16564
16878
  });
@@ -16728,52 +17042,52 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16728
17042
  requestAnimationFrame(syncCommentHighlightStyles);
16729
17043
  }, [onScrollTopChange, syncCommentHighlightStyles]);
16730
17044
  const handlePagedSelectionChange = useCallback((_from, _to) => {
16731
- const view_55 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
16732
- handleSelectionChange(view_55 ? extractSelectionState(view_55.state) : null);
17045
+ const view_54 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
17046
+ handleSelectionChange(view_54 ? extractSelectionState(view_54.state) : null);
16733
17047
  }, [getActiveEditorView, handleSelectionChange]);
16734
17048
  const handleTotalPagesChange = useCallback((totalPages) => {
16735
17049
  setScrollPageInfo((previous) => updateScrollPageTotal(previous, totalPages));
16736
17050
  }, [setScrollPageInfo]);
16737
- const handleCommentClick = useCallback((id) => setActiveCommentId(id), [setActiveCommentId]);
16738
- const handleCommentResolve = useCallback((id_0) => {
17051
+ const handleCommentClick = useCallback((id_0) => setActiveCommentId(id_0), [setActiveCommentId]);
17052
+ const handleCommentResolve = useCallback((id_1) => {
16739
17053
  if (applyCanonicalComment({
16740
17054
  type: "resolve",
16741
- id: id_0,
17055
+ id: id_1,
16742
17056
  status: "resolved"
16743
17057
  }) !== null) return;
16744
- updateComments((previous_0) => previous_0.map((comment_2) => comment_2.id === id_0 ? {
17058
+ updateComments((previous_0) => previous_0.map((comment_2) => comment_2.id === id_1 ? {
16745
17059
  ...comment_2,
16746
17060
  done: true
16747
17061
  } : comment_2));
16748
17062
  }, [applyCanonicalComment, updateComments]);
16749
- const handleCommentDelete = useCallback((id_1) => {
17063
+ const handleCommentDelete = useCallback((id_2) => {
16750
17064
  const result_5 = applyCanonicalComment({
16751
17065
  type: "delete",
16752
- id: id_1
17066
+ id: id_2
16753
17067
  });
16754
17068
  if (result_5 !== null) {
16755
- if (result_5.status === "applied" && activeCommentId === id_1) setActiveCommentId(null);
17069
+ if (result_5.status === "applied" && activeCommentId === id_2) setActiveCommentId(null);
16756
17070
  return;
16757
17071
  }
16758
- updateComments((previous_1) => previous_1.filter((comment_3) => comment_3.id !== id_1 && comment_3.parentId !== id_1));
16759
- if (activeCommentId === id_1) setActiveCommentId(null);
17072
+ updateComments((previous_1) => previous_1.filter((comment_3) => comment_3.id !== id_2 && comment_3.parentId !== id_2));
17073
+ if (activeCommentId === id_2) setActiveCommentId(null);
16760
17074
  }, [
16761
17075
  activeCommentId,
16762
17076
  applyCanonicalComment,
16763
17077
  setActiveCommentId,
16764
17078
  updateComments
16765
17079
  ]);
16766
- const handleCommentReply = useCallback((id_2, text_6) => {
17080
+ const handleCommentReply = useCallback((id_3, text_6) => {
16767
17081
  if (applyCanonicalComment({
16768
17082
  type: "create",
16769
17083
  text: text_6,
16770
17084
  author,
16771
17085
  anchor: {
16772
17086
  kind: "reply",
16773
- parentId: id_2
17087
+ parentId: id_3
16774
17088
  }
16775
17089
  }) !== null) return;
16776
- updateComments((previous_2) => [...previous_2, createComment(text_6, author, id_2)]);
17090
+ updateComments((previous_2) => [...previous_2, createComment(text_6, author, id_3)]);
16777
17091
  }, [
16778
17092
  applyCanonicalComment,
16779
17093
  author,
@@ -16781,8 +17095,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16781
17095
  updateComments
16782
17096
  ]);
16783
17097
  const handleAddComment = useCallback((addText) => {
16784
- const view_56 = pagedEditorRef.current?.getView();
16785
- if (!view_56 || !commentSelectionRange) return false;
17098
+ const view_55 = pagedEditorRef.current?.getView();
17099
+ if (!view_55 || !commentSelectionRange) return false;
16786
17100
  const result_6 = applyCanonicalComment({
16787
17101
  type: "create",
16788
17102
  text: addText,
@@ -16798,7 +17112,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16798
17112
  setVisibleCommentAuthors((current_0) => {
16799
17113
  if (current_0 === null) return null;
16800
17114
  const next_1 = new Set(current_0);
16801
- const created = result_6.comments.find(({ id: id_3 }) => id_3 === result_6.commentId);
17115
+ const created = result_6.comments.find(({ id: id_4 }) => id_4 === result_6.commentId);
16802
17116
  if (created) next_1.add(getCommentAuthorKey(created.author));
16803
17117
  return next_1;
16804
17118
  });
@@ -16809,7 +17123,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16809
17123
  return true;
16810
17124
  }
16811
17125
  const comment_4 = createComment(addText, author);
16812
- if (!applyCommentMarkRange(view_56, commentSelectionRange, comment_4.id, { replacePending: true })) return false;
17126
+ if (!applyCommentMarkRange(view_55, commentSelectionRange, comment_4.id, { replacePending: true })) return false;
16813
17127
  const commentAuthor_2 = getCommentAuthorKey(comment_4.author);
16814
17128
  setVisibleCommentAuthors((current_1) => {
16815
17129
  if (current_1 === null) return null;
@@ -16860,8 +17174,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16860
17174
  updateComments
16861
17175
  ]);
16862
17176
  const handleCancelAddComment = useCallback(() => {
16863
- const view_57 = pagedEditorRef.current?.getView();
16864
- if (view_57 && commentSelectionRange && commentDraftMode === "prosemirror") removePendingCommentMarkRange(view_57, commentSelectionRange);
17177
+ const view_56 = pagedEditorRef.current?.getView();
17178
+ if (view_56 && commentSelectionRange && commentDraftMode === "prosemirror") removePendingCommentMarkRange(view_56, commentSelectionRange);
16865
17179
  setIsAddingComment(false);
16866
17180
  setCommentSelectionRange(null);
16867
17181
  setAddCommentYPosition(null);
@@ -16878,23 +17192,23 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16878
17192
  })?.revisionId ?? null;
16879
17193
  }, []);
16880
17194
  const handleSidebarAcceptChange = useCallback((from_17, to_17) => {
16881
- const view_58 = pagedEditorRef.current?.getView();
16882
- if (!view_58) return;
17195
+ const view_57 = pagedEditorRef.current?.getView();
17196
+ if (!view_57) return;
16883
17197
  const revisionId_3 = resolveSidebarChangeRevisionId(from_17, to_17);
16884
17198
  if (revisionId_3 === null) return;
16885
17199
  const editor_7 = pagedEditorRef.current?.getEditor();
16886
17200
  if (editor_7?.getCanonicalDocument()) editor_7.resolveCanonicalRevisions([revisionId_3], "accept");
16887
- else acceptAIEditRevision(revisionId_3)(view_58.state, view_58.dispatch);
17201
+ else acceptAIEditRevision(revisionId_3)(view_57.state, view_57.dispatch);
16888
17202
  extractTrackedChanges();
16889
17203
  }, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
16890
17204
  const handleSidebarRejectChange = useCallback((from_18, to_18) => {
16891
- const view_59 = pagedEditorRef.current?.getView();
16892
- if (!view_59) return;
17205
+ const view_58 = pagedEditorRef.current?.getView();
17206
+ if (!view_58) return;
16893
17207
  const revisionId_4 = resolveSidebarChangeRevisionId(from_18, to_18);
16894
17208
  if (revisionId_4 === null) return;
16895
17209
  const editor_8 = pagedEditorRef.current?.getEditor();
16896
17210
  if (editor_8?.getCanonicalDocument()) editor_8.resolveCanonicalRevisions([revisionId_4], "reject");
16897
- else rejectAIEditRevision(revisionId_4)(view_59.state, view_59.dispatch);
17211
+ else rejectAIEditRevision(revisionId_4)(view_58.state, view_58.dispatch);
16898
17212
  extractTrackedChanges();
16899
17213
  }, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
16900
17214
  const commentsPageWidth = history.state?.package.document.finalSectionProperties?.pageWidth;
@@ -17029,9 +17343,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17029
17343
  };
17030
17344
  requestAnimationFrame(flash);
17031
17345
  }, []);
17032
- const handleOutlineJump = useCallback((id_4) => {
17033
- markHeadingJumped(id_4);
17034
- handleOutlineHeadingClick(Number(id_4));
17346
+ const handleOutlineJump = useCallback((id_5) => {
17347
+ markHeadingJumped(id_5);
17348
+ handleOutlineHeadingClick(Number(id_5));
17035
17349
  }, [handleOutlineHeadingClick, markHeadingJumped]);
17036
17350
  const handleTextContextAction = useCallback((action_3) => {
17037
17351
  handleContextMenuAction(action_3);
@@ -17044,8 +17358,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17044
17358
  }, [readOnly]);
17045
17359
  const closeTableProperties = useCallback(() => setTablePropsOpen(false), []);
17046
17360
  const applyTableProperties = useCallback((props_0) => {
17047
- const view_60 = getActiveEditorView();
17048
- if (view_60) setTableProperties(props_0)(view_60.state, view_60.dispatch);
17361
+ const view_59 = getActiveEditorView();
17362
+ if (view_59) setTableProperties(props_0)(view_59.state, view_59.dispatch);
17049
17363
  }, [getActiveEditorView]);
17050
17364
  const closeImagePosition = useCallback(() => setImagePositionOpen(false), [setImagePositionOpen]);
17051
17365
  const closeImageProperties = useCallback(() => setImagePropsOpen(false), [setImagePropsOpen]);
@@ -17053,28 +17367,37 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17053
17367
  const closeFootnoteProperties = useCallback(() => setFootnotePropsOpen(false), []);
17054
17368
  const closeInsertSymbol = useCallback(() => setShowInsertSymbol(false), []);
17055
17369
  const insertSymbol = useCallback((symbol) => {
17056
- const view_61 = getActiveEditorView();
17057
- if (view_61) view_61.dispatch(view_61.state.tr.insertText(symbol).scrollIntoView());
17370
+ const view_60 = getActiveEditorView();
17371
+ if (view_60) view_60.dispatch(view_60.state.tr.insertText(symbol).scrollIntoView());
17058
17372
  }, [getActiveEditorView]);
17059
17373
  const imagePropertiesCurrentData = useMemo(() => buildImagePropertiesData(state.pmImageContext), [state.pmImageContext]);
17374
+ const { close: closeFindDialog } = findReplace;
17060
17375
  const findReplaceDialog = useMemo(() => ({
17061
17376
  state: findReplace.state,
17062
- onClose: findReplace.close,
17377
+ onClose: () => {
17378
+ closeFindDialog();
17379
+ resetFindResult();
17380
+ },
17063
17381
  onFind: handleFind,
17382
+ onQueryChange: handleQueryChange,
17064
17383
  onFindNext: handleFindNext,
17065
17384
  onFindPrevious: handleFindPrevious,
17066
17385
  onReplace: handleReplace,
17067
17386
  onReplaceAll: handleReplaceAll,
17068
- currentResult: currentFindResult
17387
+ currentSearch: currentFindSearch,
17388
+ readOnly
17069
17389
  }), [
17070
- currentFindResult,
17071
- findReplace.close,
17390
+ currentFindSearch,
17391
+ readOnly,
17392
+ closeFindDialog,
17072
17393
  findReplace.state,
17073
17394
  handleFind,
17395
+ handleQueryChange,
17074
17396
  handleFindNext,
17075
17397
  handleFindPrevious,
17076
17398
  handleReplace,
17077
- handleReplaceAll
17399
+ handleReplaceAll,
17400
+ resetFindResult
17078
17401
  ]);
17079
17402
  const tablePropertiesDialog = useMemo(() => {
17080
17403
  const table = state.pmTableContext?.table;
@@ -17136,8 +17459,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17136
17459
  ]);
17137
17460
  const closeNumberingValueDialog = useCallback(() => setNumberingValueDialogOpen(false), []);
17138
17461
  const applyNumberingValue = useCallback((value_0) => {
17139
- const view_62 = getActiveEditorView();
17140
- if (view_62) setNumberingValue(value_0)(view_62.state, view_62.dispatch);
17462
+ const view_61 = getActiveEditorView();
17463
+ if (view_61) setNumberingValue(value_0)(view_61.state, view_61.dispatch);
17141
17464
  }, [getActiveEditorView]);
17142
17465
  const numberingValueDialog = useMemo(() => ({
17143
17466
  isOpen: numberingValueDialogOpen,
@@ -17158,6 +17481,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17158
17481
  showInsertSymbol
17159
17482
  ]);
17160
17483
  const containerStyle = {
17484
+ position: "relative",
17161
17485
  display: "flex",
17162
17486
  flexDirection: "column",
17163
17487
  height: "100%",
@@ -17437,8 +17761,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17437
17761
  onMouseDown: (e_1) => {
17438
17762
  e_1.preventDefault();
17439
17763
  e_1.stopPropagation();
17440
- const view_63 = pagedEditorRef.current?.getView();
17441
- if (!view_63) {
17764
+ const view_62 = pagedEditorRef.current?.getView();
17765
+ if (!view_62) {
17442
17766
  setFloatingCommentBtn(null);
17443
17767
  return;
17444
17768
  }
@@ -17446,9 +17770,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17446
17770
  from: floatingCommentBtn.from,
17447
17771
  to: floatingCommentBtn.to
17448
17772
  };
17449
- const currentSelection = view_63.state.selection;
17773
+ const currentSelection = view_62.state.selection;
17450
17774
  const safeRange = resolveCommentCreationRange({
17451
- docSize: view_63.state.doc.content.size,
17775
+ docSize: view_62.state.doc.content.size,
17452
17776
  capturedRange,
17453
17777
  currentRange: {
17454
17778
  from: currentSelection.from,
@@ -17463,7 +17787,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17463
17787
  }
17464
17788
  setCommentSelectionRange(safeRange);
17465
17789
  if (commentDraftMode === "prosemirror") {
17466
- if (!applyCommentMarkRange(view_63, safeRange, -1, { selectEnd: true })) {
17790
+ if (!applyCommentMarkRange(view_62, safeRange, -1, { selectEnd: true })) {
17467
17791
  setCommentSelectionRange(null);
17468
17792
  setFloatingCommentBtn(null);
17469
17793
  return;