@stll/folio-react 0.23.0 → 0.24.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,12 +1,12 @@
1
- import { i as cn, n as FolioUIProvider, r as useFolioUI, t as DEFAULT_COMPONENTS } from "./folio-ui-BgDDRsUX.js";
1
+ import { i as cn, n as FolioUIProvider, r as useFolioUI, t as DEFAULT_COMPONENTS } from "./folio-ui-DO95voaI.js";
2
2
  import { t as messages_exports } from "./messages.js";
3
3
  import { c } from "react-compiler-runtime";
4
4
  import * as React$1 from "react";
5
5
  import React, { Component, Suspense, cloneElement, createContext, forwardRef, isValidElement, lazy, memo, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
6
- import { AlertCircleIcon, AlertTriangleIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, BaselineIcon, BoldIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ClipboardCopyIcon, EyeIcon, FileIcon, GlobeIcon, ImageIcon, IndentDecreaseIcon, IndentIncreaseIcon, InfoIcon, ItalicIcon, LinkIcon, ListIcon, ListOrderedIcon, MoreHorizontalIcon, OmegaIcon, PaintbrushIcon, PenLineIcon, PencilIcon, PilcrowIcon, Redo2Icon, RulerIcon, SeparatorHorizontalIcon, SquarePenIcon, StickyNoteIcon, TableIcon, TableOfContentsIcon, TypeIcon, UnderlineIcon, Undo2Icon, UnlinkIcon, XIcon } from "lucide-react";
6
+ import { AlertCircleIcon, AlertTriangleIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, BaselineIcon, BoldIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ClipboardCopyIcon, EyeIcon, FileIcon, GlobeIcon, ImageIcon, IndentDecreaseIcon, IndentIncreaseIcon, InfoIcon, ItalicIcon, LinkIcon, ListIcon, ListOrderedIcon, ListTreeIcon, MessageSquareTextIcon, MoreHorizontalIcon, OmegaIcon, PaintbrushIcon, PanelLeftOpenIcon, PenLineIcon, PencilIcon, PilcrowIcon, Redo2Icon, RulerIcon, SeparatorHorizontalIcon, SquarePenIcon, StickyNoteIcon, TableIcon, TableOfContentsIcon, TypeIcon, UnderlineIcon, Undo2Icon, UnlinkIcon, XIcon } from "lucide-react";
7
7
  import { closeHistory, redo, undo } from "prosemirror-history";
8
- import { IntlProvider, useTranslations } from "use-intl";
9
- import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, createFolioAIEditSnapshot, getCommentAnchorsFromDoc, getFolioDocumentOperationIssues, getTrackedChangesFromDoc } from "@stll/folio-core/ai-edits";
8
+ import { IntlProvider, useFormatter, useTranslations } from "use-intl";
9
+ import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FolioPendingSuggestionRegistry, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, createFolioAIEditSnapshot, createPendingSuggestionSourceSnapshot, getCommentAnchorsFromDoc, getFolioDocumentOperationIssues, getTrackedChangesFromDoc } from "@stll/folio-core/ai-edits";
10
10
  import { resolveActiveEditorStory } from "@stll/folio-core/controller/activeEditorStory";
11
11
  import { FOLIO_DOCX_SERIALIZATION_MODE, createFolioEditor } from "@stll/folio-core/controller/folioEditor";
12
12
  import { cloneDocumentWithParagraphPropertySources } from "@stll/folio-core/docx/document-clone";
@@ -14,14 +14,14 @@ import { normalizeBaseDirection } from "@stll/folio-core/docx/normalizeBaseDirec
14
14
  import { getCachedNumberingMap } from "@stll/folio-core/docx/numberingParser";
15
15
  import { classifyEditorKeydown, deleteSelectedTable, historyShortcutOwner, isFocusInInputLike, isKeydownInShortcutScope, isMacPlatform } from "@stll/folio-core/managers/editorShortcuts";
16
16
  import { computeScrollPageInfo, updateScrollPageTotal } from "@stll/folio-core/paged-layout/scrollPageInfo";
17
- import { NO_LIST_STATE, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, captureFormatMarks, clearFormatting, clearTextColor, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, extractSelectionState, getDocumentBuiltInStyles, getSelectedText, getTableContext, increaseIndent, increaseListLevel, listStateLevel, mergeCells, removeTabStop, removeTableBorders, sameListState, schema, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, 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";
17
+ 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";
18
18
  import { acceptAIEditRevision, acceptChange, acceptSuggestion, findAIEditRevisionRange, findChangeAtPosition, findNextChange, findParagraphBoundaryChangeAtPosition, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectChange, rejectSuggestion } from "@stll/folio-core/prosemirror/commands/comments";
19
19
  import { blockSdtAttrsToSdtProperties, findBlockSdtMatch, findBlockSdtMatches, removeContentControlTr, setContentControlContentTr, setContentControlValueTr } from "@stll/folio-core/prosemirror/commands/contentControls";
20
20
  import { setContentControlContentBlocksTr } from "@stll/folio-core/prosemirror/commands/contentControlsBlockFill";
21
21
  import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice } from "@stll/folio-core/prosemirror/commands/pastePlainText";
22
22
  import { proseDocToBlocks } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
23
23
  import { ExtensionManager } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
24
- import { clearTrackedChanges, getChangedParagraphIds, hasStructuralChanges, hasUntrackedChanges } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
24
+ import { clearTrackedChanges, getChangedParagraphIds, hasStructuralChanges, hasUntrackedChanges, repackWithEditorSectionRemovals } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
25
25
  import { createStarterKit } from "@stll/folio-core/prosemirror/extensions/StarterKit";
26
26
  import { resolveFindMatchRange } from "@stll/folio-core/prosemirror/findReplaceSelection";
27
27
  import { createAICitationDecorationsPlugin } from "@stll/folio-core/prosemirror/plugins/aiCitationDecorations";
@@ -29,7 +29,7 @@ import { AI_SUGGESTION_SEVERITY_CLASS, aiSuggestionDecorationsKey, createAISugge
29
29
  import { anonymizationDecorationsKey, createAnonymizationDecorationsPlugin, slugAnonymizationLabel } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations";
30
30
  import { expectImageAttrs, expectTableAttrs, expectTableCellAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "@stll/folio-core/prosemirror/attrs";
31
31
  import { autocompleteSuggestionKey, autocompleteSuggestionPlugin } from "@stll/folio-core/prosemirror/plugins/autocompleteSuggestion";
32
- import { createSuggestionModePlugin, setSuggestionMode, suggestionModeKey } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
32
+ import { createSuggestionModePlugin, deleteSelectionAsSuggestion, setSuggestionMode, suggestionModeKey } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
33
33
  import { createTemplateDirectivesPlugin, templateDirectivesKey } from "@stll/folio-core/prosemirror/plugins/templateDirectives";
34
34
  import { createTemplatePreviewValuesPlugin, templatePreviewValuesKey } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
35
35
  import { getTemplateSlashMenu, templateSlashMenuPlugin } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
@@ -40,21 +40,23 @@ import { collectHeadings } from "@stll/folio-core/utils/headingCollector";
40
40
  import { formatPx, pixelsToTwips, pointsToHalfPoints, twipsToPixels } from "@stll/folio-core/utils/units";
41
41
  import { HistoryManager, classifyHistoryShortcut } from "@stll/folio-core/managers/HistoryManager";
42
42
  import { TableSelectionManager } from "@stll/folio-core/managers/TableSelectionManager";
43
+ import { DEFAULT_PAGE_HEIGHT_PX, getMargins, getPageSize, twipsToPixels as twipsToPixels$1 } from "@stll/folio-core/paged-layout/sectionGeometry";
43
44
  import { createPortal } from "react-dom";
44
45
  import { NodeSelection, Selection, TextSelection as TextSelection$1 } from "prosemirror-state";
45
46
  import { CellSelection } from "prosemirror-tables";
46
47
  import { createHeaderFooterEditorManager } from "@stll/folio-core/controller/headerFooterEditorManager";
47
48
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
48
49
  import { createNoteEditorManager } from "@stll/folio-core/controller/noteEditorManager";
50
+ import { projectMarkupView, visibleCaretPosition } from "@stll/folio-core/prosemirror/markupViewProjection";
49
51
  import { createFolioAIEditSnapshot as createFolioAIEditSnapshot$1 } from "@stll/folio-core/ai-edits/snapshot";
50
52
  import { createFolioEditorEmitter } from "@stll/folio-core/controller/folioEditorEvents";
51
53
  import { dispatchEditorTextInput } from "@stll/folio-core/prosemirror/textInput";
52
54
  import { createLatestRequestGate } from "@stll/folio-core/controller/latestRequestGate";
53
55
  import { runLayoutPipeline } from "@stll/folio-core/controller/layoutPipeline";
54
- import { browserClock, createLayoutScheduler } from "@stll/folio-core/controller/layoutScheduler";
56
+ import { TRANSACTION_LAYOUT_TIMING, browserClock, createLayoutScheduler } from "@stll/folio-core/controller/layoutScheduler";
55
57
  import { createLayoutSession } from "@stll/folio-core/controller/layoutSession";
56
58
  import { createHyphenationReadiness } from "@stll/folio-core/controller/hyphenationReadiness";
57
- import { documentFontsAreLoaded, getDocumentFontSet, waitForInitialLayoutFonts } from "@stll/folio-core/controller/fontReadiness";
59
+ import { readFontSetSignature, waitForInitialLayoutFonts, watchLayoutFontLoads } from "@stll/folio-core/controller/fontReadiness";
58
60
  import { getFootnoteText } from "@stll/folio-core/docx/footnoteParser";
59
61
  import { convertHeaderFooterPmDocToContent, convertHeaderFooterToContent } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
60
62
  import { templatePreviewDirtyRange } from "@stll/folio-core/layout-bridge/convert/templatePreviewFlow";
@@ -80,10 +82,8 @@ import { isReadOnlyEditKey } from "@stll/folio-core/paged-layout/readOnlyEditAtt
80
82
  import { getPageScrollTarget, prefersReducedMotionBehavior } from "@stll/folio-core/paged-layout/scrollNavigation";
81
83
  import { PAGES_CONTAINER_CLASS, scrollPagesToPmPosition } from "@stll/folio-core/paged-layout/scrollToPmPosition";
82
84
  import { flashParagraphFragmentsByParaId } from "@stll/folio-core/paged-layout/paragraphFlash";
83
- import { DEFAULT_PAGE_HEIGHT_PX, getMargins, getPageSize, twipsToPixels as twipsToPixels$1 } from "@stll/folio-core/paged-layout/sectionGeometry";
84
85
  import { resizeColumnPair } from "@stll/folio-core/paged-layout/tableColumnResize";
85
86
  import { tableInsertButtonOffset } from "@stll/folio-core/paged-layout/tableInsertButtonGeometry";
86
- import { getTransactionsDirtyRange } from "@stll/folio-core/paged-layout/transactionDirtyRange";
87
87
  import { findStartPosForParaId } from "@stll/folio-core/prosemirror/utils/findParagraphByParaId";
88
88
  import { allowsDirectDrawingEdit } from "@stll/folio-core/docx/imageRawXml";
89
89
  import { commitImageFloatMove, commitImageInlineMove, commitImageResize, isFloatingImage } from "@stll/folio-core/prosemirror/imageCommit";
@@ -97,6 +97,7 @@ import { getFolioParaIdFromBlockId } from "@stll/folio-core/types/block-id";
97
97
  import { getPageTextFromLayout } from "@stll/folio-core/paged-layout/pageText";
98
98
  import { ContentControlWidgetController } from "@stll/folio-core/controller/contentControlWidgetController";
99
99
  import { createDefaultFindOptions, findInDocument } from "@stll/folio-core/utils/findReplace";
100
+ import { PANEL_METRICS, computePanelLayout } from "@stll/folio-core/panel-layout";
100
101
  import { ErrorManager } from "@stll/folio-core/managers/ErrorManager";
101
102
  import { ContextMenuManager } from "@stll/folio-core/managers/ContextMenuManager";
102
103
  import { DocumentLoaderManager } from "@stll/folio-core/managers/DocumentLoaderManager";
@@ -212,7 +213,7 @@ function useDocumentHistory(document, t0) {
212
213
  $[1] = t1;
213
214
  } else t1 = $[1];
214
215
  const options = t1;
215
- const isEqual = _temp$12;
216
+ const isEqual = _temp$14;
216
217
  let t2;
217
218
  if ($[2] !== options) {
218
219
  t2 = {
@@ -224,7 +225,7 @@ function useDocumentHistory(document, t0) {
224
225
  } else t2 = $[3];
225
226
  return useHistory(document, t2);
226
227
  }
227
- function _temp$12(a, b) {
228
+ function _temp$14(a, b) {
228
229
  if (a === b) return true;
229
230
  const aPackage = a?.package;
230
231
  const bPackage = b?.package;
@@ -745,7 +746,7 @@ const AISuggestionRectsOverlay = (t0) => {
745
746
  if (groups.length === 0) return null;
746
747
  let t1;
747
748
  if ($[0] !== groups) {
748
- t1 = groups.map(_temp$11);
749
+ t1 = groups.map(_temp$13);
749
750
  $[0] = groups;
750
751
  $[1] = t1;
751
752
  } else t1 = $[1];
@@ -761,7 +762,7 @@ const AISuggestionRectsOverlay = (t0) => {
761
762
  } else t2 = $[3];
762
763
  return t2;
763
764
  };
764
- function _temp$11(t0) {
765
+ function _temp$13(t0) {
765
766
  const { suggestion, rects, focused, font } = t0;
766
767
  const replacementAnchor = rects.at(-1);
767
768
  const showReplacement = focused && suggestion.suggestedText.length > 0 && replacementAnchor !== void 0;
@@ -996,7 +997,7 @@ const PassageHighlightOverlay = (t0) => {
996
997
  if (rects.length === 0) return null;
997
998
  let t1;
998
999
  if ($[0] !== rects) {
999
- t1 = rects.map(_temp$10);
1000
+ t1 = rects.map(_temp$12);
1000
1001
  $[0] = rects;
1001
1002
  $[1] = t1;
1002
1003
  } else t1 = $[1];
@@ -1012,7 +1013,7 @@ const PassageHighlightOverlay = (t0) => {
1012
1013
  } else t2 = $[3];
1013
1014
  return t2;
1014
1015
  };
1015
- function _temp$10(rect, idx) {
1016
+ function _temp$12(rect, idx) {
1016
1017
  return /* @__PURE__ */ jsx("span", {
1017
1018
  className: "folio-passage-highlight",
1018
1019
  style: {
@@ -1039,7 +1040,7 @@ const EMPTY_LOADED_EMBEDDED_FONTS = {
1039
1040
  faces: [],
1040
1041
  familyMap: /* @__PURE__ */ new Map()
1041
1042
  };
1042
- function getDocumentFontSet$1() {
1043
+ function getDocumentFontSet() {
1043
1044
  if (typeof document === "undefined" || !("fonts" in document)) return null;
1044
1045
  return document.fonts;
1045
1046
  }
@@ -1070,7 +1071,7 @@ async function registerFontFace(fontSet, family, source, descriptors) {
1070
1071
  * run falls back to the CSS font stack.
1071
1072
  */
1072
1073
  async function loadEmbeddedFontFaces(buffer) {
1073
- const fontSet = getDocumentFontSet$1();
1074
+ const fontSet = getDocumentFontSet();
1074
1075
  if (!fontSet) return EMPTY_LOADED_EMBEDDED_FONTS;
1075
1076
  let fonts;
1076
1077
  try {
@@ -1094,7 +1095,7 @@ async function loadEmbeddedFontFaces(buffer) {
1094
1095
  }
1095
1096
  /** Remove previously registered faces from the document font set. */
1096
1097
  function removeFontFaces(faces) {
1097
- const fontSet = getDocumentFontSet$1();
1098
+ const fontSet = getDocumentFontSet();
1098
1099
  if (!fontSet) return;
1099
1100
  for (const face of faces) fontSet.delete(face);
1100
1101
  }
@@ -1153,7 +1154,7 @@ function toFontFaceInputs(fonts) {
1153
1154
  * thrown. Pair with {@link removeFontFaces} to unregister on change/unmount.
1154
1155
  */
1155
1156
  async function loadHostFontFaces(fonts) {
1156
- const fontSet = getDocumentFontSet$1();
1157
+ const fontSet = getDocumentFontSet();
1157
1158
  if (!fontSet) return [];
1158
1159
  const inputs = toFontFaceInputs(fonts);
1159
1160
  if (inputs.length === 0) return [];
@@ -2277,10 +2278,6 @@ const TABLE_INSERT_EDGE_PROXIMITY = 30;
2277
2278
  const TABLE_INSERT_HIDE_DELAY = 200;
2278
2279
  /** Delay before converting PM state back to the Folio document model. */
2279
2280
  const DOCUMENT_CHANGE_NOTIFY_DELAY = 250;
2280
- /** Quiet window for coalescing follow-up transactions after the leading frame. */
2281
- const TRANSACTION_LAYOUT_DEBOUNCE_MS = 32;
2282
- /** Upper bound for how long visible layout can trail the hidden editor. */
2283
- const TRANSACTION_LAYOUT_MAX_DELAY_MS = 96;
2284
2281
  /** Keep the visual caret hidden briefly while typed content relayouts. */
2285
2282
  const SELECTION_REVEAL_AFTER_INPUT_DELAY = 120;
2286
2283
  /**
@@ -2473,7 +2470,7 @@ function HfCaretOverlay(t0) {
2473
2470
  if (!pagesContainer) return null;
2474
2471
  let t4;
2475
2472
  if ($[17] !== rangeRects) {
2476
- t4 = rangeRects.map(_temp$9);
2473
+ t4 = rangeRects.map(_temp$11);
2477
2474
  $[17] = rangeRects;
2478
2475
  $[18] = t4;
2479
2476
  } else t4 = $[18];
@@ -2512,7 +2509,7 @@ function HfCaretOverlay(t0) {
2512
2509
  } else t7 = $[26];
2513
2510
  return t7;
2514
2511
  }
2515
- function _temp$9(r, i) {
2512
+ function _temp$11(r, i) {
2516
2513
  return /* @__PURE__ */ jsx("div", {
2517
2514
  "data-testid": "hf-selection-rect",
2518
2515
  style: {
@@ -2566,7 +2563,6 @@ function stableJsonStringify(value) {
2566
2563
  return nestedValue;
2567
2564
  });
2568
2565
  }
2569
- const INITIAL_FONT_READY_SUPPRESSION_MS = 250;
2570
2566
  function describeInvalidHighlightMarks(doc) {
2571
2567
  const invalidHighlights = [];
2572
2568
  const validHighlightColors = /* @__PURE__ */ new Set([
@@ -2842,7 +2838,7 @@ function buildFootnoteRenderItems(pageFootnoteMap, footnoteContentMap, doc) {
2842
2838
  * PagedEditor - Main paginated editing component.
2843
2839
  */
2844
2840
  const PagedEditor = forwardRef(function PagedEditor(props, ref) {
2845
- const { document, documentIO, documentIdentity, fonts: hostFonts, styles, theme: _theme, sectionProperties, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, pageRenderer, 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, commentsSidebarOpen = false, sidebarOverlay, scrollContainerRef: scrollContainerRefProp, onHyperlinkClick, onContextMenu, onAnchorPositionsChange, onTotalPagesChange, onError, anchorPositionMode = "comments-and-revisions", onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
2841
+ const { document, documentIO, documentIdentity, 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;
2846
2842
  const getScrollContainer = useCallback(() => {
2847
2843
  if (scrollContainerRefProp && typeof scrollContainerRefProp === "object") return scrollContainerRefProp.current;
2848
2844
  return containerRef.current;
@@ -2897,7 +2893,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
2897
2893
  const pendingHiddenEditorSelectionRef = useRef(null);
2898
2894
  const queuedInputBeforeHiddenEditorRef = useRef([]);
2899
2895
  const pendingInitialFontReadyLayoutRef = useRef(false);
2900
- const suppressFontReadyUntilRef = useRef(0);
2901
2896
  const [isFocused, setIsFocused] = useState(false);
2902
2897
  const [selectionRects, setSelectionRects] = useState([]);
2903
2898
  const [caretPosition, setCaretPosition] = useState(null);
@@ -3063,6 +3058,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3063
3058
  const sectionHeaderFooterRefs = useMemo(() => resolveSectionHeaderFooterRefs(document), [document]);
3064
3059
  const layoutInputSignature = useMemo(() => buildLayoutInputSignature({
3065
3060
  columns,
3061
+ markupView,
3066
3062
  contentWidth,
3067
3063
  defaultTabStop,
3068
3064
  mirrorMargins,
@@ -3083,6 +3079,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3083
3079
  theme: _theme
3084
3080
  }), [
3085
3081
  columns,
3082
+ markupView,
3086
3083
  contentWidth,
3087
3084
  defaultTabStop,
3088
3085
  mirrorMargins,
@@ -3157,12 +3154,13 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3157
3154
  session: layoutSessionRef.current,
3158
3155
  renderHfFromContentOrPm,
3159
3156
  renderHeaderFooterContentByRId,
3160
- documentFontsAreLoaded,
3157
+ readFontSetSignature,
3161
3158
  buildFootnoteRenderItems,
3162
3159
  describeInvalidHighlightMarks,
3163
3160
  emptyTemplatePreviewEntries: EMPTY_TEMPLATE_PREVIEW_ENTRIES,
3164
3161
  emptyTemplatePreviewHidden: EMPTY_TEMPLATE_PREVIEW_HIDDEN,
3165
- hyphenationReadiness
3162
+ hyphenationReadiness,
3163
+ markupView
3166
3164
  }, state_0, options);
3167
3165
  if (outcome.blocks) setBlocks(outcome.blocks);
3168
3166
  if (outcome.measures !== void 0) setMeasures(outcome.measures);
@@ -3197,7 +3195,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3197
3195
  document,
3198
3196
  defaultTabStop,
3199
3197
  mirrorMargins,
3200
- styles
3198
+ styles,
3199
+ markupView
3201
3200
  ]);
3202
3201
  const runLayoutPipelineRef = useRef(runLayoutPipeline$1);
3203
3202
  runLayoutPipelineRef.current = runLayoutPipeline$1;
@@ -3236,10 +3235,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3236
3235
  ]);
3237
3236
  const layoutSchedulerRef = useRef(null);
3238
3237
  if (layoutSchedulerRef.current === null) layoutSchedulerRef.current = createLayoutScheduler({
3238
+ readState: () => hiddenPMRef.current?.getState() ?? precomputedInitialStateRef.current,
3239
3239
  runLayout: (state_2, options_1) => runLayoutPipelineRef.current(state_2, options_1),
3240
- debounceMs: TRANSACTION_LAYOUT_DEBOUNCE_MS,
3241
- leadingFrame: true,
3242
- maxDelayMs: TRANSACTION_LAYOUT_MAX_DELAY_MS,
3240
+ ...TRANSACTION_LAYOUT_TIMING,
3243
3241
  clock: browserClock
3244
3242
  });
3245
3243
  const documentChangeNotifyTimerRef = useRef(null);
@@ -3261,8 +3259,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3261
3259
  flushDocumentChangeNotification();
3262
3260
  }, DOCUMENT_CHANGE_NOTIFY_DELAY);
3263
3261
  }, [flushDocumentChangeNotification]);
3264
- const scheduleLayout = useCallback((state_3, dirtyRange) => {
3265
- layoutSchedulerRef.current?.schedule(state_3, dirtyRange);
3262
+ const scheduleLayout = useCallback(() => {
3263
+ layoutSchedulerRef.current?.schedule();
3266
3264
  }, []);
3267
3265
  useEffect(() => () => {
3268
3266
  layoutSchedulerRef.current?.dispose();
@@ -3292,7 +3290,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3292
3290
  const view_2 = hiddenPMRef.current?.getView();
3293
3291
  if (!view_2) return;
3294
3292
  const { selection: selection_1 } = view_2.state;
3295
- const domCaret = selection_1.empty ? getCaretFromDom(selection_1.head, zoom) : null;
3293
+ const domCaret = selection_1.empty ? getCaretFromDom(visibleCaretPosition(projectMarkupView(view_2.state, markupView), selection_1.head), zoom) : null;
3296
3294
  const overlayRect_0 = (pagesContainerRef.current?.parentElement?.querySelector("[data-testid=\"selection-overlay\"]"))?.getBoundingClientRect();
3297
3295
  syncImeCaretAnchor({
3298
3296
  hiddenHost: hiddenPMRef.current?.getHostElement(),
@@ -3302,21 +3300,25 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3302
3300
  top: overlayRect_0.top + domCaret.y * zoom
3303
3301
  } : null
3304
3302
  });
3305
- }, [getCaretFromDom, zoom]);
3303
+ }, [
3304
+ getCaretFromDom,
3305
+ zoom,
3306
+ markupView
3307
+ ]);
3306
3308
  /**
3307
3309
  * Update selection overlay from PM selection.
3308
3310
  */
3309
- const updateSelectionOverlay = useCallback((state_4) => {
3310
- const { from, to } = state_4.selection;
3311
+ const updateSelectionOverlay = useCallback((state_3) => {
3312
+ const { from, to } = state_3.selection;
3311
3313
  const isCurrentRequest = selectionOverlayRequestGate.begin();
3312
- if (directivesRef.current.length > 0) setDirectiveCaretPos(state_4.selection.head);
3314
+ if (directivesRef.current.length > 0) setDirectiveCaretPos(state_3.selection.head);
3313
3315
  onSelectionChangeRef.current?.(from, to);
3314
3316
  folioEmitterRef.current.emit("selectionChange", {
3315
3317
  from,
3316
3318
  to
3317
3319
  });
3318
3320
  if (onSelectionTextChangeRef.current) {
3319
- const text_0 = from === to ? "" : state_4.doc.textBetween(from, to, " ", " ");
3321
+ const text_0 = from === to ? "" : state_3.doc.textBetween(from, to, " ", " ");
3320
3322
  onSelectionTextChangeRef.current({
3321
3323
  from,
3322
3324
  to,
@@ -3336,7 +3338,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3336
3338
  if (pagesContainerRef.current) {
3337
3339
  const prevSelected = pagesContainerRef.current.querySelectorAll(".layout-table-cell-selected");
3338
3340
  for (const el_0 of Array.from(prevSelected)) el_0.classList.remove("layout-table-cell-selected");
3339
- const sel = state_4.selection;
3341
+ const sel = state_3.selection;
3340
3342
  if ("$anchorCell" in sel && typeof sel.forEachCell === "function") {
3341
3343
  const selectedRanges = [];
3342
3344
  sel.forEachCell((node_0, pos) => {
@@ -3364,7 +3366,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3364
3366
  return;
3365
3367
  }
3366
3368
  if (from === to) {
3367
- const domCaret_0 = getCaretFromDom(from, zoom);
3369
+ const caretPos = visibleCaretPosition(projectMarkupView(state_3, markupView), from);
3370
+ const domCaret_0 = getCaretFromDom(caretPos, zoom);
3368
3371
  if (domCaret_0) {
3369
3372
  setCaretPosition(domCaret_0);
3370
3373
  const overlayRect_1 = (pagesContainerRef.current?.parentElement?.querySelector("[data-testid=\"selection-overlay\"]"))?.getBoundingClientRect();
@@ -3385,7 +3388,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3385
3388
  setCaretPosition(null);
3386
3389
  loadSelectionGeometry().then(({ getCaretPosition }) => {
3387
3390
  if (!isCurrentRequest()) return;
3388
- const caret_0 = getCaretPosition(layout, blocks, measures, from);
3391
+ const caret_0 = getCaretPosition(layout, blocks, measures, caretPos);
3389
3392
  if (caret_0) {
3390
3393
  const fallbackCaret = {
3391
3394
  ...caret_0,
@@ -3477,7 +3480,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3477
3480
  measures,
3478
3481
  getCaretFromDom,
3479
3482
  selectionOverlayRequestGate,
3480
- zoom
3483
+ zoom,
3484
+ markupView
3481
3485
  ]);
3482
3486
  const updateSelectionOverlayRef = useRef(updateSelectionOverlay);
3483
3487
  updateSelectionOverlayRef.current = updateSelectionOverlay;
@@ -3489,8 +3493,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3489
3493
  if (animationFrame !== null) cancelAnimationFrame(animationFrame);
3490
3494
  animationFrame = requestAnimationFrame(() => {
3491
3495
  animationFrame = null;
3492
- const state_5 = hiddenPMRef.current?.getState();
3493
- if (state_5) updateSelectionOverlayRef.current(state_5);
3496
+ const state_4 = hiddenPMRef.current?.getState();
3497
+ if (state_4) updateSelectionOverlayRef.current(state_4);
3494
3498
  });
3495
3499
  };
3496
3500
  pagesContainer_0.addEventListener(PAINTER_PAINTED_EVENT, repaintSelection);
@@ -3731,7 +3735,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3731
3735
  }
3732
3736
  updatePassageHighlightOverlay();
3733
3737
  }, [passageHighlightOverlayRequestGate, updatePassageHighlightOverlay]);
3734
- const hideSelectionOverlayDuringInput = useCallback((state_6) => {
3738
+ const hideSelectionOverlayDuringInput = useCallback((state_5) => {
3735
3739
  selectionOverlayRequestGate.invalidate();
3736
3740
  suppressSelectionOverlayRef.current = true;
3737
3741
  setCaretPosition(null);
@@ -3740,7 +3744,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3740
3744
  revealSelectionOverlayTimerRef.current = window.setTimeout(() => {
3741
3745
  revealSelectionOverlayTimerRef.current = null;
3742
3746
  suppressSelectionOverlayRef.current = false;
3743
- updateSelectionOverlay(hiddenPMRef.current?.getState() ?? state_6);
3747
+ updateSelectionOverlay(hiddenPMRef.current?.getState() ?? state_5);
3744
3748
  }, SELECTION_REVEAL_AFTER_INPUT_DELAY);
3745
3749
  }, [selectionOverlayRequestGate, updateSelectionOverlay]);
3746
3750
  useEffect(() => () => {
@@ -3765,7 +3769,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3765
3769
  /**
3766
3770
  * Handle PM transaction - re-layout on content/selection change.
3767
3771
  */
3768
- const handleTransaction = useCallback(({ transactions, newState, docChanged }) => {
3772
+ const handleTransaction = useCallback(({ newState, docChanged }) => {
3769
3773
  const nextMatches = anonymizationDecorationsKey.getState(newState)?.matches ?? [];
3770
3774
  const matchesChanged = nextMatches !== anonymizationMatchesRef.current;
3771
3775
  anonymizationMatchesRef.current = nextMatches;
@@ -3791,11 +3795,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3791
3795
  hidden: nextPreviewHidden,
3792
3796
  mode: nextPreviewMode
3793
3797
  };
3794
- if (!docChanged) if (nextPreviewMode !== previousPreview.mode) scheduleLayout(newState, null);
3795
- else {
3796
- const previewDirty = templatePreviewDirtyRange(previousPreview, templatePreviewRef.current);
3797
- if (previewDirty) scheduleLayout(newState, previewDirty);
3798
- }
3798
+ if (!docChanged && (nextPreviewMode !== previousPreview.mode || templatePreviewDirtyRange(previousPreview, templatePreviewRef.current) !== null)) scheduleLayout();
3799
3799
  }
3800
3800
  const nextAiState = aiSuggestionDecorationsKey.getState(newState);
3801
3801
  const nextAiSuggestions = nextAiState?.suggestions ?? EMPTY_AI_SUGGESTIONS;
@@ -3815,7 +3815,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3815
3815
  setPassageHighlightRects((prev_2) => prev_2.length === 0 ? prev_2 : []);
3816
3816
  }
3817
3817
  hideSelectionOverlayDuringInput(newState);
3818
- scheduleLayout(newState, getTransactionsDirtyRange(transactions));
3818
+ scheduleLayout();
3819
3819
  scheduleDocumentChangeNotification();
3820
3820
  }
3821
3821
  syncCoordinator.requestRender();
@@ -3851,13 +3851,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3851
3851
  const activeHfPageNumberRef = useRef(null);
3852
3852
  const handleHfPmTransaction = useCallback((rId, kind, view_3, docChanged_0, selectionChanged) => {
3853
3853
  if (docChanged_0) {
3854
- let bodyState = hiddenPMRef.current?.getState();
3855
- if (!bodyState && precomputedInitialStateRef.current) bodyState = precomputedInitialStateRef.current;
3856
- if (!bodyState) {
3857
- ensureHiddenEditorView({ sync: true });
3858
- bodyState = hiddenPMRef.current?.getState();
3859
- }
3860
- if (bodyState) scheduleLayout(bodyState, null);
3854
+ if (!hiddenPMRef.current?.getState() && !precomputedInitialStateRef.current) ensureHiddenEditorView({ sync: true });
3855
+ scheduleLayout();
3861
3856
  }
3862
3857
  if (docChanged_0 || selectionChanged) {
3863
3858
  const { from: from_1, to: to_1 } = view_3.state.selection;
@@ -3877,10 +3872,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3877
3872
  }
3878
3873
  }, [scheduleLayout, ensureHiddenEditorView]);
3879
3874
  const handleNoteStoryTransaction = useCallback((view_4, docChanged_1, selectionChanged_0) => {
3880
- if (docChanged_1) {
3881
- const bodyState_0 = hiddenPMRef.current?.getState();
3882
- if (bodyState_0) scheduleLayout(bodyState_0, null);
3883
- }
3875
+ if (docChanged_1) scheduleLayout();
3884
3876
  if (docChanged_1 || selectionChanged_0) {
3885
3877
  const { from: from_2, to: to_2 } = view_4.state.selection;
3886
3878
  onSelectionChangeRef.current?.(from_2, to_2);
@@ -3903,12 +3895,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3903
3895
  /**
3904
3896
  * Handle selection change from PM.
3905
3897
  */
3906
- const handleSelectionChange = useCallback((state_7) => {
3907
- const { selection: selection_2 } = state_7;
3898
+ const handleSelectionChange = useCallback((state_6) => {
3899
+ const { selection: selection_2 } = state_6;
3908
3900
  if (selection_2 instanceof NodeSelection && selection_2.node.type.name === "image") {
3909
3901
  setSelectionRects([]);
3910
3902
  setCaretPosition(null);
3911
- } else if (syncCoordinator.isSafeToRender()) updateSelectionOverlay(state_7);
3903
+ } else if (syncCoordinator.isSafeToRender()) updateSelectionOverlay(state_6);
3912
3904
  requestAnimationFrame(() => {
3913
3905
  const view_5 = hiddenPMRef.current?.getView();
3914
3906
  if (!view_5) {
@@ -4030,9 +4022,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
4030
4022
  });
4031
4023
  }, [layout, scrollToPositionImpl]);
4032
4024
  const scrollToParaIdImpl = useCallback((paraId, options_2) => {
4033
- const state_8 = hiddenPMRef.current?.getState();
4034
- if (!state_8) return false;
4035
- const startPos = findStartPosForParaId(state_8.doc, paraId);
4025
+ const state_7 = hiddenPMRef.current?.getState();
4026
+ if (!state_7) return false;
4027
+ const startPos = findStartPosForParaId(state_7.doc, paraId);
4036
4028
  if (startPos == null || startPos < 0) return false;
4037
4029
  scrollToPositionImpl(startPos);
4038
4030
  requestAnimationFrame(() => {
@@ -4040,8 +4032,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
4040
4032
  const pages = pagesContainerRef.current;
4041
4033
  if (pages) flashParagraphFragmentsByParaId(pages, paraId, options_2.highlight);
4042
4034
  }
4043
- const targetNode = state_8.doc.nodeAt(startPos);
4044
- const inner = targetNode?.isTextblock === true ? Math.min(startPos + 1 + targetNode.content.size, state_8.doc.content.size) : Math.min(startPos + 1, state_8.doc.content.size);
4035
+ const targetNode = state_7.doc.nodeAt(startPos);
4036
+ const inner = targetNode?.isTextblock === true ? Math.min(startPos + 1 + targetNode.content.size, state_7.doc.content.size) : Math.min(startPos + 1, state_7.doc.content.size);
4045
4037
  hiddenPMRef.current?.setSelection(inner);
4046
4038
  hiddenPMRef.current?.focus();
4047
4039
  });
@@ -5146,7 +5138,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5146
5138
  let cancelled = false;
5147
5139
  pendingInitialFontReadyLayoutRef.current = true;
5148
5140
  const fontWaitStartedAt = performance.now();
5149
- const runAfterFontWait = (fontsLoaded) => {
5141
+ const runAfterFontWait = () => {
5150
5142
  if (cancelled) return;
5151
5143
  pendingInitialFontReadyLayoutRef.current = false;
5152
5144
  preHiddenInitialLayoutDoneRef.current = true;
@@ -5157,12 +5149,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5157
5149
  updateSelectionOverlay(initialState);
5158
5150
  updateAnonymizationOverlay();
5159
5151
  updateDirectivesOverlay();
5160
- if (fontsLoaded) {
5161
- layoutSessionRef.current.usedLoadedFonts = true;
5162
- suppressFontReadyUntilRef.current = performance.now() + INITIAL_FONT_READY_SUPPRESSION_MS;
5163
- }
5164
5152
  };
5165
- waitForInitialLayoutFonts(document, initialState.doc).then(runAfterFontWait, () => runAfterFontWait(false));
5153
+ waitForInitialLayoutFonts(document, initialState.doc).then(runAfterFontWait, runAfterFontWait);
5166
5154
  return () => {
5167
5155
  cancelled = true;
5168
5156
  pendingInitialFontReadyLayoutRef.current = false;
@@ -5211,7 +5199,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5211
5199
  setIsFocused(true);
5212
5200
  });
5213
5201
  };
5214
- if (layoutSessionRef.current.lastPmDoc?.eq(view_24.state.doc)) {
5202
+ if (layoutSessionRef.current.lastPmDoc?.eq(view_24.state.doc) && layoutSessionRef.current.lastMeasureInputs?.markupView === markupView) {
5215
5203
  const lastPreview = layoutSessionRef.current.lastTemplatePreview;
5216
5204
  if (templatePreviewRef.current.mode !== lastPreview.mode || templatePreviewDirtyRange(lastPreview, templatePreviewRef.current) !== null) runLayoutPipeline$1(view_24.state, { reason: "manual" });
5217
5205
  updateSelectionOverlay(view_24.state);
@@ -5230,7 +5218,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5230
5218
  };
5231
5219
  pendingInitialFontReadyLayoutRef.current = true;
5232
5220
  const fontWaitStartedAt_0 = performance.now();
5233
- const runAfterFontWait_0 = (fontsLoaded_0) => {
5221
+ const runAfterFontWait_0 = () => {
5234
5222
  pendingInitialFontReadyLayoutRef.current = false;
5235
5223
  const currentView_0 = hiddenPMRef.current?.getView();
5236
5224
  if (currentView_0 !== view_24) return;
@@ -5238,12 +5226,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5238
5226
  resetCanvasContext();
5239
5227
  clearAllCaches();
5240
5228
  runInitialLayout(currentView_0);
5241
- if (fontsLoaded_0) {
5242
- layoutSessionRef.current.usedLoadedFonts = true;
5243
- suppressFontReadyUntilRef.current = performance.now() + INITIAL_FONT_READY_SUPPRESSION_MS;
5244
- }
5245
5229
  };
5246
- waitForInitialLayoutFonts(document, view_24.state.doc).then(runAfterFontWait_0, () => runAfterFontWait_0(false));
5230
+ waitForInitialLayoutFonts(document, view_24.state.doc).then(runAfterFontWait_0, runAfterFontWait_0);
5247
5231
  focusReadyView();
5248
5232
  }, [
5249
5233
  applyPendingHiddenEditorInput,
@@ -5255,7 +5239,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5255
5239
  document,
5256
5240
  updateAutocompleteOverlay,
5257
5241
  readOnly,
5258
- refreshBodyImeCaretAnchor
5242
+ refreshBodyImeCaretAnchor,
5243
+ markupView
5259
5244
  ]);
5260
5245
  const handleEditorViewDestroy = useCallback(() => {
5261
5246
  onEditorViewReadyRef.current?.(null);
@@ -5296,32 +5281,17 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5296
5281
  useEffect(() => {
5297
5282
  updateAutocompleteOverlay();
5298
5283
  }, [updateAutocompleteOverlay]);
5299
- useEffect(() => {
5300
- const fontSet = getDocumentFontSet();
5301
- if (!fontSet) return;
5302
- const handleFontsLoading = () => {
5303
- if (performance.now() < suppressFontReadyUntilRef.current) return;
5304
- layoutSessionRef.current.usedLoadedFonts = false;
5305
- };
5306
- const handleFontsLoaded = () => {
5307
- if (pendingInitialFontReadyLayoutRef.current || performance.now() < suppressFontReadyUntilRef.current || layoutSessionRef.current.usedLoadedFonts) return;
5284
+ useEffect(() => watchLayoutFontLoads({
5285
+ measuredFontSet: () => layoutSessionRef.current.lastMeasureInputs?.fontSet ?? null,
5286
+ relayout: () => {
5287
+ if (pendingInitialFontReadyLayoutRef.current) return;
5308
5288
  const view_25 = hiddenPMRef.current?.getView();
5309
- if (view_25) {
5310
- resetCanvasContext();
5311
- clearAllCaches();
5312
- runLayoutPipelineRef.current(view_25.state, { reason: "font-ready" });
5313
- updateSelectionOverlayRef.current(view_25.state);
5314
- }
5315
- };
5316
- fontSet.addEventListener("loading", handleFontsLoading);
5317
- fontSet.addEventListener("loadingdone", handleFontsLoaded);
5318
- fontSet.addEventListener("loadingerror", handleFontsLoaded);
5319
- return () => {
5320
- fontSet.removeEventListener("loading", handleFontsLoading);
5321
- fontSet.removeEventListener("loadingdone", handleFontsLoaded);
5322
- fontSet.removeEventListener("loadingerror", handleFontsLoaded);
5323
- };
5324
- }, []);
5289
+ const state_8 = view_25?.state ?? layoutSessionRef.current.lastEditorState;
5290
+ if (!state_8) return;
5291
+ runLayoutPipelineRef.current(state_8, { reason: "font-ready" });
5292
+ if (view_25) updateSelectionOverlayRef.current(view_25.state);
5293
+ }
5294
+ }), []);
5325
5295
  const embeddedFontBuffer = document?.originalBuffer ?? null;
5326
5296
  useEffect(() => {
5327
5297
  if (!embeddedFontBuffer) return;
@@ -5384,20 +5354,20 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5384
5354
  lastLayoutInputSignatureRef.current = layoutInputSignature;
5385
5355
  return;
5386
5356
  }
5387
- const view_28 = hiddenPMRef.current?.getView();
5388
- if (view_28) {
5357
+ const state_9 = hiddenPMRef.current?.getView()?.state ?? (preHiddenInitialLayoutDoneRef.current && precomputedInitialDocumentRef.current === document ? layoutSessionRef.current.lastEditorState : null);
5358
+ if (state_9) {
5389
5359
  const layoutInputsChanged = lastLayoutInputSignatureRef.current !== layoutInputSignature;
5390
5360
  lastLayoutInputSignatureRef.current = layoutInputSignature;
5391
- if (!layoutInputsChanged && view_28.state.doc === layoutSessionRef.current.lastPmDoc) return;
5392
- runLayoutPipelineRef.current(view_28.state, { reason: "layout-input" });
5361
+ if (!layoutInputsChanged && state_9.doc === layoutSessionRef.current.lastPmDoc) return;
5362
+ runLayoutPipelineRef.current(state_9, { reason: "layout-input" });
5393
5363
  }
5394
5364
  }, [document, layoutInputSignature]);
5395
5365
  useEffect(() => {
5396
5366
  const container = containerRef.current;
5397
5367
  if (!container) return;
5398
5368
  const observer = new ResizeObserver(() => {
5399
- const state_9 = hiddenPMRef.current?.getState();
5400
- if (state_9) updateSelectionOverlay(state_9);
5369
+ const state_10 = hiddenPMRef.current?.getState();
5370
+ if (state_10) updateSelectionOverlay(state_10);
5401
5371
  });
5402
5372
  observer.observe(container);
5403
5373
  return () => observer.disconnect();
@@ -5457,8 +5427,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5457
5427
  setIsFocused(true);
5458
5428
  },
5459
5429
  blur() {
5460
- const view_29 = getActiveEditorStory().view;
5461
- if (view_29?.hasFocus() && view_29.dom instanceof HTMLElement) view_29.dom.blur();
5430
+ const view_28 = getActiveEditorStory().view;
5431
+ if (view_28?.hasFocus() && view_28.dom instanceof HTMLElement) view_28.dom.blur();
5462
5432
  setIsFocused(false);
5463
5433
  },
5464
5434
  isFocused() {
@@ -5534,25 +5504,25 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5534
5504
  return bestNumber;
5535
5505
  },
5536
5506
  getBlockRect(blockId) {
5537
- const state_10 = folioEditor.getState();
5507
+ const state_11 = folioEditor.getState();
5538
5508
  const pagesContainer_6 = pagesContainerRef.current;
5539
5509
  const scrollRoot = getScrollContainer();
5540
- if (!state_10 || !pagesContainer_6 || !scrollRoot) return null;
5510
+ if (!state_11 || !pagesContainer_6 || !scrollRoot) return null;
5541
5511
  return readBlockRects({
5542
5512
  blockIds: [blockId],
5543
- snapshot: createFolioAIEditSnapshot$1(state_10.doc),
5513
+ snapshot: createFolioAIEditSnapshot$1(state_11.doc),
5544
5514
  pagesContainer: pagesContainer_6,
5545
5515
  scrollRoot
5546
5516
  }).get(blockId) ?? null;
5547
5517
  },
5548
5518
  getBlockRects(blockIds) {
5549
- const state_11 = folioEditor.getState();
5519
+ const state_12 = folioEditor.getState();
5550
5520
  const pagesContainer_7 = pagesContainerRef.current;
5551
5521
  const scrollRoot_0 = getScrollContainer();
5552
- if (!state_11 || !pagesContainer_7 || !scrollRoot_0) return /* @__PURE__ */ new Map();
5522
+ if (!state_12 || !pagesContainer_7 || !scrollRoot_0) return /* @__PURE__ */ new Map();
5553
5523
  return readBlockRects({
5554
5524
  blockIds,
5555
- snapshot: createFolioAIEditSnapshot$1(state_11.doc),
5525
+ snapshot: createFolioAIEditSnapshot$1(state_12.doc),
5556
5526
  pagesContainer: pagesContainer_7,
5557
5527
  scrollRoot: scrollRoot_0
5558
5528
  });
@@ -5581,8 +5551,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5581
5551
  onTotalPagesChangeRef.current?.(totalPages);
5582
5552
  }, [layout]);
5583
5553
  useEffect(() => {
5584
- const state_12 = hiddenPMRef.current?.getState();
5585
- if (layout && state_12) updateSelectionOverlay(state_12);
5554
+ const state_13 = hiddenPMRef.current?.getState();
5555
+ if (layout && state_13) updateSelectionOverlay(state_13);
5586
5556
  }, [layout, updateSelectionOverlay]);
5587
5557
  const totalHeight = useMemo(() => {
5588
5558
  if (!layout) return DEFAULT_PAGE_HEIGHT_PX + 48;
@@ -5594,7 +5564,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5594
5564
  pageGap
5595
5565
  ]);
5596
5566
  const scaledViewportHeight = Math.max(1, totalHeight * zoom);
5597
- const scaledViewportWidth = Math.max(1, pageSize.w * zoom + (commentsSidebarOpen ? 304 : 0));
5567
+ let widestPageWidth = layout?.pages.length ? 0 : pageSize.w;
5568
+ for (const page_1 of layout?.pages ?? []) widestPageWidth = Math.max(widestPageWidth, page_1.size.w);
5569
+ const scaledViewportWidth = Math.max(1, widestPageWidth * zoom + pageEndGutter);
5598
5570
  const viewportExtentStyle = {
5599
5571
  position: "relative",
5600
5572
  width: `max(100%, ${String(scaledViewportWidth)}px)`,
@@ -5607,7 +5579,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5607
5579
  position: "absolute",
5608
5580
  top: 0,
5609
5581
  left: `max(0px, calc((100% - ${String(scaledViewportWidth)}px) / 2))`,
5610
- width: pageSize.w,
5582
+ width: widestPageWidth,
5611
5583
  minHeight: totalHeight,
5612
5584
  transform: (() => {
5613
5585
  const parts = [];
@@ -6891,6 +6863,19 @@ function createComment(text, authorName, parentId, id) {
6891
6863
  function getCommentParentId(comment) {
6892
6864
  return comment.parentId;
6893
6865
  }
6866
+ /**
6867
+ * Threads the comments sidebar shows a card for: top-level comments not yet
6868
+ * resolved. Tracked changes are painted inline and have no card, so a
6869
+ * document with only tracked changes has none.
6870
+ */
6871
+ function countOpenCommentThreads(comments) {
6872
+ let count = 0;
6873
+ for (const comment of comments) {
6874
+ const parentId = getCommentParentId(comment);
6875
+ if ((parentId === null || parentId === void 0) && !comment.done) count += 1;
6876
+ }
6877
+ return count;
6878
+ }
6894
6879
  function applyCommentMarkRange(view, range, commentId, options) {
6895
6880
  const commentMark = view.state.schema.marks["comment"];
6896
6881
  const safeRange = clampCommentMarkRange(view.state.doc.content.size, range);
@@ -7124,7 +7109,7 @@ function ContentControlWidgetsOverlay(t0) {
7124
7109
  "aria-label": t11,
7125
7110
  style,
7126
7111
  className: "bg-popover text-popover-foreground min-w-[10rem] rounded-md border p-1 shadow-md",
7127
- onPointerDown: _temp$8,
7112
+ onPointerDown: _temp$10,
7128
7113
  children: [t12, t13]
7129
7114
  })
7130
7115
  }), document.body);
@@ -7136,7 +7121,7 @@ function ContentControlWidgetsOverlay(t0) {
7136
7121
  } else t14 = $[31];
7137
7122
  return t14;
7138
7123
  }
7139
- function _temp$8(event) {
7124
+ function _temp$10(event) {
7140
7125
  return event.stopPropagation();
7141
7126
  }
7142
7127
  function ContentControlDropdownItem(t0) {
@@ -7259,7 +7244,7 @@ function useFindReplace$1(hookOptions) {
7259
7244
  let t6;
7260
7245
  if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
7261
7246
  t6 = () => {
7262
- setState(_temp$7);
7247
+ setState(_temp$9);
7263
7248
  };
7264
7249
  $[8] = t6;
7265
7250
  } else t6 = $[8];
@@ -7423,7 +7408,7 @@ function _temp2$4(prev_2) {
7423
7408
  ...prev_2.dialog.status === "closed" ? openDialogState(prev_2.lastMode) : closedDialogState(prev_2.lastMode)
7424
7409
  };
7425
7410
  }
7426
- function _temp$7(prev_1) {
7411
+ function _temp$9(prev_1) {
7427
7412
  return {
7428
7413
  ...prev_1,
7429
7414
  ...closedDialogState(prev_1.lastMode)
@@ -7452,33 +7437,25 @@ function openDialogState(mode) {
7452
7437
  };
7453
7438
  }
7454
7439
  //#endregion
7455
- //#region src/components/DocumentOutline.tsx
7456
- const DocumentOutline = (t0) => {
7457
- const $ = c(21);
7458
- const { headings, scrollContainerRef, topOffset, docSize, onHeadingClick } = t0;
7459
- const OutlineRail = useFolioUI().OutlineRail;
7440
+ //#region src/components/hooks/useActiveHeading.ts
7441
+ /**
7442
+ * The heading the reader is in: the last heading whose paragraph starts above
7443
+ * the middle of the scroll viewport, tracked as the document scrolls. Shared
7444
+ * by every place the outline is drawn (column, rail, drawer), so a drawer
7445
+ * opens on the same heading the rail marks.
7446
+ */
7447
+ /** How long a jump holds the active heading before scrolling may move it. */
7448
+ const MANUAL_ACTIVE_LOCK_MS = 900;
7449
+ /** Outline item id for a heading: its ProseMirror position. */
7450
+ const headingId = (heading) => String(heading.pmPos);
7451
+ const useActiveHeading = (scrollContainerRef, headings) => {
7452
+ const $ = c(7);
7460
7453
  const [activeId, setActiveId] = useState(null);
7461
7454
  const manualLockUntil = useRef(0);
7455
+ let t0;
7462
7456
  let t1;
7463
- if ($[0] !== headings) {
7464
- t1 = headings.map(_temp$6);
7465
- $[0] = headings;
7466
- $[1] = t1;
7467
- } else t1 = $[1];
7468
- const items = t1;
7469
- let map;
7470
- if ($[2] !== docSize || $[3] !== headings) {
7471
- map = /* @__PURE__ */ new Map();
7472
- if (docSize > 0) for (const heading_0 of headings) map.set(String(heading_0.pmPos), Math.min(99, Math.max(1, heading_0.pmPos / docSize * 100)));
7473
- $[2] = docSize;
7474
- $[3] = headings;
7475
- $[4] = map;
7476
- } else map = $[4];
7477
- const pctByPmPos = map;
7478
- let t2;
7479
- let t3;
7480
- if ($[5] !== headings || $[6] !== scrollContainerRef) {
7481
- t2 = () => {
7457
+ if ($[0] !== headings || $[1] !== scrollContainerRef) {
7458
+ t0 = () => {
7482
7459
  const container = scrollContainerRef.current;
7483
7460
  if (!container || headings.length === 0) return;
7484
7461
  const compute = () => {
@@ -7496,15 +7473,11 @@ const DocumentOutline = (t0) => {
7496
7473
  top: el.getBoundingClientRect().top - containerTop + container.scrollTop
7497
7474
  });
7498
7475
  }
7499
- offsets.sort(_temp2$3);
7476
+ offsets.sort(_temp$8);
7500
7477
  let next = null;
7501
- for (const heading_1 of headings) {
7502
- let candidate;
7503
- for (const offset of offsets) if (offset.pm >= heading_1.pmPos) {
7504
- candidate = offset;
7505
- break;
7506
- }
7507
- if (candidate && candidate.top <= threshold) next = String(heading_1.pmPos);
7478
+ for (const heading of headings) {
7479
+ const candidate = offsets.find((offset) => offset.pm >= heading.pmPos);
7480
+ if (candidate && candidate.top <= threshold) next = headingId(heading);
7508
7481
  }
7509
7482
  setActiveId(next);
7510
7483
  };
@@ -7520,82 +7493,361 @@ const DocumentOutline = (t0) => {
7520
7493
  container.removeEventListener("scroll", onScroll);
7521
7494
  };
7522
7495
  };
7523
- t3 = [scrollContainerRef, headings];
7524
- $[5] = headings;
7525
- $[6] = scrollContainerRef;
7526
- $[7] = t2;
7527
- $[8] = t3;
7496
+ t1 = [scrollContainerRef, headings];
7497
+ $[0] = headings;
7498
+ $[1] = scrollContainerRef;
7499
+ $[2] = t0;
7500
+ $[3] = t1;
7528
7501
  } else {
7529
- t2 = $[7];
7530
- t3 = $[8];
7502
+ t0 = $[2];
7503
+ t1 = $[3];
7531
7504
  }
7532
- useEffect(t2, t3);
7533
- let t4;
7534
- if ($[9] !== onHeadingClick) {
7535
- t4 = (id) => {
7505
+ useEffect(t0, t1);
7506
+ let t2;
7507
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
7508
+ t2 = (id) => {
7536
7509
  setActiveId(id);
7537
- manualLockUntil.current = Date.now() + 900;
7538
- onHeadingClick(Number(id));
7510
+ manualLockUntil.current = Date.now() + MANUAL_ACTIVE_LOCK_MS;
7539
7511
  };
7540
- $[9] = onHeadingClick;
7541
- $[10] = t4;
7542
- } else t4 = $[10];
7543
- const handleJump = t4;
7544
- let t5;
7545
- if ($[11] !== pctByPmPos) {
7546
- t5 = (id_0) => pctByPmPos.get(id_0) ?? null;
7547
- $[11] = pctByPmPos;
7548
- $[12] = t5;
7549
- } else t5 = $[12];
7550
- const resolvePct = t5;
7512
+ $[4] = t2;
7513
+ } else t2 = $[4];
7514
+ const markJumped = t2;
7515
+ let t3;
7516
+ if ($[5] !== activeId) {
7517
+ t3 = {
7518
+ activeId,
7519
+ markJumped
7520
+ };
7521
+ $[5] = activeId;
7522
+ $[6] = t3;
7523
+ } else t3 = $[6];
7524
+ return t3;
7525
+ };
7526
+ function _temp$8(a, b) {
7527
+ return a.pm - b.pm;
7528
+ }
7529
+ //#endregion
7530
+ //#region src/components/panelDrawer.tsx
7531
+ /**
7532
+ * The shared behaviour of a panel opened as a drawer over the page: a scrim
7533
+ * that closes it on an outside press, Escape that closes it, and focus that
7534
+ * moves into the drawer when it opens and back to where it came from when it
7535
+ * closes.
7536
+ */
7537
+ const FOCUSABLE = "button:not([disabled]), [href], input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
7538
+ const LIST_TAB_STOP = ":is(ol, ul) :is(button, [href], [tabindex]):not([tabindex=\"-1\"])";
7539
+ const initialFocusTarget = (container, initial) => {
7540
+ if (initial === "container") return container;
7541
+ return container.querySelector("[aria-current=\"true\"]") ?? container.querySelector(LIST_TAB_STOP) ?? container.querySelector(FOCUSABLE) ?? container;
7542
+ };
7543
+ /**
7544
+ * While `onClose` is set, `container` is an open drawer: focus moves into it,
7545
+ * Escape calls `onClose`, and once it closes focus returns to what had it
7546
+ * before, if that is still in the document.
7547
+ */
7548
+ const useDrawerFocus = (container, onClose, t0) => {
7549
+ const $ = c(8);
7550
+ const initial = t0 === void 0 ? "item" : t0;
7551
+ const onCloseRef = useRef(onClose);
7552
+ let t1;
7553
+ let t2;
7554
+ if ($[0] !== onClose) {
7555
+ t1 = () => {
7556
+ onCloseRef.current = onClose;
7557
+ };
7558
+ t2 = [onClose];
7559
+ $[0] = onClose;
7560
+ $[1] = t1;
7561
+ $[2] = t2;
7562
+ } else {
7563
+ t1 = $[1];
7564
+ t2 = $[2];
7565
+ }
7566
+ useEffect(t1, t2);
7567
+ const active = onClose !== null;
7568
+ let t3;
7569
+ let t4;
7570
+ if ($[3] !== active || $[4] !== container || $[5] !== initial) {
7571
+ t3 = () => {
7572
+ if (!active) return;
7573
+ const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;
7574
+ const element = container.current;
7575
+ if (element) initialFocusTarget(element, initial).focus({ preventScroll: true });
7576
+ const handleKeyDown = (event) => {
7577
+ if (event.key !== "Escape" || event.defaultPrevented) return;
7578
+ event.preventDefault();
7579
+ onCloseRef.current?.();
7580
+ };
7581
+ document.addEventListener("keydown", handleKeyDown);
7582
+ return () => {
7583
+ document.removeEventListener("keydown", handleKeyDown);
7584
+ if (previous?.isConnected) previous.focus({ preventScroll: true });
7585
+ };
7586
+ };
7587
+ t4 = [
7588
+ active,
7589
+ container,
7590
+ initial
7591
+ ];
7592
+ $[3] = active;
7593
+ $[4] = container;
7594
+ $[5] = initial;
7595
+ $[6] = t3;
7596
+ $[7] = t4;
7597
+ } else {
7598
+ t3 = $[6];
7599
+ t4 = $[7];
7600
+ }
7601
+ useEffect(t3, t4);
7602
+ };
7603
+ /** Dims the page under an open drawer; pressing it closes the drawer. */
7604
+ const PanelScrim = (t0) => {
7605
+ const $ = c(2);
7606
+ const { onDismiss } = t0;
7607
+ let t1;
7608
+ if ($[0] !== onDismiss) {
7609
+ t1 = /* @__PURE__ */ jsx("div", {
7610
+ "aria-hidden": "true",
7611
+ className: "folio-panel-scrim",
7612
+ "data-testid": "folio-panel-scrim",
7613
+ onMouseDown: (event) => {
7614
+ event.preventDefault();
7615
+ onDismiss();
7616
+ }
7617
+ });
7618
+ $[0] = onDismiss;
7619
+ $[1] = t1;
7620
+ } else t1 = $[1];
7621
+ return t1;
7622
+ };
7623
+ //#endregion
7624
+ //#region src/components/DocumentOutline.tsx
7625
+ const SURFACE_WIDTH = {
7626
+ column: PANEL_METRICS.outlineColumnWidth,
7627
+ rail: PANEL_METRICS.outlineRailWidth,
7628
+ drawer: PANEL_METRICS.drawerWidth
7629
+ };
7630
+ const DocumentOutline = (t0) => {
7631
+ const $ = c(55);
7632
+ const { headings, scrollContainerRef, docSize, activeId, onJump, surface, expanded, onExpand, onClose } = t0;
7633
+ const t = useTranslations("folio");
7634
+ const OutlineRail = useFolioUI().OutlineRail;
7635
+ const navRef = useRef(null);
7636
+ useDrawerFocus(navRef, surface === "drawer" && onClose ? onClose : null);
7637
+ let t1;
7638
+ if ($[0] !== headings) {
7639
+ t1 = headings.map(_temp$7);
7640
+ $[0] = headings;
7641
+ $[1] = t1;
7642
+ } else t1 = $[1];
7643
+ const items = t1;
7644
+ let map;
7645
+ if ($[2] !== docSize || $[3] !== headings) {
7646
+ map = /* @__PURE__ */ new Map();
7647
+ if (docSize > 0) for (const heading_0 of headings) map.set(headingId(heading_0), Math.min(99, Math.max(1, heading_0.pmPos / docSize * 100)));
7648
+ $[2] = docSize;
7649
+ $[3] = headings;
7650
+ $[4] = map;
7651
+ } else map = $[4];
7652
+ const pctById = map;
7653
+ let t2;
7654
+ if ($[5] !== onClose || $[6] !== onJump || $[7] !== surface) {
7655
+ t2 = (id) => {
7656
+ onJump(id);
7657
+ if (surface === "drawer") onClose?.();
7658
+ };
7659
+ $[5] = onClose;
7660
+ $[6] = onJump;
7661
+ $[7] = surface;
7662
+ $[8] = t2;
7663
+ } else t2 = $[8];
7664
+ const handleJump = t2;
7665
+ let t3;
7666
+ if ($[9] !== pctById) {
7667
+ t3 = (id_0) => pctById.get(id_0) ?? null;
7668
+ $[9] = pctById;
7669
+ $[10] = t3;
7670
+ } else t3 = $[10];
7671
+ const resolvePct = t3;
7551
7672
  if (headings.length < 2) return null;
7673
+ let t4;
7674
+ if ($[11] !== t) {
7675
+ t4 = t("editor.showDocumentOutline");
7676
+ $[11] = t;
7677
+ $[12] = t4;
7678
+ } else t4 = $[12];
7679
+ const outlineLabel = t4;
7680
+ const width = SURFACE_WIDTH[surface];
7681
+ const t5 = surface === "rail" ? "rail" : "panel";
7552
7682
  let t6;
7553
- if ($[13] !== OutlineRail || $[14] !== activeId || $[15] !== handleJump || $[16] !== items || $[17] !== resolvePct || $[18] !== scrollContainerRef || $[19] !== topOffset) {
7683
+ if ($[13] !== OutlineRail || $[14] !== activeId || $[15] !== handleJump || $[16] !== items || $[17] !== outlineLabel || $[18] !== resolvePct || $[19] !== scrollContainerRef || $[20] !== t5 || $[21] !== width) {
7554
7684
  t6 = /* @__PURE__ */ jsx(OutlineRail, {
7555
7685
  activeId,
7556
- ariaLabel: "Document outline",
7686
+ ariaLabel: outlineLabel,
7557
7687
  items,
7558
7688
  onJump: handleJump,
7559
- panelWidth: 320,
7689
+ panelWidth: width,
7690
+ presentation: t5,
7560
7691
  resolvePct,
7561
7692
  scrollContainerRef,
7562
- topOffset
7693
+ topOffset: 0
7563
7694
  });
7564
7695
  $[13] = OutlineRail;
7565
7696
  $[14] = activeId;
7566
7697
  $[15] = handleJump;
7567
7698
  $[16] = items;
7568
- $[17] = resolvePct;
7569
- $[18] = scrollContainerRef;
7570
- $[19] = topOffset;
7571
- $[20] = t6;
7572
- } else t6 = $[20];
7573
- return t6;
7699
+ $[17] = outlineLabel;
7700
+ $[18] = resolvePct;
7701
+ $[19] = scrollContainerRef;
7702
+ $[20] = t5;
7703
+ $[21] = width;
7704
+ $[22] = t6;
7705
+ } else t6 = $[22];
7706
+ const rail = t6;
7707
+ if (surface === "rail") {
7708
+ let t7;
7709
+ if ($[23] !== width) {
7710
+ t7 = { width };
7711
+ $[23] = width;
7712
+ $[24] = t7;
7713
+ } else t7 = $[24];
7714
+ const t8 = expanded ?? false;
7715
+ let t9;
7716
+ if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
7717
+ t9 = /* @__PURE__ */ jsx(PanelLeftOpenIcon, {
7718
+ "aria-hidden": "true",
7719
+ size: 16
7720
+ });
7721
+ $[25] = t9;
7722
+ } else t9 = $[25];
7723
+ let t10;
7724
+ if ($[26] !== onExpand || $[27] !== outlineLabel || $[28] !== t8) {
7725
+ t10 = /* @__PURE__ */ jsx("button", {
7726
+ "aria-expanded": t8,
7727
+ "aria-label": outlineLabel,
7728
+ className: "folio-outline-icon-button",
7729
+ "data-testid": "folio-outline-expand",
7730
+ onClick: onExpand,
7731
+ title: outlineLabel,
7732
+ type: "button",
7733
+ children: t9
7734
+ });
7735
+ $[26] = onExpand;
7736
+ $[27] = outlineLabel;
7737
+ $[28] = t8;
7738
+ $[29] = t10;
7739
+ } else t10 = $[29];
7740
+ let t11;
7741
+ if ($[30] !== outlineLabel || $[31] !== rail || $[32] !== t10 || $[33] !== t7) {
7742
+ t11 = /* @__PURE__ */ jsxs("nav", {
7743
+ "aria-label": outlineLabel,
7744
+ className: "folio-outline folio-outline--rail",
7745
+ "data-testid": "folio-outline",
7746
+ "data-folio-outline-surface": "rail",
7747
+ style: t7,
7748
+ children: [t10, rail]
7749
+ });
7750
+ $[30] = outlineLabel;
7751
+ $[31] = rail;
7752
+ $[32] = t10;
7753
+ $[33] = t7;
7754
+ $[34] = t11;
7755
+ } else t11 = $[34];
7756
+ return t11;
7757
+ }
7758
+ const t7 = `folio-outline folio-outline--${surface}`;
7759
+ let t8;
7760
+ if ($[35] !== width) {
7761
+ t8 = { width };
7762
+ $[35] = width;
7763
+ $[36] = t8;
7764
+ } else t8 = $[36];
7765
+ let t9;
7766
+ if ($[37] !== t) {
7767
+ t9 = t("editor.outlineTitle");
7768
+ $[37] = t;
7769
+ $[38] = t9;
7770
+ } else t9 = $[38];
7771
+ let t10;
7772
+ if ($[39] !== t9) {
7773
+ t10 = /* @__PURE__ */ jsx("span", {
7774
+ className: "folio-outline-title",
7775
+ children: t9
7776
+ });
7777
+ $[39] = t9;
7778
+ $[40] = t10;
7779
+ } else t10 = $[40];
7780
+ let t11;
7781
+ if ($[41] !== onClose || $[42] !== surface || $[43] !== t) {
7782
+ t11 = surface === "drawer" && onClose && /* @__PURE__ */ jsx("button", {
7783
+ "aria-label": t("common.closeDialog"),
7784
+ className: "folio-outline-icon-button",
7785
+ onClick: onClose,
7786
+ title: t("common.closeDialog"),
7787
+ type: "button",
7788
+ children: /* @__PURE__ */ jsx(XIcon, {
7789
+ "aria-hidden": "true",
7790
+ size: 16
7791
+ })
7792
+ });
7793
+ $[41] = onClose;
7794
+ $[42] = surface;
7795
+ $[43] = t;
7796
+ $[44] = t11;
7797
+ } else t11 = $[44];
7798
+ let t12;
7799
+ if ($[45] !== t10 || $[46] !== t11) {
7800
+ t12 = /* @__PURE__ */ jsxs("div", {
7801
+ className: "folio-outline-header",
7802
+ children: [t10, t11]
7803
+ });
7804
+ $[45] = t10;
7805
+ $[46] = t11;
7806
+ $[47] = t12;
7807
+ } else t12 = $[47];
7808
+ let t13;
7809
+ if ($[48] !== outlineLabel || $[49] !== rail || $[50] !== surface || $[51] !== t12 || $[52] !== t7 || $[53] !== t8) {
7810
+ t13 = /* @__PURE__ */ jsxs("nav", {
7811
+ ref: navRef,
7812
+ "aria-label": outlineLabel,
7813
+ className: t7,
7814
+ "data-testid": "folio-outline",
7815
+ "data-folio-outline-surface": surface,
7816
+ style: t8,
7817
+ children: [t12, rail]
7818
+ });
7819
+ $[48] = outlineLabel;
7820
+ $[49] = rail;
7821
+ $[50] = surface;
7822
+ $[51] = t12;
7823
+ $[52] = t7;
7824
+ $[53] = t8;
7825
+ $[54] = t13;
7826
+ } else t13 = $[54];
7827
+ return t13;
7574
7828
  };
7575
- function _temp$6(heading) {
7829
+ function _temp$7(heading) {
7576
7830
  const item = {
7577
- id: String(heading.pmPos),
7831
+ id: headingId(heading),
7578
7832
  label: heading.text,
7579
7833
  level: heading.level
7580
7834
  };
7581
7835
  if (typeof heading.pageNumber === "number") item.meta = String(heading.pageNumber);
7582
7836
  return item;
7583
7837
  }
7584
- function _temp2$3(a, b) {
7585
- return a.pm - b.pm;
7586
- }
7587
7838
  //#endregion
7588
7839
  //#region src/components/DocxEditorDialogs.tsx
7589
- const FindReplaceDialog = lazy(() => import("./FindReplaceDialog-CqKK82nE.js").then((n) => n.n).then((m) => ({ default: m.FindReplaceDialog })));
7590
- const TablePropertiesDialog = lazy(() => import("./TablePropertiesDialog-DOUiX1KZ.js").then((n) => n.n).then((m) => ({ default: m.TablePropertiesDialog })));
7591
- const ImagePositionDialog = lazy(() => import("./ImagePositionDialog-DNodkoI2.js").then((n) => n.n).then((m) => ({ default: m.ImagePositionDialog })));
7592
- const ImagePropertiesDialog = lazy(() => import("./ImagePropertiesDialog-CLsDIUWb.js").then((n) => n.n).then((m) => ({ default: m.ImagePropertiesDialog })));
7593
- const FootnotePropertiesDialog = lazy(() => import("./FootnotePropertiesDialog-CixRdIiT.js").then((n) => n.n).then((m) => ({ default: m.FootnotePropertiesDialog })));
7594
- const PageSetupDialog = lazy(() => import("./PageSetupDialog-COkgeOQn.js").then((n) => n.n).then((m) => ({ default: m.PageSetupDialog })));
7595
- const InsertSymbolDialog = lazy(() => import("./InsertSymbolDialog-DCFLmfzn.js").then((n) => n.n).then((m) => ({ default: m.InsertSymbolDialog })));
7840
+ const FindReplaceDialog = lazy(() => import("./FindReplaceDialog-BUwFQWaq.js").then((n) => n.n).then((m) => ({ default: m.FindReplaceDialog })));
7841
+ const TablePropertiesDialog = lazy(() => import("./TablePropertiesDialog-DwPiUj4m.js").then((n) => n.n).then((m) => ({ default: m.TablePropertiesDialog })));
7842
+ const ImagePositionDialog = lazy(() => import("./ImagePositionDialog-9q71ka9N.js").then((n) => n.n).then((m) => ({ default: m.ImagePositionDialog })));
7843
+ const ImagePropertiesDialog = lazy(() => import("./ImagePropertiesDialog-o79NCGk7.js").then((n) => n.n).then((m) => ({ default: m.ImagePropertiesDialog })));
7844
+ const FootnotePropertiesDialog = lazy(() => import("./FootnotePropertiesDialog-6XdO0zBH.js").then((n) => n.n).then((m) => ({ default: m.FootnotePropertiesDialog })));
7845
+ const PageSetupDialog = lazy(() => import("./PageSetupDialog-CMdVXCZ-.js").then((n) => n.n).then((m) => ({ default: m.PageSetupDialog })));
7846
+ const SetNumberingValueDialog = lazy(() => import("./SetNumberingValueDialog-DOsaSq7e.js").then((m) => ({ default: m.SetNumberingValueDialog })));
7847
+ const InsertSymbolDialog = lazy(() => import("./InsertSymbolDialog-Cn_Nifhg.js").then((n) => n.n).then((m) => ({ default: m.InsertSymbolDialog })));
7596
7848
  function DocxEditorDialogs(t0) {
7597
- const $ = c(47);
7598
- const { findReplace, tableProperties, imagePosition, imageProperties, pageSetup, footnoteProperties, insertSymbol } = t0;
7849
+ const $ = c(52);
7850
+ const { findReplace, tableProperties, imagePosition, imageProperties, pageSetup, footnoteProperties, insertSymbol, setNumberingValue } = t0;
7599
7851
  let t1;
7600
7852
  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) {
7601
7853
  t1 = findReplace.state.dialog.status === "open" && /* @__PURE__ */ jsx(FindReplaceDialog, {
@@ -7703,8 +7955,20 @@ function DocxEditorDialogs(t0) {
7703
7955
  $[38] = t7;
7704
7956
  } else t7 = $[38];
7705
7957
  let t8;
7706
- if ($[39] !== t1 || $[40] !== t2 || $[41] !== t3 || $[42] !== t4 || $[43] !== t5 || $[44] !== t6 || $[45] !== t7) {
7707
- t8 = /* @__PURE__ */ jsxs(Suspense, {
7958
+ if ($[39] !== setNumberingValue.isOpen || $[40] !== setNumberingValue.onApply || $[41] !== setNumberingValue.onClose) {
7959
+ t8 = setNumberingValue.isOpen && /* @__PURE__ */ jsx(SetNumberingValueDialog, {
7960
+ isOpen: setNumberingValue.isOpen,
7961
+ onClose: setNumberingValue.onClose,
7962
+ onApply: setNumberingValue.onApply
7963
+ });
7964
+ $[39] = setNumberingValue.isOpen;
7965
+ $[40] = setNumberingValue.onApply;
7966
+ $[41] = setNumberingValue.onClose;
7967
+ $[42] = t8;
7968
+ } else t8 = $[42];
7969
+ let t9;
7970
+ if ($[43] !== t1 || $[44] !== t2 || $[45] !== t3 || $[46] !== t4 || $[47] !== t5 || $[48] !== t6 || $[49] !== t7 || $[50] !== t8) {
7971
+ t9 = /* @__PURE__ */ jsxs(Suspense, {
7708
7972
  fallback: null,
7709
7973
  children: [
7710
7974
  t1,
@@ -7713,19 +7977,21 @@ function DocxEditorDialogs(t0) {
7713
7977
  t4,
7714
7978
  t5,
7715
7979
  t6,
7716
- t7
7980
+ t7,
7981
+ t8
7717
7982
  ]
7718
7983
  });
7719
- $[39] = t1;
7720
- $[40] = t2;
7721
- $[41] = t3;
7722
- $[42] = t4;
7723
- $[43] = t5;
7724
- $[44] = t6;
7725
- $[45] = t7;
7726
- $[46] = t8;
7727
- } else t8 = $[46];
7728
- return t8;
7984
+ $[43] = t1;
7985
+ $[44] = t2;
7986
+ $[45] = t3;
7987
+ $[46] = t4;
7988
+ $[47] = t5;
7989
+ $[48] = t6;
7990
+ $[49] = t7;
7991
+ $[50] = t8;
7992
+ $[51] = t9;
7993
+ } else t9 = $[51];
7994
+ return t9;
7729
7995
  }
7730
7996
  //#endregion
7731
7997
  //#region src/components/DocxEditorHelpers.tsx
@@ -7954,7 +8220,7 @@ function NotificationContainer(t0) {
7954
8220
  if ($[0] !== notifications || $[1] !== onDismiss) {
7955
8221
  t3 = Symbol.for("react.early_return_sentinel");
7956
8222
  bb0: {
7957
- const visibleNotifications = notifications.filter(_temp$5);
8223
+ const visibleNotifications = notifications.filter(_temp$6);
7958
8224
  if (visibleNotifications.length === 0) {
7959
8225
  t3 = null;
7960
8226
  break bb0;
@@ -7994,7 +8260,7 @@ function NotificationContainer(t0) {
7994
8260
  } else t4 = $[9];
7995
8261
  return t4;
7996
8262
  }
7997
- function _temp$5(n) {
8263
+ function _temp$6(n) {
7998
8264
  return !n.dismissed;
7999
8265
  }
8000
8266
  const SEVERITY_STYLES = {
@@ -8436,7 +8702,7 @@ function AlignmentButtons({ value = "left", onChange, disabled = false }) {
8436
8702
  function AlignmentOption(t0) {
8437
8703
  const $ = c(16);
8438
8704
  const { PopoverClose, option, selected, onChange } = t0;
8439
- const handleMouseDown = _temp$4;
8705
+ const handleMouseDown = _temp$5;
8440
8706
  let t1;
8441
8707
  if ($[0] !== onChange || $[1] !== option.value) {
8442
8708
  t1 = () => onChange?.(option.value);
@@ -8490,7 +8756,7 @@ function AlignmentOption(t0) {
8490
8756
  } else t8 = $[15];
8491
8757
  return t8;
8492
8758
  }
8493
- function _temp$4(event) {
8759
+ function _temp$5(event) {
8494
8760
  return event.preventDefault();
8495
8761
  }
8496
8762
  //#endregion
@@ -9082,7 +9348,7 @@ const DOCUMENT_COLOR_PRESETS = [
9082
9348
  }
9083
9349
  ];
9084
9350
  function FormattingBar(props) {
9085
- const { currentFormatting = {}, onFormat, onUndo, onRedo, canUndo = false, canRedo = false, disabled = false, className, style, enableShortcuts = true, editorRef, children, showStylePicker = true, showFormatPainter = true, formatPainterActive = false, onFormatPainter, showFontPicker = true, fontFamilies, showFontSizePicker = true, showTextColorPicker = true, showAlignmentButtons = true, showListButtons = true, showZoomControl, zoom, onZoomChange, rulerVisible = false, onToggleRuler, documentStyles, theme, onRefocusEditor, onInsertImage, onInsertTable, showTableInsert = true, onInsertPageBreak, onInsertTOC, onInsertSymbol, priorityExtra, inlineExtra, stylePickerLabel, stylePickerLabelStyle, inline = false } = props;
9351
+ const { currentFormatting = {}, onFormat, onUndo, onRedo, canUndo = false, canRedo = false, disabled = false, className, style, enableShortcuts = true, editorRef, children, showStylePicker = true, showFormatPainter = true, formatPainterActive = false, onFormatPainter, showFontPicker = true, fontFamilies, showFontSizePicker = true, showTextColorPicker = true, showAlignmentButtons = true, showListButtons = true, showZoomControl, zoom, onZoomChange, rulerVisible = false, onToggleRuler, documentStyles, theme, onRefocusEditor, onInsertImage, onInsertTable, showTableInsert = true, onInsertPageBreak, onInsertTOC, onInsertSymbol, priorityExtra, inlineExtra, panelToggles, stylePickerLabel, stylePickerLabelStyle, inline = false } = props;
9086
9352
  const folioUI = useFolioUI();
9087
9353
  const { Root: Menu, Trigger: MenuTrigger, Popup: MenuPopup } = folioUI.Menu;
9088
9354
  const ColorPicker = folioUI.ColorPicker;
@@ -9640,6 +9906,7 @@ function FormattingBar(props) {
9640
9906
  /* @__PURE__ */ jsxs("div", {
9641
9907
  className: "ms-auto flex shrink-0 items-center gap-1",
9642
9908
  children: [
9909
+ panelToggles,
9643
9910
  onToggleRuler && /* @__PURE__ */ jsx(ToolbarGroup, {
9644
9911
  label: t("viewGroup"),
9645
9912
  children: /* @__PURE__ */ jsx(ToolbarButton, {
@@ -10302,8 +10569,8 @@ const useHyperlinkHandlers = (t0) => {
10302
10569
  $[0] = t1;
10303
10570
  } else t1 = $[0];
10304
10571
  const handleHyperlinkClick = t1;
10305
- const handleHyperlinkPopupNavigate = _temp$3;
10306
- const handleHyperlinkPopupCopy = _temp2$2;
10572
+ const handleHyperlinkPopupNavigate = _temp$4;
10573
+ const handleHyperlinkPopupCopy = _temp2$3;
10307
10574
  let t2;
10308
10575
  if ($[1] !== focusActiveEditor || $[2] !== getActiveEditorView) {
10309
10576
  t2 = (displayText, href_1) => {
@@ -10364,14 +10631,14 @@ const useHyperlinkHandlers = (t0) => {
10364
10631
  } else t5 = $[12];
10365
10632
  return t5;
10366
10633
  };
10367
- function _temp$3(href) {
10634
+ function _temp$4(href) {
10368
10635
  const safeHref = sanitizeExternalUrl(href);
10369
10636
  if (safeHref) {
10370
10637
  const anchor = anchorTargetAttrs(void 0);
10371
10638
  window.open(safeHref, anchor.target, windowFeaturesFor(anchor));
10372
10639
  }
10373
10640
  }
10374
- function _temp2$2(href_0) {
10641
+ function _temp2$3(href_0) {
10375
10642
  navigator.clipboard.writeText(href_0);
10376
10643
  }
10377
10644
  //#endregion
@@ -10388,7 +10655,7 @@ const useImageHandlers = (t0) => {
10388
10655
  if (!file) return;
10389
10656
  const view = getActiveEditorView();
10390
10657
  if (!view) return;
10391
- insertImageFromFile(view, file, focusActiveEditor).catch(_temp$2);
10658
+ insertImageFromFile(view, file, focusActiveEditor).catch(_temp$3);
10392
10659
  e.target.value = "";
10393
10660
  };
10394
10661
  $[0] = focusActiveEditor;
@@ -10481,7 +10748,7 @@ const useImageHandlers = (t0) => {
10481
10748
  } else t7 = $[27];
10482
10749
  return t7;
10483
10750
  };
10484
- function _temp$2() {}
10751
+ function _temp$3() {}
10485
10752
  //#endregion
10486
10753
  //#region src/components/hooks/useKeyboardShortcuts.ts
10487
10754
  /**
@@ -10564,6 +10831,114 @@ function useKeyboardShortcuts({ pagedEditorRef, findReplace, tableSelection, onD
10564
10831
  }, [pagedEditorRef, scope]);
10565
10832
  }
10566
10833
  //#endregion
10834
+ //#region src/components/hooks/usePanelLayout.ts
10835
+ /**
10836
+ * Measures the width the editor's panels row has and decides, through
10837
+ * {@link computePanelLayout}, how the outline and the comments are shown.
10838
+ * One ResizeObserver feeds it; the scroll gutter, the ruler offset and the
10839
+ * page centring all read the result, so they agree with what is on screen.
10840
+ */
10841
+ const usePanelLayout = (t0) => {
10842
+ const $ = c(22);
10843
+ const { pageWidth, outline, comments, scrollContainerRef } = t0;
10844
+ const [row, setRow] = useState(null);
10845
+ const [availableWidth, setAvailableWidth] = useState(Number.POSITIVE_INFINITY);
10846
+ const [overlay, setOverlay] = useState("none");
10847
+ let t1;
10848
+ let t2;
10849
+ if ($[0] !== row || $[1] !== scrollContainerRef) {
10850
+ t1 = () => {
10851
+ if (!row) return;
10852
+ const measure = () => {
10853
+ const scroll = scrollContainerRef.current;
10854
+ const scrollbar = scroll ? scroll.offsetWidth - scroll.clientWidth : 0;
10855
+ setAvailableWidth(Math.max(0, row.clientWidth - scrollbar));
10856
+ };
10857
+ measure();
10858
+ const observer = new ResizeObserver(measure);
10859
+ observer.observe(row);
10860
+ if (scrollContainerRef.current) observer.observe(scrollContainerRef.current);
10861
+ return () => observer.disconnect();
10862
+ };
10863
+ t2 = [row, scrollContainerRef];
10864
+ $[0] = row;
10865
+ $[1] = scrollContainerRef;
10866
+ $[2] = t1;
10867
+ $[3] = t2;
10868
+ } else {
10869
+ t1 = $[2];
10870
+ t2 = $[3];
10871
+ }
10872
+ useLayoutEffect(t1, t2);
10873
+ let t3;
10874
+ if ($[4] !== availableWidth || $[5] !== comments || $[6] !== outline || $[7] !== pageWidth) {
10875
+ t3 = computePanelLayout({
10876
+ availableWidth,
10877
+ pageWidth,
10878
+ outline,
10879
+ comments
10880
+ });
10881
+ $[4] = availableWidth;
10882
+ $[5] = comments;
10883
+ $[6] = outline;
10884
+ $[7] = pageWidth;
10885
+ $[8] = t3;
10886
+ } else t3 = $[8];
10887
+ const layout = t3;
10888
+ const outlineDrawn = layout.outline === "rail" || layout.outline === "drawer";
10889
+ const commentsDrawn = layout.comments === "drawer";
10890
+ let t4;
10891
+ let t5;
10892
+ if ($[9] !== commentsDrawn || $[10] !== outlineDrawn || $[11] !== overlay) {
10893
+ t4 = () => {
10894
+ if (overlay === "outline" && !outlineDrawn || overlay === "comments" && !commentsDrawn) setOverlay("none");
10895
+ };
10896
+ t5 = [
10897
+ commentsDrawn,
10898
+ outlineDrawn,
10899
+ overlay
10900
+ ];
10901
+ $[9] = commentsDrawn;
10902
+ $[10] = outlineDrawn;
10903
+ $[11] = overlay;
10904
+ $[12] = t4;
10905
+ $[13] = t5;
10906
+ } else {
10907
+ t4 = $[12];
10908
+ t5 = $[13];
10909
+ }
10910
+ useEffect(t4, t5);
10911
+ let t6;
10912
+ if ($[14] !== availableWidth || $[15] !== outline || $[16] !== pageWidth) {
10913
+ t6 = () => computePanelLayout({
10914
+ availableWidth,
10915
+ pageWidth,
10916
+ outline,
10917
+ comments: "open"
10918
+ });
10919
+ $[14] = availableWidth;
10920
+ $[15] = outline;
10921
+ $[16] = pageWidth;
10922
+ $[17] = t6;
10923
+ } else t6 = $[17];
10924
+ const layoutWithCommentsOpen = t6;
10925
+ let t7;
10926
+ if ($[18] !== layout || $[19] !== layoutWithCommentsOpen || $[20] !== overlay) {
10927
+ t7 = {
10928
+ rowRef: setRow,
10929
+ layout,
10930
+ overlay,
10931
+ setOverlay,
10932
+ layoutWithCommentsOpen
10933
+ };
10934
+ $[18] = layout;
10935
+ $[19] = layoutWithCommentsOpen;
10936
+ $[20] = overlay;
10937
+ $[21] = t7;
10938
+ } else t7 = $[21];
10939
+ return t7;
10940
+ };
10941
+ //#endregion
10567
10942
  //#region src/components/hooks/useZoomAndPageInfo.ts
10568
10943
  const PAGE_INFO_FADE_MS = 600;
10569
10944
  const FIT_TO_WIDTH_PADDING_PX = 16;
@@ -11146,7 +11521,7 @@ function OptionsMenu(t0) {
11146
11521
  if ($[3] !== setShowOptions) {
11147
11522
  t3 = (e) => {
11148
11523
  e.stopPropagation();
11149
- setShowOptions(_temp$1);
11524
+ setShowOptions(_temp$2);
11150
11525
  };
11151
11526
  $[3] = setShowOptions;
11152
11527
  $[4] = t3;
@@ -11163,7 +11538,7 @@ function OptionsMenu(t0) {
11163
11538
  type: "button",
11164
11539
  className: "hf-options-button",
11165
11540
  onClick: t3,
11166
- onMouseDown: _temp2$1,
11541
+ onMouseDown: _temp2$2,
11167
11542
  children: [t4, " ▾"]
11168
11543
  });
11169
11544
  $[7] = t3;
@@ -11237,45 +11612,13 @@ function OptionsMenu(t0) {
11237
11612
  } else t7 = $[21];
11238
11613
  return t7;
11239
11614
  }
11240
- function _temp2$1(e_0) {
11615
+ function _temp2$2(e_0) {
11241
11616
  return e_0.stopPropagation();
11242
11617
  }
11243
- function _temp$1(prev) {
11618
+ function _temp$2(prev) {
11244
11619
  return !prev;
11245
11620
  }
11246
11621
  //#endregion
11247
- //#region src/components/selectionFormattingBuilder.ts
11248
- /**
11249
- * Assemble the `SelectionFormatting` object the toolbar consumes.
11250
- *
11251
- * Several fields are `?: T` (no `| undefined`) under
11252
- * `exactOptionalPropertyTypes`, so we only assign them when the source
11253
- * value is defined — assigning `undefined` would be a type error. Pure
11254
- * (no DOM, no PM state mutation).
11255
- */
11256
- function buildSelectionFormatting({ selectionState, fontFamily, fontSize, textColor, listState }) {
11257
- const { textFormatting, paragraphFormatting } = selectionState;
11258
- const formatting = {
11259
- underline: !!textFormatting.underline,
11260
- superscript: textFormatting.vertAlign === "superscript",
11261
- subscript: textFormatting.vertAlign === "subscript",
11262
- bidi: !!paragraphFormatting.bidi
11263
- };
11264
- if (textFormatting.bold !== void 0) formatting.bold = textFormatting.bold;
11265
- if (textFormatting.italic !== void 0) formatting.italic = textFormatting.italic;
11266
- if (textFormatting.strike !== void 0) formatting.strike = textFormatting.strike;
11267
- if (fontFamily !== void 0) formatting.fontFamily = fontFamily;
11268
- if (fontSize !== void 0) formatting.fontSize = fontSize;
11269
- if (textColor !== void 0) formatting.color = textColor;
11270
- if (textFormatting.highlight !== void 0) formatting.highlight = textFormatting.highlight;
11271
- if (paragraphFormatting.alignment !== void 0) formatting.alignment = paragraphFormatting.alignment;
11272
- if (paragraphFormatting.lineSpacing !== void 0) formatting.lineSpacing = paragraphFormatting.lineSpacing;
11273
- if (listState !== void 0) formatting.listState = listState;
11274
- if (selectionState.styleId !== null) formatting.styleId = selectionState.styleId;
11275
- if (paragraphFormatting.indentLeft !== void 0) formatting.indentLeft = paragraphFormatting.indentLeft;
11276
- return formatting;
11277
- }
11278
- //#endregion
11279
11622
  //#region src/components/toolbarUtils.ts
11280
11623
  /**
11281
11624
  * Map hex color to OOXML highlight color name
@@ -11317,7 +11660,164 @@ function areSelectionFormattingEqual(a, b) {
11317
11660
  return a.bold === b.bold && a.italic === b.italic && a.underline === b.underline && a.strike === b.strike && a.superscript === b.superscript && a.subscript === b.subscript && a.fontFamily === b.fontFamily && a.fontSize === b.fontSize && a.color === b.color && a.highlight === b.highlight && a.alignment === b.alignment && a.lineSpacing === b.lineSpacing && sameListState(a.listState, b.listState) && a.styleId === b.styleId && a.indentLeft === b.indentLeft && a.bidi === b.bidi;
11318
11661
  }
11319
11662
  //#endregion
11320
- //#region src/components/ui/HyperlinkPopup.tsx
11663
+ //#region src/components/PanelToggles.tsx
11664
+ /**
11665
+ * Toolbar toggles for the editor's side panels, pinned at the end of the
11666
+ * toolbar so they never collapse into its overflow menu:
11667
+ *
11668
+ * - the outline, shown only while the outline is a drawer (in wider tiers it
11669
+ * has a column or a rail of its own);
11670
+ * - the comments, with the number of open threads as a badge.
11671
+ */
11672
+ /** Counts above this read as "99+". */
11673
+ const MAX_BADGE_COUNT = 99;
11674
+ function PanelToggles(t0) {
11675
+ const $ = c(27);
11676
+ const { outline, onToggleOutline, commentsShown, commentCount, onToggleComments } = t0;
11677
+ const t = useTranslations("folio");
11678
+ const format = useFormatter();
11679
+ let t1;
11680
+ if ($[0] !== t) {
11681
+ t1 = t("comments.visibility");
11682
+ $[0] = t;
11683
+ $[1] = t1;
11684
+ } else t1 = $[1];
11685
+ const commentsLabel = t1;
11686
+ let t2;
11687
+ if ($[2] !== commentCount || $[3] !== format) {
11688
+ t2 = commentCount > MAX_BADGE_COUNT ? `${format.number(MAX_BADGE_COUNT)}+` : format.number(commentCount);
11689
+ $[2] = commentCount;
11690
+ $[3] = format;
11691
+ $[4] = t2;
11692
+ } else t2 = $[4];
11693
+ const badge = t2;
11694
+ let t3;
11695
+ if ($[5] !== onToggleOutline || $[6] !== outline || $[7] !== t) {
11696
+ t3 = outline !== "absent" && /* @__PURE__ */ jsx(ToolbarButton, {
11697
+ active: outline === "open",
11698
+ ariaLabel: t("editor.showDocumentOutline"),
11699
+ onClick: onToggleOutline,
11700
+ testId: "toolbar-outline-toggle",
11701
+ title: t("editor.showDocumentOutline"),
11702
+ children: /* @__PURE__ */ jsx(ListTreeIcon, { size: 16 })
11703
+ });
11704
+ $[5] = onToggleOutline;
11705
+ $[6] = outline;
11706
+ $[7] = t;
11707
+ $[8] = t3;
11708
+ } else t3 = $[8];
11709
+ const t4 = commentsShown && "bg-[var(--doc-primary-light)] text-[var(--doc-text)]";
11710
+ let t5;
11711
+ if ($[9] !== t4) {
11712
+ t5 = cn("flex h-8 min-w-8 shrink-0 items-center justify-center gap-1 rounded-md px-1.5", "transition-colors duration-100", "text-[var(--doc-text-muted)] hover:bg-[var(--doc-primary-light)] hover:text-[var(--doc-text)]", t4);
11713
+ $[9] = t4;
11714
+ $[10] = t5;
11715
+ } else t5 = $[10];
11716
+ let t6;
11717
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
11718
+ t6 = /* @__PURE__ */ jsx(MessageSquareTextIcon, {
11719
+ "aria-hidden": "true",
11720
+ size: 16
11721
+ });
11722
+ $[11] = t6;
11723
+ } else t6 = $[11];
11724
+ let t7;
11725
+ if ($[12] !== commentsLabel) {
11726
+ t7 = /* @__PURE__ */ jsx("span", {
11727
+ className: "sr-only",
11728
+ children: commentsLabel
11729
+ });
11730
+ $[12] = commentsLabel;
11731
+ $[13] = t7;
11732
+ } else t7 = $[13];
11733
+ let t8;
11734
+ if ($[14] !== badge || $[15] !== commentCount) {
11735
+ t8 = commentCount > 0 && /* @__PURE__ */ jsx("span", {
11736
+ className: "min-w-4 rounded-full bg-[var(--doc-primary)] px-1 text-center text-[10px] leading-4 font-semibold text-[var(--primary-foreground,var(--doc-page))] tabular-nums",
11737
+ "data-testid": "toolbar-comments-count",
11738
+ children: badge
11739
+ });
11740
+ $[14] = badge;
11741
+ $[15] = commentCount;
11742
+ $[16] = t8;
11743
+ } else t8 = $[16];
11744
+ let t9;
11745
+ if ($[17] !== commentsLabel || $[18] !== commentsShown || $[19] !== onToggleComments || $[20] !== t5 || $[21] !== t7 || $[22] !== t8) {
11746
+ t9 = /* @__PURE__ */ jsxs("button", {
11747
+ "aria-pressed": commentsShown,
11748
+ className: t5,
11749
+ "data-testid": "toolbar-comments-toggle",
11750
+ onClick: onToggleComments,
11751
+ onMouseDown: _temp2$1,
11752
+ title: commentsLabel,
11753
+ type: "button",
11754
+ children: [
11755
+ t6,
11756
+ t7,
11757
+ t8
11758
+ ]
11759
+ });
11760
+ $[17] = commentsLabel;
11761
+ $[18] = commentsShown;
11762
+ $[19] = onToggleComments;
11763
+ $[20] = t5;
11764
+ $[21] = t7;
11765
+ $[22] = t8;
11766
+ $[23] = t9;
11767
+ } else t9 = $[23];
11768
+ let t10;
11769
+ if ($[24] !== t3 || $[25] !== t9) {
11770
+ t10 = /* @__PURE__ */ jsxs("div", {
11771
+ className: "flex shrink-0 items-center gap-0.5",
11772
+ onMouseUp: _temp$1,
11773
+ children: [t3, t9]
11774
+ });
11775
+ $[24] = t3;
11776
+ $[25] = t9;
11777
+ $[26] = t10;
11778
+ } else t10 = $[26];
11779
+ return t10;
11780
+ }
11781
+ function _temp2$1(event_0) {
11782
+ return event_0.preventDefault();
11783
+ }
11784
+ function _temp$1(event) {
11785
+ return event.stopPropagation();
11786
+ }
11787
+ //#endregion
11788
+ //#region src/components/selectionFormattingBuilder.ts
11789
+ /**
11790
+ * Assemble the `SelectionFormatting` object the toolbar consumes.
11791
+ *
11792
+ * Several fields are `?: T` (no `| undefined`) under
11793
+ * `exactOptionalPropertyTypes`, so we only assign them when the source
11794
+ * value is defined — assigning `undefined` would be a type error. Pure
11795
+ * (no DOM, no PM state mutation).
11796
+ */
11797
+ function buildSelectionFormatting({ selectionState, fontFamily, fontSize, textColor, listState }) {
11798
+ const { textFormatting, paragraphFormatting } = selectionState;
11799
+ const formatting = {
11800
+ underline: !!textFormatting.underline,
11801
+ superscript: textFormatting.vertAlign === "superscript",
11802
+ subscript: textFormatting.vertAlign === "subscript",
11803
+ bidi: !!paragraphFormatting.bidi
11804
+ };
11805
+ if (textFormatting.bold !== void 0) formatting.bold = textFormatting.bold;
11806
+ if (textFormatting.italic !== void 0) formatting.italic = textFormatting.italic;
11807
+ if (textFormatting.strike !== void 0) formatting.strike = textFormatting.strike;
11808
+ if (fontFamily !== void 0) formatting.fontFamily = fontFamily;
11809
+ if (fontSize !== void 0) formatting.fontSize = fontSize;
11810
+ if (textColor !== void 0) formatting.color = textColor;
11811
+ if (textFormatting.highlight !== void 0) formatting.highlight = textFormatting.highlight;
11812
+ if (paragraphFormatting.alignment !== void 0) formatting.alignment = paragraphFormatting.alignment;
11813
+ if (paragraphFormatting.lineSpacing !== void 0) formatting.lineSpacing = paragraphFormatting.lineSpacing;
11814
+ if (listState !== void 0) formatting.listState = listState;
11815
+ if (selectionState.styleId !== null) formatting.styleId = selectionState.styleId;
11816
+ if (paragraphFormatting.indentLeft !== void 0) formatting.indentLeft = paragraphFormatting.indentLeft;
11817
+ return formatting;
11818
+ }
11819
+ //#endregion
11820
+ //#region src/components/ui/HyperlinkPopup.tsx
11321
11821
  /**
11322
11822
  * HyperlinkPopup — floating popup for viewing/editing hyperlinks.
11323
11823
  * View mode: URL + copy/edit/unlink buttons.
@@ -12150,7 +12650,7 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
12150
12650
  setComments(bodyComments);
12151
12651
  setVisibleCommentAuthors(null);
12152
12652
  setActiveCommentId(null);
12153
- if (autoOpenReviewSidebar) setShowCommentsSidebar(true);
12653
+ if (autoOpenReviewSidebar && countOpenCommentThreads(bodyComments) > 0) setShowCommentsSidebar(true);
12154
12654
  commentsLoadedRef.current = true;
12155
12655
  }
12156
12656
  }, [
@@ -12279,8 +12779,10 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
12279
12779
  * - Error boundary
12280
12780
  * - Loading states
12281
12781
  */
12282
- const CommentsSidebar = lazy(() => import("./CommentsSidebar-CGs9K70B.js").then((m) => ({ default: m.CommentsSidebar })));
12283
- const TextContextMenu = lazy(() => import("./TextContextMenu-Ci7-M4oU.js").then((m) => ({ default: m.TextContextMenu })));
12782
+ /** No headings to track while the outline is not shown. */
12783
+ const NO_HEADINGS = [];
12784
+ const CommentsSidebar = lazy(() => import("./CommentsSidebar-DW2u1T_l.js").then((m) => ({ default: m.CommentsSidebar })));
12785
+ const TextContextMenu = lazy(() => import("./TextContextMenu-Bqth8itn.js").then((m) => ({ default: m.TextContextMenu })));
12284
12786
  const loadAttemptSelectiveSave = async () => {
12285
12787
  const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
12286
12788
  return attemptSelectiveSave;
@@ -12298,6 +12800,15 @@ const DISPLAY_MODE_LABEL_KEYS = {
12298
12800
  };
12299
12801
  const preventMouseDownDefault = (event) => event.preventDefault();
12300
12802
  let documentOperationUndoHandleCursor = Date.now();
12803
+ /**
12804
+ * The comments a batch's applied operations own. A run whose result the
12805
+ * save-time check refused allocated comments nothing in the document names;
12806
+ * they stay out of the comment list.
12807
+ */
12808
+ const appliedOperationComments = (created, applied) => {
12809
+ const appliedIds = new Set(applied.map(({ commentId }) => commentId));
12810
+ return created.filter((comment) => appliedIds.has(comment.id));
12811
+ };
12301
12812
  function isDisplayMode(value) {
12302
12813
  return typeof value === "string" && DISPLAY_MODES.some((mode) => mode === value);
12303
12814
  }
@@ -12370,6 +12881,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12370
12881
  const [tablePropsOpen, setTablePropsOpen] = useState(false);
12371
12882
  const [footnotePropsOpen, setFootnotePropsOpen] = useState(false);
12372
12883
  const [showInsertSymbol, setShowInsertSymbol] = useState(false);
12884
+ const [numberingValueDialogOpen, setNumberingValueDialogOpen] = useState(false);
12373
12885
  const [rulerVisible, setRulerVisible] = useState(showRulerProp);
12374
12886
  const toggleRuler = useCallback(() => setRulerVisible((visible) => !visible), []);
12375
12887
  const [showOutline, setShowOutline] = useState(showOutlineProp);
@@ -12509,11 +13021,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12509
13021
  reportEditorViewReady(null);
12510
13022
  };
12511
13023
  }, [onEditorViewReady, reportEditorViewReady]);
13024
+ const [bodyViewEpoch, setBodyViewEpoch] = useState(0);
13025
+ const handleBodyViewReady = useCallback((view_2) => {
13026
+ reportEditorViewReady(view_2);
13027
+ setBodyViewEpoch((epoch) => epoch + 1);
13028
+ }, [reportEditorViewReady]);
12512
13029
  useEffect(() => {
12513
13030
  if (!showOutline) return;
12514
- const view_2 = pagedEditorRef.current?.getView();
12515
- if (!view_2) return;
12516
- const headings = collectHeadings(view_2.state.doc, getDocumentBuiltInStyles(view_2.state));
13031
+ const view_3 = pagedEditorRef.current?.getView();
13032
+ if (!view_3) return;
13033
+ const headings = collectHeadings(view_3.state.doc, getDocumentBuiltInStyles(view_3.state));
12517
13034
  setHeadingInfos(headings);
12518
13035
  let attempts = 0;
12519
13036
  let timer = null;
@@ -12534,7 +13051,11 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12534
13051
  return () => {
12535
13052
  if (timer) clearTimeout(timer);
12536
13053
  };
12537
- }, [showOutline, history.state]);
13054
+ }, [
13055
+ showOutline,
13056
+ history.state,
13057
+ bodyViewEpoch
13058
+ ]);
12538
13059
  const pagedEditorRef = useRef(null);
12539
13060
  const hfEditorRef = useRef(null);
12540
13061
  const containerRef = useRef(null);
@@ -12544,6 +13065,31 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12544
13065
  const editorContentRef = useRef(null);
12545
13066
  const scrollContainerRef = useRef(null);
12546
13067
  const initialScrollAppliedRef = useRef(false);
13068
+ const [widestLaidOutPageWidth, setWidestLaidOutPageWidth] = useState(null);
13069
+ const hasDocument = history.state !== null;
13070
+ useEffect(() => {
13071
+ const pagedEditor = pagedEditorRef.current;
13072
+ if (!pagedEditor) {
13073
+ setWidestLaidOutPageWidth(null);
13074
+ return;
13075
+ }
13076
+ const updatePageWidth = () => {
13077
+ const pages = pagedEditor.getLayout()?.pages;
13078
+ if (!pages) {
13079
+ setWidestLaidOutPageWidth(null);
13080
+ return;
13081
+ }
13082
+ let width = 0;
13083
+ for (const page_0 of pages) width = Math.max(width, page_0.size.w);
13084
+ setWidestLaidOutPageWidth(width);
13085
+ };
13086
+ updatePageWidth();
13087
+ return pagedEditor.getEditor().on("layoutComplete", updatePageWidth);
13088
+ }, [
13089
+ state.documentLoad.status,
13090
+ hasDocument,
13091
+ preserveDocumentWhileLoading
13092
+ ]);
12547
13093
  const [formatPainterMode, setFormatPainterModeState] = useState("off");
12548
13094
  const formatPainterModeRef = useRef("off");
12549
13095
  const capturedFormatMarksRef = useRef(null);
@@ -12552,9 +13098,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12552
13098
  setFormatPainterModeState(next);
12553
13099
  }, []);
12554
13100
  const { contextMenu, openMenu: openContextMenu, closeMenu: closeContextMenu } = useContextMenu({ pagedEditorRef });
12555
- const toolbarWrapperRef = useRef(null);
12556
- const toolbarRoRef = useRef(null);
12557
- const [toolbarHeight, setToolbarHeight] = useState(0);
12558
13101
  const historyStateRef = useRef(history.state);
12559
13102
  historyStateRef.current = history.state;
12560
13103
  const borderSpecRef = useRef({
@@ -12571,6 +13114,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12571
13114
  onCommentsChange
12572
13115
  });
12573
13116
  const documentOperationUndoEntriesRef = useRef([]);
13117
+ const pendingSuggestionRegistryRef = useRef(new FolioPendingSuggestionRegistry());
12574
13118
  const styleResolverCacheRef = useRef(null);
12575
13119
  const getCachedStyleResolver = useCallback((styles) => {
12576
13120
  const cached = styleResolverCacheRef.current;
@@ -12599,26 +13143,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12599
13143
  canUndo: false
12600
13144
  });
12601
13145
  const [activeNoteStory, setActiveNoteStory] = useState(null);
12602
- const toolbarRefCallback = useCallback((el) => {
12603
- toolbarWrapperRef.current = el;
12604
- if (toolbarRoRef.current) {
12605
- toolbarRoRef.current.disconnect();
12606
- toolbarRoRef.current = null;
12607
- }
12608
- if (!el) {
12609
- setToolbarHeight(0);
12610
- return;
12611
- }
12612
- setToolbarHeight(el.offsetHeight);
12613
- const ro = new ResizeObserver(() => {
12614
- setToolbarHeight(el.offsetHeight);
12615
- });
12616
- ro.observe(el);
12617
- toolbarRoRef.current = ro;
12618
- }, []);
12619
- useEffect(() => () => {
12620
- toolbarRoRef.current?.disconnect();
12621
- }, []);
12622
13146
  const pushDocument = useCallback((document) => {
12623
13147
  history.push(document);
12624
13148
  return document;
@@ -12638,6 +13162,21 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12638
13162
  });
12639
13163
  let activeHfRId = hfEditIsFirstPage ? activeFirstFooterRId : activeFooterRId;
12640
13164
  if (hfEditPosition === "header") activeHfRId = hfEditIsFirstPage ? activeFirstHeaderRId : activeHeaderRId;
13165
+ const panels = usePanelLayout({
13166
+ pageWidth: (widestLaidOutPageWidth ?? getPageSize(effectiveSectionProperties).w) * zoom,
13167
+ outline: showOutline && outlineHeadings.length > 1 ? "available" : "absent",
13168
+ comments: showCommentsSidebar ? "open" : "closed",
13169
+ scrollContainerRef
13170
+ });
13171
+ const { overlay: panelOverlay, setOverlay: setPanelOverlay, layoutWithCommentsOpen } = panels;
13172
+ const commentsSurface = (() => {
13173
+ if (panels.layout.comments === "column") return "column";
13174
+ if (panels.layout.comments === "drawer" && panelOverlay === "comments") return "drawer";
13175
+ return null;
13176
+ })();
13177
+ const { activeId: activeHeadingId, markJumped: markHeadingJumped } = useActiveHeading(scrollContainerRef, panels.layout.outline === "none" ? NO_HEADINGS : outlineHeadings);
13178
+ const closePanelOverlay = useCallback(() => setPanelOverlay("none"), [setPanelOverlay]);
13179
+ const toggleOutlineOverlay = useCallback(() => setPanelOverlay(panelOverlay === "outline" ? "none" : "outline"), [panelOverlay, setPanelOverlay]);
12641
13180
  const getActiveEditorStory = useCallback(() => {
12642
13181
  return resolveActiveEditorStory({
12643
13182
  bodyView: pagedEditorRef.current?.getView() ?? null,
@@ -12698,7 +13237,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12698
13237
  }
12699
13238
  commentsDirtyRef.current = false;
12700
13239
  commentsLoadedRef.current = false;
12701
- trackedChangesLoadedRef.current = false;
12702
13240
  setComments([]);
12703
13241
  setTrackedChanges([]);
12704
13242
  setVisibleCommentAuthors(null);
@@ -12741,27 +13279,15 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12741
13279
  }));
12742
13280
  }, [])
12743
13281
  });
12744
- const trackedChangesLoadedRef = useRef(false);
12745
13282
  useEffect(() => {
12746
13283
  if (state.documentLoad.status === "ready" && history.state) {
12747
- const timer_0 = setTimeout(() => {
12748
- extractTrackedChanges();
12749
- if (!trackedChangesLoadedRef.current) {
12750
- trackedChangesLoadedRef.current = true;
12751
- setTrackedChanges((prev_1) => {
12752
- if (autoOpenReviewSidebar && prev_1.length > 0) setShowCommentsSidebar(true);
12753
- return prev_1;
12754
- });
12755
- }
12756
- }, 200);
13284
+ const timer_0 = setTimeout(extractTrackedChanges, 200);
12757
13285
  return () => clearTimeout(timer_0);
12758
13286
  }
12759
13287
  }, [
12760
13288
  state.documentLoad.status,
12761
13289
  history.state,
12762
- extractTrackedChanges,
12763
- autoOpenReviewSidebar,
12764
- setShowCommentsSidebar
13290
+ extractTrackedChanges
12765
13291
  ]);
12766
13292
  useEffect(() => {
12767
13293
  if (initialScrollTop === void 0 || state.documentLoad.status !== "ready" || initialScrollAppliedRef.current) return;
@@ -12783,8 +13309,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12783
13309
  });
12784
13310
  }, [onFontsLoadedCallback]);
12785
13311
  useEffect(() => {
12786
- const view_3 = pagedEditorRef.current?.getView();
12787
- if (view_3) setSuggestionMode(editingMode === "suggesting", view_3.state, view_3.dispatch, author);
13312
+ const view_4 = pagedEditorRef.current?.getView();
13313
+ if (view_4) setSuggestionMode(editingMode === "suggesting", view_4.state, view_4.dispatch, author);
12788
13314
  }, [editingMode, author]);
12789
13315
  const handleDocumentChange = useCallback((newDocument) => {
12790
13316
  const currentComments = commentsRef.current;
@@ -12803,9 +13329,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12803
13329
  if (showOutlineRef.current) {
12804
13330
  if (collectHeadingsTimerRef.current) clearTimeout(collectHeadingsTimerRef.current);
12805
13331
  collectHeadingsTimerRef.current = setTimeout(() => {
12806
- const view_4 = pagedEditorRef.current?.getView();
12807
- if (view_4) {
12808
- const headings_0 = collectHeadings(view_4.state.doc, getDocumentBuiltInStyles(view_4.state));
13332
+ const view_5 = pagedEditorRef.current?.getView();
13333
+ if (view_5) {
13334
+ const headings_0 = collectHeadings(view_5.state.doc, getDocumentBuiltInStyles(view_5.state));
12809
13335
  const pagedRef_0 = pagedEditorRef.current;
12810
13336
  for (const heading_0 of headings_0) heading_0.pageNumber = pagedRef_0?.getPageNumberForPmPos(heading_0.pmPos) ?? null;
12811
13337
  setHeadingInfos(headings_0);
@@ -12828,6 +13354,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12828
13354
  const pmDoc = pagedEditorRef.current?.getDocument();
12829
13355
  if (pmDoc) {
12830
13356
  doc_0.package.document.content = pmDoc.package.document.content;
13357
+ if (pmDoc.package.numbering) doc_0.package.numbering = pmDoc.package.numbering;
13358
+ else delete doc_0.package.numbering;
12831
13359
  if (pmDoc.package.footnotes !== void 0) doc_0.package.footnotes = pmDoc.package.footnotes;
12832
13360
  if (pmDoc.package.endnotes !== void 0) doc_0.package.endnotes = pmDoc.package.endnotes;
12833
13361
  } else doc_0 = normalizeBaseDirection(doc_0);
@@ -12836,8 +13364,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12836
13364
  const flushBag = (bag) => {
12837
13365
  if (!bag) return;
12838
13366
  for (const [rId_0, hf] of bag) {
12839
- const view_5 = editor.getHfView(rId_0);
12840
- if (view_5) hf.content = proseDocToBlocks(view_5.state.doc, hf.content);
13367
+ const view_6 = editor.getHfView(rId_0);
13368
+ if (view_6) hf.content = proseDocToBlocks(view_6.state.doc, hf.content);
12841
13369
  }
12842
13370
  };
12843
13371
  flushBag(doc_0.package.headers);
@@ -12869,9 +13397,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12869
13397
  findReplace,
12870
13398
  selectMatch: useCallback((match) => {
12871
13399
  const editor_0 = pagedEditorRef.current;
12872
- const view_6 = editor_0?.getView();
12873
- if (!editor_0 || !view_6) return false;
12874
- const range = resolveFindMatchRange(view_6.state.doc, match);
13400
+ const view_7 = editor_0?.getView();
13401
+ if (!editor_0 || !view_7) return false;
13402
+ const range = resolveFindMatchRange(view_7.state.doc, match);
12875
13403
  if (!range) return false;
12876
13404
  editor_0.setSelection(range.from, range.to);
12877
13405
  requestAnimationFrame(() => {
@@ -12881,17 +13409,17 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12881
13409
  }, [])
12882
13410
  });
12883
13411
  const handleSelectionChange = useCallback((selectionState) => {
12884
- const view_7 = getActiveEditorView();
12885
- if (view_7) {
12886
- const { from, to } = view_7.state.selection;
13412
+ const view_8 = getActiveEditorView();
13413
+ if (view_8) {
13414
+ const { from, to } = view_8.state.selection;
12887
13415
  lastSelectionRef.current = {
12888
13416
  from,
12889
13417
  to
12890
13418
  };
12891
13419
  }
12892
13420
  let pmTableCtx = null;
12893
- if (view_7) {
12894
- pmTableCtx = getTableContext(view_7.state);
13421
+ if (view_8) {
13422
+ pmTableCtx = getTableContext(view_8.state);
12895
13423
  if (!pmTableCtx.isInTable) pmTableCtx = null;
12896
13424
  }
12897
13425
  if (pmTableCtx?.cellBorderColor) {
@@ -12903,18 +13431,18 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12903
13431
  color: { rgb }
12904
13432
  };
12905
13433
  }
12906
- const pmImageCtx = view_7 ? detectImageContext(view_7.state) : null;
12907
- const trackedChange = view_7 ? detectActiveTrackedChange(view_7.state) : null;
13434
+ const pmImageCtx = view_8 ? detectImageContext(view_8.state) : null;
13435
+ const trackedChange = view_8 ? detectActiveTrackedChange(view_8.state) : null;
12908
13436
  if (!selectionState) {
12909
13437
  setFloatingCommentBtn(null);
12910
- setState((prev_2) => {
12911
- const selectionFormatting = areSelectionFormattingEqual(prev_2.selectionFormatting, EMPTY_SELECTION_FORMATTING) ? prev_2.selectionFormatting : EMPTY_SELECTION_FORMATTING;
12912
- const pmTableContext = areTableContextsEqual(prev_2.pmTableContext, pmTableCtx) ? prev_2.pmTableContext : pmTableCtx;
12913
- const pmImageContext = areImageContextsEqual(prev_2.pmImageContext, pmImageCtx) ? prev_2.pmImageContext : pmImageCtx;
12914
- const activeTrackedChange = areActiveTrackedChangesEqual(prev_2.activeTrackedChange, trackedChange) ? prev_2.activeTrackedChange : trackedChange;
12915
- if (selectionFormatting === prev_2.selectionFormatting && pmTableContext === prev_2.pmTableContext && pmImageContext === prev_2.pmImageContext && activeTrackedChange === prev_2.activeTrackedChange) return prev_2;
13438
+ setState((prev_1) => {
13439
+ const selectionFormatting = areSelectionFormattingEqual(prev_1.selectionFormatting, EMPTY_SELECTION_FORMATTING) ? prev_1.selectionFormatting : EMPTY_SELECTION_FORMATTING;
13440
+ const pmTableContext = areTableContextsEqual(prev_1.pmTableContext, pmTableCtx) ? prev_1.pmTableContext : pmTableCtx;
13441
+ const pmImageContext = areImageContextsEqual(prev_1.pmImageContext, pmImageCtx) ? prev_1.pmImageContext : pmImageCtx;
13442
+ const activeTrackedChange = areActiveTrackedChangesEqual(prev_1.activeTrackedChange, trackedChange) ? prev_1.activeTrackedChange : trackedChange;
13443
+ if (selectionFormatting === prev_1.selectionFormatting && pmTableContext === prev_1.pmTableContext && pmImageContext === prev_1.pmImageContext && activeTrackedChange === prev_1.activeTrackedChange) return prev_1;
12916
13444
  return {
12917
- ...prev_2,
13445
+ ...prev_1,
12918
13446
  selectionFormatting,
12919
13447
  pmTableContext,
12920
13448
  pmImageContext,
@@ -12943,19 +13471,19 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12943
13471
  textColor,
12944
13472
  listState: selectionState.listState
12945
13473
  });
12946
- setState((prev_3) => {
12947
- const selectionFormatting_0 = areSelectionFormattingEqual(prev_3.selectionFormatting, formatting) ? prev_3.selectionFormatting : formatting;
12948
- const pmTableContext_0 = areTableContextsEqual(prev_3.pmTableContext, pmTableCtx) ? prev_3.pmTableContext : pmTableCtx;
12949
- const pmImageContext_0 = areImageContextsEqual(prev_3.pmImageContext, pmImageCtx) ? prev_3.pmImageContext : pmImageCtx;
12950
- const activeTrackedChange_0 = areActiveTrackedChangesEqual(prev_3.activeTrackedChange, trackedChange) ? prev_3.activeTrackedChange : trackedChange;
13474
+ setState((prev_2) => {
13475
+ const selectionFormatting_0 = areSelectionFormattingEqual(prev_2.selectionFormatting, formatting) ? prev_2.selectionFormatting : formatting;
13476
+ const pmTableContext_0 = areTableContextsEqual(prev_2.pmTableContext, pmTableCtx) ? prev_2.pmTableContext : pmTableCtx;
13477
+ const pmImageContext_0 = areImageContextsEqual(prev_2.pmImageContext, pmImageCtx) ? prev_2.pmImageContext : pmImageCtx;
13478
+ const activeTrackedChange_0 = areActiveTrackedChangesEqual(prev_2.activeTrackedChange, trackedChange) ? prev_2.activeTrackedChange : trackedChange;
12951
13479
  const paragraphIndentLeft = paragraphFormatting.indentLeft ?? 0;
12952
13480
  const paragraphIndentRight = paragraphFormatting.indentRight ?? 0;
12953
13481
  const paragraphFirstLineIndent = paragraphFormatting.indentFirstLine ?? 0;
12954
13482
  const paragraphHangingIndent = paragraphFormatting.hangingIndent ?? false;
12955
13483
  const paragraphTabs = paragraphFormatting.tabs ?? null;
12956
- if (selectionFormatting_0 === prev_3.selectionFormatting && pmTableContext_0 === prev_3.pmTableContext && pmImageContext_0 === prev_3.pmImageContext && activeTrackedChange_0 === prev_3.activeTrackedChange && paragraphIndentLeft === prev_3.paragraphIndentLeft && paragraphIndentRight === prev_3.paragraphIndentRight && paragraphFirstLineIndent === prev_3.paragraphFirstLineIndent && paragraphHangingIndent === prev_3.paragraphHangingIndent && paragraphTabs === prev_3.paragraphTabs) return prev_3;
13484
+ if (selectionFormatting_0 === prev_2.selectionFormatting && pmTableContext_0 === prev_2.pmTableContext && pmImageContext_0 === prev_2.pmImageContext && activeTrackedChange_0 === prev_2.activeTrackedChange && paragraphIndentLeft === prev_2.paragraphIndentLeft && paragraphIndentRight === prev_2.paragraphIndentRight && paragraphFirstLineIndent === prev_2.paragraphFirstLineIndent && paragraphHangingIndent === prev_2.paragraphHangingIndent && paragraphTabs === prev_2.paragraphTabs) return prev_2;
12957
13485
  return {
12958
- ...prev_3,
13486
+ ...prev_2,
12959
13487
  selectionFormatting: selectionFormatting_0,
12960
13488
  paragraphIndentLeft,
12961
13489
  paragraphIndentRight,
@@ -12967,10 +13495,10 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12967
13495
  activeTrackedChange: activeTrackedChange_0
12968
13496
  };
12969
13497
  });
12970
- if (view_7 && selectionState.hasSelection && !isAddingComment && !readOnly) {
13498
+ if (view_8 && selectionState.hasSelection && !isAddingComment && !readOnly) {
12971
13499
  const container = scrollContainerRef.current;
12972
13500
  const parentEl = editorContentRef.current;
12973
- const { from: selFrom } = view_7.state.selection;
13501
+ const { from: selFrom } = view_8.state.selection;
12974
13502
  const top = findSelectionYPosition(container, parentEl, selFrom);
12975
13503
  if (top !== null && container && parentEl) {
12976
13504
  const pagesEl = container.querySelector(".paged-editor__pages");
@@ -12978,7 +13506,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12978
13506
  const parentRect = parentEl.getBoundingClientRect();
12979
13507
  const rawLeft = pageEl ? pageEl.getBoundingClientRect().right - parentRect.left + 12 : parentRect.width / 2 + 408;
12980
13508
  const left = Math.max(16, Math.min(rawLeft, parentRect.width - 16));
12981
- const { from: from_0, to: to_0 } = view_7.state.selection;
13509
+ const { from: from_0, to: to_0 } = view_8.state.selection;
12982
13510
  if (from_0 !== to_0) setFloatingCommentBtn({
12983
13511
  top,
12984
13512
  left,
@@ -13008,8 +13536,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13008
13536
  onPrint();
13009
13537
  return;
13010
13538
  }
13011
- const pages = containerRef.current?.querySelector(".paged-editor__pages");
13012
- if (!pages) {
13539
+ const pages_0 = containerRef.current?.querySelector(".paged-editor__pages");
13540
+ if (!pages_0) {
13013
13541
  toast(t("printRedirect"));
13014
13542
  return;
13015
13543
  }
@@ -13029,7 +13557,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13029
13557
  return;
13030
13558
  }
13031
13559
  const styles_0 = [...document.querySelectorAll("style, link[rel=\"stylesheet\"]")].map((node_0) => node_0.outerHTML).join("\n");
13032
- const pagesCloneRaw = pages.cloneNode(true);
13560
+ const pagesCloneRaw = pages_0.cloneNode(true);
13033
13561
  if (!(pagesCloneRaw instanceof HTMLElement)) return;
13034
13562
  const pagesClone = pagesCloneRaw;
13035
13563
  const overlays = pagesClone.querySelectorAll(".selection-overlay, .layout-selection-overlay, .image-selection-overlay");
@@ -13127,98 +13655,98 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13127
13655
  });
13128
13656
  }, [history, pushDocument]);
13129
13657
  const handleTableAction = useCallback((action_0) => {
13130
- const view_8 = getActiveEditorView();
13131
- if (!view_8) return;
13658
+ const view_9 = getActiveEditorView();
13659
+ if (!view_9) return;
13132
13660
  switch (action_0) {
13133
13661
  case "addRowAbove":
13134
- addRowAbove(view_8.state, view_8.dispatch);
13662
+ addRowAbove(view_9.state, view_9.dispatch);
13135
13663
  break;
13136
13664
  case "addRowBelow":
13137
- addRowBelow(view_8.state, view_8.dispatch);
13665
+ addRowBelow(view_9.state, view_9.dispatch);
13138
13666
  break;
13139
13667
  case "addColumnLeft":
13140
- addColumnLeft(view_8.state, view_8.dispatch);
13668
+ addColumnLeft(view_9.state, view_9.dispatch);
13141
13669
  break;
13142
13670
  case "addColumnRight":
13143
- addColumnRight(view_8.state, view_8.dispatch);
13671
+ addColumnRight(view_9.state, view_9.dispatch);
13144
13672
  break;
13145
13673
  case "deleteRow":
13146
- deleteRow(view_8.state, view_8.dispatch);
13674
+ deleteRow(view_9.state, view_9.dispatch);
13147
13675
  break;
13148
13676
  case "deleteColumn":
13149
- deleteColumn(view_8.state, view_8.dispatch);
13677
+ deleteColumn(view_9.state, view_9.dispatch);
13150
13678
  break;
13151
13679
  case "deleteTable":
13152
- deleteTable(view_8.state, view_8.dispatch);
13680
+ deleteTable(view_9.state, view_9.dispatch);
13153
13681
  break;
13154
13682
  case "selectTable":
13155
- selectTable(view_8.state, view_8.dispatch);
13683
+ selectTable(view_9.state, view_9.dispatch);
13156
13684
  break;
13157
13685
  case "selectRow":
13158
- selectRow(view_8.state, view_8.dispatch);
13686
+ selectRow(view_9.state, view_9.dispatch);
13159
13687
  break;
13160
13688
  case "selectColumn":
13161
- selectColumn(view_8.state, view_8.dispatch);
13689
+ selectColumn(view_9.state, view_9.dispatch);
13162
13690
  break;
13163
13691
  case "mergeCells":
13164
- mergeCells(view_8.state, view_8.dispatch);
13692
+ mergeCells(view_9.state, view_9.dispatch);
13165
13693
  break;
13166
13694
  case "splitCell":
13167
- splitCell(view_8.state, view_8.dispatch);
13695
+ splitCell(view_9.state, view_9.dispatch);
13168
13696
  break;
13169
13697
  case "borderAll":
13170
- setAllTableBorders(view_8.state, view_8.dispatch, borderSpecRef.current);
13698
+ setAllTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
13171
13699
  break;
13172
13700
  case "borderOutside":
13173
- setOutsideTableBorders(view_8.state, view_8.dispatch, borderSpecRef.current);
13701
+ setOutsideTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
13174
13702
  break;
13175
13703
  case "borderInside":
13176
- setInsideTableBorders(view_8.state, view_8.dispatch, borderSpecRef.current);
13704
+ setInsideTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
13177
13705
  break;
13178
13706
  case "borderNone":
13179
- removeTableBorders(view_8.state, view_8.dispatch);
13707
+ removeTableBorders(view_9.state, view_9.dispatch);
13180
13708
  break;
13181
13709
  case "borderTop":
13182
- setCellBorder("top", borderSpecRef.current, true)(view_8.state, view_8.dispatch);
13710
+ setCellBorder("top", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
13183
13711
  break;
13184
13712
  case "borderBottom":
13185
- setCellBorder("bottom", borderSpecRef.current, true)(view_8.state, view_8.dispatch);
13713
+ setCellBorder("bottom", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
13186
13714
  break;
13187
13715
  case "borderLeft":
13188
- setCellBorder("left", borderSpecRef.current, true)(view_8.state, view_8.dispatch);
13716
+ setCellBorder("left", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
13189
13717
  break;
13190
13718
  case "borderRight":
13191
- setCellBorder("right", borderSpecRef.current, true)(view_8.state, view_8.dispatch);
13719
+ setCellBorder("right", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
13192
13720
  break;
13193
- default: if (typeof action_0 === "object") if (action_0.type === "cellFillColor") setCellFillColor(action_0.color)(view_8.state, view_8.dispatch);
13721
+ default: if (typeof action_0 === "object") if (action_0.type === "cellFillColor") setCellFillColor(action_0.color)(view_9.state, view_9.dispatch);
13194
13722
  else if (action_0.type === "borderColor") {
13195
13723
  const rgb_0 = action_0.color.replace(/^#/u, "");
13196
13724
  borderSpecRef.current = {
13197
13725
  ...borderSpecRef.current,
13198
13726
  color: { rgb: rgb_0 }
13199
13727
  };
13200
- setTableBorderColor(action_0.color)(view_8.state, view_8.dispatch);
13728
+ setTableBorderColor(action_0.color)(view_9.state, view_9.dispatch);
13201
13729
  } else if (action_0.type === "borderWidth") {
13202
13730
  borderSpecRef.current = {
13203
13731
  ...borderSpecRef.current,
13204
13732
  size: action_0.size
13205
13733
  };
13206
- setTableBorderWidth(action_0.size)(view_8.state, view_8.dispatch);
13734
+ setTableBorderWidth(action_0.size)(view_9.state, view_9.dispatch);
13207
13735
  } else if (action_0.type === "cellBorder") setCellBorder(action_0.side, {
13208
13736
  style: action_0.style,
13209
13737
  size: action_0.size,
13210
13738
  color: { rgb: action_0.color.replace(/^#/u, "") }
13211
- })(view_8.state, view_8.dispatch);
13212
- else if (action_0.type === "cellVerticalAlign") setCellVerticalAlign(action_0.align)(view_8.state, view_8.dispatch);
13213
- else if (action_0.type === "cellMargins") setCellMargins(action_0.margins)(view_8.state, view_8.dispatch);
13214
- else if (action_0.type === "cellTextDirection") setCellTextDirection(action_0.direction)(view_8.state, view_8.dispatch);
13215
- else if (action_0.type === "toggleNoWrap") toggleNoWrap()(view_8.state, view_8.dispatch);
13216
- else if (action_0.type === "rowHeight") setRowHeight(action_0.height, action_0.rule)(view_8.state, view_8.dispatch);
13217
- else if (action_0.type === "toggleHeaderRow") toggleHeaderRow()(view_8.state, view_8.dispatch);
13218
- else if (action_0.type === "distributeColumns") distributeColumns()(view_8.state, view_8.dispatch);
13219
- else if (action_0.type === "autoFitContents") autoFitContents()(view_8.state, view_8.dispatch);
13739
+ })(view_9.state, view_9.dispatch);
13740
+ else if (action_0.type === "cellVerticalAlign") setCellVerticalAlign(action_0.align)(view_9.state, view_9.dispatch);
13741
+ else if (action_0.type === "cellMargins") setCellMargins(action_0.margins)(view_9.state, view_9.dispatch);
13742
+ else if (action_0.type === "cellTextDirection") setCellTextDirection(action_0.direction)(view_9.state, view_9.dispatch);
13743
+ else if (action_0.type === "toggleNoWrap") toggleNoWrap()(view_9.state, view_9.dispatch);
13744
+ else if (action_0.type === "rowHeight") setRowHeight(action_0.height, action_0.rule)(view_9.state, view_9.dispatch);
13745
+ else if (action_0.type === "toggleHeaderRow") toggleHeaderRow()(view_9.state, view_9.dispatch);
13746
+ else if (action_0.type === "distributeColumns") distributeColumns()(view_9.state, view_9.dispatch);
13747
+ else if (action_0.type === "autoFitContents") autoFitContents()(view_9.state, view_9.dispatch);
13220
13748
  else if (action_0.type === "openTableProperties") setTablePropsOpen(true);
13221
- else if (action_0.type === "tableProperties") setTableProperties(action_0.props)(view_8.state, view_8.dispatch);
13749
+ else if (action_0.type === "tableProperties") setTableProperties(action_0.props)(view_9.state, view_9.dispatch);
13222
13750
  else {
13223
13751
  let preset = getBuiltinTableStyle(action_0.styleId);
13224
13752
  const currentDocForTable = historyStateRef.current;
@@ -13289,7 +13817,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13289
13817
  if (preset.tableBorders) styleArg.tableBorders = preset.tableBorders;
13290
13818
  if (preset.conditionals) styleArg.conditionals = preset.conditionals;
13291
13819
  if (preset.look) styleArg.look = preset.look;
13292
- applyTableStyle(styleArg)(view_8.state, view_8.dispatch);
13820
+ applyTableStyle(styleArg)(view_9.state, view_9.dispatch);
13293
13821
  }
13294
13822
  }
13295
13823
  else tableSelection.handleAction(action_0);
@@ -13310,80 +13838,80 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13310
13838
  });
13311
13839
  }, [openContextMenu]);
13312
13840
  const handleFormat = useCallback((action_1) => {
13313
- const view_9 = getActiveEditorView();
13314
- if (!view_9) return;
13315
- view_9.focus();
13316
- const isBodyEditor = view_9 === pagedEditorRef.current?.getView();
13317
- const { from: from_1, to: to_1 } = view_9.state.selection;
13841
+ const view_10 = getActiveEditorView();
13842
+ if (!view_10) return;
13843
+ view_10.focus();
13844
+ const isBodyEditor = view_10 === pagedEditorRef.current?.getView();
13845
+ const { from: from_1, to: to_1 } = view_10.state.selection;
13318
13846
  const savedSelection = lastSelectionRef.current;
13319
13847
  if (isBodyEditor && savedSelection && (from_1 !== savedSelection.from || to_1 !== savedSelection.to)) try {
13320
- const tr = view_9.state.tr.setSelection(TextSelection.create(view_9.state.doc, savedSelection.from, savedSelection.to));
13321
- view_9.dispatch(tr);
13848
+ const tr = view_10.state.tr.setSelection(TextSelection.create(view_10.state.doc, savedSelection.from, savedSelection.to));
13849
+ view_10.dispatch(tr);
13322
13850
  } catch {}
13323
- const commandState = view_9.state;
13851
+ const commandState = view_10.state;
13324
13852
  if (action_1 === "bold") {
13325
- toggleBold(commandState, view_9.dispatch);
13853
+ toggleBold(commandState, view_10.dispatch);
13326
13854
  return;
13327
13855
  }
13328
13856
  if (action_1 === "italic") {
13329
- toggleItalic(commandState, view_9.dispatch);
13857
+ toggleItalic(commandState, view_10.dispatch);
13330
13858
  return;
13331
13859
  }
13332
13860
  if (action_1 === "underline") {
13333
- toggleUnderline(commandState, view_9.dispatch);
13861
+ toggleUnderline(commandState, view_10.dispatch);
13334
13862
  return;
13335
13863
  }
13336
13864
  if (action_1 === "strikethrough") {
13337
- toggleStrike(commandState, view_9.dispatch);
13865
+ toggleStrike(commandState, view_10.dispatch);
13338
13866
  return;
13339
13867
  }
13340
13868
  if (action_1 === "superscript") {
13341
- toggleSuperscript(commandState, view_9.dispatch);
13869
+ toggleSuperscript(commandState, view_10.dispatch);
13342
13870
  return;
13343
13871
  }
13344
13872
  if (action_1 === "subscript") {
13345
- toggleSubscript(commandState, view_9.dispatch);
13873
+ toggleSubscript(commandState, view_10.dispatch);
13346
13874
  return;
13347
13875
  }
13348
13876
  if (action_1 === "bulletList") {
13349
- toggleBulletList(commandState, view_9.dispatch);
13877
+ toggleBulletList(commandState, view_10.dispatch);
13350
13878
  return;
13351
13879
  }
13352
13880
  if (action_1 === "numberedList") {
13353
- toggleNumberedList(commandState, view_9.dispatch);
13881
+ toggleNumberedList(commandState, view_10.dispatch);
13354
13882
  return;
13355
13883
  }
13356
13884
  if (action_1 === "indent") {
13357
- if (!increaseListLevel(commandState, view_9.dispatch)) increaseIndent()(commandState, view_9.dispatch);
13885
+ if (!increaseListLevel(commandState, view_10.dispatch)) increaseIndent()(commandState, view_10.dispatch);
13358
13886
  return;
13359
13887
  }
13360
13888
  if (action_1 === "outdent") {
13361
- if (!decreaseListLevel(commandState, view_9.dispatch)) decreaseIndent()(commandState, view_9.dispatch);
13889
+ if (!decreaseListLevel(commandState, view_10.dispatch)) decreaseIndent()(commandState, view_10.dispatch);
13362
13890
  return;
13363
13891
  }
13364
13892
  if (action_1 === "clearFormatting") {
13365
- clearFormatting(commandState, view_9.dispatch);
13893
+ clearFormatting(commandState, view_10.dispatch);
13366
13894
  return;
13367
13895
  }
13368
13896
  if (action_1 === "setRtl") {
13369
- setRtl(commandState, view_9.dispatch);
13897
+ setRtl(commandState, view_10.dispatch);
13370
13898
  return;
13371
13899
  }
13372
13900
  if (action_1 === "setLtr") {
13373
- setLtr(commandState, view_9.dispatch);
13901
+ setLtr(commandState, view_10.dispatch);
13374
13902
  return;
13375
13903
  }
13376
13904
  if (typeof action_1 === "object") switch (action_1.type) {
13377
13905
  case "alignment":
13378
- setAlignment(action_1.value)(commandState, view_9.dispatch);
13906
+ setAlignment(action_1.value)(commandState, view_10.dispatch);
13379
13907
  break;
13380
13908
  case "toggleDirection":
13381
- toggleBidi(commandState, view_9.dispatch);
13909
+ toggleBidi(commandState, view_10.dispatch);
13382
13910
  break;
13383
13911
  case "textColor": {
13384
13912
  const colorVal_0 = action_1.value;
13385
- if (typeof colorVal_0 === "string") setTextColor({ rgb: colorVal_0.replace("#", "") })(commandState, view_9.dispatch);
13386
- else if (colorVal_0.auto) clearTextColor(commandState, view_9.dispatch);
13913
+ if (typeof colorVal_0 === "string") setTextColor({ rgb: colorVal_0.replace("#", "") })(commandState, view_10.dispatch);
13914
+ else if (colorVal_0.auto) clearTextColor(commandState, view_10.dispatch);
13387
13915
  else {
13388
13916
  const themeColor = typeof colorVal_0.themeColor === "string" ? colorVal_0.themeColor : void 0;
13389
13917
  setTextColor({
@@ -13391,21 +13919,21 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13391
13919
  ...themeColor ? { themeColor } : {},
13392
13920
  ...colorVal_0.themeTint === void 0 ? {} : { themeTint: colorVal_0.themeTint },
13393
13921
  ...colorVal_0.themeShade === void 0 ? {} : { themeShade: colorVal_0.themeShade }
13394
- })(commandState, view_9.dispatch);
13922
+ })(commandState, view_10.dispatch);
13395
13923
  }
13396
13924
  break;
13397
13925
  }
13398
13926
  case "highlightColor":
13399
- setHighlight((action_1.value ? mapHexToHighlightName(action_1.value) : "") || action_1.value)(commandState, view_9.dispatch);
13927
+ setHighlight((action_1.value ? mapHexToHighlightName(action_1.value) : "") || action_1.value)(commandState, view_10.dispatch);
13400
13928
  break;
13401
13929
  case "fontSize":
13402
- setFontSize(pointsToHalfPoints(action_1.value))(commandState, view_9.dispatch);
13930
+ setFontSize(pointsToHalfPoints(action_1.value))(commandState, view_10.dispatch);
13403
13931
  break;
13404
13932
  case "fontFamily":
13405
- setFontFamily(action_1.value)(commandState, view_9.dispatch);
13933
+ setFontFamily(action_1.value)(commandState, view_10.dispatch);
13406
13934
  break;
13407
13935
  case "lineSpacing":
13408
- setLineSpacing(action_1.value)(commandState, view_9.dispatch);
13936
+ setLineSpacing(action_1.value)(commandState, view_10.dispatch);
13409
13937
  break;
13410
13938
  case "applyStyle": {
13411
13939
  const currentDoc_0 = historyStateRef.current;
@@ -13418,22 +13946,22 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13418
13946
  const styleName = styleResolver_0.getStyle(action_1.value)?.name;
13419
13947
  if (styleName) styleAttrs.styleName = styleName;
13420
13948
  styleAttrs.numbering = currentDoc_0?.package.numbering ? getCachedNumberingMap(currentDoc_0.package.numbering) : null;
13421
- applyStyle(action_1.value, styleAttrs)(commandState, view_9.dispatch);
13422
- } else applyStyle(action_1.value)(commandState, view_9.dispatch);
13949
+ applyStyle(action_1.value, styleAttrs)(commandState, view_10.dispatch);
13950
+ } else applyStyle(action_1.value)(commandState, view_10.dispatch);
13423
13951
  break;
13424
13952
  }
13425
13953
  default: break;
13426
13954
  }
13427
13955
  }, [getActiveEditorView, getCachedStyleResolver]);
13428
13956
  const captureFormatPainter = useCallback(() => {
13429
- const view_10 = getActiveEditorView();
13430
- capturedFormatMarksRef.current = view_10 ? captureFormatMarks(view_10.state) : null;
13957
+ const view_11 = getActiveEditorView();
13958
+ capturedFormatMarksRef.current = view_11 ? captureFormatMarks(view_11.state) : null;
13431
13959
  }, [getActiveEditorView]);
13432
13960
  const paintFormatToSelection = useCallback(() => {
13433
- const view_11 = getActiveEditorView();
13434
- if (!view_11) return false;
13435
- const applied = applyFormatMarks(capturedFormatMarksRef.current)(view_11.state, view_11.dispatch);
13436
- if (applied) requestAnimationFrame(() => view_11.focus());
13961
+ const view_12 = getActiveEditorView();
13962
+ if (!view_12) return false;
13963
+ const applied = applyFormatMarks(capturedFormatMarksRef.current)(view_12.state, view_12.dispatch);
13964
+ if (applied) requestAnimationFrame(() => view_12.focus());
13437
13965
  return applied;
13438
13966
  }, [getActiveEditorView]);
13439
13967
  const handleFormatPainter = useCallback((sticky) => {
@@ -13583,6 +14111,18 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13583
14111
  label: t("rejectChange"),
13584
14112
  dividerAfter: true
13585
14113
  });
14114
+ if (contextMenu.listNumbering.type === "listItem") items.push({
14115
+ action: "restartNumbering",
14116
+ label: t("contextMenu.restartNumbering")
14117
+ }, {
14118
+ action: "continueNumbering",
14119
+ label: t("contextMenu.continueNumbering"),
14120
+ disabled: !contextMenu.listNumbering.canContinue
14121
+ }, {
14122
+ action: "setNumberingValue",
14123
+ label: t("contextMenu.setNumberingValue"),
14124
+ dividerAfter: true
14125
+ });
13586
14126
  items.push({
13587
14127
  action: "selectAll",
13588
14128
  label: t("selectAll"),
@@ -13593,17 +14133,18 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13593
14133
  contextMenu.hasSelection,
13594
14134
  contextMenu.cursorInTable,
13595
14135
  contextMenu.cursorInTrackedChange,
14136
+ contextMenu.listNumbering,
13596
14137
  customContextMenuItems,
13597
14138
  readOnly,
13598
14139
  t
13599
14140
  ]);
13600
14141
  const handleContextMenuAction = useCallback(async (action_2) => {
13601
- const view_12 = getActiveEditorView();
13602
- if (!view_12) return;
14142
+ const view_13 = getActiveEditorView();
14143
+ if (!view_13) return;
13603
14144
  focusActiveEditor();
13604
14145
  if (readOnly && action_2 !== "copy" && action_2 !== "selectAll") return;
13605
14146
  if (action_2.startsWith("custom:")) {
13606
- const { from: from_2, to: to_2 } = contextMenu.selectionRange.from !== contextMenu.selectionRange.to ? contextMenu.selectionRange : view_12.state.selection;
14147
+ const { from: from_2, to: to_2 } = contextMenu.selectionRange.from !== contextMenu.selectionRange.to ? contextMenu.selectionRange : view_13.state.selection;
13607
14148
  onCustomContextAction?.(action_2.slice(7), {
13608
14149
  from: from_2,
13609
14150
  to: to_2
@@ -13613,16 +14154,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13613
14154
  switch (action_2) {
13614
14155
  case "cut": {
13615
14156
  if (readOnly) return;
13616
- const { from: from_7, to: to_7 } = view_12.state.selection;
13617
- const text_2 = view_12.state.doc.textBetween(from_7, to_7, "\n");
14157
+ const { from: from_7, to: to_7 } = view_13.state.selection;
14158
+ const text_2 = view_13.state.doc.textBetween(from_7, to_7, "\n");
13618
14159
  navigator.clipboard.writeText(text_2).catch(() => void 0);
13619
- view_12.dispatch(view_12.state.tr.deleteSelection());
14160
+ if (!deleteSelectionAsSuggestion(view_13.state, view_13.dispatch)) view_13.dispatch(view_13.state.tr.deleteSelection());
13620
14161
  onCut?.();
13621
14162
  break;
13622
14163
  }
13623
14164
  case "copy": {
13624
- const { from: cf, to: ct } = view_12.state.selection;
13625
- const copied = view_12.state.doc.textBetween(cf, ct, "\n");
14165
+ const { from: cf, to: ct } = view_13.state.selection;
14166
+ const copied = view_13.state.doc.textBetween(cf, ct, "\n");
13626
14167
  navigator.clipboard.writeText(copied).catch(() => void 0);
13627
14168
  onCopy?.();
13628
14169
  break;
@@ -13645,12 +14186,12 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13645
14186
  bubbles: true,
13646
14187
  cancelable: true
13647
14188
  });
13648
- view_12.dom.dispatchEvent(pasteEvent);
14189
+ view_13.dom.dispatchEvent(pasteEvent);
13649
14190
  } catch {
13650
14191
  try {
13651
14192
  const text_0 = await navigator.clipboard.readText();
13652
14193
  if (text_0) {
13653
- view_12.dispatch(view_12.state.tr.insertText(text_0));
14194
+ view_13.dispatch(view_13.state.tr.insertText(text_0));
13654
14195
  onPaste?.();
13655
14196
  }
13656
14197
  } catch {}
@@ -13659,9 +14200,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13659
14200
  case "pasteAsPlainText":
13660
14201
  try {
13661
14202
  const text = await navigator.clipboard.readText();
13662
- if (text && !view_12.isDestroyed) {
13663
- const slice = buildPlainTextSlice(text, view_12.state.schema);
13664
- view_12.dispatch(view_12.state.tr.replaceSelection(slice).scrollIntoView());
14203
+ if (text && !view_13.isDestroyed) {
14204
+ const slice = buildPlainTextSlice(text, view_13.state.schema);
14205
+ view_13.dispatch(view_13.state.tr.replaceSelection(slice).scrollIntoView());
13665
14206
  onPaste?.();
13666
14207
  }
13667
14208
  } catch {
@@ -13669,46 +14210,46 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13669
14210
  }
13670
14211
  break;
13671
14212
  case "delete": {
13672
- const { from: from_6, to: to_6 } = view_12.state.selection;
13673
- if (from_6 !== to_6) view_12.dispatch(view_12.state.tr.deleteRange(from_6, to_6));
14213
+ const { from: from_6, to: to_6 } = view_13.state.selection;
14214
+ if (from_6 !== to_6) view_13.dispatch(view_13.state.tr.deleteRange(from_6, to_6));
13674
14215
  break;
13675
14216
  }
13676
14217
  case "selectAll":
13677
- view_12.dispatch(view_12.state.tr.setSelection(TextSelection.create(view_12.state.doc, 0, view_12.state.doc.content.size)));
14218
+ view_13.dispatch(view_13.state.tr.setSelection(TextSelection.create(view_13.state.doc, 0, view_13.state.doc.content.size)));
13678
14219
  break;
13679
14220
  case "addRowAbove":
13680
- addRowAbove(view_12.state, view_12.dispatch);
14221
+ addRowAbove(view_13.state, view_13.dispatch);
13681
14222
  break;
13682
14223
  case "addRowBelow":
13683
- addRowBelow(view_12.state, view_12.dispatch);
14224
+ addRowBelow(view_13.state, view_13.dispatch);
13684
14225
  break;
13685
14226
  case "deleteRow":
13686
- deleteRow(view_12.state, view_12.dispatch);
14227
+ deleteRow(view_13.state, view_13.dispatch);
13687
14228
  break;
13688
14229
  case "addColumnLeft":
13689
- addColumnLeft(view_12.state, view_12.dispatch);
14230
+ addColumnLeft(view_13.state, view_13.dispatch);
13690
14231
  break;
13691
14232
  case "addColumnRight":
13692
- addColumnRight(view_12.state, view_12.dispatch);
14233
+ addColumnRight(view_13.state, view_13.dispatch);
13693
14234
  break;
13694
14235
  case "deleteColumn":
13695
- deleteColumn(view_12.state, view_12.dispatch);
14236
+ deleteColumn(view_13.state, view_13.dispatch);
13696
14237
  break;
13697
14238
  case "tableBordersAll":
13698
- setTableBorderPreset("all")(view_12.state, view_12.dispatch);
14239
+ setTableBorderPreset("all")(view_13.state, view_13.dispatch);
13699
14240
  break;
13700
14241
  case "tableBordersNone":
13701
- setTableBorderPreset("none")(view_12.state, view_12.dispatch);
14242
+ setTableBorderPreset("none")(view_13.state, view_13.dispatch);
13702
14243
  break;
13703
14244
  case "addComment": {
13704
- const { from: from_5, to: to_5 } = contextMenu.selectionRange.from !== contextMenu.selectionRange.to ? contextMenu.selectionRange : view_12.state.selection;
14245
+ const { from: from_5, to: to_5 } = contextMenu.selectionRange.from !== contextMenu.selectionRange.to ? contextMenu.selectionRange : view_13.state.selection;
13705
14246
  if (from_5 === to_5) break;
13706
14247
  const commentY = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, from_5) ?? getFallbackCommentYPosition(scrollContainerRef.current);
13707
14248
  setCommentSelectionRange({
13708
14249
  from: from_5,
13709
14250
  to: to_5
13710
14251
  });
13711
- if (!applyCommentMarkRange(view_12, {
14252
+ if (!applyCommentMarkRange(view_13, {
13712
14253
  from: from_5,
13713
14254
  to: to_5
13714
14255
  }, -1, { selectEnd: true })) break;
@@ -13719,17 +14260,26 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13719
14260
  break;
13720
14261
  }
13721
14262
  case "acceptChange": {
13722
- const { from: from_4, to: to_4 } = view_12.state.selection;
13723
- const range_1 = findChangeAtPosition(view_12.state, from_4, to_4);
13724
- acceptChange(range_1.from, range_1.to)(view_12.state, view_12.dispatch);
14263
+ const { from: from_4, to: to_4 } = view_13.state.selection;
14264
+ const range_1 = findChangeAtPosition(view_13.state, from_4, to_4);
14265
+ acceptChange(range_1.from, range_1.to)(view_13.state, view_13.dispatch);
13725
14266
  break;
13726
14267
  }
13727
14268
  case "rejectChange": {
13728
- const { from: from_3, to: to_3 } = view_12.state.selection;
13729
- const range_0 = findChangeAtPosition(view_12.state, from_3, to_3);
13730
- rejectChange(range_0.from, range_0.to)(view_12.state, view_12.dispatch);
14269
+ const { from: from_3, to: to_3 } = view_13.state.selection;
14270
+ const range_0 = findChangeAtPosition(view_13.state, from_3, to_3);
14271
+ rejectChange(range_0.from, range_0.to)(view_13.state, view_13.dispatch);
13731
14272
  break;
13732
14273
  }
14274
+ case "restartNumbering":
14275
+ restartNumbering(view_13.state, view_13.dispatch);
14276
+ break;
14277
+ case "continueNumbering":
14278
+ continueNumbering(view_13.state, view_13.dispatch);
14279
+ break;
14280
+ case "setNumberingValue":
14281
+ setNumberingValueDialogOpen(true);
14282
+ break;
13733
14283
  case "separator": break;
13734
14284
  }
13735
14285
  }, [
@@ -13775,25 +14325,25 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13775
14325
  const handleTopMarginChange = useCallback((twips_1) => handlePageSetupApply({ marginTop: twips_1 }), [handlePageSetupApply]);
13776
14326
  const handleBottomMarginChange = useCallback((twips_2) => handlePageSetupApply({ marginBottom: twips_2 }), [handlePageSetupApply]);
13777
14327
  const handleIndentLeftChange = useCallback((twips_3) => {
13778
- const view_13 = getActiveEditorView();
13779
- if (!view_13) return;
13780
- setIndentLeft(twips_3)(view_13.state, view_13.dispatch);
13781
- }, [getActiveEditorView]);
13782
- const handleIndentRightChange = useCallback((twips_4) => {
13783
14328
  const view_14 = getActiveEditorView();
13784
14329
  if (!view_14) return;
13785
- setIndentRight(twips_4)(view_14.state, view_14.dispatch);
14330
+ setIndentLeft(twips_3)(view_14.state, view_14.dispatch);
13786
14331
  }, [getActiveEditorView]);
13787
- const handleFirstLineIndentChange = useCallback((twips_5) => {
14332
+ const handleIndentRightChange = useCallback((twips_4) => {
13788
14333
  const view_15 = getActiveEditorView();
13789
14334
  if (!view_15) return;
13790
- if (twips_5 < 0) setIndentFirstLine(-twips_5, true)(view_15.state, view_15.dispatch);
13791
- else setIndentFirstLine(twips_5, false)(view_15.state, view_15.dispatch);
14335
+ setIndentRight(twips_4)(view_15.state, view_15.dispatch);
13792
14336
  }, [getActiveEditorView]);
13793
- const handleTabStopRemove = useCallback((positionTwips) => {
14337
+ const handleFirstLineIndentChange = useCallback((twips_5) => {
13794
14338
  const view_16 = getActiveEditorView();
13795
14339
  if (!view_16) return;
13796
- removeTabStop(positionTwips)(view_16.state, view_16.dispatch);
14340
+ if (twips_5 < 0) setIndentFirstLine(-twips_5, true)(view_16.state, view_16.dispatch);
14341
+ else setIndentFirstLine(twips_5, false)(view_16.state, view_16.dispatch);
14342
+ }, [getActiveEditorView]);
14343
+ const handleTabStopRemove = useCallback((positionTwips) => {
14344
+ const view_17 = getActiveEditorView();
14345
+ if (!view_17) return;
14346
+ removeTabStop(positionTwips)(view_17.state, view_17.dispatch);
13797
14347
  }, [getActiveEditorView]);
13798
14348
  const serializeCurrentDocx = useCallback(async (options) => {
13799
14349
  let tripwireResult = null;
@@ -13805,11 +14355,11 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13805
14355
  const flags = resolveSelectiveSaveFlags(featureFlags);
13806
14356
  const useSelectiveForSave = flags.selectiveSave && options?.mode !== FOLIO_DOCX_SERIALIZATION_MODE.full;
13807
14357
  const shouldAttemptSelective = useSelectiveForSave || flags.selectiveSaveTripwire;
13808
- const view_17 = pagedEditorRef.current?.getView();
14358
+ const view_18 = pagedEditorRef.current?.getView();
13809
14359
  const baselineBuffer = originalBufferRef.current;
13810
14360
  let selectiveBuffer = null;
13811
- if (shouldAttemptSelective && view_17 && baselineBuffer) {
13812
- const editorState = view_17.state;
14361
+ if (shouldAttemptSelective && view_18 && baselineBuffer) {
14362
+ const editorState = view_18.state;
13813
14363
  selectiveBuffer = await (await loadAttemptSelectiveSave())(doc_1, baselineBuffer, {
13814
14364
  changedParaIds: getChangedParagraphIds(editorState),
13815
14365
  structuralChange: hasStructuralChanges(editorState),
@@ -13823,19 +14373,28 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13823
14373
  ...doc_1,
13824
14374
  originalBuffer: baselineBuffer
13825
14375
  } : doc_1;
14376
+ const repackFull = async () => {
14377
+ const repackDocx = await loadRepackDocx();
14378
+ const repack = () => repackDocx(repackSourceDoc);
14379
+ return view_18 ? repackWithEditorSectionRemovals({
14380
+ state: view_18.state,
14381
+ document: repackSourceDoc,
14382
+ repack
14383
+ }) : repack();
14384
+ };
13826
14385
  if (!buffer) {
13827
- fullBuffer = await (await loadRepackDocx())(repackSourceDoc);
14386
+ fullBuffer = await repackFull();
13828
14387
  buffer = fullBuffer;
13829
14388
  } else if (flags.selectiveSaveTripwire) try {
13830
- fullBuffer = await (await loadRepackDocx())(repackSourceDoc);
14389
+ fullBuffer = await repackFull();
13831
14390
  } catch {}
13832
14391
  if (flags.selectiveSaveTripwire && fullBuffer && onSelectiveSaveTripwire) try {
13833
14392
  const { compareSelectiveVsFull } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
13834
14393
  tripwireResult = await compareSelectiveVsFull(selectiveBuffer, fullBuffer);
13835
14394
  } catch {}
13836
- if (view_17) {
14395
+ if (view_18) {
13837
14396
  originalBufferRef.current = buffer;
13838
- view_17.dispatch(clearTrackedChanges(view_17.state));
14397
+ view_18.dispatch(clearTrackedChanges(view_18.state));
13839
14398
  }
13840
14399
  savedBuffer = buffer;
13841
14400
  } catch (error) {
@@ -13879,9 +14438,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13879
14438
  useImperativeHandle(ref, () => ({
13880
14439
  getDocument: () => buildCurrentDocument(),
13881
14440
  hasPendingChanges: () => {
13882
- const view_18 = pagedEditorRef.current?.getView();
13883
- if (!view_18) return false;
13884
- return commentsDirtyRef.current || getChangedParagraphIds(view_18.state).size > 0 || hasStructuralChanges(view_18.state) || hasUntrackedChanges(view_18.state);
14441
+ const view_19 = pagedEditorRef.current?.getView();
14442
+ if (!view_19) return false;
14443
+ return commentsDirtyRef.current || getChangedParagraphIds(view_19.state).size > 0 || hasStructuralChanges(view_19.state) || hasUntrackedChanges(view_19.state);
13885
14444
  },
13886
14445
  getEditorRef: () => pagedEditorRef.current,
13887
14446
  getEditor: () => pagedEditorRef.current?.getEditor() ?? null,
@@ -13906,6 +14465,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13906
14465
  findReplace.openReplace(readFindSelectionSeed());
13907
14466
  },
13908
14467
  loadDocument: (document_0) => {
14468
+ pendingSuggestionRegistryRef.current.clear();
13909
14469
  const editor_2 = pagedEditorRef.current?.getEditor();
13910
14470
  if (editor_2) {
13911
14471
  editor_2.loadDocument(document_0);
@@ -13913,18 +14473,21 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13913
14473
  }
13914
14474
  loadParsedDocument(document_0);
13915
14475
  },
13916
- loadDocumentBuffer: (buffer_1) => pagedEditorRef.current?.getEditor().loadDocx(buffer_1) ?? loadBuffer(buffer_1),
14476
+ loadDocumentBuffer: (buffer_1) => {
14477
+ pendingSuggestionRegistryRef.current.clear();
14478
+ return pagedEditorRef.current?.getEditor().loadDocx(buffer_1) ?? loadBuffer(buffer_1);
14479
+ },
13917
14480
  ensureEditorView: (options_2) => {
13918
14481
  pagedEditorRef.current?.ensureView(options_2);
13919
14482
  },
13920
14483
  createAIEditSnapshot: () => {
13921
- const view_19 = pagedEditorRef.current?.getView();
13922
- return view_19 ? createFolioAIEditSnapshot(view_19.state.doc) : null;
14484
+ const view_20 = pagedEditorRef.current?.getView();
14485
+ return view_20 ? createFolioAIEditSnapshot(view_20.state.doc) : null;
13923
14486
  },
13924
14487
  applyDocumentOperations: ({ snapshot, batch, author: operationAuthor = author }) => {
13925
14488
  assertSupportedFolioDocumentOperationVersion(batch.version);
13926
- const view_20 = pagedEditorRef.current?.getView();
13927
- if (!view_20) {
14489
+ const view_21 = pagedEditorRef.current?.getView();
14490
+ if (!view_21) {
13928
14491
  let status = "committed";
13929
14492
  if (batch.dryRun === true) status = "previewed";
13930
14493
  else if (batch.atomic === true) status = "rejected";
@@ -13943,16 +14506,17 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13943
14506
  };
13944
14507
  }
13945
14508
  const existingUndoEntry = documentOperationUndoEntriesRef.current.at(-1);
13946
- if (existingUndoEntry && (!view_20.state.doc.eq(existingUndoEntry.afterState.doc) || commentsRef.current !== existingUndoEntry.commentsAfter)) documentOperationUndoEntriesRef.current.length = 0;
14509
+ if (existingUndoEntry && (!view_21.state.doc.eq(existingUndoEntry.afterState.doc) || commentsRef.current !== existingUndoEntry.commentsAfter)) documentOperationUndoEntriesRef.current.length = 0;
13947
14510
  const commentsBefore = commentsRef.current;
13948
14511
  const createdComments = [];
13949
14512
  const operationView = {
13950
- state: view_20.state,
14513
+ state: view_21.state,
13951
14514
  dispatch: (transaction) => {
13952
- view_20.dispatch(closeHistory(transaction));
13953
- operationView.state = view_20.state;
14515
+ view_21.dispatch(closeHistory(transaction));
14516
+ operationView.state = view_21.state;
13954
14517
  }
13955
14518
  };
14519
+ const activeSuggestionIds = new Set(getSuggestions(view_21.state).map((s_0) => s_0.suggestionId));
13956
14520
  const result = applyFolioDocumentOperations({
13957
14521
  view: operationView,
13958
14522
  snapshot,
@@ -13968,10 +14532,19 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13968
14532
  id: `react-${String(documentOperationUndoHandleCursor++)}`
13969
14533
  })
13970
14534
  });
13971
- if (createdComments.length > 0) updateComments((currentComments_0) => [...currentComments_0, ...createdComments]);
14535
+ if (batch.mode === "suggested" && result.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
14536
+ snapshot,
14537
+ story: { type: "main" },
14538
+ operations: batch.operations,
14539
+ applied: result.applied,
14540
+ author: operationAuthor,
14541
+ activeSuggestionIds
14542
+ });
14543
+ const batchComments = appliedOperationComments(createdComments, result.applied);
14544
+ if (batchComments.length > 0) updateComments((currentComments_0) => [...currentComments_0, ...batchComments]);
13972
14545
  if (result.undoHandle !== null) documentOperationUndoEntriesRef.current.push({
13973
14546
  undoHandle: result.undoHandle,
13974
- afterState: view_20.state,
14547
+ afterState: view_21.state,
13975
14548
  commentsBefore,
13976
14549
  commentsAfter: commentsRef.current
13977
14550
  });
@@ -13991,18 +14564,18 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13991
14564
  reason: "notLatest"
13992
14565
  };
13993
14566
  const entry_3 = entries.at(-1);
13994
- const view_21 = pagedEditorRef.current?.getView();
13995
- if (!entry_3 || !view_21) return {
14567
+ const view_22 = pagedEditorRef.current?.getView();
14568
+ if (!entry_3 || !view_22) return {
13996
14569
  status: "rejected",
13997
14570
  undoHandle,
13998
14571
  reason: "unknownHandle"
13999
14572
  };
14000
- if (!view_21.state.doc.eq(entry_3.afterState.doc) || commentsRef.current !== entry_3.commentsAfter) return {
14573
+ if (!view_22.state.doc.eq(entry_3.afterState.doc) || commentsRef.current !== entry_3.commentsAfter) return {
14001
14574
  status: "rejected",
14002
14575
  undoHandle,
14003
14576
  reason: "documentChanged"
14004
14577
  };
14005
- if (!undo(view_21.state, view_21.dispatch)) return {
14578
+ if (!undo(view_22.state, view_22.dispatch)) return {
14006
14579
  status: "rejected",
14007
14580
  undoHandle,
14008
14581
  reason: "documentChanged"
@@ -14016,8 +14589,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14016
14589
  };
14017
14590
  },
14018
14591
  applyAIEditOperations: ({ snapshot: snapshot_0, operations, mode = "tracked-changes", author: operationAuthor_0 = author }) => {
14019
- const view_22 = pagedEditorRef.current?.getView();
14020
- if (!view_22) return {
14592
+ const view_23 = pagedEditorRef.current?.getView();
14593
+ if (!view_23) return {
14021
14594
  applied: [],
14022
14595
  skipped: operations.map((operation_0) => ({
14023
14596
  id: operation_0.id,
@@ -14025,8 +14598,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14025
14598
  }))
14026
14599
  };
14027
14600
  const createdComments_0 = [];
14601
+ const activeSuggestionIds_0 = new Set(getSuggestions(view_23.state).map((s_1) => s_1.suggestionId));
14028
14602
  const { applied: applied_0, skipped: skipped_0 } = applyFolioDocumentOperations({
14029
- view: view_22,
14603
+ view: view_23,
14030
14604
  snapshot: snapshot_0,
14031
14605
  batch: {
14032
14606
  version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
@@ -14040,21 +14614,30 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14040
14614
  return comment_0.id;
14041
14615
  }
14042
14616
  });
14043
- if (createdComments_0.length > 0) updateComments((currentComments_1) => [...currentComments_1, ...createdComments_0]);
14617
+ const batchComments_0 = appliedOperationComments(createdComments_0, applied_0);
14618
+ if (batchComments_0.length > 0) updateComments((currentComments_1) => [...currentComments_1, ...batchComments_0]);
14619
+ if (mode === "suggested") pendingSuggestionRegistryRef.current.recordApplied({
14620
+ snapshot: snapshot_0,
14621
+ story: { type: "main" },
14622
+ operations,
14623
+ applied: applied_0,
14624
+ author: operationAuthor_0,
14625
+ activeSuggestionIds: activeSuggestionIds_0
14626
+ });
14044
14627
  return {
14045
14628
  applied: applied_0,
14046
14629
  skipped: skipped_0
14047
14630
  };
14048
14631
  },
14049
14632
  acceptAIEditOperation: (revisionId) => {
14050
- const view_23 = pagedEditorRef.current?.getView();
14051
- if (!view_23) return false;
14052
- return acceptAIEditRevision(revisionId)(view_23.state, view_23.dispatch);
14053
- },
14054
- rejectAIEditOperation: (revisionId_0) => {
14055
14633
  const view_24 = pagedEditorRef.current?.getView();
14056
14634
  if (!view_24) return false;
14057
- return rejectAIEditRevision(revisionId_0)(view_24.state, view_24.dispatch);
14635
+ return acceptAIEditRevision(revisionId)(view_24.state, view_24.dispatch);
14636
+ },
14637
+ rejectAIEditOperation: (revisionId_0) => {
14638
+ const view_25 = pagedEditorRef.current?.getView();
14639
+ if (!view_25) return false;
14640
+ return rejectAIEditRevision(revisionId_0)(view_25.state, view_25.dispatch);
14058
14641
  },
14059
14642
  undo: () => {
14060
14643
  if (getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.undo();
@@ -14069,44 +14652,44 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14069
14652
  return redone;
14070
14653
  },
14071
14654
  scrollToAIEditOperation: (revisionId_1) => {
14072
- const view_25 = pagedEditorRef.current?.getView();
14073
- if (!view_25) return false;
14074
- const range_2 = findAIEditRevisionRange(view_25.state, revisionId_1);
14655
+ const view_26 = pagedEditorRef.current?.getView();
14656
+ if (!view_26) return false;
14657
+ const range_2 = findAIEditRevisionRange(view_26.state, revisionId_1);
14075
14658
  if (!range_2) return false;
14076
- const { from: from_8, to: to_8 } = clampRangeToDocSize(view_25.state.doc.content.size, range_2);
14077
- const $from = view_25.state.doc.resolve(from_8);
14078
- const $to = view_25.state.doc.resolve(to_8);
14079
- view_25.dispatch(view_25.state.tr.setSelection(TextSelection.between($from, $to)));
14659
+ const { from: from_8, to: to_8 } = clampRangeToDocSize(view_26.state.doc.content.size, range_2);
14660
+ const $from = view_26.state.doc.resolve(from_8);
14661
+ const $to = view_26.state.doc.resolve(to_8);
14662
+ view_26.dispatch(view_26.state.tr.setSelection(TextSelection.between($from, $to)));
14080
14663
  requestAnimationFrame(() => {
14081
14664
  pagedEditorRef.current?.scrollToPosition(from_8);
14082
14665
  });
14083
14666
  return true;
14084
14667
  },
14085
14668
  scrollToBlock: (blockId, snapshot_1) => {
14086
- const view_26 = pagedEditorRef.current?.getView();
14087
- if (!view_26) return false;
14669
+ const view_27 = pagedEditorRef.current?.getView();
14670
+ if (!view_27) return false;
14088
14671
  const range_3 = resolveFolioAIBlockRange({
14089
14672
  blockId,
14090
- doc: view_26.state.doc,
14673
+ doc: view_27.state.doc,
14091
14674
  snapshot: snapshot_1
14092
14675
  });
14093
14676
  if (range_3 === null) return false;
14094
14677
  const { from: from_9, to: to_9 } = range_3;
14095
- const $from_0 = view_26.state.doc.resolve(from_9);
14096
- const $to_0 = view_26.state.doc.resolve(to_9);
14097
- view_26.dispatch(view_26.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
14678
+ const $from_0 = view_27.state.doc.resolve(from_9);
14679
+ const $to_0 = view_27.state.doc.resolve(to_9);
14680
+ view_27.dispatch(view_27.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
14098
14681
  requestAnimationFrame(() => {
14099
14682
  pagedEditorRef.current?.scrollToPosition(from_9);
14100
14683
  });
14101
14684
  return true;
14102
14685
  },
14103
14686
  highlightPassage: ({ blockId: blockId_0, text: text_5, snapshot: snapshot_2 }) => {
14104
- const view_27 = pagedEditorRef.current?.getView();
14105
- if (!view_27) return "none";
14687
+ const view_28 = pagedEditorRef.current?.getView();
14688
+ if (!view_28) return "none";
14106
14689
  const passageRange = resolvePassageRange({
14107
14690
  blockId: blockId_0,
14108
14691
  text: text_5,
14109
- doc: view_27.state.doc,
14692
+ doc: view_28.state.doc,
14110
14693
  snapshot: snapshot_2
14111
14694
  });
14112
14695
  if (passageRange !== null) {
@@ -14119,16 +14702,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14119
14702
  pagedEditorRef.current?.setPassageHighlight(null);
14120
14703
  const blockRange = resolveFolioAIBlockRange({
14121
14704
  blockId: blockId_0,
14122
- doc: view_27.state.doc,
14705
+ doc: view_28.state.doc,
14123
14706
  snapshot: snapshot_2
14124
14707
  });
14125
14708
  if (blockRange === null) return "none";
14126
14709
  const paraId_0 = getFolioParaIdFromBlockId(blockId_0);
14127
14710
  if (paraId_0 !== null && pagedEditorRef.current?.scrollToParaId(paraId_0, { highlight: {} })) return "block";
14128
14711
  const { from: from_10, to: to_10 } = blockRange;
14129
- const $from_1 = view_27.state.doc.resolve(from_10);
14130
- const $to_1 = view_27.state.doc.resolve(to_10);
14131
- view_27.dispatch(view_27.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
14712
+ const $from_1 = view_28.state.doc.resolve(from_10);
14713
+ const $to_1 = view_28.state.doc.resolve(to_10);
14714
+ view_28.dispatch(view_28.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
14132
14715
  requestAnimationFrame(() => {
14133
14716
  pagedEditorRef.current?.scrollToPosition(from_10);
14134
14717
  });
@@ -14138,91 +14721,143 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14138
14721
  pagedEditorRef.current?.setPassageHighlight(null);
14139
14722
  },
14140
14723
  showInDocument: (target_1, snapshot_3) => {
14141
- const view_28 = pagedEditorRef.current?.getView();
14142
- if (!view_28) return false;
14724
+ const view_29 = pagedEditorRef.current?.getView();
14725
+ if (!view_29) return false;
14143
14726
  const range_4 = target_1.type === "textRange" ? resolveFolioAITextRange({
14144
14727
  range: target_1,
14145
- doc: view_28.state.doc,
14728
+ doc: view_29.state.doc,
14146
14729
  snapshot: snapshot_3
14147
14730
  }) : resolveFolioAIBlockRange({
14148
14731
  blockId: target_1.blockId,
14149
- doc: view_28.state.doc,
14732
+ doc: view_29.state.doc,
14150
14733
  snapshot: snapshot_3
14151
14734
  });
14152
14735
  if (range_4 === null) return false;
14153
14736
  const { from: from_11, to: to_11 } = range_4;
14154
- const $from_2 = view_28.state.doc.resolve(from_11);
14155
- const $to_2 = view_28.state.doc.resolve(to_11);
14156
- view_28.dispatch(view_28.state.tr.setSelection(TextSelection.between($from_2, $to_2)));
14737
+ const $from_2 = view_29.state.doc.resolve(from_11);
14738
+ const $to_2 = view_29.state.doc.resolve(to_11);
14739
+ view_29.dispatch(view_29.state.tr.setSelection(TextSelection.between($from_2, $to_2)));
14157
14740
  requestAnimationFrame(() => {
14158
14741
  pagedEditorRef.current?.scrollToPosition(from_11);
14159
14742
  });
14160
14743
  return true;
14161
14744
  },
14162
14745
  getSuggestions: () => {
14163
- const view_29 = pagedEditorRef.current?.getView();
14164
- return view_29 ? getSuggestions(view_29.state) : [];
14746
+ const view_30 = pagedEditorRef.current?.getView();
14747
+ return view_30 ? getSuggestions(view_30.state) : [];
14748
+ },
14749
+ exportPendingSuggestions: () => {
14750
+ const view_31 = pagedEditorRef.current?.getView();
14751
+ const activeIds = new Set(view_31 ? getSuggestions(view_31.state).map((s_2) => s_2.suggestionId) : []);
14752
+ return pendingSuggestionRegistryRef.current.exportPendingSuggestions({
14753
+ activeSuggestionIds: activeIds,
14754
+ snapshotForStory: (story_0, commentIds) => story_0.type === "main" && view_31 ? createPendingSuggestionSourceSnapshot(view_31.state, commentIds) : null
14755
+ });
14165
14756
  },
14757
+ loadPendingSuggestions: (records) => pendingSuggestionRegistryRef.current.loadPendingSuggestions({
14758
+ records,
14759
+ snapshotForStory: (story_1) => {
14760
+ const view_32 = pagedEditorRef.current?.getView();
14761
+ return story_1.type === "main" && view_32 ? createFolioAIEditSnapshot(view_32.state.doc) : null;
14762
+ },
14763
+ sourceSnapshotForStory: (story_2, commentIds_0) => {
14764
+ const view_33 = pagedEditorRef.current?.getView();
14765
+ return story_2.type === "main" && view_33 ? createPendingSuggestionSourceSnapshot(view_33.state, commentIds_0) : null;
14766
+ },
14767
+ apply: (record, snapshot_4) => {
14768
+ const view_34 = pagedEditorRef.current?.getView();
14769
+ if (!view_34) return {
14770
+ applied: [],
14771
+ skipped: []
14772
+ };
14773
+ const createdComments_1 = [];
14774
+ const result_0 = applyFolioDocumentOperations({
14775
+ view: view_34,
14776
+ snapshot: snapshot_4,
14777
+ batch: {
14778
+ version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
14779
+ operations: [record.operation],
14780
+ mode: "suggested"
14781
+ },
14782
+ author: record.author,
14783
+ createCommentId: (commentText) => {
14784
+ const comment_1 = createComment(commentText, record.author);
14785
+ createdComments_1.push(comment_1);
14786
+ return comment_1.id;
14787
+ }
14788
+ });
14789
+ const appliedComments = appliedOperationComments(createdComments_1, result_0.applied);
14790
+ if (appliedComments.length > 0) updateComments((currentComments_2) => [...currentComments_2, ...appliedComments]);
14791
+ return {
14792
+ applied: result_0.applied,
14793
+ skipped: result_0.skipped
14794
+ };
14795
+ },
14796
+ activeSuggestionIds: () => {
14797
+ const view_35 = pagedEditorRef.current?.getView();
14798
+ return new Set(view_35 ? getSuggestions(view_35.state).map((s_3) => s_3.suggestionId) : []);
14799
+ }
14800
+ }),
14166
14801
  acceptSuggestion: (suggestionId, options_3) => {
14167
- const view_30 = pagedEditorRef.current?.getView();
14168
- if (!view_30) return {
14802
+ const view_36 = pagedEditorRef.current?.getView();
14803
+ if (!view_36) return {
14169
14804
  accepted: false,
14170
14805
  appliedAs: null
14171
14806
  };
14172
- const appliedAs = getSuggestions(view_30.state).find((s_0) => s_0.suggestionId === suggestionId)?.appliedAs ?? null;
14173
- const accepted = acceptSuggestion(suggestionId, { author: options_3?.author ?? author })(view_30.state, view_30.dispatch);
14807
+ const appliedAs = getSuggestions(view_36.state).find((s_4) => s_4.suggestionId === suggestionId)?.appliedAs ?? null;
14808
+ const accepted = acceptSuggestion(suggestionId, { author: options_3?.author ?? author })(view_36.state, view_36.dispatch);
14174
14809
  return {
14175
14810
  accepted,
14176
14811
  appliedAs: accepted ? appliedAs : null
14177
14812
  };
14178
14813
  },
14179
14814
  rejectSuggestion: (suggestionId_0) => {
14180
- const view_31 = pagedEditorRef.current?.getView();
14181
- if (!view_31) return false;
14182
- return rejectSuggestion(suggestionId_0)(view_31.state, view_31.dispatch);
14815
+ const view_37 = pagedEditorRef.current?.getView();
14816
+ if (!view_37) return false;
14817
+ return rejectSuggestion(suggestionId_0)(view_37.state, view_37.dispatch);
14183
14818
  },
14184
14819
  scrollToSuggestion: (suggestionId_1) => {
14185
- const view_32 = pagedEditorRef.current?.getView();
14186
- if (!view_32) return false;
14187
- const range_5 = findSuggestionRange(view_32.state, suggestionId_1);
14820
+ const view_38 = pagedEditorRef.current?.getView();
14821
+ if (!view_38) return false;
14822
+ const range_5 = findSuggestionRange(view_38.state, suggestionId_1);
14188
14823
  if (!range_5) return false;
14189
- const { from: from_12, to: to_12 } = clampRangeToDocSize(view_32.state.doc.content.size, range_5);
14190
- const $from_3 = view_32.state.doc.resolve(from_12);
14191
- const $to_3 = view_32.state.doc.resolve(to_12);
14192
- view_32.dispatch(view_32.state.tr.setSelection(TextSelection.between($from_3, $to_3)));
14824
+ const { from: from_12, to: to_12 } = clampRangeToDocSize(view_38.state.doc.content.size, range_5);
14825
+ const $from_3 = view_38.state.doc.resolve(from_12);
14826
+ const $to_3 = view_38.state.doc.resolve(to_12);
14827
+ view_38.dispatch(view_38.state.tr.setSelection(TextSelection.between($from_3, $to_3)));
14193
14828
  requestAnimationFrame(() => {
14194
14829
  pagedEditorRef.current?.scrollToPosition(from_12);
14195
14830
  });
14196
14831
  return true;
14197
14832
  },
14198
14833
  getTrackedChanges: () => {
14199
- const view_33 = pagedEditorRef.current?.getView();
14200
- return view_33 ? getTrackedChangesFromDoc(view_33.state.doc) : [];
14834
+ const view_39 = pagedEditorRef.current?.getView();
14835
+ return view_39 ? getTrackedChangesFromDoc(view_39.state.doc) : [];
14201
14836
  },
14202
14837
  getCommentAnchors: () => {
14203
- const view_34 = pagedEditorRef.current?.getView();
14204
- return view_34 ? getCommentAnchorsFromDoc(view_34.state.doc) : [];
14838
+ const view_40 = pagedEditorRef.current?.getView();
14839
+ return view_40 ? getCommentAnchorsFromDoc(view_40.state.doc) : [];
14205
14840
  },
14206
14841
  getSelectionText: () => {
14207
- const view_35 = pagedEditorRef.current?.getView();
14208
- return view_35 ? getSelectedText(view_35.state) : "";
14842
+ const view_41 = pagedEditorRef.current?.getView();
14843
+ return view_41 ? getSelectedText(view_41.state) : "";
14209
14844
  },
14210
- getPageText: (page_0) => {
14211
- const view_36 = pagedEditorRef.current?.getView();
14212
- if (!view_36) return null;
14213
- return getPageTextFromLayout(pagedEditorRef.current?.getEditor()?.getLayout() ?? null, view_36.state.doc, page_0);
14845
+ getPageText: (page_1) => {
14846
+ const view_42 = pagedEditorRef.current?.getView();
14847
+ if (!view_42) return null;
14848
+ return getPageTextFromLayout(pagedEditorRef.current?.getEditor()?.getLayout() ?? null, view_42.state.doc, page_1);
14214
14849
  },
14215
- getTargetPage: (target_2, snapshot_4) => {
14216
- const view_37 = pagedEditorRef.current?.getView();
14217
- if (!view_37) return null;
14850
+ getTargetPage: (target_2, snapshot_5) => {
14851
+ const view_43 = pagedEditorRef.current?.getView();
14852
+ if (!view_43) return null;
14218
14853
  const range_6 = target_2.type === "textRange" ? resolveFolioAITextRange({
14219
14854
  range: target_2,
14220
- doc: view_37.state.doc,
14221
- snapshot: snapshot_4
14855
+ doc: view_43.state.doc,
14856
+ snapshot: snapshot_5
14222
14857
  }) : resolveFolioAIBlockRange({
14223
14858
  blockId: target_2.blockId,
14224
- doc: view_37.state.doc,
14225
- snapshot: snapshot_4
14859
+ doc: view_43.state.doc,
14860
+ snapshot: snapshot_5
14226
14861
  });
14227
14862
  if (range_6 === null) return null;
14228
14863
  return pagedEditorRef.current?.getPageNumberForPmPos(range_6.from) ?? null;
@@ -14232,49 +14867,49 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14232
14867
  getScrollRoot: () => pagedEditorRef.current?.getScrollRoot() ?? null,
14233
14868
  onLayoutChange: (listener) => pagedEditorRef.current?.onLayoutChange(listener) ?? (() => {}),
14234
14869
  getContentControls: (filter = {}) => {
14235
- const view_38 = pagedEditorRef.current?.getView();
14236
- if (!view_38) return [];
14237
- return findBlockSdtMatches(view_38.state.doc, filter).map((match_0) => ({
14870
+ const view_44 = pagedEditorRef.current?.getView();
14871
+ if (!view_44) return [];
14872
+ return findBlockSdtMatches(view_44.state.doc, filter).map((match_0) => ({
14238
14873
  properties: blockSdtAttrsToSdtProperties(match_0.node),
14239
14874
  path: match_0.path,
14240
14875
  pmPos: match_0.pos
14241
14876
  }));
14242
14877
  },
14243
14878
  scrollToContentControl: (filter_0) => {
14244
- const view_39 = pagedEditorRef.current?.getView();
14245
- if (!view_39) return false;
14246
- const match_1 = findBlockSdtMatch(view_39.state.doc, filter_0);
14879
+ const view_45 = pagedEditorRef.current?.getView();
14880
+ if (!view_45) return false;
14881
+ const match_1 = findBlockSdtMatch(view_45.state.doc, filter_0);
14247
14882
  if (!match_1) return false;
14248
14883
  const inside = match_1.pos + 1;
14249
- const $pos = view_39.state.doc.resolve(inside);
14250
- view_39.dispatch(view_39.state.tr.setSelection(TextSelection.near($pos)));
14884
+ const $pos = view_45.state.doc.resolve(inside);
14885
+ view_45.dispatch(view_45.state.tr.setSelection(TextSelection.near($pos)));
14251
14886
  requestAnimationFrame(() => {
14252
14887
  pagedEditorRef.current?.scrollToPosition(inside);
14253
14888
  });
14254
14889
  return true;
14255
14890
  },
14256
14891
  setContentControlContent: (filter_1, input, options_4 = {}) => {
14257
- const view_40 = pagedEditorRef.current?.getView();
14258
- if (!view_40) return false;
14259
- const tr_0 = typeof input === "string" ? setContentControlContentTr(view_40.state, filter_1, input, options_4) : setContentControlContentBlocksTr(view_40.state, filter_1, input, options_4);
14892
+ const view_46 = pagedEditorRef.current?.getView();
14893
+ if (!view_46) return false;
14894
+ const tr_0 = typeof input === "string" ? setContentControlContentTr(view_46.state, filter_1, input, options_4) : setContentControlContentBlocksTr(view_46.state, filter_1, input, options_4);
14260
14895
  if (!tr_0) return false;
14261
- view_40.dispatch(tr_0);
14896
+ view_46.dispatch(tr_0);
14262
14897
  return true;
14263
14898
  },
14264
14899
  setContentControlValue: (filter_2, input_0, options_5 = {}) => {
14265
- const view_41 = pagedEditorRef.current?.getView();
14266
- if (!view_41) return false;
14267
- const tr_1 = setContentControlValueTr(view_41.state, filter_2, input_0, options_5);
14900
+ const view_47 = pagedEditorRef.current?.getView();
14901
+ if (!view_47) return false;
14902
+ const tr_1 = setContentControlValueTr(view_47.state, filter_2, input_0, options_5);
14268
14903
  if (!tr_1) return false;
14269
- view_41.dispatch(tr_1);
14904
+ view_47.dispatch(tr_1);
14270
14905
  return true;
14271
14906
  },
14272
14907
  removeContentControl: (filter_3, options_6 = {}) => {
14273
- const view_42 = pagedEditorRef.current?.getView();
14274
- if (!view_42) return false;
14275
- const tr_2 = removeContentControlTr(view_42.state, filter_3, options_6);
14908
+ const view_48 = pagedEditorRef.current?.getView();
14909
+ if (!view_48) return false;
14910
+ const tr_2 = removeContentControlTr(view_48.state, filter_3, options_6);
14276
14911
  if (!tr_2) return false;
14277
- view_42.dispatch(tr_2);
14912
+ view_48.dispatch(tr_2);
14278
14913
  return true;
14279
14914
  }
14280
14915
  }), [
@@ -14358,39 +14993,39 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14358
14993
  if (isDisplayMode(value)) setDisplayMode(value);
14359
14994
  }, [setDisplayMode]);
14360
14995
  const handleAcceptActiveChange = useCallback(() => {
14361
- const view_43 = pagedEditorRef.current?.getView();
14362
- if (!view_43) return;
14363
- const { from: from_13, to: to_13 } = view_43.state.selection;
14364
- const range_7 = findChangeAtPosition(view_43.state, from_13, to_13);
14365
- acceptChange(range_7.from, range_7.to)(view_43.state, view_43.dispatch);
14996
+ const view_49 = pagedEditorRef.current?.getView();
14997
+ if (!view_49) return;
14998
+ const { from: from_13, to: to_13 } = view_49.state.selection;
14999
+ const range_7 = findChangeAtPosition(view_49.state, from_13, to_13);
15000
+ acceptChange(range_7.from, range_7.to)(view_49.state, view_49.dispatch);
14366
15001
  }, []);
14367
15002
  const handleRejectActiveChange = useCallback(() => {
14368
- const view_44 = pagedEditorRef.current?.getView();
14369
- if (!view_44) return;
14370
- const { from: from_14, to: to_14 } = view_44.state.selection;
14371
- const range_8 = findChangeAtPosition(view_44.state, from_14, to_14);
14372
- rejectChange(range_8.from, range_8.to)(view_44.state, view_44.dispatch);
15003
+ const view_50 = pagedEditorRef.current?.getView();
15004
+ if (!view_50) return;
15005
+ const { from: from_14, to: to_14 } = view_50.state.selection;
15006
+ const range_8 = findChangeAtPosition(view_50.state, from_14, to_14);
15007
+ rejectChange(range_8.from, range_8.to)(view_50.state, view_50.dispatch);
14373
15008
  }, []);
14374
15009
  const handlePreviousChange = useCallback(() => {
14375
- const view_45 = pagedEditorRef.current?.getView();
14376
- if (!view_45) return;
14377
- const { from: from_15 } = view_45.state.selection;
14378
- const change = findPreviousChange(view_45.state, from_15);
15010
+ const view_51 = pagedEditorRef.current?.getView();
15011
+ if (!view_51) return;
15012
+ const { from: from_15 } = view_51.state.selection;
15013
+ const change = findPreviousChange(view_51.state, from_15);
14379
15014
  if (!change) return;
14380
- view_45.dispatch(view_45.state.tr.setSelection(TextSelection.create(view_45.state.doc, change.from, change.to)));
14381
- view_45.focus();
15015
+ view_51.dispatch(view_51.state.tr.setSelection(TextSelection.create(view_51.state.doc, change.from, change.to)));
15016
+ view_51.focus();
14382
15017
  requestAnimationFrame(() => {
14383
15018
  pagedEditorRef.current?.scrollToPosition(change.from);
14384
15019
  });
14385
15020
  }, []);
14386
15021
  const handleNextChange = useCallback(() => {
14387
- const view_46 = pagedEditorRef.current?.getView();
14388
- if (!view_46) return;
14389
- const { to: to_15 } = view_46.state.selection;
14390
- const change_0 = findNextChange(view_46.state, to_15);
15022
+ const view_52 = pagedEditorRef.current?.getView();
15023
+ if (!view_52) return;
15024
+ const { to: to_15 } = view_52.state.selection;
15025
+ const change_0 = findNextChange(view_52.state, to_15);
14391
15026
  if (!change_0) return;
14392
- view_46.dispatch(view_46.state.tr.setSelection(TextSelection.create(view_46.state.doc, change_0.from, change_0.to)));
14393
- view_46.focus();
15027
+ view_52.dispatch(view_52.state.tr.setSelection(TextSelection.create(view_52.state.doc, change_0.from, change_0.to)));
15028
+ view_52.focus();
14394
15029
  requestAnimationFrame(() => {
14395
15030
  pagedEditorRef.current?.scrollToPosition(change_0.from);
14396
15031
  });
@@ -14560,21 +15195,21 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14560
15195
  requestAnimationFrame(syncCommentHighlightStyles);
14561
15196
  }, [onScrollTopChange, syncCommentHighlightStyles]);
14562
15197
  const handlePagedSelectionChange = useCallback((_from, _to) => {
14563
- const view_47 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
14564
- handleSelectionChange(view_47 ? extractSelectionState(view_47.state) : null);
15198
+ const view_53 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
15199
+ handleSelectionChange(view_53 ? extractSelectionState(view_53.state) : null);
14565
15200
  }, [getActiveEditorView, handleSelectionChange]);
14566
15201
  const handleTotalPagesChange = useCallback((totalPages) => {
14567
15202
  setScrollPageInfo((previous) => updateScrollPageTotal(previous, totalPages));
14568
15203
  }, [setScrollPageInfo]);
14569
15204
  const handleCommentClick = useCallback((id) => setActiveCommentId(id), [setActiveCommentId]);
14570
15205
  const handleCommentResolve = useCallback((id_0) => {
14571
- updateComments((previous_0) => previous_0.map((comment_1) => comment_1.id === id_0 ? {
14572
- ...comment_1,
15206
+ updateComments((previous_0) => previous_0.map((comment_2) => comment_2.id === id_0 ? {
15207
+ ...comment_2,
14573
15208
  done: true
14574
- } : comment_1));
15209
+ } : comment_2));
14575
15210
  }, [updateComments]);
14576
15211
  const handleCommentDelete = useCallback((id_1) => {
14577
- updateComments((previous_1) => previous_1.filter((comment_2) => comment_2.id !== id_1 && comment_2.parentId !== id_1));
15212
+ updateComments((previous_1) => previous_1.filter((comment_3) => comment_3.id !== id_1 && comment_3.parentId !== id_1));
14578
15213
  if (activeCommentId === id_1) setActiveCommentId(null);
14579
15214
  }, [
14580
15215
  activeCommentId,
@@ -14585,19 +15220,19 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14585
15220
  updateComments((previous_2) => [...previous_2, createComment(text_6, author, id_2)]);
14586
15221
  }, [author, updateComments]);
14587
15222
  const handleAddComment = useCallback((addText) => {
14588
- const comment_3 = createComment(addText, author);
14589
- const view_48 = pagedEditorRef.current?.getView();
14590
- if (!view_48 || !commentSelectionRange) return false;
14591
- if (!applyCommentMarkRange(view_48, commentSelectionRange, comment_3.id, { replacePending: true })) return false;
14592
- const commentAuthor_2 = getCommentAuthorKey(comment_3.author);
15223
+ const comment_4 = createComment(addText, author);
15224
+ const view_54 = pagedEditorRef.current?.getView();
15225
+ if (!view_54 || !commentSelectionRange) return false;
15226
+ if (!applyCommentMarkRange(view_54, commentSelectionRange, comment_4.id, { replacePending: true })) return false;
15227
+ const commentAuthor_2 = getCommentAuthorKey(comment_4.author);
14593
15228
  setVisibleCommentAuthors((current) => {
14594
15229
  if (current === null) return null;
14595
15230
  const next_1 = new Set(current);
14596
15231
  next_1.add(commentAuthor_2);
14597
15232
  return next_1;
14598
15233
  });
14599
- setActiveCommentId(comment_3.id);
14600
- updateComments((previous_3) => [...previous_3, comment_3]);
15234
+ setActiveCommentId(comment_4.id);
15235
+ updateComments((previous_3) => [...previous_3, comment_4]);
14601
15236
  pagedEditorRef.current?.relayout();
14602
15237
  requestAnimationFrame(() => {
14603
15238
  syncCommentHighlightStyles();
@@ -14622,8 +15257,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14622
15257
  updateComments((previous_4) => [...previous_4, createComment(text_7, author, revisionId_2)]);
14623
15258
  }, [author, updateComments]);
14624
15259
  const handleCancelAddComment = useCallback(() => {
14625
- const view_49 = pagedEditorRef.current?.getView();
14626
- if (view_49 && commentSelectionRange) removePendingCommentMarkRange(view_49, commentSelectionRange);
15260
+ const view_55 = pagedEditorRef.current?.getView();
15261
+ if (view_55 && commentSelectionRange) removePendingCommentMarkRange(view_55, commentSelectionRange);
14627
15262
  setIsAddingComment(false);
14628
15263
  setCommentSelectionRange(null);
14629
15264
  setAddCommentYPosition(null);
@@ -14639,27 +15274,89 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14639
15274
  })?.revisionId ?? null;
14640
15275
  }, []);
14641
15276
  const handleSidebarAcceptChange = useCallback((from_17, to_17) => {
14642
- const view_50 = pagedEditorRef.current?.getView();
14643
- if (!view_50) return;
15277
+ const view_56 = pagedEditorRef.current?.getView();
15278
+ if (!view_56) return;
14644
15279
  const revisionId_3 = resolveSidebarChangeRevisionId(from_17, to_17);
14645
15280
  if (revisionId_3 === null) return;
14646
- acceptAIEditRevision(revisionId_3)(view_50.state, view_50.dispatch);
15281
+ acceptAIEditRevision(revisionId_3)(view_56.state, view_56.dispatch);
14647
15282
  extractTrackedChanges();
14648
15283
  }, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
14649
15284
  const handleSidebarRejectChange = useCallback((from_18, to_18) => {
14650
- const view_51 = pagedEditorRef.current?.getView();
14651
- if (!view_51) return;
15285
+ const view_57 = pagedEditorRef.current?.getView();
15286
+ if (!view_57) return;
14652
15287
  const revisionId_4 = resolveSidebarChangeRevisionId(from_18, to_18);
14653
15288
  if (revisionId_4 === null) return;
14654
- rejectAIEditRevision(revisionId_4)(view_51.state, view_51.dispatch);
15289
+ rejectAIEditRevision(revisionId_4)(view_57.state, view_57.dispatch);
14655
15290
  extractTrackedChanges();
14656
15291
  }, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
14657
15292
  const commentsPageWidth = history.state?.package.document.finalSectionProperties?.pageWidth;
15293
+ const dismissCommentsDrawer = useCallback(() => {
15294
+ if (isAddingComment) handleCancelAddComment();
15295
+ setPanelOverlay("none");
15296
+ setShowCommentsSidebar(false);
15297
+ setActiveCommentId(null);
15298
+ }, [
15299
+ handleCancelAddComment,
15300
+ isAddingComment,
15301
+ setActiveCommentId,
15302
+ setPanelOverlay,
15303
+ setShowCommentsSidebar
15304
+ ]);
15305
+ useEffect(() => {
15306
+ if (isAddingComment && panels.layout.comments === "drawer") setPanelOverlay("comments");
15307
+ }, [
15308
+ isAddingComment,
15309
+ panels.layout.comments,
15310
+ setPanelOverlay
15311
+ ]);
15312
+ const toggleComments = useCallback(() => {
15313
+ if (commentsSurface === "drawer") {
15314
+ dismissCommentsDrawer();
15315
+ return;
15316
+ }
15317
+ if (commentsSurface === "column") {
15318
+ setShowCommentsSidebar(false);
15319
+ setActiveCommentId(null);
15320
+ return;
15321
+ }
15322
+ if (visibleCommentAuthorSet.size === 0) setVisibleCommentAuthors(null);
15323
+ setShowCommentsSidebar(true);
15324
+ if (layoutWithCommentsOpen().comments === "drawer") setPanelOverlay("comments");
15325
+ }, [
15326
+ commentsSurface,
15327
+ dismissCommentsDrawer,
15328
+ layoutWithCommentsOpen,
15329
+ setActiveCommentId,
15330
+ setPanelOverlay,
15331
+ setShowCommentsSidebar,
15332
+ setVisibleCommentAuthors,
15333
+ visibleCommentAuthorSet.size
15334
+ ]);
15335
+ const openCommentThreadCount = useMemo(() => countOpenCommentThreads(comments), [comments]);
15336
+ const outlineToggle = (() => {
15337
+ if (panels.layout.outline !== "drawer") return "absent";
15338
+ return panelOverlay === "outline" ? "open" : "closed";
15339
+ })();
15340
+ const panelToggles = useMemo(() => /* @__PURE__ */ jsx(PanelToggles, {
15341
+ outline: outlineToggle,
15342
+ onToggleOutline: toggleOutlineOverlay,
15343
+ commentsShown: commentsSurface !== null,
15344
+ commentCount: openCommentThreadCount,
15345
+ onToggleComments: toggleComments
15346
+ }), [
15347
+ commentsSurface,
15348
+ openCommentThreadCount,
15349
+ outlineToggle,
15350
+ toggleComments,
15351
+ toggleOutlineOverlay
15352
+ ]);
14658
15353
  const commentsSidebarOverlay = useMemo(() => {
14659
- if (!showCommentsSidebar) return;
15354
+ if (commentsSurface === null) return;
14660
15355
  return /* @__PURE__ */ jsx(Suspense, {
14661
15356
  fallback: null,
14662
15357
  children: /* @__PURE__ */ jsx(CommentsSidebar, {
15358
+ surface: commentsSurface,
15359
+ onDismiss: dismissCommentsDrawer,
14663
15360
  activeCommentId,
14664
15361
  comments: visibleComments,
14665
15362
  anchorPositions,
@@ -14694,7 +15391,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14694
15391
  handleSidebarRejectChange,
14695
15392
  handleTrackedChangeReply,
14696
15393
  isAddingComment,
14697
- showCommentsSidebar,
15394
+ commentsSurface,
15395
+ dismissCommentsDrawer,
14698
15396
  visibleComments
14699
15397
  ]);
14700
15398
  const getActiveHfView = useCallback(() => activeHfRId ? pagedEditorRef.current?.getHfView(activeHfRId) ?? null : null, [activeHfRId]);
@@ -14716,6 +15414,10 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14716
15414
  };
14717
15415
  requestAnimationFrame(flash);
14718
15416
  }, []);
15417
+ const handleOutlineJump = useCallback((id_3) => {
15418
+ markHeadingJumped(id_3);
15419
+ handleOutlineHeadingClick(Number(id_3));
15420
+ }, [handleOutlineHeadingClick, markHeadingJumped]);
14719
15421
  const handleTextContextAction = useCallback((action_3) => {
14720
15422
  handleContextMenuAction(action_3);
14721
15423
  }, [handleContextMenuAction]);
@@ -14727,8 +15429,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14727
15429
  }, [readOnly]);
14728
15430
  const closeTableProperties = useCallback(() => setTablePropsOpen(false), []);
14729
15431
  const applyTableProperties = useCallback((props_0) => {
14730
- const view_52 = getActiveEditorView();
14731
- if (view_52) setTableProperties(props_0)(view_52.state, view_52.dispatch);
15432
+ const view_58 = getActiveEditorView();
15433
+ if (view_58) setTableProperties(props_0)(view_58.state, view_58.dispatch);
14732
15434
  }, [getActiveEditorView]);
14733
15435
  const closeImagePosition = useCallback(() => setImagePositionOpen(false), [setImagePositionOpen]);
14734
15436
  const closeImageProperties = useCallback(() => setImagePropsOpen(false), [setImagePropsOpen]);
@@ -14736,8 +15438,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14736
15438
  const closeFootnoteProperties = useCallback(() => setFootnotePropsOpen(false), []);
14737
15439
  const closeInsertSymbol = useCallback(() => setShowInsertSymbol(false), []);
14738
15440
  const insertSymbol = useCallback((symbol) => {
14739
- const view_53 = getActiveEditorView();
14740
- if (view_53) view_53.dispatch(view_53.state.tr.insertText(symbol).scrollIntoView());
15441
+ const view_59 = getActiveEditorView();
15442
+ if (view_59) view_59.dispatch(view_59.state.tr.insertText(symbol).scrollIntoView());
14741
15443
  }, [getActiveEditorView]);
14742
15444
  const imagePropertiesCurrentData = useMemo(() => buildImagePropertiesData(state.pmImageContext), [state.pmImageContext]);
14743
15445
  const currentFindResult = findResultRef.current;
@@ -14818,6 +15520,20 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14818
15520
  footnotePropsOpen,
14819
15521
  handleApplyFootnoteProperties
14820
15522
  ]);
15523
+ const closeNumberingValueDialog = useCallback(() => setNumberingValueDialogOpen(false), []);
15524
+ const applyNumberingValue = useCallback((value_0) => {
15525
+ const view_60 = getActiveEditorView();
15526
+ if (view_60) setNumberingValue(value_0)(view_60.state, view_60.dispatch);
15527
+ }, [getActiveEditorView]);
15528
+ const numberingValueDialog = useMemo(() => ({
15529
+ isOpen: numberingValueDialogOpen,
15530
+ onClose: closeNumberingValueDialog,
15531
+ onApply: applyNumberingValue
15532
+ }), [
15533
+ applyNumberingValue,
15534
+ closeNumberingValueDialog,
15535
+ numberingValueDialogOpen
15536
+ ]);
14821
15537
  const insertSymbolDialog = useMemo(() => ({
14822
15538
  isOpen: showInsertSymbol,
14823
15539
  onClose: closeInsertSymbol,
@@ -14842,6 +15558,13 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14842
15558
  minWidth: 0,
14843
15559
  flexDirection: "row"
14844
15560
  };
15561
+ const panelsRowStyle = {
15562
+ position: "relative",
15563
+ display: "flex",
15564
+ flex: 1,
15565
+ minHeight: 0,
15566
+ minWidth: 0
15567
+ };
14845
15568
  const editorContainerStyle = {
14846
15569
  flex: 1,
14847
15570
  minHeight: 0,
@@ -14900,7 +15623,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14900
15623
  },
14901
15624
  children: [
14902
15625
  showToolbar && !readOnlyProp && /* @__PURE__ */ jsx("div", {
14903
- ref: toolbarRefCallback,
14904
15626
  className: "z-50 flex flex-shrink-0 flex-col gap-0 bg-[var(--doc-page)]",
14905
15627
  children: /* @__PURE__ */ jsx(FormattingBar, {
14906
15628
  currentFormatting: state.selectionFormatting,
@@ -14933,6 +15655,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14933
15655
  onInsertSymbol: handleOpenInsertSymbol,
14934
15656
  priorityExtra: toolbarPriorityExtra,
14935
15657
  inlineExtra: toolbarInlineExtra,
15658
+ panelToggles,
14936
15659
  ...history.state.package.styles?.styles ? { documentStyles: history.state.package.styles.styles } : {},
14937
15660
  ...state.pmImageContext ? { imageContext: state.pmImageContext } : {},
14938
15661
  ...state.pmTableContext ? { tableContext: state.pmTableContext } : {},
@@ -14940,241 +15663,273 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14940
15663
  })
14941
15664
  }),
14942
15665
  /* @__PURE__ */ jsxs("div", {
14943
- ref: scrollContainerRef,
14944
- style: editorContainerStyle,
14945
- "data-folio-scroll": "",
14946
- onScroll: handleEditorScroll,
14947
- children: [rulerVisible && !readOnly && /* @__PURE__ */ jsx("div", {
14948
- style: {
14949
- position: "sticky",
14950
- top: 0,
14951
- zIndex: 20,
14952
- display: "flex",
14953
- justifyContent: "center",
14954
- flexShrink: 0,
14955
- paddingBlock: 4,
14956
- paddingLeft: 20,
14957
- paddingRight: 20 + (showCommentsSidebar ? 304 : 0),
14958
- minWidth: twipsToPixels(effectiveSectionProperties?.pageWidth ?? 12240) * zoom + 40 + (showCommentsSidebar ? 304 : 0),
14959
- backgroundColor: "var(--muted)",
14960
- transition: "padding 0.2s ease"
14961
- },
14962
- children: /* @__PURE__ */ jsx(HorizontalRuler, {
14963
- sectionProps: effectiveSectionProperties ?? null,
14964
- zoom,
14965
- unit: rulerUnit,
14966
- editable: !readOnly,
14967
- onLeftMarginChange: handleLeftMarginChange,
14968
- onRightMarginChange: handleRightMarginChange,
14969
- indentLeft: state.paragraphIndentLeft,
14970
- indentRight: state.paragraphIndentRight,
14971
- onIndentLeftChange: handleIndentLeftChange,
14972
- onIndentRightChange: handleIndentRightChange,
14973
- firstLineIndent: state.paragraphFirstLineIndent,
14974
- hangingIndent: state.paragraphHangingIndent,
14975
- onFirstLineIndentChange: handleFirstLineIndentChange,
14976
- tabStops: state.paragraphTabs,
14977
- onTabStopRemove: handleTabStopRemove
14978
- })
14979
- }), /* @__PURE__ */ jsx("div", {
14980
- style: {
14981
- display: "flex",
14982
- flex: 1,
14983
- minHeight: 0,
14984
- position: "relative"
14985
- },
14986
- children: /* @__PURE__ */ jsxs("div", {
14987
- ref: editorContentRef,
14988
- style: {
14989
- position: "relative",
14990
- flex: 1,
14991
- minWidth: 0
14992
- },
14993
- onMouseDown: containedHandler((e_0) => {
14994
- if (e_0.target === e_0.currentTarget) {
14995
- e_0.preventDefault();
14996
- pagedEditorRef.current?.focus();
14997
- }
14998
- }),
14999
- onContextMenu: handleEditorContextMenu,
15000
- children: [
15001
- rulerVisible && !readOnly && /* @__PURE__ */ jsx("div", {
15666
+ ref: panels.rowRef,
15667
+ className: "folio-panels-row",
15668
+ style: panelsRowStyle,
15669
+ "data-folio-panel-tier": panels.layout.tier,
15670
+ "data-folio-outline": panels.layout.outline,
15671
+ "data-folio-comments": panels.layout.comments,
15672
+ children: [
15673
+ (panels.layout.outline === "column" || panels.layout.outline === "rail") && /* @__PURE__ */ jsx(DocumentOutline, {
15674
+ headings: outlineHeadings,
15675
+ scrollContainerRef,
15676
+ docSize: pagedEditorRef.current?.getView()?.state.doc.content.size ?? 0,
15677
+ activeId: activeHeadingId,
15678
+ onJump: handleOutlineJump,
15679
+ surface: panels.layout.outline,
15680
+ expanded: panelOverlay === "outline",
15681
+ onExpand: toggleOutlineOverlay
15682
+ }),
15683
+ /* @__PURE__ */ jsxs("div", {
15684
+ ref: scrollContainerRef,
15685
+ style: editorContainerStyle,
15686
+ "data-folio-scroll": "",
15687
+ onScroll: handleEditorScroll,
15688
+ children: [rulerVisible && !readOnly && /* @__PURE__ */ jsx("div", {
15689
+ "data-testid": "folio-horizontal-ruler",
15690
+ style: {
15691
+ position: "sticky",
15692
+ top: 0,
15693
+ zIndex: 20,
15694
+ display: "flex",
15695
+ justifyContent: "center",
15696
+ flexShrink: 0,
15697
+ paddingBlock: 4,
15698
+ paddingLeft: 20,
15699
+ paddingRight: 20 + panels.layout.commentsGutter,
15700
+ minWidth: twipsToPixels(effectiveSectionProperties?.pageWidth ?? 12240) * zoom + 40 + panels.layout.commentsGutter,
15701
+ background: "var(--doc-canvas-surface)",
15702
+ transition: "padding 0.2s ease"
15703
+ },
15704
+ children: /* @__PURE__ */ jsx(HorizontalRuler, {
15705
+ sectionProps: effectiveSectionProperties ?? null,
15706
+ zoom,
15707
+ unit: rulerUnit,
15708
+ editable: !readOnly,
15709
+ onLeftMarginChange: handleLeftMarginChange,
15710
+ onRightMarginChange: handleRightMarginChange,
15711
+ indentLeft: state.paragraphIndentLeft,
15712
+ indentRight: state.paragraphIndentRight,
15713
+ onIndentLeftChange: handleIndentLeftChange,
15714
+ onIndentRightChange: handleIndentRightChange,
15715
+ firstLineIndent: state.paragraphFirstLineIndent,
15716
+ hangingIndent: state.paragraphHangingIndent,
15717
+ onFirstLineIndentChange: handleFirstLineIndentChange,
15718
+ tabStops: state.paragraphTabs,
15719
+ onTabStopRemove: handleTabStopRemove
15720
+ })
15721
+ }), /* @__PURE__ */ jsx("div", {
15722
+ style: {
15723
+ display: "flex",
15724
+ flex: 1,
15725
+ minHeight: 0,
15726
+ position: "relative"
15727
+ },
15728
+ children: /* @__PURE__ */ jsxs("div", {
15729
+ ref: editorContentRef,
15002
15730
  style: {
15003
- position: "absolute",
15004
- left: 0,
15005
- top: 0,
15006
- zIndex: 20,
15007
- paddingTop: 24 * zoom
15731
+ position: "relative",
15732
+ flex: 1,
15733
+ minWidth: 0
15008
15734
  },
15009
- children: /* @__PURE__ */ jsx(VerticalRuler, {
15010
- sectionProps: effectiveSectionProperties ?? null,
15011
- zoom,
15012
- unit: rulerUnit,
15013
- editable: !readOnly,
15014
- onTopMarginChange: handleTopMarginChange,
15015
- onBottomMarginChange: handleBottomMarginChange
15016
- })
15017
- }),
15018
- /* @__PURE__ */ jsx(PagedEditor, {
15019
- ref: pagedEditorRef,
15020
- document: history.state,
15021
- documentIO,
15022
- documentIdentity: loadedDocumentIdentity,
15023
- ...fonts !== void 0 ? { fonts } : {},
15024
- theme: history.state.package.theme || theme || null,
15025
- sectionProperties: effectiveSectionProperties ?? null,
15026
- headerContent,
15027
- footerContent,
15028
- firstPageHeaderContent,
15029
- firstPageFooterContent,
15030
- headerContentRId: activeHeaderRId,
15031
- footerContentRId: activeFooterRId,
15032
- firstPageHeaderContentRId: activeFirstHeaderRId,
15033
- firstPageFooterContentRId: activeFirstFooterRId,
15034
- ...history.state.package.styles ? { styles: history.state.package.styles } : {},
15035
- onHeaderFooterDoubleClick: showHeaderFooterEditing ? handleHeaderFooterStoryOpen : void 0,
15036
- hfEditMode: hfEditPosition,
15037
- activeHeaderFooterRId: activeHfRId,
15038
- onBodyClick: handleBodyClick,
15039
- onActiveNoteStoryChange: handleActiveNoteStoryChange,
15040
- zoom,
15041
- ...pageRenderer === void 0 ? {} : { pageRenderer },
15042
- showMarginGuides,
15043
- ...marginGuideColor !== void 0 ? { marginGuideColor } : {},
15044
- readOnly,
15045
- onDocumentChange: handleDocumentChange,
15046
- extensionManager,
15047
- suggestionModeActive: editingMode === "suggesting",
15048
- suggestionAuthor: author,
15049
- ...onCopy !== void 0 ? { onCopy } : {},
15050
- ...onCut !== void 0 ? { onCut } : {},
15051
- ...onPaste !== void 0 ? { onPaste } : {},
15052
- ...onReadonlyEditAttempt !== void 0 ? { onReadOnlyEditAttempt: onReadonlyEditAttempt } : {},
15053
- onSelectionChange: handlePagedSelectionChange,
15054
- ...onSelectionTextChange !== void 0 ? { onSelectionTextChange } : {},
15055
- ...onEditorViewReady !== void 0 ? { onEditorViewReady: reportEditorViewReady } : {},
15056
- externalPlugins: editorPlugins,
15057
- showTemplateDirectives,
15058
- ...collaboration !== void 0 ? { collaboration } : {},
15059
- onHyperlinkClick: handleHyperlinkClick,
15060
- onContextMenu: handleContextMenu,
15061
- commentsSidebarOpen: showCommentsSidebar,
15062
- anchorPositionMode: "comments",
15063
- onAnonymizationTermClick,
15064
- selectedAnonymizationCanonical,
15065
- anonymizationSelectionSeq,
15066
- ...showCommentsSidebar ? { onAnchorPositionsChange: setAnchorPositions } : {},
15067
- onTotalPagesChange: handleTotalPagesChange,
15068
- onError: handleEditorError,
15069
- scrollContainerRef,
15070
- sidebarOverlay: commentsSidebarOverlay
15071
- }),
15072
- floatingCommentBtn !== null && !isAddingComment && !readOnly && /* @__PURE__ */ jsx(Tooltip, {
15073
- content: "Add comment",
15074
- side: "bottom",
15075
- delayMs: 300,
15076
- children: /* @__PURE__ */ jsx("button", {
15077
- type: "button",
15078
- onMouseDown: (e_1) => {
15079
- e_1.preventDefault();
15080
- e_1.stopPropagation();
15081
- const view_54 = pagedEditorRef.current?.getView();
15082
- if (!view_54) {
15083
- setFloatingCommentBtn(null);
15084
- return;
15085
- }
15086
- const capturedRange = {
15087
- from: floatingCommentBtn.from,
15088
- to: floatingCommentBtn.to
15089
- };
15090
- const currentSelection = view_54.state.selection;
15091
- const safeRange = resolveCommentCreationRange({
15092
- docSize: view_54.state.doc.content.size,
15093
- capturedRange,
15094
- currentRange: {
15095
- from: currentSelection.from,
15096
- to: currentSelection.to
15735
+ onMouseDown: containedHandler((e_0) => {
15736
+ if (e_0.target === e_0.currentTarget) {
15737
+ e_0.preventDefault();
15738
+ pagedEditorRef.current?.focus();
15739
+ }
15740
+ }),
15741
+ onContextMenu: handleEditorContextMenu,
15742
+ children: [
15743
+ rulerVisible && !readOnly && /* @__PURE__ */ jsx("div", {
15744
+ style: {
15745
+ position: "absolute",
15746
+ left: 0,
15747
+ top: 0,
15748
+ zIndex: 20,
15749
+ paddingTop: 24 * zoom
15750
+ },
15751
+ children: /* @__PURE__ */ jsx(VerticalRuler, {
15752
+ sectionProps: effectiveSectionProperties ?? null,
15753
+ zoom,
15754
+ unit: rulerUnit,
15755
+ editable: !readOnly,
15756
+ onTopMarginChange: handleTopMarginChange,
15757
+ onBottomMarginChange: handleBottomMarginChange
15758
+ })
15759
+ }),
15760
+ /* @__PURE__ */ jsx(PagedEditor, {
15761
+ ref: pagedEditorRef,
15762
+ document: history.state,
15763
+ documentIO,
15764
+ documentIdentity: loadedDocumentIdentity,
15765
+ markupView: displayMode,
15766
+ ...fonts !== void 0 ? { fonts } : {},
15767
+ theme: history.state.package.theme || theme || null,
15768
+ sectionProperties: effectiveSectionProperties ?? null,
15769
+ headerContent,
15770
+ footerContent,
15771
+ firstPageHeaderContent,
15772
+ firstPageFooterContent,
15773
+ headerContentRId: activeHeaderRId,
15774
+ footerContentRId: activeFooterRId,
15775
+ firstPageHeaderContentRId: activeFirstHeaderRId,
15776
+ firstPageFooterContentRId: activeFirstFooterRId,
15777
+ ...history.state.package.styles ? { styles: history.state.package.styles } : {},
15778
+ onHeaderFooterDoubleClick: showHeaderFooterEditing ? handleHeaderFooterStoryOpen : void 0,
15779
+ hfEditMode: hfEditPosition,
15780
+ activeHeaderFooterRId: activeHfRId,
15781
+ onBodyClick: handleBodyClick,
15782
+ onActiveNoteStoryChange: handleActiveNoteStoryChange,
15783
+ zoom,
15784
+ ...pageRenderer === void 0 ? {} : { pageRenderer },
15785
+ showMarginGuides,
15786
+ ...marginGuideColor !== void 0 ? { marginGuideColor } : {},
15787
+ readOnly,
15788
+ onDocumentChange: handleDocumentChange,
15789
+ extensionManager,
15790
+ suggestionModeActive: editingMode === "suggesting",
15791
+ suggestionAuthor: author,
15792
+ ...onCopy !== void 0 ? { onCopy } : {},
15793
+ ...onCut !== void 0 ? { onCut } : {},
15794
+ ...onPaste !== void 0 ? { onPaste } : {},
15795
+ ...onReadonlyEditAttempt !== void 0 ? { onReadOnlyEditAttempt: onReadonlyEditAttempt } : {},
15796
+ onSelectionChange: handlePagedSelectionChange,
15797
+ ...onSelectionTextChange !== void 0 ? { onSelectionTextChange } : {},
15798
+ onEditorViewReady: handleBodyViewReady,
15799
+ externalPlugins: editorPlugins,
15800
+ showTemplateDirectives,
15801
+ ...collaboration !== void 0 ? { collaboration } : {},
15802
+ onHyperlinkClick: handleHyperlinkClick,
15803
+ onContextMenu: handleContextMenu,
15804
+ pageEndGutter: panels.layout.commentsGutter,
15805
+ anchorPositionMode: "comments",
15806
+ onAnonymizationTermClick,
15807
+ selectedAnonymizationCanonical,
15808
+ anonymizationSelectionSeq,
15809
+ ...showCommentsSidebar ? { onAnchorPositionsChange: setAnchorPositions } : {},
15810
+ onTotalPagesChange: handleTotalPagesChange,
15811
+ onError: handleEditorError,
15812
+ scrollContainerRef,
15813
+ sidebarOverlay: commentsSidebarOverlay
15814
+ }),
15815
+ floatingCommentBtn !== null && !isAddingComment && !readOnly && /* @__PURE__ */ jsx(Tooltip, {
15816
+ content: "Add comment",
15817
+ side: "bottom",
15818
+ delayMs: 300,
15819
+ children: /* @__PURE__ */ jsx("button", {
15820
+ type: "button",
15821
+ onMouseDown: (e_1) => {
15822
+ e_1.preventDefault();
15823
+ e_1.stopPropagation();
15824
+ const view_61 = pagedEditorRef.current?.getView();
15825
+ if (!view_61) {
15826
+ setFloatingCommentBtn(null);
15827
+ return;
15828
+ }
15829
+ const capturedRange = {
15830
+ from: floatingCommentBtn.from,
15831
+ to: floatingCommentBtn.to
15832
+ };
15833
+ const currentSelection = view_61.state.selection;
15834
+ const safeRange = resolveCommentCreationRange({
15835
+ docSize: view_61.state.doc.content.size,
15836
+ capturedRange,
15837
+ currentRange: {
15838
+ from: currentSelection.from,
15839
+ to: currentSelection.to
15840
+ },
15841
+ savedRange: lastSelectionRef.current
15842
+ });
15843
+ if (!safeRange) {
15844
+ setCommentSelectionRange(null);
15845
+ setFloatingCommentBtn(null);
15846
+ return;
15847
+ }
15848
+ setCommentSelectionRange(safeRange);
15849
+ if (!applyCommentMarkRange(view_61, safeRange, -1, { selectEnd: true })) {
15850
+ setCommentSelectionRange(null);
15851
+ setFloatingCommentBtn(null);
15852
+ return;
15853
+ }
15854
+ const yPos_0 = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, safeRange.from);
15855
+ setAddCommentYPosition(yPos_0 ?? floatingCommentBtn.top);
15856
+ setShowCommentsSidebar(true);
15857
+ setIsAddingComment(true);
15858
+ setFloatingCommentBtn(null);
15859
+ },
15860
+ style: {
15861
+ position: "absolute",
15862
+ top: floatingCommentBtn.top,
15863
+ left: floatingCommentBtn.left,
15864
+ transform: "translate(-50%, -50%)",
15865
+ zIndex: 50,
15866
+ width: 28,
15867
+ height: 28,
15868
+ borderRadius: 6,
15869
+ border: "1px solid var(--doc-border)",
15870
+ backgroundColor: "var(--doc-page)",
15871
+ color: "var(--doc-text-muted)",
15872
+ cursor: "pointer",
15873
+ display: "flex",
15874
+ alignItems: "center",
15875
+ justifyContent: "center",
15876
+ boxShadow: "0 2px 8px var(--doc-border)",
15877
+ transition: "background-color 0.15s, box-shadow 0.15s"
15878
+ },
15879
+ onMouseOver: (e_2) => {
15880
+ e_2.currentTarget.style.backgroundColor = "rgba(26, 115, 232, 0.08)";
15881
+ e_2.currentTarget.style.boxShadow = "0 1px 4px rgba(26, 115, 232, 0.3)";
15097
15882
  },
15098
- savedRange: lastSelectionRef.current
15883
+ onFocus: (e_3) => {
15884
+ e_3.currentTarget.style.backgroundColor = "rgba(26, 115, 232, 0.08)";
15885
+ },
15886
+ onMouseOut: (e_4) => {
15887
+ e_4.currentTarget.style.backgroundColor = "var(--doc-canvas, #fff)";
15888
+ e_4.currentTarget.style.boxShadow = "0 1px 3px rgba(60,64,67,0.2)";
15889
+ },
15890
+ onBlur: (e_5) => {
15891
+ e_5.currentTarget.style.backgroundColor = "var(--doc-canvas, #fff)";
15892
+ },
15893
+ children: /* @__PURE__ */ jsx(SquarePenIcon, { size: 16 })
15894
+ })
15895
+ }),
15896
+ hfEditPosition && (() => {
15897
+ if (!(() => {
15898
+ if (hfEditIsFirstPage) return (() => {
15899
+ if (hfEditPosition === "header") return firstPageHeaderContent;
15900
+ return firstPageFooterContent;
15901
+ })();
15902
+ if (hfEditPosition === "header") return headerContent;
15903
+ return footerContent;
15904
+ })()) return null;
15905
+ const targetEl = getHfTargetElement(hfEditPosition);
15906
+ const parentEl_0 = editorContentRef.current;
15907
+ if (!targetEl || !parentEl_0) return null;
15908
+ return /* @__PURE__ */ jsx(InlineHeaderFooterEditor, {
15909
+ ref: hfEditorRef,
15910
+ position: hfEditPosition,
15911
+ targetElement: targetEl,
15912
+ parentElement: parentEl_0,
15913
+ getActiveView: getActiveHfView,
15914
+ onClose: handleBodyClick,
15915
+ onRemove: handleRemoveHeaderFooter
15099
15916
  });
15100
- if (!safeRange) {
15101
- setCommentSelectionRange(null);
15102
- setFloatingCommentBtn(null);
15103
- return;
15104
- }
15105
- setCommentSelectionRange(safeRange);
15106
- if (!applyCommentMarkRange(view_54, safeRange, -1, { selectEnd: true })) {
15107
- setCommentSelectionRange(null);
15108
- setFloatingCommentBtn(null);
15109
- return;
15110
- }
15111
- const yPos_0 = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, safeRange.from);
15112
- setAddCommentYPosition(yPos_0 ?? floatingCommentBtn.top);
15113
- setShowCommentsSidebar(true);
15114
- setIsAddingComment(true);
15115
- setFloatingCommentBtn(null);
15116
- },
15117
- style: {
15118
- position: "absolute",
15119
- top: floatingCommentBtn.top,
15120
- left: floatingCommentBtn.left,
15121
- transform: "translate(-50%, -50%)",
15122
- zIndex: 50,
15123
- width: 28,
15124
- height: 28,
15125
- borderRadius: 6,
15126
- border: "1px solid var(--doc-border)",
15127
- backgroundColor: "var(--doc-page)",
15128
- color: "var(--doc-text-muted)",
15129
- cursor: "pointer",
15130
- display: "flex",
15131
- alignItems: "center",
15132
- justifyContent: "center",
15133
- boxShadow: "0 2px 8px var(--doc-border)",
15134
- transition: "background-color 0.15s, box-shadow 0.15s"
15135
- },
15136
- onMouseOver: (e_2) => {
15137
- e_2.currentTarget.style.backgroundColor = "rgba(26, 115, 232, 0.08)";
15138
- e_2.currentTarget.style.boxShadow = "0 1px 4px rgba(26, 115, 232, 0.3)";
15139
- },
15140
- onFocus: (e_3) => {
15141
- e_3.currentTarget.style.backgroundColor = "rgba(26, 115, 232, 0.08)";
15142
- },
15143
- onMouseOut: (e_4) => {
15144
- e_4.currentTarget.style.backgroundColor = "var(--doc-canvas, #fff)";
15145
- e_4.currentTarget.style.boxShadow = "0 1px 3px rgba(60,64,67,0.2)";
15146
- },
15147
- onBlur: (e_5) => {
15148
- e_5.currentTarget.style.backgroundColor = "var(--doc-canvas, #fff)";
15149
- },
15150
- children: /* @__PURE__ */ jsx(SquarePenIcon, { size: 16 })
15151
- })
15152
- }),
15153
- hfEditPosition && (() => {
15154
- if (!(() => {
15155
- if (hfEditIsFirstPage) return (() => {
15156
- if (hfEditPosition === "header") return firstPageHeaderContent;
15157
- return firstPageFooterContent;
15158
- })();
15159
- if (hfEditPosition === "header") return headerContent;
15160
- return footerContent;
15161
- })()) return null;
15162
- const targetEl = getHfTargetElement(hfEditPosition);
15163
- const parentEl_0 = editorContentRef.current;
15164
- if (!targetEl || !parentEl_0) return null;
15165
- return /* @__PURE__ */ jsx(InlineHeaderFooterEditor, {
15166
- ref: hfEditorRef,
15167
- position: hfEditPosition,
15168
- targetElement: targetEl,
15169
- parentElement: parentEl_0,
15170
- getActiveView: getActiveHfView,
15171
- onClose: handleBodyClick,
15172
- onRemove: handleRemoveHeaderFooter
15173
- });
15174
- })()
15175
- ]
15176
- })
15177
- })]
15917
+ })()
15918
+ ]
15919
+ })
15920
+ })]
15921
+ }),
15922
+ panelOverlay === "outline" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(PanelScrim, { onDismiss: closePanelOverlay }), /* @__PURE__ */ jsx(DocumentOutline, {
15923
+ headings: outlineHeadings,
15924
+ scrollContainerRef,
15925
+ docSize: pagedEditorRef.current?.getView()?.state.doc.content.size ?? 0,
15926
+ activeId: activeHeadingId,
15927
+ onJump: handleOutlineJump,
15928
+ surface: "drawer",
15929
+ onClose: closePanelOverlay
15930
+ })] }),
15931
+ commentsSurface === "drawer" && /* @__PURE__ */ jsx(PanelScrim, { onDismiss: dismissCommentsDrawer })
15932
+ ]
15178
15933
  }),
15179
15934
  scrollPageInfo.totalPages > 1 && /* @__PURE__ */ jsx("div", {
15180
15935
  style: {
@@ -15201,13 +15956,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15201
15956
  current: String(scrollPageInfo.currentPage),
15202
15957
  total: String(scrollPageInfo.totalPages)
15203
15958
  })
15204
- }),
15205
- showOutline && outlineHeadings.length > 1 && /* @__PURE__ */ jsx(DocumentOutline, {
15206
- headings: outlineHeadings,
15207
- scrollContainerRef,
15208
- topOffset: toolbarHeight,
15209
- docSize: pagedEditorRef.current?.getView()?.state.doc.content.size ?? 0,
15210
- onHeadingClick: handleOutlineHeadingClick
15211
15959
  })
15212
15960
  ]
15213
15961
  })
@@ -15244,7 +15992,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15244
15992
  imageProperties: imagePropertiesDialog,
15245
15993
  pageSetup: pageSetupDialog,
15246
15994
  footnoteProperties: footnotePropertiesDialog,
15247
- insertSymbol: insertSymbolDialog
15995
+ insertSymbol: insertSymbolDialog,
15996
+ setNumberingValue: numberingValueDialog
15248
15997
  }),
15249
15998
  /* @__PURE__ */ jsx("input", {
15250
15999
  ref: imageInputRef,
@@ -15385,4 +16134,4 @@ const renderAsync = (input, container, options = {}) => {
15385
16134
  });
15386
16135
  };
15387
16136
  //#endregion
15388
- export { formatZoom as a, FormattingBar as c, containedHandler as d, clampZoom as i, ZoomControl as l, DocxEditor as n, parseZoom as o, ZOOM_PRESETS as r, useWheelZoom as s, renderAsync as t, AutocompleteCaretOverlay as u };
16137
+ export { formatZoom as a, FormattingBar as c, AutocompleteCaretOverlay as d, containedHandler as f, clampZoom as i, ZoomControl as l, DocxEditor as n, parseZoom as o, ZOOM_PRESETS as r, useWheelZoom as s, renderAsync as t, useDrawerFocus as u };