@stll/folio-react 0.27.0 → 0.29.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.
@@ -1,6 +1,7 @@
1
- import { i as cn, n as FolioUIProvider, r as useFolioUI, t as DEFAULT_COMPONENTS } from "./folio-ui-rCHqCEG6.js";
1
+ import { i as cn, n as FolioUIProvider, r as useFolioUI, t as DEFAULT_COMPONENTS } from "./folio-ui-ruRywxeb.js";
2
2
  import { t as messages_exports } from "./messages.js";
3
3
  import { c } from "react-compiler-runtime";
4
+ import { readBlobText } from "@stll/folio-core/utils/textEncoding";
4
5
  import { CANONICAL_GAP, canonicalRefusalMessage, usesCanonicalSession } from "@stll/folio-core/types/canonicalCapabilities";
5
6
  import * as React$1 from "react";
6
7
  import React, { Component, Suspense, cloneElement, createContext, forwardRef, isValidElement, lazy, memo, useCallback, useEffect, useEffectEvent, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
@@ -16,7 +17,7 @@ import { createNoteReferenceFollower, withoutUnreferencedNotes } from "@stll/fol
16
17
  import { cloneDocumentWithParagraphPropertySources } from "@stll/folio-core/docx/document-clone";
17
18
  import { normalizeBaseDirection } from "@stll/folio-core/docx/normalizeBaseDirection";
18
19
  import { getCachedNumberingMap } from "@stll/folio-core/docx/numberingParser";
19
- import { classifyEditorKeydown, deleteSelectedTable, historyShortcutOwner, isFocusInInputLike, isKeydownInShortcutScope, isMacPlatform } from "@stll/folio-core/managers/editorShortcuts";
20
+ import { DEFAULT_KEYBOARD_SHORTCUT_SCOPE, classifyEditorKeydown, deleteSelectedTable, historyShortcutOwner, isFocusInInputLike, isKeydownInShortcutScope, isMacPlatform } from "@stll/folio-core/managers/editorShortcuts";
20
21
  import { getEditorScrollRoot, scrollEditorBy, scrollEditorElementIntoView, scrollEditorTo } from "@stll/folio-core/paged-layout/editorScrollRoot";
21
22
  import { computeScrollPageInfo, updateScrollPageTotal } from "@stll/folio-core/paged-layout/scrollPageInfo";
22
23
  import { NO_LIST_STATE, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, captureFormatMarks, clearFormatting, clearTextColor, continueNumbering, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, extractSelectionState, getDocumentBuiltInStyles, getSelectedText, getTableContext, increaseIndent, increaseListLevel, listStateLevel, mergeCells, removeTabStop, removeTableBorders, restartNumbering, sameListState, schema, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableProperties, setTextColor, splitCell, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "@stll/folio-core/prosemirror";
@@ -30,7 +31,7 @@ import { executeEditorCommand, executeFirstEditorCommand } from "@stll/folio-cor
30
31
  import { insertPageBreak } from "@stll/folio-core/prosemirror/commands/pageBreak";
31
32
  import { clearTrackedChanges, getChangedParagraphIds, hasStructuralChanges, hasUntrackedChanges, repackWithEditorSectionRemovals } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
32
33
  import { createStarterKit } from "@stll/folio-core/prosemirror/extensions/StarterKit";
33
- import { resolveFindMatchRange } from "@stll/folio-core/prosemirror/findReplaceSelection";
34
+ import { findInMarkupView, resolveFindMatchRange } from "@stll/folio-core/prosemirror/findReplaceSelection";
34
35
  import { createAICitationDecorationsPlugin } from "@stll/folio-core/prosemirror/plugins/aiCitationDecorations";
35
36
  import { AI_SUGGESTION_SEVERITY_CLASS, aiSuggestionDecorationsKey, createAISuggestionDecorationsPlugin } from "@stll/folio-core/prosemirror/plugins/aiSuggestionDecorations";
36
37
  import { anonymizationDecorationsKey, createAnonymizationDecorationsPlugin, slugAnonymizationLabel } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations";
@@ -81,7 +82,6 @@ import { clickToPosition } from "@stll/folio-core/layout-bridge/engine/clickToPo
81
82
  import { getPageTop, hitTestFragment, hitTestTableCell } from "@stll/folio-core/layout-bridge/engine/hitTest";
82
83
  import { clearAllCaches, resetCanvasContext } from "@stll/folio-core/layout-bridge/engine/measuring";
83
84
  import { resolveHeaderFooterSelectionGeometry } from "@stll/folio-core/render-dom/HeaderFooterSelectionOverlay";
84
- import { setEmbeddedFontFamilyMap } from "@stll/folio-core/utils/fontResolver";
85
85
  import { resolveSectionHeaderFooterRefs } from "@stll/folio-core/layout-engine";
86
86
  import { recordLayoutPhase } from "@stll/folio-core/layout-engine/layoutInstrumentation";
87
87
  import { LayoutPainter } from "@stll/folio-core/layout-painter";
@@ -113,7 +113,8 @@ import { ErrorManager } from "@stll/folio-core/managers/ErrorManager";
113
113
  import { ContextMenuManager } from "@stll/folio-core/managers/ContextMenuManager";
114
114
  import { DocumentLoaderManager } from "@stll/folio-core/managers/DocumentLoaderManager";
115
115
  import { getDocumentLoadSource } from "@stll/folio-core/utils/documentLoaderBehavior";
116
- import { DISPLAY_MODES, EditorModeManager, isReadOnlyMode, isTrackChangesMode, toggledTrackChangesMode } from "@stll/folio-core/managers/EditorModeManager";
116
+ import { DISPLAY_MODES, EditorModeManager, getEditorReadOnlyReason, getReviewViewReadOnlyReason, isTrackChangesMode, toggledTrackChangesMode } from "@stll/folio-core/managers/EditorModeManager";
117
+ import { reviewDisplayModeToDisplayMode } from "@stll/folio-core/managers/reviewDisplayMode";
117
118
  import { FindReplaceManager } from "@stll/folio-core/managers/FindReplaceManager";
118
119
  import { createEmptyHeaderFooter, pickActiveHeaderFooterRId, removeHeaderFooter, resolveEffectiveSectionProperties, resolveHeaderFooterContent, saveHeaderFooterContent } from "@stll/folio-core/utils/headerFooter";
119
120
  import { createCanonicalHeaderFooterOperation, removeCanonicalHeaderFooterOperations } from "@stll/folio-core/controller/canonicalOperations";
@@ -355,9 +356,10 @@ const HOST_STYLES = {
355
356
  zIndex: -1,
356
357
  pointerEvents: "none"
357
358
  };
358
- const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ document, styles, theme, onTransaction, experimentalSession, getCanonicalApi, onSessionRefusal }, ref) {
359
+ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ document, readOnly, styles, theme, onTransaction, experimentalSession, getCanonicalApi, onSessionRefusal }, ref) {
359
360
  const hostRef = useRef(null);
360
361
  const documentRef = useRef(document);
362
+ const readOnlyRef = useRef(readOnly);
361
363
  const stylesRef = useRef(styles);
362
364
  const themeRef = useRef(theme);
363
365
  const onTransactionRef = useRef(onTransaction);
@@ -367,6 +369,7 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
367
369
  const managerRef = useRef(null);
368
370
  useLayoutEffect(() => {
369
371
  documentRef.current = document;
372
+ readOnlyRef.current = readOnly;
370
373
  stylesRef.current = styles;
371
374
  themeRef.current = theme;
372
375
  onTransactionRef.current = onTransaction;
@@ -376,6 +379,7 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
376
379
  managerRef.current ??= createHeaderFooterEditorManager({
377
380
  getHost: () => hostRef.current,
378
381
  getDocument: () => documentRef.current,
382
+ getReadOnly: () => readOnlyRef.current ?? false,
379
383
  getStyles: () => stylesRef.current,
380
384
  getTheme: () => themeRef.current,
381
385
  getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
@@ -385,8 +389,10 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
385
389
  onTransactionRef.current?.(rId, kind, view, docChanged, selectionChanged);
386
390
  }
387
391
  });
392
+ managerRef.current.sync();
388
393
  }, [
389
394
  document,
395
+ readOnly,
390
396
  styles,
391
397
  theme,
392
398
  onTransaction,
@@ -394,9 +400,6 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
394
400
  experimentalSession,
395
401
  onSessionRefusal
396
402
  ]);
397
- useEffect(() => {
398
- managerRef.current?.sync();
399
- });
400
403
  useEffect(() => () => {
401
404
  managerRef.current?.destroy();
402
405
  }, []);
@@ -3045,7 +3048,7 @@ function buildFootnoteRenderItems(pageFootnoteMap, footnoteContentMap, doc) {
3045
3048
  * PagedEditor - Main paginated editing component.
3046
3049
  */
3047
3050
  const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3048
- const { document, documentIO, documentIdentity, experimentalSession, fonts: hostFonts, styles, theme: _theme, sectionProperties, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, pageRenderer, markupView, showMarginGuides = false, marginGuideColor, onDocumentChange, onReadOnlyEditAttempt, onCopy, onCut, onPaste, onSelectionChange, onSelectionTextChange, onEditorViewReady, externalPlugins = EMPTY_PLUGINS, showTemplateDirectives = true, collaboration, extensionManager, suggestionModeActive = false, suggestionAuthor, onActiveNoteStoryChange, onHeaderFooterDoubleClick, hfEditMode, activeHeaderFooterRId, onBodyClick, className, style, pageEndGutter = 0, sidebarOverlay, scrollContainerRef: scrollContainerRefProp, onHyperlinkClick, onContextMenu, onAnchorPositionsChange, onTotalPagesChange, onError, anchorPositionMode = "comments-and-revisions", onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
3051
+ const { document, documentIO, documentIdentity, experimentalSession, fonts: hostFonts, styles, theme: _theme, sectionProperties, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, pageRenderer, markupView, showCommentHighlights = true, showMarginGuides = false, marginGuideColor, onDocumentChange, onReadOnlyEditAttempt, onCopy, onCut, onPaste, onSelectionChange, onSelectionTextChange, onEditorViewReady, externalPlugins = EMPTY_PLUGINS, showTemplateDirectives = true, collaboration, extensionManager, suggestionModeActive = false, suggestionAuthor, onActiveNoteStoryChange, onHeaderFooterDoubleClick, hfEditMode, activeHeaderFooterRId, onBodyClick, className, style, pageEndGutter = 0, sidebarOverlay, scrollContainerRef: scrollContainerRefProp, onHyperlinkClick, onContextMenu, onAnchorPositionsChange, onTotalPagesChange, onError, anchorPositionMode = "comments-and-revisions", onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
3049
3052
  const getScrollContainer = useCallback(() => {
3050
3053
  if (scrollContainerRefProp && typeof scrollContainerRefProp === "object") return getEditorScrollRoot(scrollContainerRefProp.current);
3051
3054
  return getEditorScrollRoot(containerRef.current);
@@ -3069,7 +3072,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3069
3072
  const activeNoteStoryRef = useRef(null);
3070
3073
  const [noteStoryActive, setNoteStoryActive] = useState(false);
3071
3074
  const painterRef = useRef(null);
3072
- const noteStoryPlugins = useMemo(() => externalPlugins.filter(({ spec }) => spec.key === suggestionModeKey), [externalPlugins]);
3075
+ const noteStoryPlugins = useMemo(() => externalPlugins.filter((plugin) => suggestionModeKey.owns(plugin)), [externalPlugins]);
3073
3076
  const handleActiveNoteStoryChange = useCallback((story) => {
3074
3077
  activeNoteStoryRef.current = story;
3075
3078
  setNoteStoryActive(story !== null);
@@ -3322,6 +3325,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3322
3325
  const layoutInputSignature = useMemo(() => buildLayoutInputSignature({
3323
3326
  columns,
3324
3327
  markupView,
3328
+ showCommentHighlights,
3325
3329
  contentWidth,
3326
3330
  defaultTabStop,
3327
3331
  mirrorMargins,
@@ -3343,6 +3347,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3343
3347
  }), [
3344
3348
  columns,
3345
3349
  markupView,
3350
+ showCommentHighlights,
3346
3351
  contentWidth,
3347
3352
  defaultTabStop,
3348
3353
  mirrorMargins,
@@ -3417,7 +3422,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3417
3422
  emptyTemplatePreviewEntries: EMPTY_TEMPLATE_PREVIEW_ENTRIES,
3418
3423
  emptyTemplatePreviewHidden: EMPTY_TEMPLATE_PREVIEW_HIDDEN,
3419
3424
  hyphenationReadiness,
3420
- markupView
3425
+ markupView,
3426
+ showCommentHighlights
3421
3427
  }, state, options);
3422
3428
  if (outcome.blocks) setBlocks(outcome.blocks);
3423
3429
  if (outcome.measures !== void 0) setMeasures(outcome.measures);
@@ -3454,6 +3460,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3454
3460
  mirrorMargins,
3455
3461
  styles,
3456
3462
  markupView,
3463
+ showCommentHighlights,
3457
3464
  layoutInputSignature,
3458
3465
  hyphenationReadiness
3459
3466
  ]);
@@ -5533,7 +5540,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5533
5540
  setIsFocused(true);
5534
5541
  });
5535
5542
  };
5536
- if (layoutSessionRef.current.lastPmDoc?.eq(view_24.state.doc) && layoutSessionRef.current.lastMeasureInputs?.markupView === markupView) {
5543
+ if (layoutSessionRef.current.lastPmDoc?.eq(view_24.state.doc) && layoutSessionRef.current.lastMeasureInputs?.markupView === markupView && layoutSessionRef.current.lastMeasureInputs?.showCommentHighlights === (showCommentHighlights && markupView !== "no-markup" && markupView !== "original")) {
5537
5544
  const lastPreview = layoutSessionRef.current.lastTemplatePreview;
5538
5545
  if (templatePreviewRef.current.mode !== lastPreview.mode || templatePreviewDirtyRange(lastPreview, templatePreviewRef.current) !== null) runLayoutPipeline$1(view_24.state, { reason: "manual" });
5539
5546
  updateSelectionOverlay(view_24.state);
@@ -5574,7 +5581,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5574
5581
  updateAutocompleteOverlay,
5575
5582
  readOnly,
5576
5583
  refreshBodyImeCaretAnchor,
5577
- markupView
5584
+ markupView,
5585
+ showCommentHighlights
5578
5586
  ]);
5579
5587
  const handleEditorViewDestroy = useCallback(() => {
5580
5588
  onEditorViewReadyRef.current?.(null);
@@ -5638,7 +5646,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5638
5646
  }
5639
5647
  registered = faces;
5640
5648
  if (faces.length === 0 && familyMap.size === 0) return;
5641
- setEmbeddedFontFamilyMap(familyMap.size > 0 ? familyMap : null);
5649
+ layoutSessionRef.current.embeddedFontFamilyMap = new Map(familyMap);
5642
5650
  const view_26 = hiddenPMRef.current?.getView();
5643
5651
  if (!view_26) return;
5644
5652
  resetCanvasContext();
@@ -5649,7 +5657,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5649
5657
  return () => {
5650
5658
  cancelled_1 = true;
5651
5659
  removeFontFaces(registered);
5652
- setEmbeddedFontFamilyMap(null);
5660
+ delete layoutSessionRef.current.embeddedFontFamilyMap;
5653
5661
  };
5654
5662
  }, [embeddedFontBuffer, runtime]);
5655
5663
  useEffect(() => {
@@ -5962,6 +5970,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5962
5970
  /* @__PURE__ */ jsx(HiddenHeaderFooterPMs, {
5963
5971
  ref: hfPMsRef,
5964
5972
  document,
5973
+ readOnly,
5965
5974
  onTransaction: handleHfPmTransaction,
5966
5975
  getCanonicalApi,
5967
5976
  onSessionRefusal: handleSessionRefusal,
@@ -8339,14 +8348,14 @@ function _temp$10(heading) {
8339
8348
  }
8340
8349
  //#endregion
8341
8350
  //#region src/components/DocxEditorDialogs.tsx
8342
- const FindReplaceDialog = lazy(() => import("./FindReplaceDialog-LlVMe3EW.js").then((n) => n.n).then((m) => ({ default: m.FindReplaceDialog })));
8343
- const TablePropertiesDialog = lazy(() => import("./TablePropertiesDialog-Vu0HXQz6.js").then((n) => n.n).then((m) => ({ default: m.TablePropertiesDialog })));
8344
- const ImagePositionDialog = lazy(() => import("./ImagePositionDialog-Cwt6R8iM.js").then((n) => n.n).then((m) => ({ default: m.ImagePositionDialog })));
8345
- const ImagePropertiesDialog = lazy(() => import("./ImagePropertiesDialog-GNZLBFLB.js").then((n) => n.n).then((m) => ({ default: m.ImagePropertiesDialog })));
8346
- const FootnotePropertiesDialog = lazy(() => import("./FootnotePropertiesDialog-D73t3LNP.js").then((n) => n.n).then((m) => ({ default: m.FootnotePropertiesDialog })));
8347
- const PageSetupDialog = lazy(() => import("./PageSetupDialog-DD6IEZAo.js").then((n) => n.n).then((m) => ({ default: m.PageSetupDialog })));
8348
- const SetNumberingValueDialog = lazy(() => import("./SetNumberingValueDialog-CDQGDvP1.js").then((m) => ({ default: m.SetNumberingValueDialog })));
8349
- const InsertSymbolDialog = lazy(() => import("./InsertSymbolDialog-CeEhkEvc.js").then((n) => n.n).then((m) => ({ default: m.InsertSymbolDialog })));
8351
+ const FindReplaceDialog = lazy(() => import("./FindReplaceDialog-CUd8xdgd.js").then((n) => n.n).then((m) => ({ default: m.FindReplaceDialog })));
8352
+ const TablePropertiesDialog = lazy(() => import("./TablePropertiesDialog-uSTmyEcu.js").then((n) => n.n).then((m) => ({ default: m.TablePropertiesDialog })));
8353
+ const ImagePositionDialog = lazy(() => import("./ImagePositionDialog-Oap9knQ-.js").then((n) => n.n).then((m) => ({ default: m.ImagePositionDialog })));
8354
+ const ImagePropertiesDialog = lazy(() => import("./ImagePropertiesDialog-lLMKHv0u.js").then((n) => n.n).then((m) => ({ default: m.ImagePropertiesDialog })));
8355
+ const FootnotePropertiesDialog = lazy(() => import("./FootnotePropertiesDialog-BEs7N62_.js").then((n) => n.n).then((m) => ({ default: m.FootnotePropertiesDialog })));
8356
+ const PageSetupDialog = lazy(() => import("./PageSetupDialog-DTWCdPkX.js").then((n) => n.n).then((m) => ({ default: m.PageSetupDialog })));
8357
+ const SetNumberingValueDialog = lazy(() => import("./SetNumberingValueDialog-twVIZMLc.js").then((m) => ({ default: m.SetNumberingValueDialog })));
8358
+ const InsertSymbolDialog = lazy(() => import("./InsertSymbolDialog-Drm40-9j.js").then((n) => n.n).then((m) => ({ default: m.InsertSymbolDialog })));
8350
8359
  function DocxEditorDialogs(t0) {
8351
8360
  const $ = c(52);
8352
8361
  const { findReplace, tableProperties, imagePosition, imageProperties, pageSetup, footnoteProperties, insertSymbol, setNumberingValue } = t0;
@@ -10786,8 +10795,8 @@ const useDocumentLoader = (t0) => {
10786
10795
  * editing mode does not switch the display mode.
10787
10796
  */
10788
10797
  function useEditorMode(t0) {
10789
- const $ = c(24);
10790
- const { modeProp, onModeChange, readOnlyProp } = t0;
10798
+ const $ = c(28);
10799
+ const { modeProp, onModeChange, readOnlyProp, reviewDisplayMode } = t0;
10791
10800
  let t1;
10792
10801
  if ($[0] !== modeProp) {
10793
10802
  t1 = () => new EditorModeManager(modeProp ?? "editing");
@@ -10809,60 +10818,75 @@ function useEditorMode(t0) {
10809
10818
  $[5] = t2;
10810
10819
  } else t2 = $[5];
10811
10820
  const setEditingMode = t2;
10821
+ let effectiveDisplayMode;
10812
10822
  let t3;
10813
- if ($[6] !== editingMode || $[7] !== readOnlyProp) {
10814
- t3 = isReadOnlyMode(editingMode, readOnlyProp);
10815
- $[6] = editingMode;
10816
- $[7] = readOnlyProp;
10817
- $[8] = t3;
10818
- } else t3 = $[8];
10819
- const readOnly = t3;
10823
+ if ($[6] !== displayMode || $[7] !== editingMode || $[8] !== readOnlyProp || $[9] !== reviewDisplayMode) {
10824
+ effectiveDisplayMode = reviewDisplayMode === void 0 ? displayMode : reviewDisplayModeToDisplayMode(reviewDisplayMode);
10825
+ t3 = getEditorReadOnlyReason({
10826
+ editingMode,
10827
+ readOnlyProp,
10828
+ displayMode: effectiveDisplayMode
10829
+ });
10830
+ $[6] = displayMode;
10831
+ $[7] = editingMode;
10832
+ $[8] = readOnlyProp;
10833
+ $[9] = reviewDisplayMode;
10834
+ $[10] = effectiveDisplayMode;
10835
+ $[11] = t3;
10836
+ } else {
10837
+ effectiveDisplayMode = $[10];
10838
+ t3 = $[11];
10839
+ }
10840
+ const readOnlyReason = t3;
10841
+ const readOnly = readOnlyReason !== null;
10820
10842
  let t4;
10821
- if ($[9] !== editingMode) {
10843
+ if ($[12] !== editingMode) {
10822
10844
  t4 = isTrackChangesMode(editingMode);
10823
- $[9] = editingMode;
10824
- $[10] = t4;
10825
- } else t4 = $[10];
10845
+ $[12] = editingMode;
10846
+ $[13] = t4;
10847
+ } else t4 = $[13];
10826
10848
  const trackChangesOn = t4;
10827
10849
  let t5;
10828
- if ($[11] !== editingMode || $[12] !== setEditingMode) {
10850
+ if ($[14] !== editingMode || $[15] !== setEditingMode) {
10829
10851
  t5 = () => {
10830
10852
  setEditingMode(toggledTrackChangesMode(editingMode));
10831
10853
  };
10832
- $[11] = editingMode;
10833
- $[12] = setEditingMode;
10834
- $[13] = t5;
10835
- } else t5 = $[13];
10854
+ $[14] = editingMode;
10855
+ $[15] = setEditingMode;
10856
+ $[16] = t5;
10857
+ } else t5 = $[16];
10836
10858
  const toggleTrackChanges = t5;
10837
10859
  let t6;
10838
- if ($[14] !== manager) {
10860
+ if ($[17] !== manager) {
10839
10861
  t6 = (mode_0) => {
10840
10862
  manager.setDisplayMode(mode_0);
10841
10863
  };
10842
- $[14] = manager;
10843
- $[15] = t6;
10844
- } else t6 = $[15];
10864
+ $[17] = manager;
10865
+ $[18] = t6;
10866
+ } else t6 = $[18];
10845
10867
  const setDisplayMode = t6;
10846
10868
  let t7;
10847
- if ($[16] !== displayMode || $[17] !== editingMode || $[18] !== readOnly || $[19] !== setDisplayMode || $[20] !== setEditingMode || $[21] !== toggleTrackChanges || $[22] !== trackChangesOn) {
10869
+ if ($[19] !== editingMode || $[20] !== effectiveDisplayMode || $[21] !== readOnly || $[22] !== readOnlyReason || $[23] !== setDisplayMode || $[24] !== setEditingMode || $[25] !== toggleTrackChanges || $[26] !== trackChangesOn) {
10848
10870
  t7 = {
10849
10871
  editingMode,
10850
10872
  setEditingMode,
10851
10873
  readOnly,
10874
+ readOnlyReason,
10852
10875
  trackChangesOn,
10853
10876
  toggleTrackChanges,
10854
- displayMode,
10877
+ displayMode: effectiveDisplayMode,
10855
10878
  setDisplayMode
10856
10879
  };
10857
- $[16] = displayMode;
10858
- $[17] = editingMode;
10859
- $[18] = readOnly;
10860
- $[19] = setDisplayMode;
10861
- $[20] = setEditingMode;
10862
- $[21] = toggleTrackChanges;
10863
- $[22] = trackChangesOn;
10864
- $[23] = t7;
10865
- } else t7 = $[23];
10880
+ $[19] = editingMode;
10881
+ $[20] = effectiveDisplayMode;
10882
+ $[21] = readOnly;
10883
+ $[22] = readOnlyReason;
10884
+ $[23] = setDisplayMode;
10885
+ $[24] = setEditingMode;
10886
+ $[25] = toggleTrackChanges;
10887
+ $[26] = trackChangesOn;
10888
+ $[27] = t7;
10889
+ } else t7 = $[27];
10866
10890
  return t7;
10867
10891
  }
10868
10892
  //#endregion
@@ -10880,71 +10904,130 @@ function useEditorMode(t0) {
10880
10904
  * from `dialogs/useFindReplace.ts`; this hook layers the document-aware
10881
10905
  * operations (find, replace, scroll-to-match) on top.
10882
10906
  */
10907
+ const toEditorFindMatch = ({ from, to, ...match }) => ({
10908
+ ...match,
10909
+ contentIndex: 0,
10910
+ authoredRange: {
10911
+ from,
10912
+ to
10913
+ }
10914
+ });
10883
10915
  function useFindReplace(t0) {
10884
- const $ = c(35);
10885
- const { documentState, getDocumentState, containerRef, handleDocumentChange, findReplace, selectMatch } = 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";
10886
10919
  let t1;
10887
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
10888
- t1 = new FindReplaceManager();
10889
- $[0] = t1;
10890
- } else t1 = $[0];
10891
- const manager = t1;
10920
+ if ($[0] !== markupView || $[1] !== readOnlyReason) {
10921
+ t1 = getReviewViewReadOnlyReason(markupView) ?? readOnlyReason ?? null;
10922
+ $[0] = markupView;
10923
+ $[1] = readOnlyReason;
10924
+ $[2] = t1;
10925
+ } else t1 = $[2];
10926
+ const replacementRefusal = t1;
10927
+ let t2;
10928
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
10929
+ t2 = new FindReplaceManager();
10930
+ $[3] = t2;
10931
+ } else t2 = $[3];
10932
+ const manager = t2;
10892
10933
  const [currentResult, setCurrentResult] = useState(null);
10934
+ const activeSearch = useRef(null);
10893
10935
  const { setMatches, goToMatch } = findReplace;
10894
- let t2;
10895
- if ($[1] !== setMatches) {
10896
- t2 = () => {
10936
+ let t3;
10937
+ if ($[4] !== setMatches) {
10938
+ t3 = () => {
10939
+ activeSearch.current = null;
10897
10940
  manager.clear();
10898
10941
  setCurrentResult(null);
10899
10942
  setMatches([], 0);
10900
10943
  };
10901
- $[1] = setMatches;
10902
- $[2] = t2;
10903
- } else t2 = $[2];
10904
- const resetFindResult = t2;
10905
- let t3;
10906
- if ($[3] !== documentState || $[4] !== getDocumentState) {
10907
- t3 = () => getDocumentState?.() ?? documentState ?? null;
10908
- $[3] = documentState;
10909
- $[4] = getDocumentState;
10944
+ $[4] = setMatches;
10910
10945
  $[5] = t3;
10911
10946
  } else t3 = $[5];
10912
- const readDocumentState = t3;
10947
+ const resetFindResult = t3;
10913
10948
  let t4;
10914
- if ($[6] !== containerRef || $[7] !== selectMatch) {
10915
- t4 = (match) => {
10916
- if (!selectMatch?.(match) && containerRef.current) scrollToMatch(containerRef.current, match);
10917
- };
10918
- $[6] = containerRef;
10919
- $[7] = selectMatch;
10949
+ if ($[6] !== documentState || $[7] !== getDocumentState) {
10950
+ t4 = () => getDocumentState?.() ?? documentState ?? null;
10951
+ $[6] = documentState;
10952
+ $[7] = getDocumentState;
10920
10953
  $[8] = t4;
10921
10954
  } else t4 = $[8];
10922
- const revealMatch = t4;
10955
+ const readDocumentState = t4;
10923
10956
  let t5;
10924
- if ($[9] !== readDocumentState || $[10] !== resetFindResult || $[11] !== revealMatch || $[12] !== setMatches) {
10925
- t5 = (searchText, options) => {
10957
+ if ($[9] !== containerRef || $[10] !== selectMatch) {
10958
+ t5 = (match) => {
10959
+ if (!selectMatch?.(match) && containerRef.current) scrollToMatch(containerRef.current, match);
10960
+ };
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) => {
10926
10969
  const currentDocument = readDocumentState();
10927
10970
  if (!currentDocument || !searchText.trim()) {
10928
10971
  resetFindResult();
10929
10972
  return null;
10930
10973
  }
10931
- const matches = findInDocument(currentDocument, searchText, options);
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);
10988
+ }
10989
+ activeSearch.current = {
10990
+ searchText,
10991
+ options
10992
+ };
10932
10993
  const result = manager.setMatches(matches);
10933
10994
  setCurrentResult(result);
10934
10995
  setMatches(matches, 0);
10935
10996
  if (matches.length > 0) revealMatch(matches[0]);
10936
10997
  return result;
10937
10998
  };
10938
- $[9] = readDocumentState;
10939
- $[10] = resetFindResult;
10940
- $[11] = revealMatch;
10941
- $[12] = setMatches;
10942
- $[13] = t5;
10943
- } else t5 = $[13];
10944
- const handleFind = t5;
10945
- let t6;
10946
- if ($[14] !== goToMatch || $[15] !== revealMatch) {
10947
- t6 = () => {
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);
11017
+ };
11018
+ t8 = [markupView, handleFind];
11019
+ $[19] = handleFind;
11020
+ $[20] = markupView;
11021
+ $[21] = t7;
11022
+ $[22] = t8;
11023
+ } else {
11024
+ t7 = $[21];
11025
+ t8 = $[22];
11026
+ }
11027
+ useEffect(t7, t8);
11028
+ let t9;
11029
+ if ($[23] !== goToMatch || $[24] !== revealMatch) {
11030
+ t9 = () => {
10948
11031
  const stepped = manager.navigate("next");
10949
11032
  if (!stepped) return null;
10950
11033
  setCurrentResult(manager.getResult());
@@ -10952,14 +11035,14 @@ function useFindReplace(t0) {
10952
11035
  revealMatch(stepped.match);
10953
11036
  return stepped.match;
10954
11037
  };
10955
- $[14] = goToMatch;
10956
- $[15] = revealMatch;
10957
- $[16] = t6;
10958
- } else t6 = $[16];
10959
- const handleFindNext = t6;
10960
- let t7;
10961
- if ($[17] !== goToMatch || $[18] !== revealMatch) {
10962
- t7 = () => {
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 = () => {
10963
11046
  const stepped_0 = manager.navigate("previous");
10964
11047
  if (!stepped_0) return null;
10965
11048
  setCurrentResult(manager.getResult());
@@ -10967,14 +11050,14 @@ function useFindReplace(t0) {
10967
11050
  revealMatch(stepped_0.match);
10968
11051
  return stepped_0.match;
10969
11052
  };
10970
- $[17] = goToMatch;
10971
- $[18] = revealMatch;
10972
- $[19] = t7;
10973
- } else t7 = $[19];
10974
- const handleFindPrevious = t7;
10975
- let t8;
10976
- if ($[20] !== handleDocumentChange || $[21] !== readDocumentState) {
10977
- t8 = (replaceText) => {
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) => {
10978
11061
  const currentDocument_0 = readDocumentState();
10979
11062
  if (!currentDocument_0) return false;
10980
11063
  const newDoc = manager.replaceCurrent(currentDocument_0, replaceText);
@@ -10982,14 +11065,14 @@ function useFindReplace(t0) {
10982
11065
  handleDocumentChange(newDoc);
10983
11066
  return true;
10984
11067
  };
10985
- $[20] = handleDocumentChange;
10986
- $[21] = readDocumentState;
10987
- $[22] = t8;
10988
- } else t8 = $[22];
10989
- const handleReplace = t8;
10990
- let t9;
10991
- if ($[23] !== handleDocumentChange || $[24] !== readDocumentState || $[25] !== resetFindResult) {
10992
- t9 = (searchText_0, replaceText_0, options_0) => {
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) => {
10993
11076
  const currentDocument_1 = readDocumentState();
10994
11077
  if (!currentDocument_1 || !searchText_0.trim()) return 0;
10995
11078
  const matches_0 = findInDocument(currentDocument_1, searchText_0, options_0);
@@ -10999,33 +11082,56 @@ function useFindReplace(t0) {
10999
11082
  resetFindResult();
11000
11083
  return outcome.replacedCount;
11001
11084
  };
11002
- $[23] = handleDocumentChange;
11003
- $[24] = readDocumentState;
11004
- $[25] = resetFindResult;
11005
- $[26] = t9;
11006
- } else t9 = $[26];
11007
- const handleReplaceAll = t9;
11008
- let t10;
11009
- if ($[27] !== currentResult || $[28] !== handleFind || $[29] !== handleFindNext || $[30] !== handleFindPrevious || $[31] !== handleReplace || $[32] !== handleReplaceAll || $[33] !== resetFindResult) {
11010
- t10 = {
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 = () => {
11094
+ if (replacementRefusal) onReadonlyEditAttempt?.(replacementRefusal);
11095
+ return false;
11096
+ };
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 = () => {
11105
+ refuseReplace();
11106
+ return 0;
11107
+ };
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 = {
11011
11117
  currentResult,
11012
11118
  resetFindResult,
11013
11119
  handleFind,
11014
11120
  handleFindNext,
11015
11121
  handleFindPrevious,
11016
- handleReplace,
11017
- handleReplaceAll
11122
+ handleReplace: t15,
11123
+ handleReplaceAll: t16
11018
11124
  };
11019
- $[27] = currentResult;
11020
- $[28] = handleFind;
11021
- $[29] = handleFindNext;
11022
- $[30] = handleFindPrevious;
11023
- $[31] = handleReplace;
11024
- $[32] = handleReplaceAll;
11025
- $[33] = resetFindResult;
11026
- $[34] = t10;
11027
- } else t10 = $[34];
11028
- return t10;
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;
11029
11135
  }
11030
11136
  //#endregion
11031
11137
  //#region src/components/hooks/useHeaderFooterEditor.ts
@@ -11945,7 +12051,7 @@ function roundZoom(zoom) {
11945
12051
  * React hook for Ctrl+scroll zoom functionality
11946
12052
  */
11947
12053
  function useWheelZoom(options = {}) {
11948
- const { initialZoom = DEFAULT_INITIAL_ZOOM, minZoom = DEFAULT_MIN_ZOOM, maxZoom = DEFAULT_MAX_ZOOM, zoomStep = DEFAULT_ZOOM_STEP, enabled = true, containerRef, getCurrentZoom, onZoomChange, keyboardShortcuts = "document", shortcutRoots = NO_SHORTCUT_ROOTS, preventDefault = true } = options;
12054
+ const { initialZoom = DEFAULT_INITIAL_ZOOM, minZoom = DEFAULT_MIN_ZOOM, maxZoom = DEFAULT_MAX_ZOOM, zoomStep = DEFAULT_ZOOM_STEP, enabled = true, containerRef, getCurrentZoom, onZoomChange, keyboardShortcuts = DEFAULT_KEYBOARD_SHORTCUT_SCOPE, shortcutRoots = NO_SHORTCUT_ROOTS, preventDefault = true } = options;
11949
12055
  const [zoom, setZoomState] = useState(initialZoom);
11950
12056
  const zoomRef = useRef(zoom);
11951
12057
  useEffect(() => {
@@ -13819,7 +13925,7 @@ function _temp(id_4) {
13819
13925
  */
13820
13926
  /** No headings to track while the outline is not shown. */
13821
13927
  const NO_HEADINGS = [];
13822
- const CommentsSidebar = lazy(() => import("./CommentsSidebar-BbwdJakm.js").then((m) => ({ default: m.CommentsSidebar })));
13928
+ const CommentsSidebar = lazy(() => import("./CommentsSidebar-D7eTgHpL.js").then((m) => ({ default: m.CommentsSidebar })));
13823
13929
  const TextContextMenu = lazy(() => import("./TextContextMenu-DZ3AUFKh.js").then((m) => ({ default: m.TextContextMenu })));
13824
13930
  const loadAttemptSelectiveSave = async () => {
13825
13931
  const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
@@ -13921,7 +14027,7 @@ const createPagedEditorBinding = () => {
13921
14027
  /**
13922
14028
  * DocxEditor - Complete DOCX editor component
13923
14029
  */
13924
- 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 = "document", hostShortcuts: hostShortcutsProp, readOnly: readOnlyProp = false, 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) {
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) {
13925
14031
  const pagedEditorRef = useRef(null);
13926
14032
  const [pagedEditorBinding] = useState(createPagedEditorBinding);
13927
14033
  const scrollContainerRef = useRef(null);
@@ -13976,10 +14082,11 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13976
14082
  setTrackedChangeEntries(entries);
13977
14083
  }, []);
13978
14084
  const [anchorPositions, setAnchorPositions] = useState(EMPTY_ANCHOR_POSITIONS);
13979
- const { editingMode, readOnly, trackChangesOn, toggleTrackChanges, displayMode, setDisplayMode } = useEditorMode({
14085
+ const { editingMode, readOnly, readOnlyReason, trackChangesOn, toggleTrackChanges, displayMode, setDisplayMode } = useEditorMode({
13980
14086
  modeProp,
13981
14087
  onModeChange,
13982
- readOnlyProp
14088
+ readOnlyProp,
14089
+ ...reviewDisplayMode === void 0 ? {} : { reviewDisplayMode }
13983
14090
  });
13984
14091
  useEffect(() => {
13985
14092
  pagedEditorRef.current?.getEditor().setCanonicalMode(editingMode === "suggesting" ? {
@@ -14322,6 +14429,13 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14322
14429
  ...!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? {} : { experimentalSession },
14323
14430
  getHfView: pagedEditorBinding.getHfView
14324
14431
  });
14432
+ useLayoutEffect(() => {
14433
+ if (readOnly && hfEditPosition) handleBodyClick();
14434
+ }, [
14435
+ readOnly,
14436
+ hfEditPosition,
14437
+ handleBodyClick
14438
+ ]);
14325
14439
  let activeHfRId = hfEditIsFirstPage ? activeFirstFooterRId : activeFooterRId;
14326
14440
  if (hfEditPosition === "header") activeHfRId = hfEditIsFirstPage ? activeFirstHeaderRId : activeHeaderRId;
14327
14441
  const visibleOutlineHeadings = useMemo(() => filterHeadingsByDepth(outlineHeadings, outlineDepth), [outlineDepth, outlineHeadings]);
@@ -14671,23 +14785,31 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14671
14785
  canonicalCommentsSerialized,
14672
14786
  onCommentsChange
14673
14787
  ]);
14788
+ 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;
14799
+ }, []);
14800
+ const notifyReadonlyEditAttempt = useCallback(() => {
14801
+ if (readOnlyReason) onReadonlyEditAttempt?.(readOnlyReason);
14802
+ }, [readOnlyReason, onReadonlyEditAttempt]);
14674
14803
  const { currentResult: currentFindResult, resetFindResult, handleFind, handleFindNext, handleFindPrevious, handleReplace, handleReplaceAll } = useFindReplace({
14675
14804
  getDocumentState: buildCurrentDocument,
14805
+ getEditorState: () => pagedEditorRef.current?.getView()?.state ?? null,
14806
+ markupView: displayMode,
14676
14807
  containerRef,
14677
14808
  handleDocumentChange,
14678
14809
  findReplace,
14679
- selectMatch: useCallback((match) => {
14680
- const editor_1 = pagedEditorRef.current;
14681
- const view_8 = editor_1?.getView();
14682
- if (!editor_1 || !view_8) return false;
14683
- const range = resolveFindMatchRange(view_8.state.doc, match);
14684
- if (!range) return false;
14685
- editor_1.setSelection(range.from, range.to);
14686
- requestAnimationFrame(() => {
14687
- editor_1.scrollToPosition(range.from);
14688
- });
14689
- return true;
14690
- }, [])
14810
+ selectMatch: selectFindMatch,
14811
+ readOnlyReason,
14812
+ onReadonlyEditAttempt
14691
14813
  });
14692
14814
  useLayoutEffect(() => {
14693
14815
  resetFindResultRef.current = resetFindResult;
@@ -15480,8 +15602,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15480
15602
  let html = "";
15481
15603
  let text_1 = "";
15482
15604
  for (const item_1 of items_0) {
15483
- if (item_1.types.includes("text/html")) html = await (await item_1.getType("text/html")).text();
15484
- if (item_1.types.includes("text/plain")) text_1 = await (await item_1.getType("text/plain")).text();
15605
+ if (item_1.types.includes("text/html")) html = await readBlobText(await item_1.getType("text/html"));
15606
+ if (item_1.types.includes("text/plain")) text_1 = await readBlobText(await item_1.getType("text/plain"));
15485
15607
  }
15486
15608
  const dt = new DataTransfer();
15487
15609
  if (html) dt.items.add(html, "text/html");
@@ -15786,6 +15908,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15786
15908
  onError?.(error_1);
15787
15909
  }, [onError]);
15788
15910
  useImperativeHandle(ref, () => ({
15911
+ getReadOnlyReason: () => readOnlyReason,
15789
15912
  getDocument: () => buildCurrentDocument(),
15790
15913
  hasPendingChanges: () => {
15791
15914
  const view_21 = pagedEditorRef.current?.getView();
@@ -15812,6 +15935,10 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15812
15935
  openFind(readFindSelectionSeed());
15813
15936
  },
15814
15937
  openReplace: () => {
15938
+ if (readOnlyReason) {
15939
+ notifyReadonlyEditAttempt();
15940
+ return;
15941
+ }
15815
15942
  openReplace(readFindSelectionSeed());
15816
15943
  },
15817
15944
  loadDocument: (document_0) => {
@@ -16234,7 +16361,12 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16234
16361
  getPageText: (page_1) => {
16235
16362
  const view_44 = pagedEditorRef.current?.getView();
16236
16363
  if (!view_44) return null;
16237
- return getPageTextFromLayout(pagedEditorRef.current?.getEditor()?.getLayout() ?? null, view_44.state.doc, page_1);
16364
+ return getPageTextFromLayout({
16365
+ layout: pagedEditorRef.current?.getEditor()?.getLayout() ?? null,
16366
+ doc: view_44.state.doc,
16367
+ page: page_1,
16368
+ projection: projectMarkupView(view_44.state, displayMode)
16369
+ });
16238
16370
  },
16239
16371
  getTargetPage: (target_2, snapshot_6) => {
16240
16372
  const view_45 = pagedEditorRef.current?.getView();
@@ -16304,6 +16436,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16304
16436
  }), [
16305
16437
  author,
16306
16438
  buildCurrentDocument,
16439
+ displayMode,
16440
+ readOnlyReason,
16441
+ notifyReadonlyEditAttempt,
16307
16442
  scrollPageInfo,
16308
16443
  handleSave,
16309
16444
  setZoomWithViewportAnchor,
@@ -17242,6 +17377,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17242
17377
  documentIO,
17243
17378
  documentIdentity: loadedDocumentIdentity,
17244
17379
  markupView: displayMode,
17380
+ showCommentHighlights,
17245
17381
  ...fonts !== void 0 ? { fonts } : {},
17246
17382
  theme: history.state.package.theme || theme || null,
17247
17383
  sectionProperties: effectiveSectionProperties ?? null,
@@ -17272,7 +17408,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17272
17408
  ...onCopy !== void 0 ? { onCopy } : {},
17273
17409
  ...onCut !== void 0 ? { onCut } : {},
17274
17410
  ...onPaste !== void 0 ? { onPaste } : {},
17275
- ...onReadonlyEditAttempt !== void 0 ? { onReadOnlyEditAttempt: onReadonlyEditAttempt } : {},
17411
+ ...onReadonlyEditAttempt !== void 0 ? { onReadOnlyEditAttempt: notifyReadonlyEditAttempt } : {},
17276
17412
  onSelectionChange: handlePagedSelectionChange,
17277
17413
  ...onSelectionTextChange !== void 0 ? { onSelectionTextChange } : {},
17278
17414
  onEditorViewReady: handleBodyViewReady,