@stll/folio-react 0.36.0 → 0.37.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.
@@ -12,15 +12,12 @@ import { resolveActiveEditorStory } from "@stll/folio-core/controller/activeEdit
12
12
  import { NO_ANONYMIZATION_HIGHLIGHTS, NO_ANONYMIZATION_TERMS, slugAnonymizationLabel } from "@stll/folio-core/controller/anonymizationHighlights";
13
13
  import { afterCanonicalCompositionSettles } from "@stll/folio-core/controller/canonicalInputTimer";
14
14
  import { resolveCanonicalReviewRange } from "@stll/folio-core/controller/canonicalReview";
15
- import { isCanonicalRoomCollaboration } from "@stll/folio-core/controller/canonicalRoomEditor";
16
15
  import { DOCUMENT_CHANGE_NOTIFY_DELAY_MS } from "@stll/folio-core/controller/documentChangeNotification";
17
16
  import { FOLIO_DOCX_SERIALIZATION_MODE, createFolioEditor } from "@stll/folio-core/controller/folioEditor";
18
17
  import { NO_AUTOCOMPLETE, delegateAutocomplete } from "@stll/folio-core/controller/hiddenEditorApi";
19
- import { CanonicalSessionRefusalError, collectRemoteSelections, createHiddenEditorManager, createHiddenEditorState } from "@stll/folio-core/controller/hiddenEditorManager";
18
+ import { CanonicalSessionRefusalError, createHiddenEditorManager, createHiddenEditorState } from "@stll/folio-core/controller/hiddenEditorManager";
20
19
  import { canonicalSaveDiagnosticError, serializeCanonicalSave } from "@stll/folio-core/docx/canonicalSave";
21
20
  import { cloneCommentsWithParagraphPropertySources, cloneDocumentWithParagraphPropertySources } from "@stll/folio-core/docx/document-clone";
22
- import { getCommentParentId, getCommentParentId as getCommentParentId$1, withHostCommentThreads } from "@stll/folio-core/docx/hostCommentThreads";
23
- import { normalizeBaseDirection } from "@stll/folio-core/docx/normalizeBaseDirection";
24
21
  import { getCachedNumberingMap } from "@stll/folio-core/docx/numberingParser";
25
22
  import { findPageNumberAtEditorPosition } from "@stll/folio-core/layout-engine/pmPageIndex";
26
23
  import { DEFAULT_KEYBOARD_SHORTCUT_SCOPE, classifyEditorKeydown, deleteSelectedTable, historyShortcutOwner, isFocusInInputLike, isKeydownInShortcutScope, isMacPlatform } from "@stll/folio-core/managers/editorShortcuts";
@@ -37,23 +34,20 @@ import { insertPageBreak } from "@stll/folio-core/prosemirror/commands/pageBreak
37
34
  import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice, pastePlainTextSlice } from "@stll/folio-core/prosemirror/commands/pastePlainText";
38
35
  import { replaceRangeText } from "@stll/folio-core/prosemirror/commands/replaceRangeText";
39
36
  import { applyRulerParagraphEdit } from "@stll/folio-core/prosemirror/commands/rulerParagraph";
40
- import { clearPendingComment, commentIdsNamedIn, commentRecordsOf, commentThreadIds, commitCommentThread, deleteCommentThread, editCommentRecords, markPendingComment, recordingCommentsView, subscribeCommentRecords, syncCommentRecords } from "@stll/folio-core/prosemirror/commentRecords";
41
- import { proseDocToBlocks } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
37
+ import { commentRecordsOf, commentThreadIds, commitCommentThread, deleteCommentThread, editCommentRecords, recordingCommentsView, subscribeCommentRecords, syncCommentRecords } from "@stll/folio-core/prosemirror/commentRecords";
42
38
  import { executeEditorCommand, executeFirstEditorCommand } from "@stll/folio-core/prosemirror/executeEditorCommand";
43
39
  import { ExtensionManager } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
44
- import { clearTrackedChanges, getChangedParagraphIds, hasStructuralChanges, hasUntrackedChanges, repackWithEditorSectionRemovals } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
40
+ import { getChangedParagraphIds, hasStructuralChanges, hasUntrackedChanges } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
45
41
  import { createStarterKit } from "@stll/folio-core/prosemirror/extensions/StarterKit";
46
42
  import { projectMarkupView, visibleCaretPosition } from "@stll/folio-core/prosemirror/markupViewProjection";
47
- import { createNoteReferenceFollower, withoutUnreferencedNotes } from "@stll/folio-core/prosemirror/noteReferenceReview";
48
43
  import { createAICitationDecorationsPlugin } from "@stll/folio-core/prosemirror/plugins/aiCitationDecorations";
49
44
  import { AI_SUGGESTION_SEVERITY_CLASS, aiSuggestionDecorationsKey, createAISuggestionDecorationsPlugin } from "@stll/folio-core/prosemirror/plugins/aiSuggestionDecorations";
50
- import { createDerivedFieldsPlugin } from "@stll/folio-core/prosemirror/plugins/derivedFields";
51
45
  import { createSuggestionModePlugin, setSuggestionMode, suggestionModeKey } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
52
46
  import { createTemplateDirectivesPlugin, templateDirectivesKey } from "@stll/folio-core/prosemirror/plugins/templateDirectives";
53
47
  import { createTemplatePreviewValuesPlugin, templatePreviewValuesKey } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
54
48
  import { getTemplateSlashMenu, templateSlashMenuPlugin } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
55
49
  import { getFolioParaIdFromBlockId } from "@stll/folio-core/types/block-id";
56
- import { CANONICAL_GAP, canonicalRefusalMessage, canonicalRefusalNotice, usesCanonicalSession } from "@stll/folio-core/types/canonicalCapabilities";
50
+ import { CANONICAL_GAP, canonicalRefusalMessage, canonicalRefusalNotice } from "@stll/folio-core/types/canonicalCapabilities";
57
51
  import { readModel, writableCopy } from "@stll/folio-core/types/documentModel";
58
52
  import { canonicalJson } from "@stll/folio-core/utils/canonicalJson";
59
53
  import { resolveColor } from "@stll/folio-core/utils/colorResolver";
@@ -109,20 +103,20 @@ import { FOLIO_INPUT_HIDDEN_ATTRIBUTE } from "@stll/folio-core/paged-layout/sele
109
103
  import { resizeColumnPair } from "@stll/folio-core/paged-layout/tableColumnResize";
110
104
  import { tableInsertButtonOffset } from "@stll/folio-core/paged-layout/tableInsertButtonGeometry";
111
105
  import { commitImageFloatMove, commitImageInlineMove, commitImageResize, isFloatingImage } from "@stll/folio-core/prosemirror/imageCommit";
106
+ import { createNoteReferenceFollower } from "@stll/folio-core/prosemirror/noteReferenceReview";
112
107
  import { singletonManager } from "@stll/folio-core/prosemirror/schema";
113
108
  import { MIN_ROW_HEIGHT_TWIPS, clampRowResizeDelta, columnResizeCommand, rightEdgeResizeCommand, rowResizeCommand } from "@stll/folio-core/prosemirror/tableResize";
114
- import { dispatchEditorTextInput } from "@stll/folio-core/prosemirror/textInput";
115
109
  import { findStartPosForParaId } from "@stll/folio-core/prosemirror/utils/findParagraphByParaId";
116
110
  import { resolveHeaderFooterSelectionGeometry } from "@stll/folio-core/render-dom/HeaderFooterSelectionOverlay";
117
- import { createEmptyHeaderFooter, pickActiveHeaderFooterRId, removeHeaderFooter, resolveEffectiveSectionProperties, resolveHeaderFooterContent, saveHeaderFooterContent } from "@stll/folio-core/utils/headerFooter";
111
+ import { pickActiveHeaderFooterRId, resolveEffectiveSectionProperties, resolveHeaderFooterContent } from "@stll/folio-core/utils/headerFooter";
118
112
  import { createHeaderFooterEditorManager } from "@stll/folio-core/controller/headerFooterEditorManager";
119
113
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
120
114
  import { createNoteEditorManager } from "@stll/folio-core/controller/noteEditorManager";
121
115
  import { buildEmbeddedFontFamilyMap, extractEmbeddedFonts } from "@stll/folio-core/fonts/embeddedFonts";
122
- import { loadCollaborationModules } from "@stll/folio-core/controller/collaborationModules";
123
116
  import { calculateResizedImageDimensions } from "@stll/folio-core/utils/imageResize";
124
117
  import "@stll/folio-core/layout-bridge/engine/selectionRects";
125
118
  import { createVisualLineState, handleVisualLineKeyDown } from "@stll/folio-core/prosemirror/utils/visualLineNavigation";
119
+ import { getCommentParentId, getCommentParentId as getCommentParentId$1 } from "@stll/folio-core/docx/hostCommentThreads";
126
120
  import { ContentControlWidgetController, contentControlRefusalMessageKey } from "@stll/folio-core/controller/contentControlWidgetController";
127
121
  import { createDefaultFindOptions, replaceEligibility } from "@stll/folio-core/utils/findReplace";
128
122
  import { PANEL_METRICS, computePanelLayout, overlayAfterLayout, requestedOutline } from "@stll/folio-core/panel-layout";
@@ -692,37 +686,28 @@ const HOST_STYLES = {
692
686
  zIndex: -1,
693
687
  pointerEvents: "none"
694
688
  };
695
- const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ document, readOnly, styles, theme, onTransaction, experimentalSession, getCanonicalApi, readCanonicalDocument, onSessionRefusal }, ref) {
689
+ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ document, readOnly, styles, onTransaction, getCanonicalApi, readCanonicalDocument, onSessionRefusal }, ref) {
696
690
  const hostRef = useRef(null);
697
- const documentRef = useRef(document);
698
691
  const readOnlyRef = useRef(readOnly);
699
692
  const stylesRef = useRef(styles);
700
- const themeRef = useRef(theme);
701
693
  const onTransactionRef = useRef(onTransaction);
702
694
  const canonicalApiRef = useRef(getCanonicalApi);
703
695
  const readCanonicalDocumentRef = useRef(readCanonicalDocument);
704
- const sessionRef = useRef(experimentalSession);
705
696
  const refusalRef = useRef(onSessionRefusal);
706
697
  const managerRef = useRef(null);
707
698
  useLayoutEffect(() => {
708
- documentRef.current = document;
709
699
  readOnlyRef.current = readOnly;
710
700
  stylesRef.current = styles;
711
- themeRef.current = theme;
712
701
  onTransactionRef.current = onTransaction;
713
702
  canonicalApiRef.current = getCanonicalApi;
714
703
  readCanonicalDocumentRef.current = readCanonicalDocument;
715
- sessionRef.current = experimentalSession;
716
704
  refusalRef.current = onSessionRefusal;
717
705
  managerRef.current ??= createHeaderFooterEditorManager({
718
706
  getHost: () => hostRef.current,
719
- getDocument: () => documentRef.current,
720
707
  getReadOnly: () => readOnlyRef.current ?? false,
721
708
  getStyles: () => stylesRef.current,
722
- getTheme: () => themeRef.current,
723
709
  getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
724
710
  readCanonicalDocument: () => readCanonicalDocumentRef.current(),
725
- getExperimentalSession: () => sessionRef.current,
726
711
  onSessionRefusal: (reason, ground, error) => refusalRef.current?.(reason, ground, error),
727
712
  onTransaction: ({ rId, kind, view, docChanged, selectionChanged }) => {
728
713
  onTransactionRef.current?.(rId, kind, view, docChanged, selectionChanged);
@@ -733,11 +718,9 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
733
718
  document,
734
719
  readOnly,
735
720
  styles,
736
- theme,
737
721
  onTransaction,
738
722
  getCanonicalApi,
739
723
  readCanonicalDocument,
740
- experimentalSession,
741
724
  onSessionRefusal
742
725
  ]);
743
726
  useEffect(() => () => {
@@ -746,7 +729,8 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
746
729
  useImperativeHandle(ref, () => ({
747
730
  getHostElement: () => hostRef.current,
748
731
  getView: (rId) => managerRef.current?.getView(rId) ?? null,
749
- listSlots: () => managerRef.current?.listSlots() ?? []
732
+ listSlots: () => managerRef.current?.listSlots() ?? [],
733
+ sync: () => managerRef.current?.sync()
750
734
  }), []);
751
735
  return /* @__PURE__ */ jsx("div", {
752
736
  ref: hostRef,
@@ -787,57 +771,41 @@ const hostStyle = {
787
771
  padding: "12px 16px",
788
772
  minHeight: 72
789
773
  };
790
- const EMPTY_PLUGINS$1 = [];
791
774
  const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
792
- const $ = c(45);
793
- const { document, experimentalSession, getCanonicalApi, readCanonicalDocument, onSessionRefusal, onActiveChange, onDocumentChange, onStoryChange, plugins, styles, suggestionAuthor, suggestionModeActive, theme } = t0;
775
+ const $ = c(50);
776
+ const { document, getCanonicalApi, readCanonicalDocument, onSessionRefusal, onActiveChange, onDocumentChange, onStoryChange, styles, suggestionAuthor, suggestionModeActive } = t0;
794
777
  const t = useTranslations("folio");
795
- const resolvedPlugins = plugins ?? EMPTY_PLUGINS$1;
796
778
  const isSuggestionModeActive = suggestionModeActive ?? false;
797
779
  const hostRef = useRef(null);
798
- const documentRef = useRef(document);
799
780
  const canonicalApiRef = useRef(getCanonicalApi);
800
781
  const readCanonicalDocumentRef = useRef(readCanonicalDocument);
801
- const sessionRef = useRef(experimentalSession);
802
782
  const refusalRef = useRef(onSessionRefusal);
803
783
  const stylesRef = useRef(styles);
804
- const themeRef = useRef(theme);
805
- const pluginsRef = useRef(resolvedPlugins);
806
784
  const onDocumentChangeRef = useRef(onDocumentChange);
807
785
  const onActiveChangeRef = useRef(onActiveChange);
808
786
  const onStoryChangeRef = useRef(onStoryChange);
809
787
  const [active, setActive] = useState(null);
810
788
  const managerRef = useRef(null);
811
789
  let t1;
812
- let t2;
813
- if ($[0] !== active || $[1] !== document || $[2] !== experimentalSession || $[3] !== getCanonicalApi || $[4] !== onActiveChange || $[5] !== onDocumentChange || $[6] !== onSessionRefusal || $[7] !== onStoryChange || $[8] !== readCanonicalDocument || $[9] !== resolvedPlugins || $[10] !== styles || $[11] !== theme) {
790
+ if ($[0] !== active || $[1] !== getCanonicalApi || $[2] !== onActiveChange || $[3] !== onDocumentChange || $[4] !== onSessionRefusal || $[5] !== onStoryChange || $[6] !== readCanonicalDocument || $[7] !== styles) {
814
791
  t1 = () => {
815
- documentRef.current = document;
816
792
  canonicalApiRef.current = getCanonicalApi;
817
793
  readCanonicalDocumentRef.current = readCanonicalDocument;
818
- sessionRef.current = experimentalSession;
819
794
  refusalRef.current = onSessionRefusal;
820
795
  stylesRef.current = styles;
821
- themeRef.current = theme;
822
- pluginsRef.current = resolvedPlugins;
823
796
  onDocumentChangeRef.current = onDocumentChange;
824
797
  onActiveChangeRef.current = onActiveChange;
825
798
  onStoryChangeRef.current = onStoryChange;
826
799
  if (managerRef.current === null) managerRef.current = createNoteEditorManager({
827
- getDocument: () => documentRef.current,
828
800
  getHost: () => hostRef.current,
829
- getPlugins: () => pluginsRef.current,
830
801
  getStyles: () => stylesRef.current,
831
- getTheme: () => themeRef.current,
832
802
  getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
833
803
  readCanonicalDocument: () => readCanonicalDocumentRef.current(),
834
- getExperimentalSession: () => sessionRef.current,
835
804
  onSessionRefusal: (reason, ground, error) => refusalRef.current?.(reason, ground, error),
836
- onTransaction: (t3) => {
837
- const { docChanged, selectionChanged, view } = t3;
805
+ onTransaction: (t2) => {
806
+ const { docChanged, selectionChanged, view } = t2;
838
807
  if (docChanged) {
839
- const current = documentRef.current;
840
- const model = readCanonicalDocumentRef.current() ?? (current && managerRef.current ? managerRef.current.snapshotDocument(readModel(current)) : current);
808
+ const model = readCanonicalDocumentRef.current();
841
809
  if (model) onDocumentChangeRef.current(model);
842
810
  }
843
811
  onStoryChangeRef.current(view, docChanged, selectionChanged);
@@ -850,42 +818,44 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
850
818
  onActiveChangeRef.current(null);
851
819
  }
852
820
  };
821
+ $[0] = active;
822
+ $[1] = getCanonicalApi;
823
+ $[2] = onActiveChange;
824
+ $[3] = onDocumentChange;
825
+ $[4] = onSessionRefusal;
826
+ $[5] = onStoryChange;
827
+ $[6] = readCanonicalDocument;
828
+ $[7] = styles;
829
+ $[8] = t1;
830
+ } else t1 = $[8];
831
+ let t2;
832
+ if ($[9] !== active || $[10] !== document || $[11] !== getCanonicalApi || $[12] !== onActiveChange || $[13] !== onDocumentChange || $[14] !== onSessionRefusal || $[15] !== onStoryChange || $[16] !== readCanonicalDocument || $[17] !== styles) {
853
833
  t2 = [
854
834
  active,
855
835
  document,
856
- experimentalSession,
857
836
  getCanonicalApi,
858
837
  readCanonicalDocument,
859
838
  onActiveChange,
860
839
  onDocumentChange,
861
840
  onSessionRefusal,
862
841
  onStoryChange,
863
- resolvedPlugins,
864
- styles,
865
- theme
842
+ styles
866
843
  ];
867
- $[0] = active;
868
- $[1] = document;
869
- $[2] = experimentalSession;
870
- $[3] = getCanonicalApi;
871
- $[4] = onActiveChange;
872
- $[5] = onDocumentChange;
873
- $[6] = onSessionRefusal;
874
- $[7] = onStoryChange;
875
- $[8] = readCanonicalDocument;
876
- $[9] = resolvedPlugins;
877
- $[10] = styles;
878
- $[11] = theme;
879
- $[12] = t1;
880
- $[13] = t2;
881
- } else {
882
- t1 = $[12];
883
- t2 = $[13];
884
- }
844
+ $[9] = active;
845
+ $[10] = document;
846
+ $[11] = getCanonicalApi;
847
+ $[12] = onActiveChange;
848
+ $[13] = onDocumentChange;
849
+ $[14] = onSessionRefusal;
850
+ $[15] = onStoryChange;
851
+ $[16] = readCanonicalDocument;
852
+ $[17] = styles;
853
+ $[18] = t2;
854
+ } else t2 = $[18];
885
855
  useEffect(t1, t2);
886
856
  let t3;
887
857
  let t4;
888
- if ($[14] !== isSuggestionModeActive || $[15] !== suggestionAuthor) {
858
+ if ($[19] !== isSuggestionModeActive || $[20] !== suggestionAuthor) {
889
859
  t3 = () => {
890
860
  const manager_0 = managerRef.current;
891
861
  if (!manager_0) return;
@@ -895,41 +865,41 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
895
865
  }
896
866
  };
897
867
  t4 = [isSuggestionModeActive, suggestionAuthor];
898
- $[14] = isSuggestionModeActive;
899
- $[15] = suggestionAuthor;
900
- $[16] = t3;
901
- $[17] = t4;
868
+ $[19] = isSuggestionModeActive;
869
+ $[20] = suggestionAuthor;
870
+ $[21] = t3;
871
+ $[22] = t4;
902
872
  } else {
903
- t3 = $[16];
904
- t4 = $[17];
873
+ t3 = $[21];
874
+ t4 = $[22];
905
875
  }
906
876
  useEffect(t3, t4);
907
877
  let t5;
908
878
  let t6;
909
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
879
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
910
880
  t5 = () => () => {
911
881
  managerRef.current?.destroy();
912
882
  };
913
883
  t6 = [];
914
- $[18] = t5;
915
- $[19] = t6;
884
+ $[23] = t5;
885
+ $[24] = t6;
916
886
  } else {
917
- t5 = $[18];
918
- t6 = $[19];
887
+ t5 = $[23];
888
+ t6 = $[24];
919
889
  }
920
890
  useEffect(t5, t6);
921
891
  let t7;
922
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
892
+ if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
923
893
  t7 = () => {
924
894
  managerRef.current?.activate(null);
925
895
  setActive(null);
926
896
  onActiveChangeRef.current(null);
927
897
  };
928
- $[20] = t7;
929
- } else t7 = $[20];
898
+ $[25] = t7;
899
+ } else t7 = $[25];
930
900
  const closeEditor = t7;
931
901
  let t8;
932
- if ($[21] !== isSuggestionModeActive || $[22] !== suggestionAuthor) {
902
+ if ($[26] !== isSuggestionModeActive || $[27] !== suggestionAuthor) {
933
903
  t8 = () => ({
934
904
  close: closeEditor,
935
905
  getActiveView: () => {
@@ -944,65 +914,65 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
944
914
  onActiveChangeRef.current(story_1);
945
915
  requestAnimationFrame(() => view_1.focus());
946
916
  },
947
- snapshotDocument: (current_0) => managerRef.current?.snapshotDocument(current_0) ?? current_0
917
+ sync: () => managerRef.current?.sync()
948
918
  });
949
- $[21] = isSuggestionModeActive;
950
- $[22] = suggestionAuthor;
951
- $[23] = t8;
952
- } else t8 = $[23];
919
+ $[26] = isSuggestionModeActive;
920
+ $[27] = suggestionAuthor;
921
+ $[28] = t8;
922
+ } else t8 = $[28];
953
923
  useImperativeHandle(ref, t8);
954
924
  let t9;
955
- if ($[24] !== active || $[25] !== t) {
925
+ if ($[29] !== active || $[30] !== t) {
956
926
  t9 = active ? t(active.kind === "footnote" ? "dialogs.footnoteProperties.footnotes" : "dialogs.footnoteProperties.endnotes") : "";
957
- $[24] = active;
958
- $[25] = t;
959
- $[26] = t9;
960
- } else t9 = $[26];
927
+ $[29] = active;
928
+ $[30] = t;
929
+ $[31] = t9;
930
+ } else t9 = $[31];
961
931
  const title = t9;
962
932
  const t10 = active ? "block" : "none";
963
933
  let t11;
964
- if ($[27] !== t10) {
934
+ if ($[32] !== t10) {
965
935
  t11 = {
966
936
  ...panelStyle,
967
937
  display: t10
968
938
  };
969
- $[27] = t10;
970
- $[28] = t11;
971
- } else t11 = $[28];
939
+ $[32] = t10;
940
+ $[33] = t11;
941
+ } else t11 = $[33];
972
942
  let t12;
973
- if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
943
+ if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
974
944
  t12 = (event) => {
975
945
  if (event.key !== "Escape") return;
976
946
  event.preventDefault();
977
947
  event.stopPropagation();
978
948
  closeEditor();
979
949
  };
980
- $[29] = t12;
981
- } else t12 = $[29];
950
+ $[34] = t12;
951
+ } else t12 = $[34];
982
952
  let t13;
983
- if ($[30] !== title) {
953
+ if ($[35] !== title) {
984
954
  t13 = /* @__PURE__ */ jsx("span", { children: title });
985
- $[30] = title;
986
- $[31] = t13;
987
- } else t13 = $[31];
955
+ $[35] = title;
956
+ $[36] = t13;
957
+ } else t13 = $[36];
988
958
  let t14;
989
- if ($[32] !== t) {
959
+ if ($[37] !== t) {
990
960
  t14 = t("common.closeDialog");
991
- $[32] = t;
992
- $[33] = t14;
993
- } else t14 = $[33];
961
+ $[37] = t;
962
+ $[38] = t14;
963
+ } else t14 = $[38];
994
964
  let t15;
995
- if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
965
+ if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
996
966
  t15 = {
997
967
  border: 0,
998
968
  background: "transparent",
999
969
  color: "inherit",
1000
970
  cursor: "pointer"
1001
971
  };
1002
- $[34] = t15;
1003
- } else t15 = $[34];
972
+ $[39] = t15;
973
+ } else t15 = $[39];
1004
974
  let t16;
1005
- if ($[35] !== t14) {
975
+ if ($[40] !== t14) {
1006
976
  t16 = /* @__PURE__ */ jsx("button", {
1007
977
  type: "button",
1008
978
  "aria-label": t14,
@@ -1010,40 +980,40 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
1010
980
  style: t15,
1011
981
  children: "×"
1012
982
  });
1013
- $[35] = t14;
1014
- $[36] = t16;
1015
- } else t16 = $[36];
983
+ $[40] = t14;
984
+ $[41] = t16;
985
+ } else t16 = $[41];
1016
986
  let t17;
1017
- if ($[37] !== t13 || $[38] !== t16) {
987
+ if ($[42] !== t13 || $[43] !== t16) {
1018
988
  t17 = /* @__PURE__ */ jsxs("div", {
1019
989
  style: headerStyle,
1020
990
  children: [t13, t16]
1021
991
  });
1022
- $[37] = t13;
1023
- $[38] = t16;
1024
- $[39] = t17;
1025
- } else t17 = $[39];
992
+ $[42] = t13;
993
+ $[43] = t16;
994
+ $[44] = t17;
995
+ } else t17 = $[44];
1026
996
  let t18;
1027
- if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
997
+ if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
1028
998
  t18 = /* @__PURE__ */ jsx("div", {
1029
999
  ref: hostRef,
1030
1000
  style: hostStyle
1031
1001
  });
1032
- $[40] = t18;
1033
- } else t18 = $[40];
1002
+ $[45] = t18;
1003
+ } else t18 = $[45];
1034
1004
  let t19;
1035
- if ($[41] !== t11 || $[42] !== t17 || $[43] !== title) {
1005
+ if ($[46] !== t11 || $[47] !== t17 || $[48] !== title) {
1036
1006
  t19 = /* @__PURE__ */ jsxs("aside", {
1037
1007
  style: t11,
1038
1008
  "aria-label": title,
1039
1009
  onKeyDown: t12,
1040
1010
  children: [t17, t18]
1041
1011
  });
1042
- $[41] = t11;
1043
- $[42] = t17;
1044
- $[43] = title;
1045
- $[44] = t19;
1046
- } else t19 = $[44];
1012
+ $[46] = t11;
1013
+ $[47] = t17;
1014
+ $[48] = title;
1015
+ $[49] = t19;
1016
+ } else t19 = $[49];
1047
1017
  return t19;
1048
1018
  });
1049
1019
  NoteStoryEditor.displayName = "NoteStoryEditor";
@@ -1456,15 +1426,9 @@ const HIDDEN_HOST_STYLES = {
1456
1426
  * HiddenProseMirror - Off-screen ProseMirror editor for keyboard input
1457
1427
  */
1458
1428
  const HiddenProseMirror = forwardRef((props, ref) => {
1459
- const { document, documentIdentity, experimentalSession, historyShortcuts = "editor", suggestionModeActive = false, suggestionAuthor = "User", onSessionRefusal, styles, theme: _theme, widthPx = 612, readOnly = false, onTransaction, onCanonicalCompositionLayout, getEmbeddedFontFamilyMap, onSelectionChange, externalPlugins = EMPTY_EXTERNAL_PLUGINS, anonymizationTerms, derivedFields, collaboration, canonicalRoom, extensionManager, onEditorViewReady, onCanonicalHistory, onCanonicalHistoryDrop, onEditorViewDestroy, onKeyDown, onCopy, onCut, onPaste, onReadOnlyEditAttempt, onRemoteSelectionsChange, getPrecomputedInitialState } = props;
1460
- const hasCollaboration = collaboration !== void 0;
1461
- const [collaborationLoad, setCollaborationLoad] = useState(() => ({ status: hasCollaboration ? "loading" : "disabled" }));
1462
- if (hasCollaboration !== (collaborationLoad.status !== "disabled")) setCollaborationLoad({ status: hasCollaboration ? "loading" : "disabled" });
1463
- const collaborationModules = hasCollaboration && collaborationLoad.status === "ready" ? collaborationLoad.modules : null;
1464
- const collaborationModulesError = hasCollaboration && collaborationLoad.status === "failed" ? collaborationLoad.error : null;
1429
+ const { document, documentIdentity, historyShortcuts = "editor", suggestionModeActive = false, suggestionAuthor = "User", onSessionRefusal, styles, theme: _theme, widthPx = 612, readOnly = false, onTransaction, onCanonicalCompositionLayout, getEmbeddedFontFamilyMap, onSelectionChange, externalPlugins = EMPTY_EXTERNAL_PLUGINS, anonymizationTerms, derivedFields, canonicalRoom, extensionManager, onEditorViewReady, onCanonicalHistory, onCanonicalHistoryDrop, onEditorViewDestroy, onKeyDown, onCopy, onCut, onPaste, onReadOnlyEditAttempt, onRemoteSelectionsChange } = props;
1465
1430
  const hostRef = useRef(null);
1466
1431
  const readOnlyRef = useRef(readOnly);
1467
- const experimentalSessionRef = useRef(experimentalSession);
1468
1432
  const historyShortcutsRef = useRef(historyShortcuts);
1469
1433
  const suggestionModeActiveRef = useRef(suggestionModeActive);
1470
1434
  const suggestionAuthorRef = useRef(suggestionAuthor);
@@ -1476,10 +1440,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
1476
1440
  const externalPluginsRef = useRef(externalPlugins);
1477
1441
  const anonymizationTermsRef = useRef(anonymizationTerms);
1478
1442
  const derivedFieldsRef = useRef(derivedFields);
1479
- const getPrecomputedInitialStateRef = useRef(getPrecomputedInitialState);
1480
- const collaborationRef = useRef(collaboration);
1481
1443
  const canonicalRoomRef = useRef(canonicalRoom);
1482
- const collaborationModulesRef = useRef(collaborationModules);
1483
1444
  const onTransactionRef = useRef(onTransaction);
1484
1445
  const onCanonicalCompositionLayoutRef = useRef(onCanonicalCompositionLayout);
1485
1446
  const getEmbeddedFontFamilyMapRef = useRef(getEmbeddedFontFamilyMap);
@@ -1497,7 +1458,6 @@ const HiddenProseMirror = forwardRef((props, ref) => {
1497
1458
  const managerRef = useRef(null);
1498
1459
  useLayoutEffect(() => {
1499
1460
  readOnlyRef.current = readOnly;
1500
- experimentalSessionRef.current = experimentalSession;
1501
1461
  historyShortcutsRef.current = historyShortcuts;
1502
1462
  suggestionModeActiveRef.current = suggestionModeActive;
1503
1463
  suggestionAuthorRef.current = suggestionAuthor;
@@ -1507,7 +1467,6 @@ const HiddenProseMirror = forwardRef((props, ref) => {
1507
1467
  externalPluginsRef.current = externalPlugins;
1508
1468
  anonymizationTermsRef.current = anonymizationTerms;
1509
1469
  derivedFieldsRef.current = derivedFields;
1510
- getPrecomputedInitialStateRef.current = getPrecomputedInitialState;
1511
1470
  onTransactionRef.current = onTransaction;
1512
1471
  onCanonicalCompositionLayoutRef.current = onCanonicalCompositionLayout;
1513
1472
  getEmbeddedFontFamilyMapRef.current = getEmbeddedFontFamilyMap;
@@ -1522,9 +1481,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
1522
1481
  onPasteRef.current = onPaste;
1523
1482
  onReadOnlyEditAttemptRef.current = onReadOnlyEditAttempt;
1524
1483
  onRemoteSelectionsChangeRef.current = onRemoteSelectionsChange;
1525
- collaborationRef.current = collaboration;
1526
1484
  canonicalRoomRef.current = canonicalRoom;
1527
- collaborationModulesRef.current = collaborationModules;
1528
1485
  documentRef.current = document;
1529
1486
  documentIdentityRef.current = documentIdentity;
1530
1487
  if (managerRef.current === null) managerRef.current = createHiddenEditorManager({
@@ -1535,12 +1492,8 @@ const HiddenProseMirror = forwardRef((props, ref) => {
1535
1492
  getExternalPlugins: () => externalPluginsRef.current,
1536
1493
  getAnonymizationTerms: () => anonymizationTermsRef.current ?? NO_ANONYMIZATION_TERMS,
1537
1494
  getDerivedFields: () => derivedFieldsRef.current,
1538
- getCollaboration: () => collaborationRef.current,
1539
- getCollaborationModules: () => collaborationModulesRef.current,
1540
1495
  getCanonicalRoom: () => canonicalRoomRef.current,
1541
- getPrecomputedInitialState: () => getPrecomputedInitialStateRef.current?.() ?? null,
1542
1496
  getReadOnly: () => readOnlyRef.current,
1543
- getExperimentalSession: () => experimentalSessionRef.current,
1544
1497
  getHistoryShortcuts: () => historyShortcutsRef.current,
1545
1498
  onCanonicalHistory: (effect) => onCanonicalHistoryRef.current?.(effect),
1546
1499
  onCanonicalHistoryDrop: (drop) => onCanonicalHistoryDropRef.current?.(drop),
@@ -1568,42 +1521,6 @@ const HiddenProseMirror = forwardRef((props, ref) => {
1568
1521
  managerRef.current?.syncExternalDocument();
1569
1522
  managerRef.current?.syncEditable();
1570
1523
  });
1571
- useEffect(() => {
1572
- if (!hasCollaboration) return;
1573
- let cancelled = false;
1574
- loadCollaborationModules().then((modules) => {
1575
- if (!cancelled) setCollaborationLoad({
1576
- status: "ready",
1577
- modules
1578
- });
1579
- }, (error_0) => {
1580
- if (!cancelled) setCollaborationLoad({
1581
- status: "failed",
1582
- error: error_0
1583
- });
1584
- });
1585
- return () => {
1586
- cancelled = true;
1587
- };
1588
- }, [hasCollaboration]);
1589
- useEffect(() => {
1590
- const awareness = collaboration?.awareness;
1591
- if (!awareness || !managerRef.current?.getView() || !collaborationModules) {
1592
- onRemoteSelectionsChangeRef.current?.([]);
1593
- return;
1594
- }
1595
- const publishRemoteSelections = () => {
1596
- const view_1 = managerRef.current?.getView();
1597
- if (!view_1) return;
1598
- onRemoteSelectionsChangeRef.current?.(collectRemoteSelections(view_1.state, awareness, collaborationModules));
1599
- };
1600
- awareness.on("change", publishRemoteSelections);
1601
- publishRemoteSelections();
1602
- return () => {
1603
- awareness.off("change", publishRemoteSelections);
1604
- onRemoteSelectionsChangeRef.current?.([]);
1605
- };
1606
- }, [collaboration, collaborationModules]);
1607
1524
  const destroyView = useCallback(() => {
1608
1525
  managerRef.current?.destroyView();
1609
1526
  }, []);
@@ -1615,12 +1532,6 @@ const HiddenProseMirror = forwardRef((props, ref) => {
1615
1532
  refreshFonts: () => managerRef.current?.refreshFonts(),
1616
1533
  readCanonicalDocument: () => managerRef.current?.readCanonicalDocument() ?? null
1617
1534
  }), []);
1618
- if (hasCollaboration && collaborationModulesError) {
1619
- let detail = "unknown error";
1620
- if (collaborationModulesError instanceof Error) detail = collaborationModulesError.message;
1621
- else if (typeof collaborationModulesError === "string") detail = collaborationModulesError;
1622
- panic(`Failed to load collaboration editor modules. Reload the document to retry. Cause: ${detail}`);
1623
- }
1624
1535
  return /* @__PURE__ */ jsx("div", {
1625
1536
  className: HIDDEN_EDITOR_WRAPPER_CLASS,
1626
1537
  style: HIDDEN_WRAPPER_STYLES,
@@ -3385,7 +3296,7 @@ function buildFootnoteRenderItems(pageFootnoteMap, footnoteContentMap, doc) {
3385
3296
  * PagedEditor - Main paginated editing component.
3386
3297
  */
3387
3298
  const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3388
- const { accessibleName, document, documentIO, documentIdentity, experimentalSession, historyShortcuts, fonts: hostFonts, theme: _theme, hasTitlePg = false, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, pageRenderer, markupView, showCommentHighlights = true, altChunkMarkerText, showMarginGuides = false, marginGuideColor, onDocumentChange, onReadOnlyEditAttempt, onCopy, onCut, onPaste, onSelectionChange, onSelectionTextChange, onEditorViewReady, onCanonicalHistory, onCanonicalHistoryDrop, externalPlugins = EMPTY_PLUGINS, showTemplateDirectives = true, collaboration, canonicalRoom, 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, onAutocompleteChange, anonymizationTerms, onAnonymizationMatchesChange, derivedFields, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
3299
+ const { accessibleName, document, documentIO, documentIdentity, historyShortcuts, fonts: hostFonts, theme: _theme, hasTitlePg = false, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, pageRenderer, markupView, showCommentHighlights = true, altChunkMarkerText, showMarginGuides = false, marginGuideColor, onDocumentChange, onReadOnlyEditAttempt, onCopy, onCut, onPaste, onSelectionChange, onSelectionTextChange, onEditorViewReady, onCanonicalHistory, onCanonicalHistoryDrop, externalPlugins = EMPTY_PLUGINS, showTemplateDirectives = true, canonicalRoom, 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, onAutocompleteChange, anonymizationTerms, onAnonymizationMatchesChange, derivedFields, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
3389
3300
  const styles = document?.package.styles;
3390
3301
  const sectionProperties = useMemo(() => resolveEffectiveSectionProperties(document ? readModel(document).package.document : void 0, hasTitlePg) ?? null, [document, hasTitlePg]);
3391
3302
  const getScrollContainer = useCallback(() => {
@@ -3411,7 +3322,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3411
3322
  const activeNoteStoryRef = useRef(null);
3412
3323
  const [noteStoryActive, setNoteStoryActive] = useState(false);
3413
3324
  const painterRef = useRef(null);
3414
- const noteStoryPlugins = useMemo(() => externalPlugins.filter((plugin) => suggestionModeKey.owns(plugin)), [externalPlugins]);
3415
3325
  const handleActiveNoteStoryChange = useCallback((story) => {
3416
3326
  activeNoteStoryRef.current = story;
3417
3327
  setNoteStoryActive(story !== null);
@@ -3465,9 +3375,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3465
3375
  const layoutRef = useRef(null);
3466
3376
  const [blocks, setBlocks] = useState([]);
3467
3377
  const [measures, setMeasures] = useState([]);
3468
- const [hiddenEditorRequested, setShouldCreateHiddenEditorView] = useState(() => collaboration !== void 0);
3469
- const shouldCreateHiddenEditorView = hiddenEditorRequested || collaboration !== void 0;
3470
- const shouldFocusHiddenEditorOnReadyRef = useRef(collaboration !== void 0);
3378
+ const [shouldCreateHiddenEditorView, setShouldCreateHiddenEditorView] = useState(false);
3379
+ const shouldFocusHiddenEditorOnReadyRef = useRef(false);
3471
3380
  const layoutSessionRef = useRef(createLayoutSession());
3472
3381
  const readPrecomputedInitialStateRef = useRef(readNoHiddenEditorState);
3473
3382
  const precomputedInitialDocumentRef = useRef(null);
@@ -3560,18 +3469,16 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3560
3469
  * a refused seed (or a view not created yet) pays for this conversion.
3561
3470
  */
3562
3471
  const readPrecomputedInitialState = useMemo(() => {
3563
- if (shouldCreateHiddenEditorView || collaboration !== void 0 || !document) return readNoHiddenEditorState;
3472
+ if (shouldCreateHiddenEditorView || !document) return readNoHiddenEditorState;
3564
3473
  return readHiddenEditorStateOnce({
3565
3474
  document,
3566
3475
  styles,
3567
3476
  manager: extensionManager,
3568
3477
  externalPlugins,
3569
- collaborationModules: null,
3570
3478
  reason: "mount"
3571
3479
  });
3572
3480
  }, [
3573
3481
  shouldCreateHiddenEditorView,
3574
- collaboration,
3575
3482
  document,
3576
3483
  styles,
3577
3484
  extensionManager,
@@ -3642,18 +3549,17 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3642
3549
  queuedInputBeforeHiddenEditorRef.current = [];
3643
3550
  for (const input of queuedInput) {
3644
3551
  if (input.type === "text") {
3645
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) view_0.dom.dispatchEvent(new InputEvent("beforeinput", {
3552
+ view_0.dom.dispatchEvent(new InputEvent("beforeinput", {
3646
3553
  inputType: "insertText",
3647
3554
  data: input.text,
3648
3555
  cancelable: true,
3649
3556
  bubbles: true
3650
3557
  }));
3651
- else dispatchEditorTextInput(view_0, input.text);
3652
3558
  continue;
3653
3559
  }
3654
3560
  replayDeferredKeyDown(view_0, input.eventInit);
3655
3561
  }
3656
- }, [experimentalSession]);
3562
+ }, []);
3657
3563
  const isResizingColumnRef = useRef(false);
3658
3564
  const resizeStartXRef = useRef(0);
3659
3565
  const resizeColumnIndexRef = useRef(0);
@@ -3894,9 +3800,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3894
3800
  readState: () => hiddenPMRef.current?.getState() ?? readPrecomputedInitialStateRef.current()
3895
3801
  });
3896
3802
  }, [runtime]);
3897
- useLayoutEffect(() => {
3898
- if (collaboration !== void 0) hiddenPMRef.current?.ensureView();
3899
- }, [collaboration]);
3900
3803
  const getActiveEditorStory = useCallback(() => resolveActiveEditorStory({
3901
3804
  bodyView: folioEditor.getView(),
3902
3805
  headerFooterView: hfEditMode && activeHeaderFooterRId ? hfPMsRef.current?.getView(activeHeaderFooterRId) ?? null : null,
@@ -3964,16 +3867,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3964
3867
  * model, with one copy for the host.
3965
3868
  */
3966
3869
  const settledDocumentChange = useCallback(() => {
3967
- const hidden = hiddenPMRef.current;
3968
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.save)) {
3969
- const model = hidden?.readCanonicalDocument() ?? null;
3970
- return model === null ? null : settledChangeOf(model);
3971
- }
3972
- const built = hidden?.getDocument();
3973
- const body = hidden?.getState()?.doc;
3974
- if (!built) return null;
3975
- return settledChangeOf(body ? noteFollower.reconcile(readModel(built), body) : built);
3976
- }, [experimentalSession, noteFollower]);
3870
+ const model = hiddenPMRef.current?.readCanonicalDocument() ?? null;
3871
+ return model === null ? null : settledChangeOf(model);
3872
+ }, []);
3977
3873
  const flushDocumentChangeNotification = useCallback(() => {
3978
3874
  const flush = () => {
3979
3875
  if (documentChangeNotifyTimerRef.current !== null) {
@@ -3993,6 +3889,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
3993
3889
  const change = settledDocumentChange();
3994
3890
  if (change) {
3995
3891
  cancelNoteChangeNotification();
3892
+ noteEditorRef.current?.sync();
3893
+ hfPMsRef.current?.sync();
3996
3894
  onDocumentChangeRef.current?.(change);
3997
3895
  folioEmitterRef.current.emit("docChange", change.forHost);
3998
3896
  }
@@ -4600,7 +4498,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
4600
4498
  if (docChanged_0) {
4601
4499
  if (!hiddenPMRef.current?.getState() && !readPrecomputedInitialStateRef.current()) ensureHiddenEditorView({ sync: true });
4602
4500
  scheduleLayout();
4603
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) scheduleDocumentChangeNotification();
4501
+ scheduleDocumentChangeNotification();
4604
4502
  }
4605
4503
  if (docChanged_0 || selectionChanged) {
4606
4504
  const { from: from_0, to: to_0 } = view_3.state.selection;
@@ -4621,7 +4519,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
4621
4519
  }, [
4622
4520
  scheduleLayout,
4623
4521
  ensureHiddenEditorView,
4624
- experimentalSession,
4625
4522
  scheduleDocumentChangeNotification,
4626
4523
  setHfCaretSelection
4627
4524
  ]);
@@ -5844,7 +5741,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5844
5741
  preHiddenInitialLayoutDoneRef.current = false;
5845
5742
  precomputedInitialDocumentRef.current = null;
5846
5743
  }
5847
- if (shouldCreateHiddenEditorView || collaboration !== void 0 || preHiddenInitialLayoutDoneRef.current) return;
5744
+ if (shouldCreateHiddenEditorView || preHiddenInitialLayoutDoneRef.current) return;
5848
5745
  if (!document) {
5849
5746
  hiddenPMRef.current?.ensureView();
5850
5747
  return;
@@ -5877,7 +5774,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
5877
5774
  queueMicrotask(runLayoutInputDeferredByFontWait);
5878
5775
  };
5879
5776
  }, [
5880
- collaboration,
5881
5777
  document,
5882
5778
  readPrecomputedInitialState,
5883
5779
  runLayoutPipeline$1,
@@ -6149,10 +6045,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
6149
6045
  },
6150
6046
  getDocument() {
6151
6047
  if (documentChangeNotifyTimerRef.current !== null) flushDocumentChangeNotification();
6152
- const editorDocument = folioEditor.getDocument();
6153
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return editorDocument;
6154
- const current_0 = editorDocument ? noteFollower.withPending(readModel(editorDocument)) : null;
6155
- return current_0 ? noteEditorRef.current?.snapshotDocument(current_0) ?? current_0 : null;
6048
+ return folioEditor.getDocument();
6156
6049
  },
6157
6050
  getState() {
6158
6051
  return folioEditor.getState();
@@ -6192,34 +6085,28 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
6192
6085
  undo() {
6193
6086
  const target_5 = getActiveEditorStory();
6194
6087
  if (target_5.type === "none") return false;
6195
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return hiddenPMRef.current?.applyCanonicalStoryHistory({
6088
+ return hiddenPMRef.current?.applyCanonicalStoryHistory({
6196
6089
  view: target_5.view,
6197
6090
  story: getCanonicalActiveStory(),
6198
6091
  direction: "undo"
6199
6092
  }) ?? false;
6200
- if (target_5.type === "body") return hiddenPMRef.current?.undo() ?? false;
6201
- return undo(target_5.view.state, target_5.view.dispatch);
6202
6093
  },
6203
6094
  redo() {
6204
6095
  const target_6 = getActiveEditorStory();
6205
6096
  if (target_6.type === "none") return false;
6206
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return hiddenPMRef.current?.applyCanonicalStoryHistory({
6097
+ return hiddenPMRef.current?.applyCanonicalStoryHistory({
6207
6098
  view: target_6.view,
6208
6099
  story: getCanonicalActiveStory(),
6209
6100
  direction: "redo"
6210
6101
  }) ?? false;
6211
- if (target_6.type === "body") return hiddenPMRef.current?.redo() ?? false;
6212
- return redo(target_6.view.state, target_6.view.dispatch);
6213
6102
  },
6214
6103
  canUndo() {
6215
- const target_7 = getActiveEditorStory();
6216
- if (target_7.type === "none") return false;
6217
- return usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) || target_7.type === "body" ? hiddenPMRef.current?.canUndo() ?? false : undo(target_7.view.state);
6104
+ if (getActiveEditorStory().type === "none") return false;
6105
+ return hiddenPMRef.current?.canUndo() ?? false;
6218
6106
  },
6219
6107
  canRedo() {
6220
- const target_8 = getActiveEditorStory();
6221
- if (target_8.type === "none") return false;
6222
- return usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) || target_8.type === "body" ? hiddenPMRef.current?.canRedo() ?? false : redo(target_8.view.state);
6108
+ if (getActiveEditorStory().type === "none") return false;
6109
+ return hiddenPMRef.current?.canRedo() ?? false;
6223
6110
  },
6224
6111
  setSelection(anchor_3, head_1) {
6225
6112
  folioEditor.setSelection(anchor_3, head_1);
@@ -6269,14 +6156,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
6269
6156
  folioEditor,
6270
6157
  getActiveEditorStory,
6271
6158
  getCanonicalActiveStory,
6272
- noteFollower,
6273
6159
  getScrollContainer,
6274
6160
  refreshBodyImeCaretAnchor,
6275
6161
  scrollToPageImpl,
6276
6162
  scrollToParaIdImpl,
6277
6163
  scrollToPositionImpl,
6278
- setPassageHighlightImpl,
6279
- experimentalSession
6164
+ setPassageHighlightImpl
6280
6165
  ]);
6281
6166
  useEffect(() => {
6282
6167
  if (!layout) return;
@@ -6352,9 +6237,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
6352
6237
  getCanonicalApi,
6353
6238
  readCanonicalDocument,
6354
6239
  onSessionRefusal: handleSessionRefusal,
6355
- experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
6356
- ...styles !== void 0 ? { styles } : {},
6357
- ..._theme !== void 0 ? { theme: _theme } : {}
6240
+ ...styles !== void 0 ? { styles } : {}
6358
6241
  }),
6359
6242
  /* @__PURE__ */ jsx(NoteStoryEditor, {
6360
6243
  ref: noteEditorRef,
@@ -6363,14 +6246,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
6363
6246
  getCanonicalApi,
6364
6247
  readCanonicalDocument,
6365
6248
  onSessionRefusal: handleSessionRefusal,
6366
- experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
6367
6249
  onDocumentChange: handleNoteDocumentChange,
6368
6250
  onStoryChange: handleNoteStoryTransaction,
6369
- plugins: noteStoryPlugins,
6370
6251
  suggestionModeActive,
6371
6252
  ...suggestionAuthor !== void 0 ? { suggestionAuthor } : {},
6372
- ...styles !== void 0 ? { styles } : {},
6373
- ..._theme !== void 0 ? { theme: _theme } : {}
6253
+ ...styles !== void 0 ? { styles } : {}
6374
6254
  }),
6375
6255
  /* @__PURE__ */ jsx(HiddenProseMirror, {
6376
6256
  ref: hiddenPMRef,
@@ -6378,7 +6258,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
6378
6258
  derivedFields,
6379
6259
  document,
6380
6260
  documentIdentity,
6381
- experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
6382
6261
  ...historyShortcuts === void 0 ? {} : { historyShortcuts },
6383
6262
  ...onCanonicalHistory === void 0 ? {} : { onCanonicalHistory },
6384
6263
  ...onCanonicalHistoryDrop === void 0 ? {} : { onCanonicalHistoryDrop },
@@ -6386,7 +6265,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
6386
6265
  ...suggestionAuthor !== void 0 ? { suggestionAuthor } : {},
6387
6266
  suggestionModeActive,
6388
6267
  widthPx: contentWidth,
6389
- getPrecomputedInitialState: readPrecomputedInitialState,
6390
6268
  readOnly,
6391
6269
  onTransaction: handleTransaction,
6392
6270
  onCanonicalCompositionLayout: layoutCanonicalComposition,
@@ -6401,7 +6279,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
6401
6279
  ...onPaste !== void 0 ? { onPaste } : {},
6402
6280
  ...styles !== void 0 ? { styles } : {},
6403
6281
  externalPlugins,
6404
- ...collaboration !== void 0 ? { collaboration } : {},
6405
6282
  ...canonicalRoom !== void 0 ? { canonicalRoom } : {},
6406
6283
  ...extensionManager !== void 0 ? { extensionManager } : {},
6407
6284
  ...onReadOnlyEditAttempt !== void 0 ? { onReadOnlyEditAttempt } : {}
@@ -9905,17 +9782,16 @@ function useContextMenu(t0) {
9905
9782
  * callbacks each render.
9906
9783
  */
9907
9784
  const useDocumentLoader = (t0) => {
9908
- const $ = c(46);
9909
- const { documentBuffer, initialDocument, password, experimentalSession, history, onError, onCompatibilityChange, onReset, setDocumentLoadState } = t0;
9785
+ const $ = c(42);
9786
+ const { documentBuffer, initialDocument, password, history, onError, onCompatibilityChange, onReset, setDocumentLoadState } = t0;
9910
9787
  const originalBufferRef = useRef(null);
9911
9788
  const originalBufferIdentityRef = useRef(null);
9912
9789
  const [loadedDocumentIdentity, setLoadedDocumentIdentity] = useState("0");
9913
9790
  let t1;
9914
- if ($[0] !== experimentalSession || $[1] !== history || $[2] !== onCompatibilityChange || $[3] !== onError || $[4] !== onReset || $[5] !== setDocumentLoadState) {
9791
+ if ($[0] !== history || $[1] !== onCompatibilityChange || $[2] !== onError || $[3] !== onReset || $[4] !== setDocumentLoadState) {
9915
9792
  t1 = () => {
9916
9793
  const instance = new DocumentLoaderManager({
9917
9794
  history,
9918
- getExperimentalSession: () => experimentalSession,
9919
9795
  onError,
9920
9796
  onCompatibilityChange,
9921
9797
  onReset,
@@ -9932,23 +9808,21 @@ const useDocumentLoader = (t0) => {
9932
9808
  }
9933
9809
  };
9934
9810
  };
9935
- $[0] = experimentalSession;
9936
- $[1] = history;
9937
- $[2] = onCompatibilityChange;
9938
- $[3] = onError;
9939
- $[4] = onReset;
9940
- $[5] = setDocumentLoadState;
9941
- $[6] = t1;
9942
- } else t1 = $[6];
9811
+ $[0] = history;
9812
+ $[1] = onCompatibilityChange;
9813
+ $[2] = onError;
9814
+ $[3] = onReset;
9815
+ $[4] = setDocumentLoadState;
9816
+ $[5] = t1;
9817
+ } else t1 = $[5];
9943
9818
  const [t2] = useState(t1);
9944
9819
  const { manager, api } = t2;
9945
9820
  let t3;
9946
9821
  let t4;
9947
- if ($[7] !== experimentalSession || $[8] !== history || $[9] !== manager || $[10] !== onCompatibilityChange || $[11] !== onError || $[12] !== onReset || $[13] !== setDocumentLoadState) {
9822
+ if ($[6] !== history || $[7] !== manager || $[8] !== onCompatibilityChange || $[9] !== onError || $[10] !== onReset || $[11] !== setDocumentLoadState) {
9948
9823
  t3 = () => {
9949
9824
  manager.setCallbacks({
9950
9825
  history,
9951
- getExperimentalSession: () => experimentalSession,
9952
9826
  onError,
9953
9827
  onCompatibilityChange,
9954
9828
  onReset,
@@ -9959,33 +9833,30 @@ const useDocumentLoader = (t0) => {
9959
9833
  t4 = [
9960
9834
  manager,
9961
9835
  history,
9962
- experimentalSession,
9963
9836
  onError,
9964
9837
  onCompatibilityChange,
9965
9838
  onReset,
9966
9839
  setDocumentLoadState
9967
9840
  ];
9968
- $[7] = experimentalSession;
9969
- $[8] = history;
9970
- $[9] = manager;
9971
- $[10] = onCompatibilityChange;
9972
- $[11] = onError;
9973
- $[12] = onReset;
9974
- $[13] = setDocumentLoadState;
9975
- $[14] = t3;
9976
- $[15] = t4;
9841
+ $[6] = history;
9842
+ $[7] = manager;
9843
+ $[8] = onCompatibilityChange;
9844
+ $[9] = onError;
9845
+ $[10] = onReset;
9846
+ $[11] = setDocumentLoadState;
9847
+ $[12] = t3;
9848
+ $[13] = t4;
9977
9849
  } else {
9978
- t3 = $[14];
9979
- t4 = $[15];
9850
+ t3 = $[12];
9851
+ t4 = $[13];
9980
9852
  }
9981
9853
  useLayoutEffect(t3, t4);
9982
9854
  let t5;
9983
- if ($[16] !== api || $[17] !== history || $[18] !== manager || $[19] !== onCompatibilityChange || $[20] !== onError || $[21] !== onReset || $[22] !== setDocumentLoadState) {
9855
+ if ($[14] !== api || $[15] !== history || $[16] !== manager || $[17] !== onCompatibilityChange || $[18] !== onError || $[19] !== onReset || $[20] !== setDocumentLoadState) {
9984
9856
  t5 = (t6) => {
9985
- const { session, source, loadPassword } = t6;
9857
+ const { source, loadPassword } = t6;
9986
9858
  manager.setCallbacks({
9987
9859
  history,
9988
- getExperimentalSession: () => session,
9989
9860
  onError,
9990
9861
  onCompatibilityChange,
9991
9862
  onReset,
@@ -9999,21 +9870,20 @@ const useDocumentLoader = (t0) => {
9999
9870
  }
10000
9871
  api.loadBuffer(source.buffer, { password: loadPassword });
10001
9872
  };
10002
- $[16] = api;
10003
- $[17] = history;
10004
- $[18] = manager;
10005
- $[19] = onCompatibilityChange;
10006
- $[20] = onError;
10007
- $[21] = onReset;
10008
- $[22] = setDocumentLoadState;
10009
- $[23] = t5;
10010
- } else t5 = $[23];
9873
+ $[14] = api;
9874
+ $[15] = history;
9875
+ $[16] = manager;
9876
+ $[17] = onCompatibilityChange;
9877
+ $[18] = onError;
9878
+ $[19] = onReset;
9879
+ $[20] = setDocumentLoadState;
9880
+ $[21] = t5;
9881
+ } else t5 = $[21];
10011
9882
  const loadCommittedSource = useEffectEvent(t5);
10012
9883
  let t6;
10013
- if ($[24] !== documentBuffer || $[25] !== experimentalSession || $[26] !== initialDocument || $[27] !== loadCommittedSource || $[28] !== password) {
9884
+ if ($[22] !== documentBuffer || $[23] !== initialDocument || $[24] !== loadCommittedSource || $[25] !== password) {
10014
9885
  t6 = () => {
10015
9886
  loadCommittedSource({
10016
- session: experimentalSession,
10017
9887
  source: getDocumentLoadSource({
10018
9888
  documentBuffer,
10019
9889
  initialDocument
@@ -10021,31 +9891,28 @@ const useDocumentLoader = (t0) => {
10021
9891
  loadPassword: password
10022
9892
  });
10023
9893
  };
10024
- $[24] = documentBuffer;
10025
- $[25] = experimentalSession;
10026
- $[26] = initialDocument;
10027
- $[27] = loadCommittedSource;
10028
- $[28] = password;
10029
- $[29] = t6;
10030
- } else t6 = $[29];
9894
+ $[22] = documentBuffer;
9895
+ $[23] = initialDocument;
9896
+ $[24] = loadCommittedSource;
9897
+ $[25] = password;
9898
+ $[26] = t6;
9899
+ } else t6 = $[26];
10031
9900
  let t7;
10032
- if ($[30] !== documentBuffer || $[31] !== experimentalSession || $[32] !== initialDocument || $[33] !== password) {
9901
+ if ($[27] !== documentBuffer || $[28] !== initialDocument || $[29] !== password) {
10033
9902
  t7 = [
10034
9903
  documentBuffer,
10035
9904
  initialDocument,
10036
- password,
10037
- experimentalSession
9905
+ password
10038
9906
  ];
10039
- $[30] = documentBuffer;
10040
- $[31] = experimentalSession;
10041
- $[32] = initialDocument;
10042
- $[33] = password;
10043
- $[34] = t7;
10044
- } else t7 = $[34];
9907
+ $[27] = documentBuffer;
9908
+ $[28] = initialDocument;
9909
+ $[29] = password;
9910
+ $[30] = t7;
9911
+ } else t7 = $[30];
10045
9912
  useEffect(t6, t7);
10046
9913
  let t8;
10047
9914
  let t9;
10048
- if ($[35] !== documentBuffer || $[36] !== history.state || $[37] !== loadedDocumentIdentity) {
9915
+ if ($[31] !== documentBuffer || $[32] !== history.state || $[33] !== loadedDocumentIdentity) {
10049
9916
  t8 = () => {
10050
9917
  if (originalBufferIdentityRef.current === loadedDocumentIdentity) return;
10051
9918
  originalBufferIdentityRef.current = loadedDocumentIdentity;
@@ -10060,18 +9927,18 @@ const useDocumentLoader = (t0) => {
10060
9927
  documentBuffer,
10061
9928
  loadedDocumentIdentity
10062
9929
  ];
10063
- $[35] = documentBuffer;
10064
- $[36] = history.state;
10065
- $[37] = loadedDocumentIdentity;
10066
- $[38] = t8;
10067
- $[39] = t9;
9930
+ $[31] = documentBuffer;
9931
+ $[32] = history.state;
9932
+ $[33] = loadedDocumentIdentity;
9933
+ $[34] = t8;
9934
+ $[35] = t9;
10068
9935
  } else {
10069
- t8 = $[38];
10070
- t9 = $[39];
9936
+ t8 = $[34];
9937
+ t9 = $[35];
10071
9938
  }
10072
9939
  useEffect(t8, t9);
10073
9940
  let t10;
10074
- if ($[40] !== api.heldUnreferencedNotes || $[41] !== api.loadBuffer || $[42] !== api.loadParsedDocument || $[43] !== api.resetForNewDocument || $[44] !== loadedDocumentIdentity) {
9941
+ if ($[36] !== api.heldUnreferencedNotes || $[37] !== api.loadBuffer || $[38] !== api.loadParsedDocument || $[39] !== api.resetForNewDocument || $[40] !== loadedDocumentIdentity) {
10075
9942
  t10 = {
10076
9943
  loadBuffer: api.loadBuffer,
10077
9944
  loadParsedDocument: api.loadParsedDocument,
@@ -10080,13 +9947,13 @@ const useDocumentLoader = (t0) => {
10080
9947
  originalBufferRef,
10081
9948
  loadedDocumentIdentity
10082
9949
  };
10083
- $[40] = api.heldUnreferencedNotes;
10084
- $[41] = api.loadBuffer;
10085
- $[42] = api.loadParsedDocument;
10086
- $[43] = api.resetForNewDocument;
10087
- $[44] = loadedDocumentIdentity;
10088
- $[45] = t10;
10089
- } else t10 = $[45];
9950
+ $[36] = api.heldUnreferencedNotes;
9951
+ $[37] = api.loadBuffer;
9952
+ $[38] = api.loadParsedDocument;
9953
+ $[39] = api.resetForNewDocument;
9954
+ $[40] = loadedDocumentIdentity;
9955
+ $[41] = t10;
9956
+ } else t10 = $[41];
10090
9957
  return t10;
10091
9958
  };
10092
9959
  // src/components/hooks/useEditorMode.ts
@@ -10683,30 +10550,13 @@ function useFindReplace(t0) {
10683
10550
  return t34;
10684
10551
  }
10685
10552
  // src/components/hooks/useHeaderFooterEditor.ts
10686
- const saveAndCloseHeaderFooterEdit = ({ activeRId, document: model, editPosition, isFirstPage, pushDocument, setEditPosition, view }) => {
10687
- if (!activeRId || !view) {
10688
- setEditPosition(null);
10689
- return;
10690
- }
10691
- const document = cloneDocumentWithParagraphPropertySources(model);
10692
- const source = (editPosition === "header" ? document.package.headers : document.package.footers)?.get(activeRId);
10693
- if (!source) {
10694
- setEditPosition(null);
10695
- return;
10696
- }
10697
- const newDocument = saveHeaderFooterContent({
10698
- document,
10699
- position: editPosition,
10700
- isFirstPage,
10701
- activeRId,
10702
- blocks: proseDocToBlocks(view.state.doc, source.content)
10703
- });
10704
- if (newDocument) pushDocument(newDocument);
10705
- setEditPosition(null);
10706
- };
10553
+ /**
10554
+ * Hook encapsulating header/footer editing state, content resolution, and
10555
+ * the canonical operations that create and remove a header or footer.
10556
+ */
10707
10557
  const useHeaderFooterEditor = (t0) => {
10708
- const $ = c(51);
10709
- const { history, pushDocument, getHfView, getCanonicalApi, experimentalSession } = t0;
10558
+ const $ = c(37);
10559
+ const { history, getCanonicalApi } = t0;
10710
10560
  const [hfEditPosition, setHfEditPosition] = useState(null);
10711
10561
  const [hfEditIsFirstPage, setHfEditIsFirstPage] = useState(false);
10712
10562
  let t1;
@@ -10733,7 +10583,7 @@ const useHeaderFooterEditor = (t0) => {
10733
10583
  } else t4 = $[4];
10734
10584
  const effectiveSectionProperties = t4;
10735
10585
  let t5;
10736
- if ($[5] !== experimentalSession || $[6] !== firstPageFooterContent || $[7] !== firstPageHeaderContent || $[8] !== footerContent || $[9] !== getCanonicalApi || $[10] !== hasTitlePg || $[11] !== headerContent || $[12] !== history.state || $[13] !== pushDocument) {
10586
+ if ($[5] !== firstPageFooterContent || $[6] !== firstPageHeaderContent || $[7] !== footerContent || $[8] !== getCanonicalApi || $[9] !== hasTitlePg || $[10] !== headerContent) {
10737
10587
  t5 = (position, pageNumber) => {
10738
10588
  const isFirstPage = hasTitlePg && (pageNumber ?? 1) === 1;
10739
10589
  let hf = position === "header" ? headerContent : footerContent;
@@ -10743,119 +10593,71 @@ const useHeaderFooterEditor = (t0) => {
10743
10593
  setHfEditPosition(position);
10744
10594
  return;
10745
10595
  }
10746
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) {
10747
- const api = getCanonicalApi?.();
10748
- api?.ensureView();
10749
- const canonical = api?.getCanonicalDocument();
10750
- if (!canonical || !api) return;
10751
- const operation = createCanonicalHeaderFooterOperation({
10752
- document: canonical,
10753
- position,
10754
- referenceType: isFirstPage ? "first" : "default"
10755
- });
10756
- if (api.applyCanonicalOperations([operation])) setHfEditPosition(position);
10757
- return;
10758
- }
10759
- if (!history.state) return;
10760
- const newDoc = createEmptyHeaderFooter(cloneDocumentWithParagraphPropertySources(history.state), position, isFirstPage);
10761
- if (!newDoc) return;
10762
- pushDocument(newDoc);
10763
- setHfEditPosition(position);
10596
+ const api = getCanonicalApi?.();
10597
+ api?.ensureView();
10598
+ const canonical = api?.getCanonicalDocument();
10599
+ if (!canonical || !api) return;
10600
+ const operation = createCanonicalHeaderFooterOperation({
10601
+ document: canonical,
10602
+ position,
10603
+ referenceType: isFirstPage ? "first" : "default"
10604
+ });
10605
+ if (api.applyCanonicalOperations([operation])) setHfEditPosition(position);
10764
10606
  };
10765
- $[5] = experimentalSession;
10766
- $[6] = firstPageFooterContent;
10767
- $[7] = firstPageHeaderContent;
10768
- $[8] = footerContent;
10769
- $[9] = getCanonicalApi;
10770
- $[10] = hasTitlePg;
10771
- $[11] = headerContent;
10772
- $[12] = history.state;
10773
- $[13] = pushDocument;
10774
- $[14] = t5;
10775
- } else t5 = $[14];
10607
+ $[5] = firstPageFooterContent;
10608
+ $[6] = firstPageHeaderContent;
10609
+ $[7] = footerContent;
10610
+ $[8] = getCanonicalApi;
10611
+ $[9] = hasTitlePg;
10612
+ $[10] = headerContent;
10613
+ $[11] = t5;
10614
+ } else t5 = $[11];
10776
10615
  const handleHeaderFooterDoubleClick = t5;
10777
10616
  let t6;
10778
- if ($[15] !== experimentalSession || $[16] !== getHfView || $[17] !== hfEditIsFirstPage || $[18] !== hfEditPosition || $[19] !== history.state || $[20] !== pushDocument || $[21] !== resolution) {
10617
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
10779
10618
  t6 = () => {
10780
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) {
10781
- setHfEditPosition(null);
10782
- return;
10783
- }
10784
- if (!hfEditPosition || !history.state?.package) {
10785
- setHfEditPosition(null);
10786
- return;
10787
- }
10788
- const activeRId = pickActiveHeaderFooterRId(resolution, hfEditPosition, hfEditIsFirstPage);
10789
- const view = activeRId ? getHfView(activeRId) : null;
10790
- saveAndCloseHeaderFooterEdit({
10791
- activeRId,
10792
- document: history.state,
10793
- editPosition: hfEditPosition,
10794
- isFirstPage: hfEditIsFirstPage,
10795
- pushDocument,
10796
- setEditPosition: setHfEditPosition,
10797
- view
10798
- });
10619
+ setHfEditPosition(null);
10799
10620
  };
10800
- $[15] = experimentalSession;
10801
- $[16] = getHfView;
10802
- $[17] = hfEditIsFirstPage;
10803
- $[18] = hfEditPosition;
10804
- $[19] = history.state;
10805
- $[20] = pushDocument;
10806
- $[21] = resolution;
10807
- $[22] = t6;
10808
- } else t6 = $[22];
10621
+ $[12] = t6;
10622
+ } else t6 = $[12];
10809
10623
  const handleHeaderFooterSave = t6;
10810
10624
  let t7;
10811
- if ($[23] !== handleHeaderFooterSave || $[24] !== hfEditPosition) {
10625
+ if ($[13] !== hfEditPosition) {
10812
10626
  t7 = () => {
10813
10627
  if (!hfEditPosition) return;
10814
10628
  handleHeaderFooterSave();
10815
10629
  };
10816
- $[23] = handleHeaderFooterSave;
10817
- $[24] = hfEditPosition;
10818
- $[25] = t7;
10819
- } else t7 = $[25];
10630
+ $[13] = hfEditPosition;
10631
+ $[14] = t7;
10632
+ } else t7 = $[14];
10820
10633
  const handleBodyClick = t7;
10821
10634
  let t8;
10822
- if ($[26] !== experimentalSession || $[27] !== getCanonicalApi || $[28] !== hfEditIsFirstPage || $[29] !== hfEditPosition || $[30] !== history.state || $[31] !== pushDocument || $[32] !== resolution) {
10635
+ if ($[15] !== getCanonicalApi || $[16] !== hfEditIsFirstPage || $[17] !== hfEditPosition || $[18] !== history.state?.package || $[19] !== resolution) {
10823
10636
  t8 = () => {
10824
10637
  if (!hfEditPosition || !history.state?.package) {
10825
10638
  setHfEditPosition(null);
10826
10639
  return;
10827
10640
  }
10828
- const activeRId_0 = pickActiveHeaderFooterRId(resolution, hfEditPosition, hfEditIsFirstPage);
10829
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) {
10830
- const api_0 = getCanonicalApi?.();
10831
- const canonical_0 = api_0?.getCanonicalDocument();
10832
- if (api_0 && canonical_0 && activeRId_0) api_0.applyCanonicalOperations(removeCanonicalHeaderFooterOperations({
10833
- document: canonical_0,
10834
- position: hfEditPosition,
10835
- rId: activeRId_0
10836
- }));
10837
- setHfEditPosition(null);
10838
- return;
10839
- }
10840
- if (activeRId_0) pushDocument(removeHeaderFooter({
10841
- document: cloneDocumentWithParagraphPropertySources(history.state),
10641
+ const activeRId = pickActiveHeaderFooterRId(resolution, hfEditPosition, hfEditIsFirstPage);
10642
+ const api_0 = getCanonicalApi?.();
10643
+ const canonical_0 = api_0?.getCanonicalDocument();
10644
+ if (api_0 && canonical_0 && activeRId) api_0.applyCanonicalOperations(removeCanonicalHeaderFooterOperations({
10645
+ document: canonical_0,
10842
10646
  position: hfEditPosition,
10843
- activeRId: activeRId_0
10647
+ rId: activeRId
10844
10648
  }));
10845
10649
  setHfEditPosition(null);
10846
10650
  };
10847
- $[26] = experimentalSession;
10848
- $[27] = getCanonicalApi;
10849
- $[28] = hfEditIsFirstPage;
10850
- $[29] = hfEditPosition;
10851
- $[30] = history.state;
10852
- $[31] = pushDocument;
10853
- $[32] = resolution;
10854
- $[33] = t8;
10855
- } else t8 = $[33];
10651
+ $[15] = getCanonicalApi;
10652
+ $[16] = hfEditIsFirstPage;
10653
+ $[17] = hfEditPosition;
10654
+ $[18] = history.state?.package;
10655
+ $[19] = resolution;
10656
+ $[20] = t8;
10657
+ } else t8 = $[20];
10856
10658
  const handleRemoveHeaderFooter = t8;
10857
10659
  let t9;
10858
- if ($[34] !== activeFirstFooterRId || $[35] !== activeFirstHeaderRId || $[36] !== activeFooterRId || $[37] !== activeHeaderRId || $[38] !== effectiveSectionProperties || $[39] !== firstPageFooterContent || $[40] !== firstPageHeaderContent || $[41] !== footerContent || $[42] !== handleBodyClick || $[43] !== handleHeaderFooterDoubleClick || $[44] !== handleHeaderFooterSave || $[45] !== handleRemoveHeaderFooter || $[46] !== hasTitlePg || $[47] !== headerContent || $[48] !== hfEditIsFirstPage || $[49] !== hfEditPosition) {
10660
+ if ($[21] !== activeFirstFooterRId || $[22] !== activeFirstHeaderRId || $[23] !== activeFooterRId || $[24] !== activeHeaderRId || $[25] !== effectiveSectionProperties || $[26] !== firstPageFooterContent || $[27] !== firstPageHeaderContent || $[28] !== footerContent || $[29] !== handleBodyClick || $[30] !== handleHeaderFooterDoubleClick || $[31] !== handleRemoveHeaderFooter || $[32] !== hasTitlePg || $[33] !== headerContent || $[34] !== hfEditIsFirstPage || $[35] !== hfEditPosition) {
10859
10661
  t9 = {
10860
10662
  hfEditPosition,
10861
10663
  setHfEditPosition,
@@ -10875,24 +10677,23 @@ const useHeaderFooterEditor = (t0) => {
10875
10677
  handleBodyClick,
10876
10678
  handleRemoveHeaderFooter
10877
10679
  };
10878
- $[34] = activeFirstFooterRId;
10879
- $[35] = activeFirstHeaderRId;
10880
- $[36] = activeFooterRId;
10881
- $[37] = activeHeaderRId;
10882
- $[38] = effectiveSectionProperties;
10883
- $[39] = firstPageFooterContent;
10884
- $[40] = firstPageHeaderContent;
10885
- $[41] = footerContent;
10886
- $[42] = handleBodyClick;
10887
- $[43] = handleHeaderFooterDoubleClick;
10888
- $[44] = handleHeaderFooterSave;
10889
- $[45] = handleRemoveHeaderFooter;
10890
- $[46] = hasTitlePg;
10891
- $[47] = headerContent;
10892
- $[48] = hfEditIsFirstPage;
10893
- $[49] = hfEditPosition;
10894
- $[50] = t9;
10895
- } else t9 = $[50];
10680
+ $[21] = activeFirstFooterRId;
10681
+ $[22] = activeFirstHeaderRId;
10682
+ $[23] = activeFooterRId;
10683
+ $[24] = activeHeaderRId;
10684
+ $[25] = effectiveSectionProperties;
10685
+ $[26] = firstPageFooterContent;
10686
+ $[27] = firstPageHeaderContent;
10687
+ $[28] = footerContent;
10688
+ $[29] = handleBodyClick;
10689
+ $[30] = handleHeaderFooterDoubleClick;
10690
+ $[31] = handleRemoveHeaderFooter;
10691
+ $[32] = hasTitlePg;
10692
+ $[33] = headerContent;
10693
+ $[34] = hfEditIsFirstPage;
10694
+ $[35] = hfEditPosition;
10695
+ $[36] = t9;
10696
+ } else t9 = $[36];
10896
10697
  return t9;
10897
10698
  };
10898
10699
  // src/components/hooks/useHyperlinkHandlers.ts
@@ -11531,34 +11332,6 @@ function _temp$3(prev) {
11531
11332
  visible: false
11532
11333
  };
11533
11334
  }
11534
- // src/components/hostDocument.ts
11535
- /**
11536
- * The host's own copy of the document the editor shows: the committed
11537
- * document with the live body, numbering and notes in place of its own.
11538
- *
11539
- * Both inputs share objects with the editor's model, so neither is written:
11540
- * the document is put together over them one level deep, and that whole is
11541
- * copied once by the copy owner. The copy shares no object with either.
11542
- */
11543
- const copyHostDocument = (committed, live) => {
11544
- const model = readModel(committed);
11545
- const stories = readModel(live).package;
11546
- const documentPackage = {
11547
- ...model.package,
11548
- document: {
11549
- ...model.package.document,
11550
- content: stories.document.content
11551
- }
11552
- };
11553
- if (stories.numbering) documentPackage.numbering = stories.numbering;
11554
- else delete documentPackage.numbering;
11555
- if (stories.footnotes) documentPackage.footnotes = stories.footnotes;
11556
- if (stories.endnotes) documentPackage.endnotes = stories.endnotes;
11557
- return cloneDocumentWithParagraphPropertySources({
11558
- ...model,
11559
- package: documentPackage
11560
- });
11561
- };
11562
11335
  // src/components/InlineHeaderFooterEditor.tsx
11563
11336
  /**
11564
11337
  * InlineHeaderFooterEditor — UI chrome for HF editing.
@@ -14195,16 +13968,8 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
14195
13968
  // src/components/DocxEditor.tsx
14196
13969
  /** No headings to track while the outline is not shown. */
14197
13970
  const NO_HEADINGS = [];
14198
- const CommentsSidebar = lazy(() => import("./CommentsSidebar-CMNMCb-Y.js").then((m) => ({ default: m.CommentsSidebar })));
13971
+ const CommentsSidebar = lazy(() => import("./CommentsSidebar-CjRWDQe6.js").then((m) => ({ default: m.CommentsSidebar })));
14199
13972
  const TextContextMenu = lazy(() => import("./TextContextMenu-jOBgICwD.js").then((m) => ({ default: m.TextContextMenu })));
14200
- const loadAttemptSelectiveSave = async () => {
14201
- const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
14202
- return attemptSelectiveSave;
14203
- };
14204
- const loadRepackDocx = async () => {
14205
- const { repackDocx } = await import("@stll/folio-core/docx/rezip");
14206
- return repackDocx;
14207
- };
14208
13973
  /** Translation key for each display mode's label (trigger and popup). */
14209
13974
  const DISPLAY_MODE_LABEL_KEYS = {
14210
13975
  "all-markup": "markupView.allMarkup",
@@ -14288,10 +14053,8 @@ const createPagedEditorBinding = () => {
14288
14053
  /**
14289
14054
  * DocxEditor - Complete DOCX editor component
14290
14055
  */
14291
- const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuffer, password, document: initialDocument, onSave, author = "User", onChange, onFindResultChange, onSelectionChange, onSelectionTextChange, onError, onFontsLoaded: onFontsLoadedCallback, fontFamilies, fonts, theme, showToolbar = true, showZoomControl = true, showReviewControls = true, showHeaderFooterEditing = true, pageRenderer, showMarginGuides = false, marginGuideColor, showRuler: showRulerProp = false, rulerUnit = "inch", initialZoom = 1, enableWheelZoom = true, keyboardShortcuts = DEFAULT_KEYBOARD_SHORTCUT_SCOPE, hostShortcuts: hostShortcutsProp, readOnly: readOnlyProp = false, reviewDisplayMode, showCommentHighlights = true, autoOpenReviewSidebar = true, components, toolbarExtra, className = "", style, placeholder, loadingIndicator, preserveDocumentWhileLoading = false, initialScrollTop, onScrollTopChange, showOutline: showOutlineProp = true, outlineDepth: outlineDepthProp, onOutlineDepthChange, onPrint, onInsertImage, onInsertTable, showTableInsert = true, onInsertPageBreak, onInsertTOC, onCopy, onCut, onPaste, mode: modeProp, onModeChange, onReadonlyEditAttempt, onCompatibilityChange, onEditorViewReady, onCanonicalHistory, onCanonicalHistoryDrop, anonymizationTerms, onAnonymizationMatchesChange, onAnonymizationTermClick, derivedFields, onAutocompleteChange, selectedAnonymizationCanonical = null, anonymizationSelectionSeq, showTemplateDirectives = false, onSlashMenuChange, onSlashMenuKeyAction, customContextMenuItems, onCustomContextAction, comments: commentsProp, onCommentsChange, collaboration, plugins, featureFlags, experimentalSession: experimentalSessionProp, onSelectiveSaveTripwire }, ref) {
14292
- const experimentalSession = experimentalSessionProp ?? (collaboration?.yXmlFragment === void 0 ? void 0 : "legacy");
14293
- const canonicalRoom = collaboration !== void 0 && isCanonicalRoomCollaboration(collaboration) ? collaboration : void 0;
14294
- const yjsCollaboration = collaboration !== void 0 && !isCanonicalRoomCollaboration(collaboration) ? collaboration : void 0;
14056
+ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuffer, password, document: initialDocument, onSave, author = "User", onChange, onFindResultChange, onSelectionChange, onSelectionTextChange, onError, onFontsLoaded: onFontsLoadedCallback, fontFamilies, fonts, theme, showToolbar = true, showZoomControl = true, showReviewControls = true, showHeaderFooterEditing = true, pageRenderer, showMarginGuides = false, marginGuideColor, showRuler: showRulerProp = false, rulerUnit = "inch", initialZoom = 1, enableWheelZoom = true, keyboardShortcuts = DEFAULT_KEYBOARD_SHORTCUT_SCOPE, hostShortcuts: hostShortcutsProp, readOnly: readOnlyProp = false, reviewDisplayMode, showCommentHighlights = true, autoOpenReviewSidebar = true, components, toolbarExtra, className = "", style, placeholder, loadingIndicator, preserveDocumentWhileLoading = false, initialScrollTop, onScrollTopChange, showOutline: showOutlineProp = true, outlineDepth: outlineDepthProp, onOutlineDepthChange, onPrint, onInsertImage, onInsertTable, showTableInsert = true, onInsertPageBreak, onInsertTOC, onCopy, onCut, onPaste, mode: modeProp, onModeChange, onReadonlyEditAttempt, onCompatibilityChange, onEditorViewReady, onCanonicalHistory, onCanonicalHistoryDrop, anonymizationTerms, onAnonymizationMatchesChange, onAnonymizationTermClick, derivedFields, onAutocompleteChange, selectedAnonymizationCanonical = null, anonymizationSelectionSeq, showTemplateDirectives = false, onSlashMenuChange, onSlashMenuKeyAction, customContextMenuItems, onCustomContextAction, comments: commentsProp, onCommentsChange, collaboration, plugins, featureFlags, onSelectiveSaveTripwire }, ref) {
14057
+ const canonicalRoom = collaboration;
14295
14058
  const pagedEditorRef = useRef(null);
14296
14059
  const [pagedEditorBinding] = useState(createPagedEditorBinding);
14297
14060
  const scrollContainerRef = useRef(null);
@@ -14404,10 +14167,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
14404
14167
  const history = useDocumentHistory(initialDocument || null, {
14405
14168
  maxEntries: 100,
14406
14169
  groupingInterval: 500,
14407
- enableKeyboardShortcuts: historyShortcuts === "editor" && !usesCanonicalSession(experimentalSession, CANONICAL_GAP.history)
14170
+ enableKeyboardShortcuts: false
14408
14171
  });
14409
14172
  const refuseCanonicalModelEdit = useCallback((gap, message) => {
14410
- if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return false;
14411
14173
  const error = new CanonicalSessionRefusalError({
14412
14174
  ground: { gap },
14413
14175
  message: canonicalRefusalMessage(gap, message)
@@ -14415,7 +14177,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
14415
14177
  toast(error.message);
14416
14178
  onError?.(error);
14417
14179
  return true;
14418
- }, [experimentalSession, onError]);
14180
+ }, [onError]);
14419
14181
  const extensionManager = useMemo(() => {
14420
14182
  const mgr = new ExtensionManager(createStarterKit({ historyShortcuts }));
14421
14183
  mgr.buildSchema();
@@ -14441,32 +14203,23 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
14441
14203
  onKeyAction: (action) => slashKeyCallback.invoke(action) ?? false
14442
14204
  }));
14443
14205
  const templatePreviewPlugin = useMemo(() => createTemplatePreviewValuesPlugin(), []);
14444
- const [derivedFieldsSlot] = useState(() => createCallbackSlot(() => derivedFields));
14445
- useLayoutEffect(() => {
14446
- derivedFieldsSlot.commit(() => derivedFields);
14447
- });
14448
- const [derivedFieldsPlugin] = useState(() => createDerivedFieldsPlugin(derivedFieldsSlot.invoke));
14449
14206
  const [hostPlugins] = useState(() => plugins ?? []);
14450
14207
  const editorPlugins = useMemo(() => [
14451
14208
  ...hostPlugins,
14452
- ...yjsCollaboration?.plugins ?? [],
14453
14209
  suggestionPlugin,
14454
14210
  aiSuggestionPlugin,
14455
14211
  aiCitationPlugin,
14456
14212
  ...showTemplateDirectives ? [templateDirectivesPlugin, templateSlashMenu] : [],
14457
- templatePreviewPlugin,
14458
- derivedFieldsPlugin
14213
+ templatePreviewPlugin
14459
14214
  ], [
14460
14215
  hostPlugins,
14461
- yjsCollaboration?.plugins,
14462
14216
  suggestionPlugin,
14463
14217
  aiSuggestionPlugin,
14464
14218
  aiCitationPlugin,
14465
14219
  showTemplateDirectives,
14466
14220
  templateDirectivesPlugin,
14467
14221
  templateSlashMenu,
14468
- templatePreviewPlugin,
14469
- derivedFieldsPlugin
14222
+ templatePreviewPlugin
14470
14223
  ]);
14471
14224
  const lastReportedViewRef = useRef(null);
14472
14225
  const reportEditorViewReady = useCallback((view_0) => {
@@ -14648,7 +14401,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
14648
14401
  bodyView: bodyEditorView
14649
14402
  });
14650
14403
  const comments = canonicalComments ?? legacyComments;
14651
- const commentDraftMode = usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "prosemirror";
14652
14404
  const documentOperationUndoEntriesRef = useRef([]);
14653
14405
  const pendingSuggestionRegistryRef = useRef(new FolioPendingSuggestionRegistry());
14654
14406
  const styleResolverCacheRef = useRef(null);
@@ -14696,10 +14448,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
14696
14448
  }, [setBodyHistoryAvailability]);
14697
14449
  const { hfEditPosition, setHfEditPosition, hfEditIsFirstPage, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, activeHeaderRId, activeFooterRId, activeFirstHeaderRId, activeFirstFooterRId, hasTitlePg, effectiveSectionProperties, handleHeaderFooterDoubleClick, handleBodyClick, handleRemoveHeaderFooter } = useHeaderFooterEditor({
14698
14450
  history,
14699
- pushDocument,
14700
- getCanonicalApi,
14701
- experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
14702
- getHfView: pagedEditorBinding.getHfView
14451
+ getCanonicalApi
14703
14452
  });
14704
14453
  useLayoutEffect(() => {
14705
14454
  if (readOnly && hfEditPosition) handleBodyClick();
@@ -14753,27 +14502,13 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
14753
14502
  });
14754
14503
  const focusActiveEditor = focusCallback.invoke;
14755
14504
  const undoActiveEditor = useCallback(() => {
14756
- if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) hfEditorRef.current.undo();
14757
- else {
14758
- pagedEditorRef.current?.undo();
14759
- requestAnimationFrame(refreshBodyHistoryAvailability);
14760
- }
14761
- }, [
14762
- getActiveEditorStory,
14763
- refreshBodyHistoryAvailability,
14764
- experimentalSession
14765
- ]);
14505
+ pagedEditorRef.current?.undo();
14506
+ requestAnimationFrame(refreshBodyHistoryAvailability);
14507
+ }, [refreshBodyHistoryAvailability]);
14766
14508
  const redoActiveEditor = useCallback(() => {
14767
- if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) hfEditorRef.current.redo();
14768
- else {
14769
- pagedEditorRef.current?.redo();
14770
- requestAnimationFrame(refreshBodyHistoryAvailability);
14771
- }
14772
- }, [
14773
- getActiveEditorStory,
14774
- refreshBodyHistoryAvailability,
14775
- experimentalSession
14776
- ]);
14509
+ pagedEditorRef.current?.redo();
14510
+ requestAnimationFrame(refreshBodyHistoryAvailability);
14511
+ }, [refreshBodyHistoryAvailability]);
14777
14512
  const handleActiveNoteStoryChange = useCallback((story) => {
14778
14513
  setActiveNoteStory(story);
14779
14514
  requestAnimationFrame(refreshBodyHistoryAvailability);
@@ -14810,11 +14545,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
14810
14545
  builtChangeNotifyRef.current = null;
14811
14546
  }, []);
14812
14547
  useEffect(() => cancelBuiltChangeNotification, [cancelBuiltChangeNotification]);
14813
- const { loadBuffer, loadParsedDocument, heldUnreferencedNotes, originalBufferRef, loadedDocumentIdentity } = useDocumentLoader({
14548
+ const { loadBuffer, loadParsedDocument, loadedDocumentIdentity } = useDocumentLoader({
14814
14549
  documentBuffer: documentBuffer ?? null,
14815
14550
  initialDocument: initialDocument ?? null,
14816
14551
  password,
14817
- experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
14818
14552
  history,
14819
14553
  onError,
14820
14554
  onCompatibilityChange,
@@ -14924,33 +14658,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
14924
14658
  * and hand the host one copy of it it owns. A document built outside the
14925
14659
  * paged editor's notification arrives as `built` and is the model; the
14926
14660
  * host gets its copy now or, for a change still in progress, once the
14927
- * change settles. In the legacy session the model holds this hook's
14928
- * comment list, and the host's document a copy of it.
14661
+ * change settles.
14929
14662
  */
14930
14663
  const applyDocumentChange = useCallback((change) => {
14931
- const canonical = usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting);
14932
- const held = (model_0) => canonical ? model_0 : {
14933
- ...model_0,
14934
- package: {
14935
- ...model_0.package,
14936
- document: {
14937
- ...model_0.package.document,
14938
- comments: commentsRef.current
14939
- }
14940
- }
14941
- };
14942
- const owned = (copy) => canonical ? copy : {
14943
- ...copy,
14944
- package: {
14945
- ...copy.package,
14946
- document: {
14947
- ...copy.package.document,
14948
- comments: cloneCommentsWithParagraphPropertySources(commentsRef.current)
14949
- }
14950
- }
14951
- };
14952
14664
  if ("built" in change) {
14953
- const built = held(change.built);
14665
+ const built = change.built;
14954
14666
  pushDocument(built);
14955
14667
  cancelBuiltChangeNotification();
14956
14668
  if (change.settles === "later") builtChangeNotifyRef.current = window.setTimeout(() => {
@@ -14959,10 +14671,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
14959
14671
  }, DOCUMENT_CHANGE_NOTIFY_DELAY_MS);
14960
14672
  else onChange?.(cloneDocumentWithParagraphPropertySources(built));
14961
14673
  } else {
14962
- if (change.model) pushDocument(held(change.model));
14674
+ if (change.model) pushDocument(change.model);
14963
14675
  if (change.forHost) {
14964
14676
  cancelBuiltChangeNotification();
14965
- onChange?.(owned(change.forHost));
14677
+ onChange?.(change.forHost);
14966
14678
  }
14967
14679
  if (!change.model) return;
14968
14680
  }
@@ -14974,36 +14686,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
14974
14686
  pushDocument,
14975
14687
  extractTrackedChanges,
14976
14688
  refreshBodyHistoryAvailability,
14977
- commentsRef,
14978
- experimentalSession,
14979
14689
  cancelBuiltChangeNotification
14980
14690
  ]);
14981
14691
  /** A document changed outside the paged editor's own notification. */
14982
14692
  const handleDocumentChange = useCallback((newDocument) => applyDocumentChange({ built: newDocument }), [applyDocumentChange]);
14983
14693
  const buildCurrentDocument = useCallback(() => {
14984
- const committed = historyStateRef.current;
14985
- if (!committed) return null;
14986
- const canonical_0 = pagedEditorRef.current?.getEditor().getCanonicalDocument();
14987
- if (canonical_0) return canonical_0;
14988
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return null;
14989
- const live = pagedEditorRef.current?.getDocument();
14990
- let doc_0 = live ? copyHostDocument(committed, live) : cloneDocumentWithParagraphPropertySources(committed);
14991
- if (!live) doc_0 = normalizeBaseDirection(doc_0);
14992
- const editor_0 = pagedEditorRef.current;
14993
- if (editor_0) {
14994
- const flushBag = (bag) => {
14995
- if (!bag) return;
14996
- for (const [rId, hf] of bag) {
14997
- const view_6 = editor_0.getHfView(rId);
14998
- if (view_6) hf.content = proseDocToBlocks(view_6.state.doc, hf.content);
14999
- }
15000
- };
15001
- flushBag(doc_0.package.headers);
15002
- flushBag(doc_0.package.footers);
15003
- }
15004
- const editorDoc = pagedEditorRef.current?.getView()?.state.doc;
15005
- return withHostCommentThreads(doc_0, commentsRef.current, { anchoredInEditor: editorDoc ? commentIdsNamedIn(editorDoc) : null });
15006
- }, [commentsRef, experimentalSession]);
14694
+ if (!historyStateRef.current) return null;
14695
+ return pagedEditorRef.current?.getEditor().getCanonicalDocument() ?? null;
14696
+ }, []);
15007
14697
  const applyCanonicalComment = useCallback((request) => {
15008
14698
  return getCanonicalApi()?.applyCanonicalComment(request) ?? null;
15009
14699
  }, [getCanonicalApi]);
@@ -15049,9 +14739,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15049
14739
  return;
15050
14740
  }
15051
14741
  if (result?.status !== "refused" || result.retry !== "afterComposition") return;
15052
- const view_7 = getCanonicalApi()?.getView();
15053
- if (!view_7) return;
15054
- return afterCanonicalCompositionSettles(view_7, () => setControlledCommentsRetry((attempt) => attempt + 1));
14742
+ const view_6 = getCanonicalApi()?.getView();
14743
+ if (!view_6) return;
14744
+ return afterCanonicalCompositionSettles(view_6, () => setControlledCommentsRetry((attempt) => attempt + 1));
15055
14745
  });
15056
14746
  useEffect(() => synchronizeControlledComments({
15057
14747
  commentsProp,
@@ -15127,15 +14817,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15127
14817
  }, [refreshFind]);
15128
14818
  useEffect(() => {
15129
14819
  if (bodyViewEpoch === 0) return;
15130
- const editor_1 = pagedEditorRef.current?.getEditor();
15131
- if (!editor_1) return;
14820
+ const editor_0 = pagedEditorRef.current?.getEditor();
14821
+ if (!editor_0) return;
15132
14822
  let timer_0 = null;
15133
14823
  const schedule = () => {
15134
14824
  if (timer_0 !== null) clearTimeout(timer_0);
15135
14825
  timer_0 = setTimeout(() => refreshFindRef.current(), 200);
15136
14826
  };
15137
- const unsubscribe = editor_1.on("docChange", schedule);
15138
- const unsubscribeLayout = editor_1.on("layoutComplete", schedule);
14827
+ const unsubscribe = editor_0.on("docChange", schedule);
14828
+ const unsubscribeLayout = editor_0.on("layoutComplete", schedule);
15139
14829
  return () => {
15140
14830
  unsubscribe();
15141
14831
  unsubscribeLayout();
@@ -15153,17 +14843,17 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15153
14843
  resetFindResultRef.current = resetFindResult;
15154
14844
  }, [resetFindResult]);
15155
14845
  const handleSelectionChange = useCallback((selectionState) => {
15156
- const view_8 = getActiveEditorView();
15157
- if (view_8) {
15158
- const { from, to } = view_8.state.selection;
14846
+ const view_7 = getActiveEditorView();
14847
+ if (view_7) {
14848
+ const { from, to } = view_7.state.selection;
15159
14849
  lastSelectionRef.current = {
15160
14850
  from,
15161
14851
  to
15162
14852
  };
15163
14853
  }
15164
14854
  let pmTableCtx = null;
15165
- if (view_8) {
15166
- pmTableCtx = getTableContext(view_8.state);
14855
+ if (view_7) {
14856
+ pmTableCtx = getTableContext(view_7.state);
15167
14857
  if (!pmTableCtx.isInTable) pmTableCtx = null;
15168
14858
  }
15169
14859
  if (pmTableCtx?.cellBorderColor) {
@@ -15175,8 +14865,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15175
14865
  color: { rgb }
15176
14866
  };
15177
14867
  }
15178
- const pmImageCtx = view_8 ? detectImageContext(view_8.state) : null;
15179
- const detectedChange = view_8 ? detectActiveTrackedChange(view_8.state) : null;
14868
+ const pmImageCtx = view_7 ? detectImageContext(view_7.state) : null;
14869
+ const detectedChange = view_7 ? detectActiveTrackedChange(view_7.state) : null;
15180
14870
  const trackedChange = detectedChange === null ? null : {
15181
14871
  type: detectedChange.type,
15182
14872
  author: detectedChange.author,
@@ -15246,10 +14936,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15246
14936
  activeTrackedChange: activeTrackedChange_0
15247
14937
  };
15248
14938
  });
15249
- if (view_8 && selectionState.hasSelection && !isAddingComment && !readOnly) {
14939
+ if (view_7 && selectionState.hasSelection && !isAddingComment && !readOnly) {
15250
14940
  const container = scrollContainerRef.current;
15251
14941
  const parentEl = editorContentRef.current;
15252
- const { from: selFrom } = view_8.state.selection;
14942
+ const { from: selFrom } = view_7.state.selection;
15253
14943
  const top = findSelectionYPosition(container, parentEl, selFrom);
15254
14944
  if (top !== null && container && parentEl) {
15255
14945
  const pagesEl = container.querySelector(".paged-editor__pages");
@@ -15257,7 +14947,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15257
14947
  const parentRect = parentEl.getBoundingClientRect();
15258
14948
  const rawLeft = pageEl ? pageEl.getBoundingClientRect().right - parentRect.left + 12 : parentRect.width / 2 + 408;
15259
14949
  const left = Math.max(16, Math.min(rawLeft, parentRect.width - 16));
15260
- const { from: from_0, to: to_0 } = view_8.state.selection;
14950
+ const { from: from_0, to: to_0 } = view_7.state.selection;
15261
14951
  if (from_0 !== to_0) setFloatingCommentBtn({
15262
14952
  top,
15263
14953
  left,
@@ -15420,10 +15110,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15420
15110
  refuseCanonicalModelEdit
15421
15111
  ]);
15422
15112
  const handleTableAction = useCallback((action_0) => {
15423
- const view_9 = getActiveEditorView();
15424
- if (!view_9) return;
15113
+ const view_8 = getActiveEditorView();
15114
+ if (!view_8) return;
15425
15115
  const commands = extensionManager;
15426
- const run = (command) => executeEditorCommand(view_9, command);
15116
+ const run = (command) => executeEditorCommand(view_8, command);
15427
15117
  switch (action_0) {
15428
15118
  case "addRowAbove":
15429
15119
  run(commands.requireCommand("addRowAbove")());
@@ -15609,86 +15299,86 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15609
15299
  }, { pointer: null });
15610
15300
  }, [openContextMenu]);
15611
15301
  const handleFormat = useCallback((action_1) => {
15612
- const view_10 = getActiveEditorView();
15613
- if (!view_10) return;
15614
- view_10.focus();
15615
- const isBodyEditor = view_10 === pagedEditorRef.current?.getView();
15616
- const { from: from_1, to: to_1 } = view_10.state.selection;
15302
+ const view_9 = getActiveEditorView();
15303
+ if (!view_9) return;
15304
+ view_9.focus();
15305
+ const isBodyEditor = view_9 === pagedEditorRef.current?.getView();
15306
+ const { from: from_1, to: to_1 } = view_9.state.selection;
15617
15307
  const savedSelection = lastSelectionRef.current;
15618
15308
  if (isBodyEditor && savedSelection && (from_1 !== savedSelection.from || to_1 !== savedSelection.to)) try {
15619
- const tr = view_10.state.tr.setSelection(TextSelection.create(view_10.state.doc, savedSelection.from, savedSelection.to));
15620
- view_10.dispatch(tr);
15309
+ const tr = view_9.state.tr.setSelection(TextSelection.create(view_9.state.doc, savedSelection.from, savedSelection.to));
15310
+ view_9.dispatch(tr);
15621
15311
  } catch {}
15622
15312
  if (action_1 === "bold") {
15623
- executeEditorCommand(view_10, toggleBold);
15313
+ executeEditorCommand(view_9, toggleBold);
15624
15314
  return;
15625
15315
  }
15626
15316
  if (action_1 === "italic") {
15627
- executeEditorCommand(view_10, toggleItalic);
15317
+ executeEditorCommand(view_9, toggleItalic);
15628
15318
  return;
15629
15319
  }
15630
15320
  if (action_1 === "underline") {
15631
- executeEditorCommand(view_10, toggleUnderline);
15321
+ executeEditorCommand(view_9, toggleUnderline);
15632
15322
  return;
15633
15323
  }
15634
15324
  if (action_1 === "strikethrough") {
15635
- executeEditorCommand(view_10, toggleStrike);
15325
+ executeEditorCommand(view_9, toggleStrike);
15636
15326
  return;
15637
15327
  }
15638
15328
  if (action_1 === "superscript") {
15639
- executeEditorCommand(view_10, toggleSuperscript);
15329
+ executeEditorCommand(view_9, toggleSuperscript);
15640
15330
  return;
15641
15331
  }
15642
15332
  if (action_1 === "subscript") {
15643
- executeEditorCommand(view_10, toggleSubscript);
15333
+ executeEditorCommand(view_9, toggleSubscript);
15644
15334
  return;
15645
15335
  }
15646
15336
  if (action_1 === "bulletList") {
15647
- executeEditorCommand(view_10, toggleBulletList);
15337
+ executeEditorCommand(view_9, toggleBulletList);
15648
15338
  return;
15649
15339
  }
15650
15340
  if (action_1 === "numberedList") {
15651
- executeEditorCommand(view_10, toggleNumberedList);
15341
+ executeEditorCommand(view_9, toggleNumberedList);
15652
15342
  return;
15653
15343
  }
15654
15344
  if (action_1 === "indent") {
15655
- executeFirstEditorCommand(view_10, [increaseListLevel, increaseIndent()]);
15345
+ executeFirstEditorCommand(view_9, [increaseListLevel, increaseIndent()]);
15656
15346
  return;
15657
15347
  }
15658
15348
  if (action_1 === "outdent") {
15659
- executeFirstEditorCommand(view_10, [decreaseListLevel, decreaseIndent()]);
15349
+ executeFirstEditorCommand(view_9, [decreaseListLevel, decreaseIndent()]);
15660
15350
  return;
15661
15351
  }
15662
15352
  if (action_1 === "clearFormatting") {
15663
- executeEditorCommand(view_10, clearFormatting);
15353
+ executeEditorCommand(view_9, clearFormatting);
15664
15354
  return;
15665
15355
  }
15666
15356
  if (action_1 === "setRtl") {
15667
- executeEditorCommand(view_10, setRtl);
15357
+ executeEditorCommand(view_9, setRtl);
15668
15358
  return;
15669
15359
  }
15670
15360
  if (action_1 === "setLtr") {
15671
- executeEditorCommand(view_10, setLtr);
15361
+ executeEditorCommand(view_9, setLtr);
15672
15362
  return;
15673
15363
  }
15674
15364
  if (action_1 === "insertPageBreak") {
15675
- executeEditorCommand(view_10, insertPageBreak);
15365
+ executeEditorCommand(view_9, insertPageBreak);
15676
15366
  return;
15677
15367
  }
15678
15368
  if (typeof action_1 === "object") switch (action_1.type) {
15679
15369
  case "alignment":
15680
- executeEditorCommand(view_10, setAlignment(action_1.value));
15370
+ executeEditorCommand(view_9, setAlignment(action_1.value));
15681
15371
  break;
15682
15372
  case "toggleDirection":
15683
- executeEditorCommand(view_10, toggleBidi);
15373
+ executeEditorCommand(view_9, toggleBidi);
15684
15374
  break;
15685
15375
  case "textColor": {
15686
15376
  const colorVal_0 = action_1.value;
15687
- if (typeof colorVal_0 === "string") executeEditorCommand(view_10, setTextColor({ rgb: colorVal_0.replace("#", "") }));
15688
- else if (colorVal_0.auto) executeEditorCommand(view_10, clearTextColor);
15377
+ if (typeof colorVal_0 === "string") executeEditorCommand(view_9, setTextColor({ rgb: colorVal_0.replace("#", "") }));
15378
+ else if (colorVal_0.auto) executeEditorCommand(view_9, clearTextColor);
15689
15379
  else {
15690
15380
  const themeColor = typeof colorVal_0.themeColor === "string" ? colorVal_0.themeColor : void 0;
15691
- executeEditorCommand(view_10, setTextColor({
15381
+ executeEditorCommand(view_9, setTextColor({
15692
15382
  ...colorVal_0.rgb === void 0 ? {} : { rgb: colorVal_0.rgb },
15693
15383
  ...themeColor ? { themeColor } : {},
15694
15384
  ...colorVal_0.themeTint === void 0 ? {} : { themeTint: colorVal_0.themeTint },
@@ -15699,17 +15389,17 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15699
15389
  }
15700
15390
  case "highlightColor": {
15701
15391
  const highlightName = action_1.value ? mapHexToHighlightName(action_1.value) : "";
15702
- executeEditorCommand(view_10, setHighlight(highlightName || action_1.value));
15392
+ executeEditorCommand(view_9, setHighlight(highlightName || action_1.value));
15703
15393
  break;
15704
15394
  }
15705
15395
  case "fontSize":
15706
- executeEditorCommand(view_10, setFontSize(pointsToHalfPoints(action_1.value)));
15396
+ executeEditorCommand(view_9, setFontSize(pointsToHalfPoints(action_1.value)));
15707
15397
  break;
15708
15398
  case "fontFamily":
15709
- executeEditorCommand(view_10, setFontFamily(action_1.value));
15399
+ executeEditorCommand(view_9, setFontFamily(action_1.value));
15710
15400
  break;
15711
15401
  case "lineSpacing":
15712
- executeEditorCommand(view_10, setLineSpacing(action_1.value));
15402
+ executeEditorCommand(view_9, setLineSpacing(action_1.value));
15713
15403
  break;
15714
15404
  case "applyStyle": {
15715
15405
  const committed_2 = historyStateRef.current;
@@ -15723,21 +15413,21 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15723
15413
  const styleName = styleResolver_0.getStyle(action_1.value)?.name;
15724
15414
  if (styleName) styleAttrs.styleName = styleName;
15725
15415
  styleAttrs.numbering = currentDoc_0?.package.numbering ? getCachedNumberingMap(currentDoc_0.package.numbering) : null;
15726
- executeEditorCommand(view_10, applyStyle(action_1.value, styleAttrs));
15727
- } else executeEditorCommand(view_10, applyStyle(action_1.value));
15416
+ executeEditorCommand(view_9, applyStyle(action_1.value, styleAttrs));
15417
+ } else executeEditorCommand(view_9, applyStyle(action_1.value));
15728
15418
  break;
15729
15419
  }
15730
15420
  }
15731
15421
  }, [getActiveEditorView, getCachedStyleResolver]);
15732
15422
  const captureFormatPainter = useCallback(() => {
15733
- const view_11 = getActiveEditorView();
15734
- capturedFormatMarksRef.current = view_11 ? captureFormatMarks(view_11.state) : null;
15423
+ const view_10 = getActiveEditorView();
15424
+ capturedFormatMarksRef.current = view_10 ? captureFormatMarks(view_10.state) : null;
15735
15425
  }, [getActiveEditorView]);
15736
15426
  const paintFormatToSelection = useCallback(() => {
15737
- const view_12 = getActiveEditorView();
15738
- if (!view_12) return false;
15739
- const applied = applyFormatMarks(capturedFormatMarksRef.current)(view_12.state, view_12.dispatch);
15740
- if (applied) requestAnimationFrame(() => view_12.focus());
15427
+ const view_11 = getActiveEditorView();
15428
+ if (!view_11) return false;
15429
+ const applied = applyFormatMarks(capturedFormatMarksRef.current)(view_11.state, view_11.dispatch);
15430
+ if (applied) requestAnimationFrame(() => view_11.focus());
15741
15431
  return applied;
15742
15432
  }, [getActiveEditorView]);
15743
15433
  const handleFormatPainter = useCallback((sticky) => {
@@ -15797,14 +15487,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15797
15487
  setFormatPainterMode
15798
15488
  ]);
15799
15489
  const handleContextMenu = useCallback((data) => {
15800
- const view_13 = getActiveEditorView();
15490
+ const view_12 = getActiveEditorView();
15801
15491
  openContextMenu({
15802
15492
  x: data.x,
15803
15493
  y: data.y
15804
15494
  }, {
15805
15495
  hasSelectionOverride: data.hasSelection,
15806
- pointer: view_13 && data.position !== null ? {
15807
- state: view_13.state,
15496
+ pointer: view_12 && data.position !== null ? {
15497
+ state: view_12.state,
15808
15498
  position: data.position
15809
15499
  } : null
15810
15500
  });
@@ -15887,12 +15577,12 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15887
15577
  dividerAfter: true
15888
15578
  });
15889
15579
  if (contextMenu.trackedChange) {
15890
- const held_0 = contextMenu.trackedChange.heldByLock;
15580
+ const held = contextMenu.trackedChange.heldByLock;
15891
15581
  const reason = t("trackedChanges.heldByLock");
15892
15582
  items.push({
15893
15583
  action: "acceptChange",
15894
15584
  label: t("acceptChange"),
15895
- ...held_0.accept && {
15585
+ ...held.accept && {
15896
15586
  disabled: true,
15897
15587
  disabledReason: reason
15898
15588
  }
@@ -15900,7 +15590,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15900
15590
  action: "rejectChange",
15901
15591
  label: t("rejectChange"),
15902
15592
  dividerAfter: true,
15903
- ...held_0.reject && {
15593
+ ...held.reject && {
15904
15594
  disabled: true,
15905
15595
  disabledReason: reason
15906
15596
  }
@@ -15936,15 +15626,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15936
15626
  const { from: contextSelectionFrom, to: contextSelectionTo } = contextMenu.selectionRange;
15937
15627
  const contextTrackedChange = contextMenu.trackedChange;
15938
15628
  const handleContextMenuAction = useCallback(async (action_2) => {
15939
- const view_14 = getActiveEditorView();
15940
- if (!view_14) return;
15629
+ const view_13 = getActiveEditorView();
15630
+ if (!view_13) return;
15941
15631
  focusActiveEditor();
15942
15632
  if (readOnly && action_2 !== "copy" && action_2 !== "selectAll") return;
15943
15633
  if (action_2.startsWith("custom:")) {
15944
15634
  const { from: from_2, to: to_2 } = contextSelectionFrom !== contextSelectionTo ? {
15945
15635
  from: contextSelectionFrom,
15946
15636
  to: contextSelectionTo
15947
- } : view_14.state.selection;
15637
+ } : view_13.state.selection;
15948
15638
  onCustomContextAction?.(action_2.slice(7), {
15949
15639
  from: from_2,
15950
15640
  to: to_2
@@ -15954,10 +15644,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15954
15644
  switch (action_2) {
15955
15645
  case "cut": {
15956
15646
  if (readOnly) return;
15957
- const { from: from_5, to: to_5 } = view_14.state.selection;
15958
- const text_2 = view_14.state.doc.textBetween(from_5, to_5, "\n");
15647
+ const { from: from_5, to: to_5 } = view_13.state.selection;
15648
+ const text_2 = view_13.state.doc.textBetween(from_5, to_5, "\n");
15959
15649
  navigator.clipboard.writeText(text_2).catch(() => void 0);
15960
- executeEditorCommand(view_14, replaceRangeText({
15650
+ executeEditorCommand(view_13, replaceRangeText({
15961
15651
  from: from_5,
15962
15652
  to: to_5,
15963
15653
  text: ""
@@ -15966,8 +15656,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15966
15656
  break;
15967
15657
  }
15968
15658
  case "copy": {
15969
- const { from: cf, to: ct } = view_14.state.selection;
15970
- const copied = view_14.state.doc.textBetween(cf, ct, "\n");
15659
+ const { from: cf, to: ct } = view_13.state.selection;
15660
+ const copied = view_13.state.doc.textBetween(cf, ct, "\n");
15971
15661
  navigator.clipboard.writeText(copied).catch(() => void 0);
15972
15662
  onCopy?.();
15973
15663
  break;
@@ -15990,12 +15680,12 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
15990
15680
  bubbles: true,
15991
15681
  cancelable: true
15992
15682
  });
15993
- view_14.dom.dispatchEvent(pasteEvent);
15683
+ view_13.dom.dispatchEvent(pasteEvent);
15994
15684
  } catch {
15995
15685
  try {
15996
15686
  const text_0 = await navigator.clipboard.readText();
15997
- if (text_0 && !view_14.isDestroyed) {
15998
- pastePlainTextSlice(view_14, buildPlainTextSlice(text_0, view_14.state.schema));
15687
+ if (text_0 && !view_13.isDestroyed) {
15688
+ pastePlainTextSlice(view_13, buildPlainTextSlice(text_0, view_13.state.schema));
15999
15689
  onPaste?.();
16000
15690
  }
16001
15691
  } catch {}
@@ -16004,8 +15694,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16004
15694
  case "pasteAsPlainText":
16005
15695
  try {
16006
15696
  const text = await navigator.clipboard.readText();
16007
- if (text && !view_14.isDestroyed) {
16008
- pastePlainTextSlice(view_14, buildPlainTextSlice(text, view_14.state.schema));
15697
+ if (text && !view_13.isDestroyed) {
15698
+ pastePlainTextSlice(view_13, buildPlainTextSlice(text, view_13.state.schema));
16009
15699
  onPaste?.();
16010
15700
  }
16011
15701
  } catch {
@@ -16013,8 +15703,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16013
15703
  }
16014
15704
  break;
16015
15705
  case "delete": {
16016
- const { from: from_4, to: to_4 } = view_14.state.selection;
16017
- if (from_4 !== to_4) executeEditorCommand(view_14, replaceRangeText({
15706
+ const { from: from_4, to: to_4 } = view_13.state.selection;
15707
+ if (from_4 !== to_4) executeEditorCommand(view_13, replaceRangeText({
16018
15708
  from: from_4,
16019
15709
  to: to_4,
16020
15710
  text: ""
@@ -16022,49 +15712,43 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16022
15712
  break;
16023
15713
  }
16024
15714
  case "selectAll":
16025
- view_14.dispatch(view_14.state.tr.setSelection(TextSelection.create(view_14.state.doc, 0, view_14.state.doc.content.size)));
15715
+ view_13.dispatch(view_13.state.tr.setSelection(TextSelection.create(view_13.state.doc, 0, view_13.state.doc.content.size)));
16026
15716
  break;
16027
15717
  case "addRowAbove":
16028
- executeEditorCommand(view_14, extensionManager.requireCommand("addRowAbove")());
15718
+ executeEditorCommand(view_13, extensionManager.requireCommand("addRowAbove")());
16029
15719
  break;
16030
15720
  case "addRowBelow":
16031
- executeEditorCommand(view_14, extensionManager.requireCommand("addRowBelow")());
15721
+ executeEditorCommand(view_13, extensionManager.requireCommand("addRowBelow")());
16032
15722
  break;
16033
15723
  case "deleteRow":
16034
- executeEditorCommand(view_14, extensionManager.requireCommand("deleteRow")());
15724
+ executeEditorCommand(view_13, extensionManager.requireCommand("deleteRow")());
16035
15725
  break;
16036
15726
  case "addColumnLeft":
16037
- executeEditorCommand(view_14, extensionManager.requireCommand("addColumnLeft")());
15727
+ executeEditorCommand(view_13, extensionManager.requireCommand("addColumnLeft")());
16038
15728
  break;
16039
15729
  case "addColumnRight":
16040
- executeEditorCommand(view_14, extensionManager.requireCommand("addColumnRight")());
15730
+ executeEditorCommand(view_13, extensionManager.requireCommand("addColumnRight")());
16041
15731
  break;
16042
15732
  case "deleteColumn":
16043
- executeEditorCommand(view_14, extensionManager.requireCommand("deleteColumn")());
15733
+ executeEditorCommand(view_13, extensionManager.requireCommand("deleteColumn")());
16044
15734
  break;
16045
15735
  case "tableBordersAll":
16046
- executeEditorCommand(view_14, extensionManager.requireCommand("setTableBorderPreset")("all"));
15736
+ executeEditorCommand(view_13, extensionManager.requireCommand("setTableBorderPreset")("all"));
16047
15737
  break;
16048
15738
  case "tableBordersNone":
16049
- executeEditorCommand(view_14, extensionManager.requireCommand("setTableBorderPreset")("none"));
15739
+ executeEditorCommand(view_13, extensionManager.requireCommand("setTableBorderPreset")("none"));
16050
15740
  break;
16051
15741
  case "addComment": {
16052
15742
  const { from: from_3, to: to_3 } = contextSelectionFrom !== contextSelectionTo ? {
16053
15743
  from: contextSelectionFrom,
16054
15744
  to: contextSelectionTo
16055
- } : view_14.state.selection;
15745
+ } : view_13.state.selection;
16056
15746
  if (from_3 === to_3) break;
16057
15747
  const commentY = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, from_3) ?? getFallbackCommentYPosition(scrollContainerRef.current);
16058
15748
  setCommentSelectionRange({
16059
15749
  from: from_3,
16060
15750
  to: to_3
16061
15751
  });
16062
- if (commentDraftMode === "prosemirror") {
16063
- if (!markPendingComment(view_14, {
16064
- from: from_3,
16065
- to: to_3
16066
- }, { selectEnd: true })) break;
16067
- }
16068
15752
  setAddCommentYPosition(commentY);
16069
15753
  setShowCommentsSidebar(true);
16070
15754
  setIsAddingComment(true);
@@ -16078,7 +15762,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16078
15762
  editor: pagedEditorRef.current?.getEditor(),
16079
15763
  ...range_0,
16080
15764
  resolution: "accept"
16081
- }) === null) acceptChange(range_0.from, range_0.to)(view_14.state, view_14.dispatch);
15765
+ }) === null) acceptChange(range_0.from, range_0.to)(view_13.state, view_13.dispatch);
16082
15766
  break;
16083
15767
  }
16084
15768
  case "rejectChange": {
@@ -16088,14 +15772,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16088
15772
  editor: pagedEditorRef.current?.getEditor(),
16089
15773
  ...range,
16090
15774
  resolution: "reject"
16091
- }) === null) rejectChange(range.from, range.to)(view_14.state, view_14.dispatch);
15775
+ }) === null) rejectChange(range.from, range.to)(view_13.state, view_13.dispatch);
16092
15776
  break;
16093
15777
  }
16094
15778
  case "restartNumbering":
16095
- executeEditorCommand(view_14, restartNumbering);
15779
+ executeEditorCommand(view_13, restartNumbering);
16096
15780
  break;
16097
15781
  case "continueNumbering":
16098
- executeEditorCommand(view_14, continueNumbering);
15782
+ executeEditorCommand(view_13, continueNumbering);
16099
15783
  break;
16100
15784
  case "setNumberingValue": setNumberingValueDialogOpen(true);
16101
15785
  }
@@ -16111,7 +15795,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16111
15795
  contextSelectionFrom,
16112
15796
  contextSelectionTo,
16113
15797
  contextTrackedChange,
16114
- commentDraftMode,
16115
15798
  setAddCommentYPosition,
16116
15799
  setCommentSelectionRange,
16117
15800
  setFloatingCommentBtn,
@@ -16128,13 +15811,13 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16128
15811
  }
16129
15812
  if (api_0.applyCanonicalSectionProperties(props) !== null) return;
16130
15813
  if (!history.state || readOnly) return;
16131
- const model_1 = history.state;
16132
- const body = model_1.package.document;
15814
+ const model_0 = history.state;
15815
+ const body = model_0.package.document;
16133
15816
  applyDocumentChange({
16134
15817
  built: {
16135
- ...model_1,
15818
+ ...model_0,
16136
15819
  package: {
16137
- ...model_1.package,
15820
+ ...model_0.package,
16138
15821
  document: {
16139
15822
  ...body,
16140
15823
  finalSectionProperties: {
@@ -16158,9 +15841,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16158
15841
  const handleTopMarginChange = useCallback((twips_1) => handlePageSetupApply({ marginTop: twips_1 }), [handlePageSetupApply]);
16159
15842
  const handleBottomMarginChange = useCallback((twips_2) => handlePageSetupApply({ marginBottom: twips_2 }), [handlePageSetupApply]);
16160
15843
  const applyRulerEdit = useCallback((edit) => {
16161
- const view_15 = getActiveEditorView();
16162
- if (!view_15) return;
16163
- applyRulerParagraphEdit(view_15, edit);
15844
+ const view_14 = getActiveEditorView();
15845
+ if (!view_14) return;
15846
+ applyRulerParagraphEdit(view_14, edit);
16164
15847
  }, [getActiveEditorView]);
16165
15848
  const handleIndentLeftChange = useCallback((twips_3) => applyRulerEdit({
16166
15849
  type: "indentLeft",
@@ -16182,11 +15865,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16182
15865
  let tripwireResult = null;
16183
15866
  let savedBuffer = null;
16184
15867
  try {
16185
- const editor_2 = pagedEditorRef.current?.getEditor();
16186
- const snapshot_0 = editor_2?.captureCanonicalSave();
16187
- if (snapshot_0 && editor_2) {
16188
- const view_16 = editor_2.getView();
16189
- const editorState = view_16?.state;
15868
+ const editor_1 = pagedEditorRef.current?.getEditor();
15869
+ const snapshot_0 = editor_1?.captureCanonicalSave();
15870
+ if (snapshot_0 && editor_1) {
15871
+ const view_15 = editor_1.getView();
15872
+ const editorState = view_15?.state;
16190
15873
  const result_2 = await serializeCanonicalSave({
16191
15874
  snapshot: snapshot_0,
16192
15875
  options,
@@ -16194,70 +15877,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16194
15877
  });
16195
15878
  for (const diagnostic of result_2.diagnostics) if (!options?.onDiagnostic) onError?.(canonicalSaveDiagnosticError(diagnostic));
16196
15879
  tripwireResult = result_2.tripwireResult;
16197
- if (view_16 && pagedEditorRef.current?.getEditor() === editor_2 && editor_2.getView() === view_16 && view_16.state.doc === editorState?.doc && editor_2.isCanonicalSaveCurrent(snapshot_0.version)) editor_2.markCanonicalSaved(snapshot_0.version, result_2);
15880
+ if (view_15 && pagedEditorRef.current?.getEditor() === editor_1 && editor_1.getView() === view_15 && view_15.state.doc === editorState?.doc && editor_1.isCanonicalSaveCurrent(snapshot_0.version)) editor_1.markCanonicalSaved(snapshot_0.version, result_2);
16198
15881
  savedBuffer = result_2.buffer;
16199
- } else {
16200
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.save)) return null;
16201
- const view_17 = pagedEditorRef.current?.getView();
16202
- const editorState_0 = view_17?.state;
16203
- const baselineBuffer = originalBufferRef.current;
16204
- const current_0 = buildCurrentDocument();
16205
- const doc_1 = current_0 ? withoutUnreferencedNotes(current_0, heldUnreferencedNotes()) : null;
16206
- if (!doc_1) return null;
16207
- const { resolveSelectiveSaveFlags } = await import("@stll/folio-core/docx/selectiveSaveFlags");
16208
- const flags = resolveSelectiveSaveFlags(featureFlags);
16209
- const useSelectiveForSave = flags.selectiveSave && options?.mode !== FOLIO_DOCX_SERIALIZATION_MODE.full;
16210
- const shouldAttemptSelective = useSelectiveForSave || flags.selectiveSaveTripwire;
16211
- let selectiveBuffer = null;
16212
- if (shouldAttemptSelective && editorState_0 && baselineBuffer) selectiveBuffer = await (await loadAttemptSelectiveSave())(doc_1, baselineBuffer, {
16213
- changedParaIds: getChangedParagraphIds(editorState_0),
16214
- structuralChange: hasStructuralChanges(editorState_0),
16215
- hasUntrackedChanges: hasUntrackedChanges(editorState_0),
16216
- maxBytes: flags.selectiveSaveMaxBytes,
16217
- onSelectiveDecline: options?.onSelectiveDecline,
16218
- onDiagnostic: options?.onDiagnostic
16219
- });
16220
- let buffer = useSelectiveForSave ? selectiveBuffer : null;
16221
- let fullBuffer = null;
16222
- let path = "selective";
16223
- const repackSourceDoc = baselineBuffer ? {
16224
- ...doc_1,
16225
- originalBuffer: baselineBuffer
16226
- } : doc_1;
16227
- const fullDiagnostics = [];
16228
- const collectFullDiagnostic = (diagnostic_0) => fullDiagnostics.push(diagnostic_0);
16229
- const repackFull = async () => {
16230
- if (!baselineBuffer) {
16231
- const { createDocx } = await import("@stll/folio-core/docx/rezip");
16232
- return createDocx(repackSourceDoc, { onDiagnostic: collectFullDiagnostic });
16233
- }
16234
- const repackDocx = await loadRepackDocx();
16235
- const repack = () => repackDocx(repackSourceDoc, { onDiagnostic: collectFullDiagnostic });
16236
- return editorState_0 ? repackWithEditorSectionRemovals({
16237
- state: editorState_0,
16238
- document: repackSourceDoc,
16239
- repack
16240
- }) : repack();
16241
- };
16242
- if (!buffer) {
16243
- fullBuffer = await repackFull();
16244
- buffer = fullBuffer;
16245
- path = "full-repack";
16246
- } else if (flags.selectiveSaveTripwire) try {
16247
- fullBuffer = await repackFull();
16248
- } catch {}
16249
- if (flags.selectiveSaveTripwire && fullBuffer && onSelectiveSaveTripwire) try {
16250
- const { compareSelectiveVsFull } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
16251
- tripwireResult = await compareSelectiveVsFull(selectiveBuffer, fullBuffer);
16252
- } catch {}
16253
- for (const diagnostic_1 of fullDiagnostics) options?.onDiagnostic?.(diagnostic_1);
16254
- options?.onSerializationPath?.(path);
16255
- if (view_17 && pagedEditorRef.current?.getView() === view_17 && view_17.state.doc === editorState_0?.doc) {
16256
- originalBufferRef.current = buffer;
16257
- view_17.dispatch(clearTrackedChanges(view_17.state));
16258
- }
16259
- savedBuffer = buffer;
16260
- }
15882
+ } else return null;
16261
15883
  } catch (error_0) {
16262
15884
  onError?.(error_0 instanceof Error ? error_0 : /* @__PURE__ */ new Error("Failed to save document"));
16263
15885
  return null;
@@ -16265,27 +15887,23 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16265
15887
  if (tripwireResult && onSelectiveSaveTripwire) onSelectiveSaveTripwire(tripwireResult);
16266
15888
  return savedBuffer;
16267
15889
  }, [
16268
- buildCurrentDocument,
16269
- heldUnreferencedNotes,
16270
15890
  onError,
16271
- originalBufferRef,
16272
15891
  featureFlags,
16273
- onSelectiveSaveTripwire,
16274
- experimentalSession
15892
+ onSelectiveSaveTripwire
16275
15893
  ]);
16276
15894
  const handleSave = useCallback(async (options_0) => {
16277
- const editor_3 = pagedEditorRef.current?.getEditor();
15895
+ const editor_2 = pagedEditorRef.current?.getEditor();
16278
15896
  const serializationOptions = {
16279
15897
  onDiagnostic: options_0?.onDiagnostic,
16280
15898
  onSelectiveDecline: options_0?.onSelectiveDecline,
16281
15899
  onSerializationPath: options_0?.onSerializationPath,
16282
15900
  mode: options_0?.selective === false ? FOLIO_DOCX_SERIALIZATION_MODE.full : FOLIO_DOCX_SERIALIZATION_MODE.preferSelective
16283
15901
  };
16284
- const buffer_0 = editor_3 ? await editor_3.getDocx(serializationOptions) : await serializeCurrentDocx(serializationOptions);
16285
- if (!buffer_0) return null;
15902
+ const buffer = editor_2 ? await editor_2.getDocx(serializationOptions) : await serializeCurrentDocx(serializationOptions);
15903
+ if (!buffer) return null;
16286
15904
  setCommentsDirty(false);
16287
- onSave?.(buffer_0);
16288
- return buffer_0;
15905
+ onSave?.(buffer);
15906
+ return buffer;
16289
15907
  }, [
16290
15908
  setCommentsDirty,
16291
15909
  onSave,
@@ -16316,11 +15934,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16316
15934
  getFindResult,
16317
15935
  clearFind: resetFindResult,
16318
15936
  hasPendingChanges: () => {
16319
- const view_18 = pagedEditorRef.current?.getView();
16320
- if (!view_18) return false;
16321
- const canonical_1 = pagedEditorRef.current?.getEditor().hasCanonicalPendingChanges();
16322
- if (canonical_1 !== null && canonical_1 !== void 0) return getCommentsDirty() || canonical_1;
16323
- return getCommentsDirty() || getChangedParagraphIds(view_18.state).size > 0 || hasStructuralChanges(view_18.state) || hasUntrackedChanges(view_18.state);
15937
+ const view_16 = pagedEditorRef.current?.getView();
15938
+ if (!view_16) return false;
15939
+ const canonical = pagedEditorRef.current?.getEditor().hasCanonicalPendingChanges();
15940
+ if (canonical !== null && canonical !== void 0) return getCommentsDirty() || canonical;
15941
+ return getCommentsDirty() || getChangedParagraphIds(view_16.state).size > 0 || hasStructuralChanges(view_16.state) || hasUntrackedChanges(view_16.state);
16324
15942
  },
16325
15943
  getEditorRef: () => pagedEditorRef.current,
16326
15944
  getEditor: () => pagedEditorRef.current?.getEditor() ?? null,
@@ -16350,28 +15968,28 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16350
15968
  },
16351
15969
  loadDocument: (document_0) => {
16352
15970
  pendingSuggestionRegistryRef.current.clear();
16353
- const editor_4 = pagedEditorRef.current?.getEditor();
16354
- if (editor_4) {
16355
- editor_4.loadDocument(document_0);
15971
+ const editor_3 = pagedEditorRef.current?.getEditor();
15972
+ if (editor_3) {
15973
+ editor_3.loadDocument(document_0);
16356
15974
  return;
16357
15975
  }
16358
15976
  loadParsedDocument(document_0);
16359
15977
  },
16360
- loadDocumentBuffer: (buffer_1) => {
15978
+ loadDocumentBuffer: (buffer_0) => {
16361
15979
  pendingSuggestionRegistryRef.current.clear();
16362
- return pagedEditorRef.current?.getEditor().loadDocx(buffer_1) ?? loadBuffer(buffer_1);
15980
+ return pagedEditorRef.current?.getEditor().loadDocx(buffer_0) ?? loadBuffer(buffer_0);
16363
15981
  },
16364
15982
  ensureEditorView: (options_3) => {
16365
15983
  pagedEditorRef.current?.ensureView(options_3);
16366
15984
  },
16367
15985
  createAIEditSnapshot: () => {
16368
- const view_19 = pagedEditorRef.current?.getView();
16369
- return view_19 ? createFolioAIEditSnapshot(view_19.state.doc) : null;
15986
+ const view_17 = pagedEditorRef.current?.getView();
15987
+ return view_17 ? createFolioAIEditSnapshot(view_17.state.doc) : null;
16370
15988
  },
16371
15989
  applyDocumentOperations: ({ undefinedReferences, snapshot: snapshot_1, batch, author: operationAuthor = author }) => {
16372
15990
  assertSupportedFolioDocumentOperationVersion(batch.version);
16373
- const view_20 = pagedEditorRef.current?.getView();
16374
- if (!view_20) {
15991
+ const view_18 = pagedEditorRef.current?.getView();
15992
+ if (!view_18) {
16375
15993
  let status = "committed";
16376
15994
  if (batch.dryRun === true) status = "previewed";
16377
15995
  else if (batch.atomic === true) status = "rejected";
@@ -16389,36 +16007,36 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16389
16007
  undoHandle: null
16390
16008
  };
16391
16009
  }
16392
- const activeBeforeCanonical = new Set(getSuggestions(view_20.state).map((s_0) => s_0.suggestionId));
16393
- const canonical_2 = getCanonicalApi()?.applyCanonicalDocumentOperations({
16010
+ const activeBeforeCanonical = new Set(getSuggestions(view_18.state).map((s_0) => s_0.suggestionId));
16011
+ const canonical_0 = getCanonicalApi()?.applyCanonicalDocumentOperations({
16394
16012
  undefinedReferences,
16395
16013
  snapshot: snapshot_1,
16396
16014
  batch,
16397
16015
  author: operationAuthor
16398
16016
  });
16399
- if (canonical_2) {
16400
- if (batch.mode === "suggested" && canonical_2.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
16017
+ if (canonical_0) {
16018
+ if (batch.mode === "suggested" && canonical_0.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
16401
16019
  snapshot: snapshot_1,
16402
16020
  story: { type: "main" },
16403
16021
  operations: batch.operations,
16404
- applied: canonical_2.applied,
16022
+ applied: canonical_0.applied,
16405
16023
  author: operationAuthor,
16406
16024
  activeSuggestionIds: activeBeforeCanonical
16407
16025
  });
16408
- return canonical_2;
16026
+ return canonical_0;
16409
16027
  }
16410
16028
  const existingUndoEntry = documentOperationUndoEntriesRef.current.at(-1);
16411
- if (existingUndoEntry && (!view_20.state.doc.eq(existingUndoEntry.afterState.doc) || canonicalJson(commentRecordsOf(view_20.state)) !== existingUndoEntry.commentsAfterJson)) documentOperationUndoEntriesRef.current.length = 0;
16029
+ if (existingUndoEntry && (!view_18.state.doc.eq(existingUndoEntry.afterState.doc) || canonicalJson(commentRecordsOf(view_18.state)) !== existingUndoEntry.commentsAfterJson)) documentOperationUndoEntriesRef.current.length = 0;
16412
16030
  const createdComments = [];
16413
- const recordingView = recordingCommentsView(view_20, createdComments);
16031
+ const recordingView = recordingCommentsView(view_18, createdComments);
16414
16032
  const operationView = {
16415
- state: view_20.state,
16033
+ state: view_18.state,
16416
16034
  dispatch: (transaction) => {
16417
16035
  recordingView.dispatch(closeHistory(transaction));
16418
- operationView.state = view_20.state;
16036
+ operationView.state = view_18.state;
16419
16037
  }
16420
16038
  };
16421
- const activeSuggestionIds = new Set(getSuggestions(view_20.state).map((s_1) => s_1.suggestionId));
16039
+ const activeSuggestionIds = new Set(getSuggestions(view_18.state).map((s_1) => s_1.suggestionId));
16422
16040
  const result_3 = applyFolioDocumentOperations({
16423
16041
  undefinedReferences,
16424
16042
  view: operationView,
@@ -16445,14 +16063,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16445
16063
  });
16446
16064
  if (result_3.undoHandle !== null) documentOperationUndoEntriesRef.current.push({
16447
16065
  undoHandle: result_3.undoHandle,
16448
- afterState: view_20.state,
16449
- commentsAfterJson: canonicalJson(commentRecordsOf(view_20.state))
16066
+ afterState: view_18.state,
16067
+ commentsAfterJson: canonicalJson(commentRecordsOf(view_18.state))
16450
16068
  });
16451
16069
  return result_3;
16452
16070
  },
16453
16071
  undoDocumentOperations: (undoHandle) => {
16454
- const canonical_3 = getCanonicalApi()?.undoCanonicalDocumentOperations(undoHandle);
16455
- if (canonical_3) return canonical_3;
16072
+ const canonical_1 = getCanonicalApi()?.undoCanonicalDocumentOperations(undoHandle);
16073
+ if (canonical_1) return canonical_1;
16456
16074
  const entries_0 = documentOperationUndoEntriesRef.current;
16457
16075
  const entryIndex = entries_0.findIndex((entry_2) => entry_2.undoHandle.type === undoHandle.type && entry_2.undoHandle.id === undoHandle.id);
16458
16076
  if (entryIndex === -1) return {
@@ -16466,18 +16084,18 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16466
16084
  reason: "notLatest"
16467
16085
  };
16468
16086
  const entry_3 = entries_0.at(-1);
16469
- const view_21 = pagedEditorRef.current?.getView();
16470
- if (!entry_3 || !view_21) return {
16087
+ const view_19 = pagedEditorRef.current?.getView();
16088
+ if (!entry_3 || !view_19) return {
16471
16089
  status: "rejected",
16472
16090
  undoHandle,
16473
16091
  reason: "unknownHandle"
16474
16092
  };
16475
- if (!view_21.state.doc.eq(entry_3.afterState.doc) || canonicalJson(commentRecordsOf(view_21.state)) !== entry_3.commentsAfterJson) return {
16093
+ if (!view_19.state.doc.eq(entry_3.afterState.doc) || canonicalJson(commentRecordsOf(view_19.state)) !== entry_3.commentsAfterJson) return {
16476
16094
  status: "rejected",
16477
16095
  undoHandle,
16478
16096
  reason: "documentChanged"
16479
16097
  };
16480
- if (!undo(view_21.state, view_21.dispatch)) return {
16098
+ if (!undo(view_19.state, view_19.dispatch)) return {
16481
16099
  status: "rejected",
16482
16100
  undoHandle,
16483
16101
  reason: "documentChanged"
@@ -16490,16 +16108,16 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16490
16108
  };
16491
16109
  },
16492
16110
  applyAIEditOperations: ({ undefinedReferences: undefinedReferences_0, snapshot: snapshot_2, operations, mode = "tracked-changes", author: operationAuthor_0 = author }) => {
16493
- const view_22 = pagedEditorRef.current?.getView();
16494
- if (!view_22) return {
16111
+ const view_20 = pagedEditorRef.current?.getView();
16112
+ if (!view_20) return {
16495
16113
  applied: [],
16496
16114
  skipped: operations.map((operation_0) => ({
16497
16115
  id: operation_0.id,
16498
16116
  reason: "unsupportedBlock"
16499
16117
  }))
16500
16118
  };
16501
- const activeSuggestionIds_0 = new Set(getSuggestions(view_22.state).map((s_2) => s_2.suggestionId));
16502
- const canonical_4 = getCanonicalApi()?.applyCanonicalDocumentOperations({
16119
+ const activeSuggestionIds_0 = new Set(getSuggestions(view_20.state).map((s_2) => s_2.suggestionId));
16120
+ const canonical_2 = getCanonicalApi()?.applyCanonicalDocumentOperations({
16503
16121
  undefinedReferences: undefinedReferences_0,
16504
16122
  snapshot: snapshot_2,
16505
16123
  batch: {
@@ -16509,21 +16127,21 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16509
16127
  },
16510
16128
  author: operationAuthor_0
16511
16129
  });
16512
- if (canonical_4) {
16513
- if (mode === "suggested" && canonical_4.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
16130
+ if (canonical_2) {
16131
+ if (mode === "suggested" && canonical_2.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
16514
16132
  snapshot: snapshot_2,
16515
16133
  story: { type: "main" },
16516
16134
  operations,
16517
- applied: canonical_4.applied,
16135
+ applied: canonical_2.applied,
16518
16136
  author: operationAuthor_0,
16519
16137
  activeSuggestionIds: activeSuggestionIds_0
16520
16138
  });
16521
- return canonical_4;
16139
+ return canonical_2;
16522
16140
  }
16523
16141
  const createdComments_0 = [];
16524
16142
  const { applied: applied_0, skipped: skipped_0 } = applyFolioDocumentOperations({
16525
16143
  undefinedReferences: undefinedReferences_0,
16526
- view: recordingCommentsView(view_22, createdComments_0),
16144
+ view: recordingCommentsView(view_20, createdComments_0),
16527
16145
  snapshot: snapshot_2,
16528
16146
  batch: {
16529
16147
  version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
@@ -16551,70 +16169,68 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16551
16169
  };
16552
16170
  },
16553
16171
  acceptAIEditOperation: (revisionId) => {
16554
- const view_23 = pagedEditorRef.current?.getView();
16555
- if (!view_23) return false;
16556
- const editor_5 = pagedEditorRef.current?.getEditor();
16557
- if (editor_5?.getCanonicalDocument()) return editor_5.resolveCanonicalRevisions(typeof revisionId === "number" ? [revisionId] : revisionId, "accept");
16558
- return acceptAIEditRevision(revisionId)(view_23.state, view_23.dispatch);
16172
+ const view_21 = pagedEditorRef.current?.getView();
16173
+ if (!view_21) return false;
16174
+ const editor_4 = pagedEditorRef.current?.getEditor();
16175
+ if (editor_4?.getCanonicalDocument()) return editor_4.resolveCanonicalRevisions(typeof revisionId === "number" ? [revisionId] : revisionId, "accept");
16176
+ return acceptAIEditRevision(revisionId)(view_21.state, view_21.dispatch);
16559
16177
  },
16560
16178
  rejectAIEditOperation: (revisionId_0) => {
16561
- const view_24 = pagedEditorRef.current?.getView();
16562
- if (!view_24) return false;
16563
- const editor_6 = pagedEditorRef.current?.getEditor();
16564
- if (editor_6?.getCanonicalDocument()) return editor_6.resolveCanonicalRevisions(typeof revisionId_0 === "number" ? [revisionId_0] : revisionId_0, "reject");
16565
- return rejectAIEditRevision(revisionId_0)(view_24.state, view_24.dispatch);
16179
+ const view_22 = pagedEditorRef.current?.getView();
16180
+ if (!view_22) return false;
16181
+ const editor_5 = pagedEditorRef.current?.getEditor();
16182
+ if (editor_5?.getCanonicalDocument()) return editor_5.resolveCanonicalRevisions(typeof revisionId_0 === "number" ? [revisionId_0] : revisionId_0, "reject");
16183
+ return rejectAIEditRevision(revisionId_0)(view_22.state, view_22.dispatch);
16566
16184
  },
16567
16185
  undo: () => {
16568
- if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.undo();
16569
16186
  const undone = pagedEditorRef.current?.undo() ?? false;
16570
16187
  requestAnimationFrame(refreshBodyHistoryAvailability);
16571
16188
  return undone;
16572
16189
  },
16573
16190
  redo: () => {
16574
- if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.redo();
16575
16191
  const redone = pagedEditorRef.current?.redo() ?? false;
16576
16192
  requestAnimationFrame(refreshBodyHistoryAvailability);
16577
16193
  return redone;
16578
16194
  },
16579
16195
  scrollToAIEditOperation: (revisionId_1) => {
16580
- const view_25 = pagedEditorRef.current?.getView();
16581
- if (!view_25) return false;
16582
- const range_1 = findAIEditRevisionRange(view_25.state, revisionId_1);
16196
+ const view_23 = pagedEditorRef.current?.getView();
16197
+ if (!view_23) return false;
16198
+ const range_1 = findAIEditRevisionRange(view_23.state, revisionId_1);
16583
16199
  if (!range_1) return false;
16584
- const { from: from_6, to: to_6 } = clampRangeToDocSize(view_25.state.doc.content.size, range_1);
16585
- const $from = view_25.state.doc.resolve(from_6);
16586
- const $to = view_25.state.doc.resolve(to_6);
16587
- view_25.dispatch(view_25.state.tr.setSelection(TextSelection.between($from, $to)));
16200
+ const { from: from_6, to: to_6 } = clampRangeToDocSize(view_23.state.doc.content.size, range_1);
16201
+ const $from = view_23.state.doc.resolve(from_6);
16202
+ const $to = view_23.state.doc.resolve(to_6);
16203
+ view_23.dispatch(view_23.state.tr.setSelection(TextSelection.between($from, $to)));
16588
16204
  requestAnimationFrame(() => {
16589
16205
  pagedEditorRef.current?.scrollToPosition(from_6);
16590
16206
  });
16591
16207
  return true;
16592
16208
  },
16593
16209
  scrollToBlock: (blockId, snapshot_3) => {
16594
- const view_26 = pagedEditorRef.current?.getView();
16595
- if (!view_26) return false;
16210
+ const view_24 = pagedEditorRef.current?.getView();
16211
+ if (!view_24) return false;
16596
16212
  const range_2 = resolveFolioAIBlockRange({
16597
16213
  blockId,
16598
- doc: view_26.state.doc,
16214
+ doc: view_24.state.doc,
16599
16215
  snapshot: snapshot_3
16600
16216
  });
16601
16217
  if (range_2 === null) return false;
16602
16218
  const { from: from_7, to: to_7 } = range_2;
16603
- const $from_0 = view_26.state.doc.resolve(from_7);
16604
- const $to_0 = view_26.state.doc.resolve(to_7);
16605
- view_26.dispatch(view_26.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
16219
+ const $from_0 = view_24.state.doc.resolve(from_7);
16220
+ const $to_0 = view_24.state.doc.resolve(to_7);
16221
+ view_24.dispatch(view_24.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
16606
16222
  requestAnimationFrame(() => {
16607
16223
  pagedEditorRef.current?.scrollToPosition(from_7);
16608
16224
  });
16609
16225
  return true;
16610
16226
  },
16611
16227
  highlightPassage: ({ blockId: blockId_0, text: text_5, snapshot: snapshot_4 }) => {
16612
- const view_27 = pagedEditorRef.current?.getView();
16613
- if (!view_27) return "none";
16228
+ const view_25 = pagedEditorRef.current?.getView();
16229
+ if (!view_25) return "none";
16614
16230
  const passageRange = resolvePassageRange({
16615
16231
  blockId: blockId_0,
16616
16232
  text: text_5,
16617
- doc: view_27.state.doc,
16233
+ doc: view_25.state.doc,
16618
16234
  snapshot: snapshot_4
16619
16235
  });
16620
16236
  if (passageRange !== null) {
@@ -16627,16 +16243,16 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16627
16243
  pagedEditorRef.current?.setPassageHighlight(null);
16628
16244
  const blockRange = resolveFolioAIBlockRange({
16629
16245
  blockId: blockId_0,
16630
- doc: view_27.state.doc,
16246
+ doc: view_25.state.doc,
16631
16247
  snapshot: snapshot_4
16632
16248
  });
16633
16249
  if (blockRange === null) return "none";
16634
16250
  const paraId_0 = getFolioParaIdFromBlockId(blockId_0);
16635
16251
  if (paraId_0 !== null && pagedEditorRef.current?.scrollToParaId(paraId_0, { highlight: {} })) return "block";
16636
16252
  const { from: from_8, to: to_8 } = blockRange;
16637
- const $from_1 = view_27.state.doc.resolve(from_8);
16638
- const $to_1 = view_27.state.doc.resolve(to_8);
16639
- view_27.dispatch(view_27.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
16253
+ const $from_1 = view_25.state.doc.resolve(from_8);
16254
+ const $to_1 = view_25.state.doc.resolve(to_8);
16255
+ view_25.dispatch(view_25.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
16640
16256
  requestAnimationFrame(() => {
16641
16257
  pagedEditorRef.current?.scrollToPosition(from_8);
16642
16258
  });
@@ -16646,56 +16262,56 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16646
16262
  pagedEditorRef.current?.setPassageHighlight(null);
16647
16263
  },
16648
16264
  showInDocument: (target_1, snapshot_5) => {
16649
- const view_28 = pagedEditorRef.current?.getView();
16650
- if (!view_28) return false;
16265
+ const view_26 = pagedEditorRef.current?.getView();
16266
+ if (!view_26) return false;
16651
16267
  const range_3 = target_1.type === "textRange" ? resolveFolioAITextRange({
16652
16268
  range: target_1,
16653
- doc: view_28.state.doc,
16269
+ doc: view_26.state.doc,
16654
16270
  snapshot: snapshot_5
16655
16271
  }) : resolveFolioAIBlockRange({
16656
16272
  blockId: target_1.blockId,
16657
- doc: view_28.state.doc,
16273
+ doc: view_26.state.doc,
16658
16274
  snapshot: snapshot_5
16659
16275
  });
16660
16276
  if (range_3 === null) return false;
16661
16277
  const { from: from_9, to: to_9 } = range_3;
16662
- const $from_2 = view_28.state.doc.resolve(from_9);
16663
- const $to_2 = view_28.state.doc.resolve(to_9);
16664
- view_28.dispatch(view_28.state.tr.setSelection(TextSelection.between($from_2, $to_2)));
16278
+ const $from_2 = view_26.state.doc.resolve(from_9);
16279
+ const $to_2 = view_26.state.doc.resolve(to_9);
16280
+ view_26.dispatch(view_26.state.tr.setSelection(TextSelection.between($from_2, $to_2)));
16665
16281
  requestAnimationFrame(() => {
16666
16282
  pagedEditorRef.current?.scrollToPosition(from_9);
16667
16283
  });
16668
16284
  return true;
16669
16285
  },
16670
16286
  getSuggestions: () => {
16671
- const view_29 = pagedEditorRef.current?.getView();
16672
- return view_29 ? getSuggestions(view_29.state) : [];
16287
+ const view_27 = pagedEditorRef.current?.getView();
16288
+ return view_27 ? getSuggestions(view_27.state) : [];
16673
16289
  },
16674
16290
  exportPendingSuggestions: () => {
16675
- const view_30 = pagedEditorRef.current?.getView();
16676
- const activeIds = new Set(view_30 ? getSuggestions(view_30.state).map((s_3) => s_3.suggestionId) : []);
16291
+ const view_28 = pagedEditorRef.current?.getView();
16292
+ const activeIds = new Set(view_28 ? getSuggestions(view_28.state).map((s_3) => s_3.suggestionId) : []);
16677
16293
  return pendingSuggestionRegistryRef.current.exportPendingSuggestions({
16678
16294
  activeSuggestionIds: activeIds,
16679
- snapshotForStory: (story_0, commentIds) => story_0.type === "main" && view_30 ? createPendingSuggestionSourceSnapshot(view_30.state, commentIds) : null
16295
+ snapshotForStory: (story_0, commentIds) => story_0.type === "main" && view_28 ? createPendingSuggestionSourceSnapshot(view_28.state, commentIds) : null
16680
16296
  });
16681
16297
  },
16682
16298
  loadPendingSuggestions: (records) => pendingSuggestionRegistryRef.current.loadPendingSuggestions({
16683
16299
  records,
16684
16300
  snapshotForStory: (story_1) => {
16685
- const view_31 = pagedEditorRef.current?.getView();
16686
- return story_1.type === "main" && view_31 ? createFolioAIEditSnapshot(view_31.state.doc) : null;
16301
+ const view_29 = pagedEditorRef.current?.getView();
16302
+ return story_1.type === "main" && view_29 ? createFolioAIEditSnapshot(view_29.state.doc) : null;
16687
16303
  },
16688
16304
  sourceSnapshotForStory: (story_2, commentIds_0) => {
16689
- const view_32 = pagedEditorRef.current?.getView();
16690
- return story_2.type === "main" && view_32 ? createPendingSuggestionSourceSnapshot(view_32.state, commentIds_0) : null;
16305
+ const view_30 = pagedEditorRef.current?.getView();
16306
+ return story_2.type === "main" && view_30 ? createPendingSuggestionSourceSnapshot(view_30.state, commentIds_0) : null;
16691
16307
  },
16692
16308
  apply: (record, snapshot_6) => {
16693
- const view_33 = pagedEditorRef.current?.getView();
16694
- if (!view_33) return {
16309
+ const view_31 = pagedEditorRef.current?.getView();
16310
+ if (!view_31) return {
16695
16311
  applied: [],
16696
16312
  skipped: []
16697
16313
  };
16698
- const canonical_5 = getCanonicalApi()?.applyCanonicalDocumentOperations({
16314
+ const canonical_3 = getCanonicalApi()?.applyCanonicalDocumentOperations({
16699
16315
  undefinedReferences: "refuse",
16700
16316
  snapshot: snapshot_6,
16701
16317
  batch: {
@@ -16705,11 +16321,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16705
16321
  },
16706
16322
  author: record.author
16707
16323
  });
16708
- if (canonical_5) return canonical_5;
16324
+ if (canonical_3) return canonical_3;
16709
16325
  const createdComments_1 = [];
16710
16326
  const result_4 = applyFolioDocumentOperations({
16711
16327
  undefinedReferences: "refuse",
16712
- view: recordingCommentsView(view_33, createdComments_1),
16328
+ view: recordingCommentsView(view_31, createdComments_1),
16713
16329
  snapshot: snapshot_6,
16714
16330
  batch: {
16715
16331
  version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
@@ -16729,78 +16345,78 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16729
16345
  };
16730
16346
  },
16731
16347
  activeSuggestionIds: () => {
16732
- const view_34 = pagedEditorRef.current?.getView();
16733
- return new Set(view_34 ? getSuggestions(view_34.state).map((s_4) => s_4.suggestionId) : []);
16348
+ const view_32 = pagedEditorRef.current?.getView();
16349
+ return new Set(view_32 ? getSuggestions(view_32.state).map((s_4) => s_4.suggestionId) : []);
16734
16350
  }
16735
16351
  }),
16736
16352
  acceptSuggestion: (suggestionId, options_4) => {
16737
- const view_35 = pagedEditorRef.current?.getView();
16738
- if (!view_35) return {
16353
+ const view_33 = pagedEditorRef.current?.getView();
16354
+ if (!view_33) return {
16739
16355
  accepted: false,
16740
16356
  appliedAs: null
16741
16357
  };
16742
- const appliedAs = getSuggestions(view_35.state).find((s_5) => s_5.suggestionId === suggestionId)?.appliedAs ?? null;
16743
- const editor_7 = pagedEditorRef.current?.getEditor();
16744
- const accepted = editor_7?.getCanonicalDocument() ? editor_7.resolveCanonicalSuggestion(suggestionId, "accept", options_4?.author ?? author) : acceptSuggestion(suggestionId, { author: options_4?.author ?? author })(view_35.state, view_35.dispatch);
16358
+ const appliedAs = getSuggestions(view_33.state).find((s_5) => s_5.suggestionId === suggestionId)?.appliedAs ?? null;
16359
+ const editor_6 = pagedEditorRef.current?.getEditor();
16360
+ const accepted = editor_6?.getCanonicalDocument() ? editor_6.resolveCanonicalSuggestion(suggestionId, "accept", options_4?.author ?? author) : acceptSuggestion(suggestionId, { author: options_4?.author ?? author })(view_33.state, view_33.dispatch);
16745
16361
  return {
16746
16362
  accepted,
16747
16363
  appliedAs: accepted ? appliedAs : null
16748
16364
  };
16749
16365
  },
16750
16366
  rejectSuggestion: (suggestionId_0) => {
16751
- const view_36 = pagedEditorRef.current?.getView();
16752
- if (!view_36) return false;
16753
- const editor_8 = pagedEditorRef.current?.getEditor();
16754
- if (editor_8?.getCanonicalDocument()) return editor_8.resolveCanonicalSuggestion(suggestionId_0, "reject", author);
16755
- return rejectSuggestion(suggestionId_0)(view_36.state, view_36.dispatch);
16367
+ const view_34 = pagedEditorRef.current?.getView();
16368
+ if (!view_34) return false;
16369
+ const editor_7 = pagedEditorRef.current?.getEditor();
16370
+ if (editor_7?.getCanonicalDocument()) return editor_7.resolveCanonicalSuggestion(suggestionId_0, "reject", author);
16371
+ return rejectSuggestion(suggestionId_0)(view_34.state, view_34.dispatch);
16756
16372
  },
16757
16373
  scrollToSuggestion: (suggestionId_1) => {
16758
- const view_37 = pagedEditorRef.current?.getView();
16759
- if (!view_37) return false;
16760
- const range_4 = findSuggestionRange(view_37.state, suggestionId_1);
16374
+ const view_35 = pagedEditorRef.current?.getView();
16375
+ if (!view_35) return false;
16376
+ const range_4 = findSuggestionRange(view_35.state, suggestionId_1);
16761
16377
  if (!range_4) return false;
16762
- const { from: from_10, to: to_10 } = clampRangeToDocSize(view_37.state.doc.content.size, range_4);
16763
- const $from_3 = view_37.state.doc.resolve(from_10);
16764
- const $to_3 = view_37.state.doc.resolve(to_10);
16765
- view_37.dispatch(view_37.state.tr.setSelection(TextSelection.between($from_3, $to_3)));
16378
+ const { from: from_10, to: to_10 } = clampRangeToDocSize(view_35.state.doc.content.size, range_4);
16379
+ const $from_3 = view_35.state.doc.resolve(from_10);
16380
+ const $to_3 = view_35.state.doc.resolve(to_10);
16381
+ view_35.dispatch(view_35.state.tr.setSelection(TextSelection.between($from_3, $to_3)));
16766
16382
  requestAnimationFrame(() => {
16767
16383
  pagedEditorRef.current?.scrollToPosition(from_10);
16768
16384
  });
16769
16385
  return true;
16770
16386
  },
16771
16387
  getTrackedChanges: () => {
16772
- const view_38 = pagedEditorRef.current?.getView();
16773
- return view_38 ? getTrackedChangesFromDoc(view_38.state.doc) : [];
16388
+ const view_36 = pagedEditorRef.current?.getView();
16389
+ return view_36 ? getTrackedChangesFromDoc(view_36.state.doc) : [];
16774
16390
  },
16775
16391
  getCommentAnchors: () => {
16776
- const view_39 = pagedEditorRef.current?.getView();
16777
- return view_39 ? getCommentAnchorsFromDoc(view_39.state.doc) : [];
16392
+ const view_37 = pagedEditorRef.current?.getView();
16393
+ return view_37 ? getCommentAnchorsFromDoc(view_37.state.doc) : [];
16778
16394
  },
16779
16395
  getSelectionText: () => {
16780
- const view_40 = pagedEditorRef.current?.getView();
16781
- return view_40 ? getSelectedText(view_40.state) : "";
16396
+ const view_38 = pagedEditorRef.current?.getView();
16397
+ return view_38 ? getSelectedText(view_38.state) : "";
16782
16398
  },
16783
16399
  getPageText: (page_0) => {
16784
- const view_41 = pagedEditorRef.current?.getView();
16785
- if (!view_41) return null;
16400
+ const view_39 = pagedEditorRef.current?.getView();
16401
+ if (!view_39) return null;
16786
16402
  const layout_0 = pagedEditorRef.current?.getEditor()?.getLayout() ?? null;
16787
16403
  return getPageTextFromLayout({
16788
16404
  layout: layout_0,
16789
- doc: view_41.state.doc,
16405
+ doc: view_39.state.doc,
16790
16406
  page: page_0,
16791
- projection: projectMarkupView(view_41.state, displayMode)
16407
+ projection: projectMarkupView(view_39.state, displayMode)
16792
16408
  });
16793
16409
  },
16794
16410
  getTargetPage: (target_2, snapshot_7) => {
16795
- const view_42 = pagedEditorRef.current?.getView();
16796
- if (!view_42) return null;
16411
+ const view_40 = pagedEditorRef.current?.getView();
16412
+ if (!view_40) return null;
16797
16413
  const range_5 = target_2.type === "textRange" ? resolveFolioAITextRange({
16798
16414
  range: target_2,
16799
- doc: view_42.state.doc,
16415
+ doc: view_40.state.doc,
16800
16416
  snapshot: snapshot_7
16801
16417
  }) : resolveFolioAIBlockRange({
16802
16418
  blockId: target_2.blockId,
16803
- doc: view_42.state.doc,
16419
+ doc: view_40.state.doc,
16804
16420
  snapshot: snapshot_7
16805
16421
  });
16806
16422
  const layout_1 = pagedEditorRef.current?.getEditor()?.getLayout() ?? null;
@@ -16816,49 +16432,49 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16816
16432
  getScrollRoot: () => pagedEditorRef.current?.getScrollRoot() ?? null,
16817
16433
  onLayoutChange: (listener) => pagedEditorRef.current?.onLayoutChange(listener) ?? (() => {}),
16818
16434
  getContentControls: (filter = {}) => {
16819
- const view_43 = pagedEditorRef.current?.getView();
16820
- if (!view_43) return [];
16821
- return findBlockSdtMatches(view_43.state.doc, filter).map((match_0) => ({
16435
+ const view_41 = pagedEditorRef.current?.getView();
16436
+ if (!view_41) return [];
16437
+ return findBlockSdtMatches(view_41.state.doc, filter).map((match_0) => ({
16822
16438
  properties: blockSdtAttrsToSdtProperties(match_0.node),
16823
16439
  path: match_0.path,
16824
16440
  pmPos: match_0.pos
16825
16441
  }));
16826
16442
  },
16827
16443
  scrollToContentControl: (filter_0) => {
16828
- const view_44 = pagedEditorRef.current?.getView();
16829
- if (!view_44) return false;
16830
- const match_1 = findBlockSdtMatch(view_44.state.doc, filter_0);
16444
+ const view_42 = pagedEditorRef.current?.getView();
16445
+ if (!view_42) return false;
16446
+ const match_1 = findBlockSdtMatch(view_42.state.doc, filter_0);
16831
16447
  if (!match_1) return false;
16832
16448
  const inside = match_1.pos + 1;
16833
- const $pos = view_44.state.doc.resolve(inside);
16834
- view_44.dispatch(view_44.state.tr.setSelection(TextSelection.near($pos)));
16449
+ const $pos = view_42.state.doc.resolve(inside);
16450
+ view_42.dispatch(view_42.state.tr.setSelection(TextSelection.near($pos)));
16835
16451
  requestAnimationFrame(() => {
16836
16452
  pagedEditorRef.current?.scrollToPosition(inside);
16837
16453
  });
16838
16454
  return true;
16839
16455
  },
16840
16456
  setContentControlContent: (filter_1, input, options_5 = {}) => {
16841
- const view_45 = pagedEditorRef.current?.getView();
16842
- if (!view_45) return false;
16843
- const tr_0 = typeof input === "string" ? setContentControlContentTr(view_45.state, filter_1, input, options_5) : setContentControlContentBlocksTr(view_45.state, filter_1, input, options_5);
16457
+ const view_43 = pagedEditorRef.current?.getView();
16458
+ if (!view_43) return false;
16459
+ const tr_0 = typeof input === "string" ? setContentControlContentTr(view_43.state, filter_1, input, options_5) : setContentControlContentBlocksTr(view_43.state, filter_1, input, options_5);
16844
16460
  if (!tr_0) return false;
16845
- view_45.dispatch(tr_0);
16461
+ view_43.dispatch(tr_0);
16846
16462
  return true;
16847
16463
  },
16848
16464
  setContentControlValue: (filter_2, input_0, options_6 = {}) => {
16849
- const view_46 = pagedEditorRef.current?.getView();
16850
- if (!view_46) return false;
16851
- const tr_1 = setContentControlValueTr(view_46.state, filter_2, input_0, options_6);
16465
+ const view_44 = pagedEditorRef.current?.getView();
16466
+ if (!view_44) return false;
16467
+ const tr_1 = setContentControlValueTr(view_44.state, filter_2, input_0, options_6);
16852
16468
  if (!tr_1) return false;
16853
- view_46.dispatch(tr_1);
16469
+ view_44.dispatch(tr_1);
16854
16470
  return true;
16855
16471
  },
16856
16472
  removeContentControl: (filter_3, options_7 = {}) => {
16857
- const view_47 = pagedEditorRef.current?.getView();
16858
- if (!view_47) return false;
16859
- const tr_2 = removeContentControlTr(view_47.state, filter_3, options_7);
16473
+ const view_45 = pagedEditorRef.current?.getView();
16474
+ if (!view_45) return false;
16475
+ const tr_2 = removeContentControlTr(view_45.state, filter_3, options_7);
16860
16476
  if (!tr_2) return false;
16861
- view_47.dispatch(tr_2);
16477
+ view_45.dispatch(tr_2);
16862
16478
  return true;
16863
16479
  }
16864
16480
  }), [
@@ -16888,28 +16504,13 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16888
16504
  commentsRef,
16889
16505
  getCommentsDirty,
16890
16506
  getActiveEditorStory,
16891
- refreshBodyHistoryAvailability,
16892
- experimentalSession
16507
+ refreshBodyHistoryAvailability
16893
16508
  ]);
16894
16509
  const displayModeItems = useMemo(() => DISPLAY_MODES.map((mode_0) => ({
16895
16510
  value: mode_0,
16896
16511
  label: t(DISPLAY_MODE_LABEL_KEYS[mode_0])
16897
16512
  })), [t]);
16898
- const activeHistoryAvailability = (() => {
16899
- if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return {
16900
- canRedo: bodyHistoryAvailability.canRedo,
16901
- canUndo: bodyHistoryAvailability.canUndo
16902
- };
16903
- if (activeNoteStory) return {
16904
- canRedo: bodyHistoryAvailability.canRedo,
16905
- canUndo: bodyHistoryAvailability.canUndo
16906
- };
16907
- if (hfEditPosition) return {
16908
- canRedo: history.canRedo,
16909
- canUndo: history.canUndo
16910
- };
16911
- return bodyHistoryAvailability;
16912
- })();
16513
+ const activeHistoryAvailability = bodyHistoryAvailability;
16913
16514
  const toolbarChildren = toolbarExtra ?? null;
16914
16515
  const visibleCommentAuthorCount = commentAuthors.filter((commentAuthor) => visibleCommentAuthorSet.has(commentAuthor)).length;
16915
16516
  const allCommentAuthorsVisible = commentAuthors.length > 0 && showCommentsSidebar && visibleCommentAuthorCount === commentAuthors.length;
@@ -16951,47 +16552,47 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
16951
16552
  if (isDisplayMode(value)) setDisplayMode(value);
16952
16553
  }, [setDisplayMode]);
16953
16554
  const handleAcceptActiveChange = useCallback(() => {
16954
- const view_48 = pagedEditorRef.current?.getView();
16955
- if (!view_48) return;
16956
- const { from: from_11, to: to_11 } = view_48.state.selection;
16957
- const range_6 = findChangeAtPosition(view_48.state, from_11, to_11);
16555
+ const view_46 = pagedEditorRef.current?.getView();
16556
+ if (!view_46) return;
16557
+ const { from: from_11, to: to_11 } = view_46.state.selection;
16558
+ const range_6 = findChangeAtPosition(view_46.state, from_11, to_11);
16958
16559
  if (resolveCanonicalReviewRange({
16959
16560
  editor: pagedEditorRef.current?.getEditor(),
16960
16561
  ...range_6,
16961
16562
  resolution: "accept"
16962
- }) === null) acceptChange(range_6.from, range_6.to)(view_48.state, view_48.dispatch);
16563
+ }) === null) acceptChange(range_6.from, range_6.to)(view_46.state, view_46.dispatch);
16963
16564
  }, []);
16964
16565
  const handleRejectActiveChange = useCallback(() => {
16965
- const view_49 = pagedEditorRef.current?.getView();
16966
- if (!view_49) return;
16967
- const { from: from_12, to: to_12 } = view_49.state.selection;
16968
- const range_7 = findChangeAtPosition(view_49.state, from_12, to_12);
16566
+ const view_47 = pagedEditorRef.current?.getView();
16567
+ if (!view_47) return;
16568
+ const { from: from_12, to: to_12 } = view_47.state.selection;
16569
+ const range_7 = findChangeAtPosition(view_47.state, from_12, to_12);
16969
16570
  if (resolveCanonicalReviewRange({
16970
16571
  editor: pagedEditorRef.current?.getEditor(),
16971
16572
  ...range_7,
16972
16573
  resolution: "reject"
16973
- }) === null) rejectChange(range_7.from, range_7.to)(view_49.state, view_49.dispatch);
16574
+ }) === null) rejectChange(range_7.from, range_7.to)(view_47.state, view_47.dispatch);
16974
16575
  }, []);
16975
16576
  const handlePreviousChange = useCallback(() => {
16976
- const view_50 = pagedEditorRef.current?.getView();
16977
- if (!view_50) return;
16978
- const { from: from_13 } = view_50.state.selection;
16979
- const change_0 = findPreviousChange(view_50.state, from_13);
16577
+ const view_48 = pagedEditorRef.current?.getView();
16578
+ if (!view_48) return;
16579
+ const { from: from_13 } = view_48.state.selection;
16580
+ const change_0 = findPreviousChange(view_48.state, from_13);
16980
16581
  if (!change_0) return;
16981
- view_50.dispatch(view_50.state.tr.setSelection(TextSelection.create(view_50.state.doc, change_0.from, change_0.to)));
16982
- view_50.focus();
16582
+ view_48.dispatch(view_48.state.tr.setSelection(TextSelection.create(view_48.state.doc, change_0.from, change_0.to)));
16583
+ view_48.focus();
16983
16584
  requestAnimationFrame(() => {
16984
16585
  pagedEditorRef.current?.scrollToPosition(change_0.from);
16985
16586
  });
16986
16587
  }, []);
16987
16588
  const handleNextChange = useCallback(() => {
16988
- const view_51 = pagedEditorRef.current?.getView();
16989
- if (!view_51) return;
16990
- const { to: to_13 } = view_51.state.selection;
16991
- const change_1 = findNextChange(view_51.state, to_13);
16589
+ const view_49 = pagedEditorRef.current?.getView();
16590
+ if (!view_49) return;
16591
+ const { to: to_13 } = view_49.state.selection;
16592
+ const change_1 = findNextChange(view_49.state, to_13);
16992
16593
  if (!change_1) return;
16993
- view_51.dispatch(view_51.state.tr.setSelection(TextSelection.create(view_51.state.doc, change_1.from, change_1.to)));
16994
- view_51.focus();
16594
+ view_49.dispatch(view_49.state.tr.setSelection(TextSelection.create(view_49.state.doc, change_1.from, change_1.to)));
16595
+ view_49.focus();
16995
16596
  requestAnimationFrame(() => {
16996
16597
  pagedEditorRef.current?.scrollToPosition(change_1.from);
16997
16598
  });
@@ -17161,8 +16762,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17161
16762
  requestAnimationFrame(syncCommentHighlightStyles);
17162
16763
  }, [onScrollTopChange, syncCommentHighlightStyles]);
17163
16764
  const handlePagedSelectionChange = useCallback((_from, _to) => {
17164
- const view_52 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
17165
- handleSelectionChange(view_52 ? extractSelectionState(view_52.state) : null);
16765
+ const view_50 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
16766
+ handleSelectionChange(view_50 ? extractSelectionState(view_50.state) : null);
17166
16767
  }, [getActiveEditorView, handleSelectionChange]);
17167
16768
  const handleTotalPagesChange = useCallback((totalPages) => {
17168
16769
  setScrollPageInfo((previous_0) => updateScrollPageTotal(previous_0, totalPages));
@@ -17201,10 +16802,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17201
16802
  notifyReadonlyEditAttempt();
17202
16803
  return;
17203
16804
  }
17204
- const view_53 = pagedEditorRef.current?.getView();
17205
- if (view_53 && commentRecordsOf(view_53.state) !== null) {
17206
- const deleted = deleteCommentThread(view_53.state, id_2);
17207
- if (deleted) view_53.dispatch(deleted);
16805
+ const view_51 = pagedEditorRef.current?.getView();
16806
+ if (view_51 && commentRecordsOf(view_51.state) !== null) {
16807
+ const deleted = deleteCommentThread(view_51.state, id_2);
16808
+ if (deleted) view_51.dispatch(deleted);
17208
16809
  } else {
17209
16810
  const thread = commentThreadIds(commentsRef.current, id_2);
17210
16811
  updateComments((previous_2) => previous_2.filter((comment_3) => !thread.has(comment_3.id)));
@@ -17243,8 +16844,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17243
16844
  updateComments
17244
16845
  ]);
17245
16846
  const handleAddComment = useCallback((addText) => {
17246
- const view_54 = pagedEditorRef.current?.getView();
17247
- if (!view_54 || !commentSelectionRange) return false;
16847
+ const view_52 = pagedEditorRef.current?.getView();
16848
+ if (!view_52 || !commentSelectionRange) return false;
17248
16849
  const result_6 = applyCanonicalComment({
17249
16850
  type: "create",
17250
16851
  text: addText,
@@ -17257,9 +16858,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17257
16858
  });
17258
16859
  if (result_6 !== null) {
17259
16860
  if (result_6?.status !== "applied") return false;
17260
- setVisibleCommentAuthors((current_1) => {
17261
- if (current_1 === null) return null;
17262
- const next_1 = new Set(current_1);
16861
+ setVisibleCommentAuthors((current_0) => {
16862
+ if (current_0 === null) return null;
16863
+ const next_1 = new Set(current_0);
17263
16864
  const created = result_6.comments.find(({ id: id_4 }) => id_4 === result_6.commentId);
17264
16865
  if (created) next_1.add(getCommentAuthorKey(created.author));
17265
16866
  return next_1;
@@ -17275,11 +16876,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17275
16876
  return false;
17276
16877
  }
17277
16878
  const comment_4 = createComment(addText, author);
17278
- if (!commitCommentThread(view_54, commentSelectionRange, comment_4)) return false;
16879
+ if (!commitCommentThread(view_52, commentSelectionRange, comment_4)) return false;
17279
16880
  const commentAuthor_2 = getCommentAuthorKey(comment_4.author);
17280
- setVisibleCommentAuthors((current_2) => {
17281
- if (current_2 === null) return null;
17282
- const next_2 = new Set(current_2);
16881
+ setVisibleCommentAuthors((current_1) => {
16882
+ if (current_1 === null) return null;
16883
+ const next_2 = new Set(current_1);
17283
16884
  next_2.add(commentAuthor_2);
17284
16885
  return next_2;
17285
16886
  });
@@ -17332,14 +16933,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17332
16933
  updateComments
17333
16934
  ]);
17334
16935
  const handleCancelAddComment = useCallback(() => {
17335
- const view_55 = pagedEditorRef.current?.getView();
17336
- if (view_55 && commentSelectionRange && commentDraftMode === "prosemirror") clearPendingComment(view_55, commentSelectionRange);
17337
16936
  setIsAddingComment(false);
17338
16937
  setCommentSelectionRange(null);
17339
16938
  setAddCommentYPosition(null);
17340
16939
  }, [
17341
- commentSelectionRange,
17342
- commentDraftMode,
17343
16940
  setAddCommentYPosition,
17344
16941
  setCommentSelectionRange,
17345
16942
  setIsAddingComment
@@ -17350,23 +16947,23 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17350
16947
  })?.revisionId ?? null;
17351
16948
  }, []);
17352
16949
  const handleSidebarAcceptChange = useCallback((from_15, to_15) => {
17353
- const view_56 = pagedEditorRef.current?.getView();
17354
- if (!view_56) return;
16950
+ const view_53 = pagedEditorRef.current?.getView();
16951
+ if (!view_53) return;
17355
16952
  const revisionId_3 = resolveSidebarChangeRevisionId(from_15, to_15);
17356
16953
  if (revisionId_3 === null) return;
17357
- const editor_9 = pagedEditorRef.current?.getEditor();
17358
- if (editor_9?.getCanonicalDocument()) editor_9.resolveCanonicalRevisions([revisionId_3], "accept");
17359
- else acceptAIEditRevision(revisionId_3)(view_56.state, view_56.dispatch);
16954
+ const editor_8 = pagedEditorRef.current?.getEditor();
16955
+ if (editor_8?.getCanonicalDocument()) editor_8.resolveCanonicalRevisions([revisionId_3], "accept");
16956
+ else acceptAIEditRevision(revisionId_3)(view_53.state, view_53.dispatch);
17360
16957
  extractTrackedChanges();
17361
16958
  }, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
17362
16959
  const handleSidebarRejectChange = useCallback((from_16, to_16) => {
17363
- const view_57 = pagedEditorRef.current?.getView();
17364
- if (!view_57) return;
16960
+ const view_54 = pagedEditorRef.current?.getView();
16961
+ if (!view_54) return;
17365
16962
  const revisionId_4 = resolveSidebarChangeRevisionId(from_16, to_16);
17366
16963
  if (revisionId_4 === null) return;
17367
- const editor_10 = pagedEditorRef.current?.getEditor();
17368
- if (editor_10?.getCanonicalDocument()) editor_10.resolveCanonicalRevisions([revisionId_4], "reject");
17369
- else rejectAIEditRevision(revisionId_4)(view_57.state, view_57.dispatch);
16964
+ const editor_9 = pagedEditorRef.current?.getEditor();
16965
+ if (editor_9?.getCanonicalDocument()) editor_9.resolveCanonicalRevisions([revisionId_4], "reject");
16966
+ else rejectAIEditRevision(revisionId_4)(view_54.state, view_54.dispatch);
17370
16967
  extractTrackedChanges();
17371
16968
  }, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
17372
16969
  const commentsPageWidth = history.state?.package.document.finalSectionProperties?.pageWidth;
@@ -17519,8 +17116,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17519
17116
  }, [readOnly]);
17520
17117
  const closeTableProperties = useCallback(() => setTablePropsOpen(false), []);
17521
17118
  const applyTableProperties = useCallback((props_0) => {
17522
- const view_58 = getActiveEditorView();
17523
- if (view_58) executeEditorCommand(view_58, setTableProperties(props_0));
17119
+ const view_55 = getActiveEditorView();
17120
+ if (view_55) executeEditorCommand(view_55, setTableProperties(props_0));
17524
17121
  }, [getActiveEditorView]);
17525
17122
  const closeImagePosition = useCallback(() => setImagePositionOpen(false), [setImagePositionOpen]);
17526
17123
  const closeImageProperties = useCallback(() => setImagePropsOpen(false), [setImagePropsOpen]);
@@ -17528,8 +17125,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17528
17125
  const closeFootnoteProperties = useCallback(() => setFootnotePropsOpen(false), []);
17529
17126
  const closeInsertSymbol = useCallback(() => setShowInsertSymbol(false), []);
17530
17127
  const insertSymbol = useCallback((symbol) => {
17531
- const view_59 = getActiveEditorView();
17532
- if (view_59) view_59.dispatch(view_59.state.tr.insertText(symbol).scrollIntoView());
17128
+ const view_56 = getActiveEditorView();
17129
+ if (view_56) view_56.dispatch(view_56.state.tr.insertText(symbol).scrollIntoView());
17533
17130
  }, [getActiveEditorView]);
17534
17131
  const imagePropertiesCurrentData = useMemo(() => buildImagePropertiesData(state.pmImageContext), [state.pmImageContext]);
17535
17132
  const { close: closeFindDialog } = findReplace;
@@ -17620,8 +17217,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17620
17217
  ]);
17621
17218
  const closeNumberingValueDialog = useCallback(() => setNumberingValueDialogOpen(false), []);
17622
17219
  const applyNumberingValue = useCallback((value_0) => {
17623
- const view_60 = getActiveEditorView();
17624
- if (view_60) executeEditorCommand(view_60, setNumberingValue(value_0));
17220
+ const view_57 = getActiveEditorView();
17221
+ if (view_57) executeEditorCommand(view_57, setNumberingValue(value_0));
17625
17222
  }, [getActiveEditorView]);
17626
17223
  const numberingValueDialog = useMemo(() => ({
17627
17224
  isOpen: numberingValueDialogOpen,
@@ -17889,7 +17486,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17889
17486
  showMarginGuides,
17890
17487
  ...marginGuideColor !== void 0 ? { marginGuideColor } : {},
17891
17488
  readOnly,
17892
- experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
17893
17489
  onDocumentChange: applyDocumentChange,
17894
17490
  extensionManager,
17895
17491
  suggestionModeActive: editingMode === "suggesting",
@@ -17903,7 +17499,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17903
17499
  onEditorViewReady: handleBodyViewReady,
17904
17500
  externalPlugins: editorPlugins,
17905
17501
  showTemplateDirectives,
17906
- ...yjsCollaboration !== void 0 ? { collaboration: yjsCollaboration } : {},
17907
17502
  ...canonicalRoom !== void 0 ? { canonicalRoom } : {},
17908
17503
  onHyperlinkClick: handleHyperlinkClick,
17909
17504
  onContextMenu: handleContextMenu,
@@ -17932,8 +17527,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17932
17527
  onMouseDown: (e_1) => {
17933
17528
  e_1.preventDefault();
17934
17529
  e_1.stopPropagation();
17935
- const view_61 = pagedEditorRef.current?.getView();
17936
- if (!view_61) {
17530
+ const view_58 = pagedEditorRef.current?.getView();
17531
+ if (!view_58) {
17937
17532
  setFloatingCommentBtn(null);
17938
17533
  return;
17939
17534
  }
@@ -17941,9 +17536,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17941
17536
  from: floatingCommentBtn.from,
17942
17537
  to: floatingCommentBtn.to
17943
17538
  };
17944
- const currentSelection = view_61.state.selection;
17539
+ const currentSelection = view_58.state.selection;
17945
17540
  const safeRange = resolveCommentCreationRange({
17946
- docSize: view_61.state.doc.content.size,
17541
+ docSize: view_58.state.doc.content.size,
17947
17542
  capturedRange,
17948
17543
  currentRange: {
17949
17544
  from: currentSelection.from,
@@ -17957,13 +17552,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
17957
17552
  return;
17958
17553
  }
17959
17554
  setCommentSelectionRange(safeRange);
17960
- if (commentDraftMode === "prosemirror") {
17961
- if (!markPendingComment(view_61, safeRange, { selectEnd: true })) {
17962
- setCommentSelectionRange(null);
17963
- setFloatingCommentBtn(null);
17964
- return;
17965
- }
17966
- }
17967
17555
  const yPos_0 = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, safeRange.from);
17968
17556
  setAddCommentYPosition(yPos_0 ?? floatingCommentBtn.top);
17969
17557
  setShowCommentsSidebar(true);