@stll/folio-react 0.35.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.
- package/README.md +2 -2
- package/dist/{CommentsSidebar-l092CpvD.js → CommentsSidebar-CjRWDQe6.js} +1 -1
- package/dist/compat/eigenpal.d.ts +1 -1
- package/dist/compat/eigenpal.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/{renderAsync-Ddsn6AyR.d.ts → renderAsync-BxzAiwBg.d.ts} +17 -29
- package/dist/{renderAsync-CeGgJz8j.js → renderAsync-oOJytPjH.js} +597 -995
- package/package.json +2 -4
|
@@ -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,
|
|
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,14 +34,12 @@ 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 {
|
|
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 {
|
|
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
45
|
import { createSuggestionModePlugin, setSuggestionMode, suggestionModeKey } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
|
|
@@ -52,7 +47,7 @@ import { createTemplateDirectivesPlugin, templateDirectivesKey } from "@stll/fol
|
|
|
52
47
|
import { createTemplatePreviewValuesPlugin, templatePreviewValuesKey } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
|
|
53
48
|
import { getTemplateSlashMenu, templateSlashMenuPlugin } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
|
|
54
49
|
import { getFolioParaIdFromBlockId } from "@stll/folio-core/types/block-id";
|
|
55
|
-
import { CANONICAL_GAP, canonicalRefusalMessage, canonicalRefusalNotice
|
|
50
|
+
import { CANONICAL_GAP, canonicalRefusalMessage, canonicalRefusalNotice } from "@stll/folio-core/types/canonicalCapabilities";
|
|
56
51
|
import { readModel, writableCopy } from "@stll/folio-core/types/documentModel";
|
|
57
52
|
import { canonicalJson } from "@stll/folio-core/utils/canonicalJson";
|
|
58
53
|
import { resolveColor } from "@stll/folio-core/utils/colorResolver";
|
|
@@ -108,20 +103,20 @@ import { FOLIO_INPUT_HIDDEN_ATTRIBUTE } from "@stll/folio-core/paged-layout/sele
|
|
|
108
103
|
import { resizeColumnPair } from "@stll/folio-core/paged-layout/tableColumnResize";
|
|
109
104
|
import { tableInsertButtonOffset } from "@stll/folio-core/paged-layout/tableInsertButtonGeometry";
|
|
110
105
|
import { commitImageFloatMove, commitImageInlineMove, commitImageResize, isFloatingImage } from "@stll/folio-core/prosemirror/imageCommit";
|
|
106
|
+
import { createNoteReferenceFollower } from "@stll/folio-core/prosemirror/noteReferenceReview";
|
|
111
107
|
import { singletonManager } from "@stll/folio-core/prosemirror/schema";
|
|
112
108
|
import { MIN_ROW_HEIGHT_TWIPS, clampRowResizeDelta, columnResizeCommand, rightEdgeResizeCommand, rowResizeCommand } from "@stll/folio-core/prosemirror/tableResize";
|
|
113
|
-
import { dispatchEditorTextInput } from "@stll/folio-core/prosemirror/textInput";
|
|
114
109
|
import { findStartPosForParaId } from "@stll/folio-core/prosemirror/utils/findParagraphByParaId";
|
|
115
110
|
import { resolveHeaderFooterSelectionGeometry } from "@stll/folio-core/render-dom/HeaderFooterSelectionOverlay";
|
|
116
|
-
import {
|
|
111
|
+
import { pickActiveHeaderFooterRId, resolveEffectiveSectionProperties, resolveHeaderFooterContent } from "@stll/folio-core/utils/headerFooter";
|
|
117
112
|
import { createHeaderFooterEditorManager } from "@stll/folio-core/controller/headerFooterEditorManager";
|
|
118
113
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
119
114
|
import { createNoteEditorManager } from "@stll/folio-core/controller/noteEditorManager";
|
|
120
115
|
import { buildEmbeddedFontFamilyMap, extractEmbeddedFonts } from "@stll/folio-core/fonts/embeddedFonts";
|
|
121
|
-
import { loadCollaborationModules } from "@stll/folio-core/controller/collaborationModules";
|
|
122
116
|
import { calculateResizedImageDimensions } from "@stll/folio-core/utils/imageResize";
|
|
123
117
|
import "@stll/folio-core/layout-bridge/engine/selectionRects";
|
|
124
118
|
import { createVisualLineState, handleVisualLineKeyDown } from "@stll/folio-core/prosemirror/utils/visualLineNavigation";
|
|
119
|
+
import { getCommentParentId, getCommentParentId as getCommentParentId$1 } from "@stll/folio-core/docx/hostCommentThreads";
|
|
125
120
|
import { ContentControlWidgetController, contentControlRefusalMessageKey } from "@stll/folio-core/controller/contentControlWidgetController";
|
|
126
121
|
import { createDefaultFindOptions, replaceEligibility } from "@stll/folio-core/utils/findReplace";
|
|
127
122
|
import { PANEL_METRICS, computePanelLayout, overlayAfterLayout, requestedOutline } from "@stll/folio-core/panel-layout";
|
|
@@ -691,37 +686,28 @@ const HOST_STYLES = {
|
|
|
691
686
|
zIndex: -1,
|
|
692
687
|
pointerEvents: "none"
|
|
693
688
|
};
|
|
694
|
-
const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ document, readOnly, styles,
|
|
689
|
+
const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ document, readOnly, styles, onTransaction, getCanonicalApi, readCanonicalDocument, onSessionRefusal }, ref) {
|
|
695
690
|
const hostRef = useRef(null);
|
|
696
|
-
const documentRef = useRef(document);
|
|
697
691
|
const readOnlyRef = useRef(readOnly);
|
|
698
692
|
const stylesRef = useRef(styles);
|
|
699
|
-
const themeRef = useRef(theme);
|
|
700
693
|
const onTransactionRef = useRef(onTransaction);
|
|
701
694
|
const canonicalApiRef = useRef(getCanonicalApi);
|
|
702
695
|
const readCanonicalDocumentRef = useRef(readCanonicalDocument);
|
|
703
|
-
const sessionRef = useRef(experimentalSession);
|
|
704
696
|
const refusalRef = useRef(onSessionRefusal);
|
|
705
697
|
const managerRef = useRef(null);
|
|
706
698
|
useLayoutEffect(() => {
|
|
707
|
-
documentRef.current = document;
|
|
708
699
|
readOnlyRef.current = readOnly;
|
|
709
700
|
stylesRef.current = styles;
|
|
710
|
-
themeRef.current = theme;
|
|
711
701
|
onTransactionRef.current = onTransaction;
|
|
712
702
|
canonicalApiRef.current = getCanonicalApi;
|
|
713
703
|
readCanonicalDocumentRef.current = readCanonicalDocument;
|
|
714
|
-
sessionRef.current = experimentalSession;
|
|
715
704
|
refusalRef.current = onSessionRefusal;
|
|
716
705
|
managerRef.current ??= createHeaderFooterEditorManager({
|
|
717
706
|
getHost: () => hostRef.current,
|
|
718
|
-
getDocument: () => documentRef.current,
|
|
719
707
|
getReadOnly: () => readOnlyRef.current ?? false,
|
|
720
708
|
getStyles: () => stylesRef.current,
|
|
721
|
-
getTheme: () => themeRef.current,
|
|
722
709
|
getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
|
|
723
710
|
readCanonicalDocument: () => readCanonicalDocumentRef.current(),
|
|
724
|
-
getExperimentalSession: () => sessionRef.current,
|
|
725
711
|
onSessionRefusal: (reason, ground, error) => refusalRef.current?.(reason, ground, error),
|
|
726
712
|
onTransaction: ({ rId, kind, view, docChanged, selectionChanged }) => {
|
|
727
713
|
onTransactionRef.current?.(rId, kind, view, docChanged, selectionChanged);
|
|
@@ -732,11 +718,9 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
|
|
|
732
718
|
document,
|
|
733
719
|
readOnly,
|
|
734
720
|
styles,
|
|
735
|
-
theme,
|
|
736
721
|
onTransaction,
|
|
737
722
|
getCanonicalApi,
|
|
738
723
|
readCanonicalDocument,
|
|
739
|
-
experimentalSession,
|
|
740
724
|
onSessionRefusal
|
|
741
725
|
]);
|
|
742
726
|
useEffect(() => () => {
|
|
@@ -745,7 +729,8 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
|
|
|
745
729
|
useImperativeHandle(ref, () => ({
|
|
746
730
|
getHostElement: () => hostRef.current,
|
|
747
731
|
getView: (rId) => managerRef.current?.getView(rId) ?? null,
|
|
748
|
-
listSlots: () => managerRef.current?.listSlots() ?? []
|
|
732
|
+
listSlots: () => managerRef.current?.listSlots() ?? [],
|
|
733
|
+
sync: () => managerRef.current?.sync()
|
|
749
734
|
}), []);
|
|
750
735
|
return /* @__PURE__ */ jsx("div", {
|
|
751
736
|
ref: hostRef,
|
|
@@ -786,57 +771,41 @@ const hostStyle = {
|
|
|
786
771
|
padding: "12px 16px",
|
|
787
772
|
minHeight: 72
|
|
788
773
|
};
|
|
789
|
-
const EMPTY_PLUGINS$1 = [];
|
|
790
774
|
const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
791
|
-
const $ = c(
|
|
792
|
-
const { document,
|
|
775
|
+
const $ = c(50);
|
|
776
|
+
const { document, getCanonicalApi, readCanonicalDocument, onSessionRefusal, onActiveChange, onDocumentChange, onStoryChange, styles, suggestionAuthor, suggestionModeActive } = t0;
|
|
793
777
|
const t = useTranslations("folio");
|
|
794
|
-
const resolvedPlugins = plugins ?? EMPTY_PLUGINS$1;
|
|
795
778
|
const isSuggestionModeActive = suggestionModeActive ?? false;
|
|
796
779
|
const hostRef = useRef(null);
|
|
797
|
-
const documentRef = useRef(document);
|
|
798
780
|
const canonicalApiRef = useRef(getCanonicalApi);
|
|
799
781
|
const readCanonicalDocumentRef = useRef(readCanonicalDocument);
|
|
800
|
-
const sessionRef = useRef(experimentalSession);
|
|
801
782
|
const refusalRef = useRef(onSessionRefusal);
|
|
802
783
|
const stylesRef = useRef(styles);
|
|
803
|
-
const themeRef = useRef(theme);
|
|
804
|
-
const pluginsRef = useRef(resolvedPlugins);
|
|
805
784
|
const onDocumentChangeRef = useRef(onDocumentChange);
|
|
806
785
|
const onActiveChangeRef = useRef(onActiveChange);
|
|
807
786
|
const onStoryChangeRef = useRef(onStoryChange);
|
|
808
787
|
const [active, setActive] = useState(null);
|
|
809
788
|
const managerRef = useRef(null);
|
|
810
789
|
let t1;
|
|
811
|
-
|
|
812
|
-
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) {
|
|
813
791
|
t1 = () => {
|
|
814
|
-
documentRef.current = document;
|
|
815
792
|
canonicalApiRef.current = getCanonicalApi;
|
|
816
793
|
readCanonicalDocumentRef.current = readCanonicalDocument;
|
|
817
|
-
sessionRef.current = experimentalSession;
|
|
818
794
|
refusalRef.current = onSessionRefusal;
|
|
819
795
|
stylesRef.current = styles;
|
|
820
|
-
themeRef.current = theme;
|
|
821
|
-
pluginsRef.current = resolvedPlugins;
|
|
822
796
|
onDocumentChangeRef.current = onDocumentChange;
|
|
823
797
|
onActiveChangeRef.current = onActiveChange;
|
|
824
798
|
onStoryChangeRef.current = onStoryChange;
|
|
825
799
|
if (managerRef.current === null) managerRef.current = createNoteEditorManager({
|
|
826
|
-
getDocument: () => documentRef.current,
|
|
827
800
|
getHost: () => hostRef.current,
|
|
828
|
-
getPlugins: () => pluginsRef.current,
|
|
829
801
|
getStyles: () => stylesRef.current,
|
|
830
|
-
getTheme: () => themeRef.current,
|
|
831
802
|
getCanonicalApi: () => canonicalApiRef.current?.() ?? null,
|
|
832
803
|
readCanonicalDocument: () => readCanonicalDocumentRef.current(),
|
|
833
|
-
getExperimentalSession: () => sessionRef.current,
|
|
834
804
|
onSessionRefusal: (reason, ground, error) => refusalRef.current?.(reason, ground, error),
|
|
835
|
-
onTransaction: (
|
|
836
|
-
const { docChanged, selectionChanged, view } =
|
|
805
|
+
onTransaction: (t2) => {
|
|
806
|
+
const { docChanged, selectionChanged, view } = t2;
|
|
837
807
|
if (docChanged) {
|
|
838
|
-
const
|
|
839
|
-
const model = readCanonicalDocumentRef.current() ?? (current && managerRef.current ? managerRef.current.snapshotDocument(readModel(current)) : current);
|
|
808
|
+
const model = readCanonicalDocumentRef.current();
|
|
840
809
|
if (model) onDocumentChangeRef.current(model);
|
|
841
810
|
}
|
|
842
811
|
onStoryChangeRef.current(view, docChanged, selectionChanged);
|
|
@@ -849,42 +818,44 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
849
818
|
onActiveChangeRef.current(null);
|
|
850
819
|
}
|
|
851
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) {
|
|
852
833
|
t2 = [
|
|
853
834
|
active,
|
|
854
835
|
document,
|
|
855
|
-
experimentalSession,
|
|
856
836
|
getCanonicalApi,
|
|
857
837
|
readCanonicalDocument,
|
|
858
838
|
onActiveChange,
|
|
859
839
|
onDocumentChange,
|
|
860
840
|
onSessionRefusal,
|
|
861
841
|
onStoryChange,
|
|
862
|
-
|
|
863
|
-
styles,
|
|
864
|
-
theme
|
|
842
|
+
styles
|
|
865
843
|
];
|
|
866
|
-
$[
|
|
867
|
-
$[
|
|
868
|
-
$[
|
|
869
|
-
$[
|
|
870
|
-
$[
|
|
871
|
-
$[
|
|
872
|
-
$[
|
|
873
|
-
$[
|
|
874
|
-
$[
|
|
875
|
-
$[
|
|
876
|
-
|
|
877
|
-
$[11] = theme;
|
|
878
|
-
$[12] = t1;
|
|
879
|
-
$[13] = t2;
|
|
880
|
-
} else {
|
|
881
|
-
t1 = $[12];
|
|
882
|
-
t2 = $[13];
|
|
883
|
-
}
|
|
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];
|
|
884
855
|
useEffect(t1, t2);
|
|
885
856
|
let t3;
|
|
886
857
|
let t4;
|
|
887
|
-
if ($[
|
|
858
|
+
if ($[19] !== isSuggestionModeActive || $[20] !== suggestionAuthor) {
|
|
888
859
|
t3 = () => {
|
|
889
860
|
const manager_0 = managerRef.current;
|
|
890
861
|
if (!manager_0) return;
|
|
@@ -894,41 +865,41 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
894
865
|
}
|
|
895
866
|
};
|
|
896
867
|
t4 = [isSuggestionModeActive, suggestionAuthor];
|
|
897
|
-
$[
|
|
898
|
-
$[
|
|
899
|
-
$[
|
|
900
|
-
$[
|
|
868
|
+
$[19] = isSuggestionModeActive;
|
|
869
|
+
$[20] = suggestionAuthor;
|
|
870
|
+
$[21] = t3;
|
|
871
|
+
$[22] = t4;
|
|
901
872
|
} else {
|
|
902
|
-
t3 = $[
|
|
903
|
-
t4 = $[
|
|
873
|
+
t3 = $[21];
|
|
874
|
+
t4 = $[22];
|
|
904
875
|
}
|
|
905
876
|
useEffect(t3, t4);
|
|
906
877
|
let t5;
|
|
907
878
|
let t6;
|
|
908
|
-
if ($[
|
|
879
|
+
if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
|
|
909
880
|
t5 = () => () => {
|
|
910
881
|
managerRef.current?.destroy();
|
|
911
882
|
};
|
|
912
883
|
t6 = [];
|
|
913
|
-
$[
|
|
914
|
-
$[
|
|
884
|
+
$[23] = t5;
|
|
885
|
+
$[24] = t6;
|
|
915
886
|
} else {
|
|
916
|
-
t5 = $[
|
|
917
|
-
t6 = $[
|
|
887
|
+
t5 = $[23];
|
|
888
|
+
t6 = $[24];
|
|
918
889
|
}
|
|
919
890
|
useEffect(t5, t6);
|
|
920
891
|
let t7;
|
|
921
|
-
if ($[
|
|
892
|
+
if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
|
|
922
893
|
t7 = () => {
|
|
923
894
|
managerRef.current?.activate(null);
|
|
924
895
|
setActive(null);
|
|
925
896
|
onActiveChangeRef.current(null);
|
|
926
897
|
};
|
|
927
|
-
$[
|
|
928
|
-
} else t7 = $[
|
|
898
|
+
$[25] = t7;
|
|
899
|
+
} else t7 = $[25];
|
|
929
900
|
const closeEditor = t7;
|
|
930
901
|
let t8;
|
|
931
|
-
if ($[
|
|
902
|
+
if ($[26] !== isSuggestionModeActive || $[27] !== suggestionAuthor) {
|
|
932
903
|
t8 = () => ({
|
|
933
904
|
close: closeEditor,
|
|
934
905
|
getActiveView: () => {
|
|
@@ -943,65 +914,65 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
943
914
|
onActiveChangeRef.current(story_1);
|
|
944
915
|
requestAnimationFrame(() => view_1.focus());
|
|
945
916
|
},
|
|
946
|
-
|
|
917
|
+
sync: () => managerRef.current?.sync()
|
|
947
918
|
});
|
|
948
|
-
$[
|
|
949
|
-
$[
|
|
950
|
-
$[
|
|
951
|
-
} else t8 = $[
|
|
919
|
+
$[26] = isSuggestionModeActive;
|
|
920
|
+
$[27] = suggestionAuthor;
|
|
921
|
+
$[28] = t8;
|
|
922
|
+
} else t8 = $[28];
|
|
952
923
|
useImperativeHandle(ref, t8);
|
|
953
924
|
let t9;
|
|
954
|
-
if ($[
|
|
925
|
+
if ($[29] !== active || $[30] !== t) {
|
|
955
926
|
t9 = active ? t(active.kind === "footnote" ? "dialogs.footnoteProperties.footnotes" : "dialogs.footnoteProperties.endnotes") : "";
|
|
956
|
-
$[
|
|
957
|
-
$[
|
|
958
|
-
$[
|
|
959
|
-
} else t9 = $[
|
|
927
|
+
$[29] = active;
|
|
928
|
+
$[30] = t;
|
|
929
|
+
$[31] = t9;
|
|
930
|
+
} else t9 = $[31];
|
|
960
931
|
const title = t9;
|
|
961
932
|
const t10 = active ? "block" : "none";
|
|
962
933
|
let t11;
|
|
963
|
-
if ($[
|
|
934
|
+
if ($[32] !== t10) {
|
|
964
935
|
t11 = {
|
|
965
936
|
...panelStyle,
|
|
966
937
|
display: t10
|
|
967
938
|
};
|
|
968
|
-
$[
|
|
969
|
-
$[
|
|
970
|
-
} else t11 = $[
|
|
939
|
+
$[32] = t10;
|
|
940
|
+
$[33] = t11;
|
|
941
|
+
} else t11 = $[33];
|
|
971
942
|
let t12;
|
|
972
|
-
if ($[
|
|
943
|
+
if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
|
|
973
944
|
t12 = (event) => {
|
|
974
945
|
if (event.key !== "Escape") return;
|
|
975
946
|
event.preventDefault();
|
|
976
947
|
event.stopPropagation();
|
|
977
948
|
closeEditor();
|
|
978
949
|
};
|
|
979
|
-
$[
|
|
980
|
-
} else t12 = $[
|
|
950
|
+
$[34] = t12;
|
|
951
|
+
} else t12 = $[34];
|
|
981
952
|
let t13;
|
|
982
|
-
if ($[
|
|
953
|
+
if ($[35] !== title) {
|
|
983
954
|
t13 = /* @__PURE__ */ jsx("span", { children: title });
|
|
984
|
-
$[
|
|
985
|
-
$[
|
|
986
|
-
} else t13 = $[
|
|
955
|
+
$[35] = title;
|
|
956
|
+
$[36] = t13;
|
|
957
|
+
} else t13 = $[36];
|
|
987
958
|
let t14;
|
|
988
|
-
if ($[
|
|
959
|
+
if ($[37] !== t) {
|
|
989
960
|
t14 = t("common.closeDialog");
|
|
990
|
-
$[
|
|
991
|
-
$[
|
|
992
|
-
} else t14 = $[
|
|
961
|
+
$[37] = t;
|
|
962
|
+
$[38] = t14;
|
|
963
|
+
} else t14 = $[38];
|
|
993
964
|
let t15;
|
|
994
|
-
if ($[
|
|
965
|
+
if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
|
|
995
966
|
t15 = {
|
|
996
967
|
border: 0,
|
|
997
968
|
background: "transparent",
|
|
998
969
|
color: "inherit",
|
|
999
970
|
cursor: "pointer"
|
|
1000
971
|
};
|
|
1001
|
-
$[
|
|
1002
|
-
} else t15 = $[
|
|
972
|
+
$[39] = t15;
|
|
973
|
+
} else t15 = $[39];
|
|
1003
974
|
let t16;
|
|
1004
|
-
if ($[
|
|
975
|
+
if ($[40] !== t14) {
|
|
1005
976
|
t16 = /* @__PURE__ */ jsx("button", {
|
|
1006
977
|
type: "button",
|
|
1007
978
|
"aria-label": t14,
|
|
@@ -1009,40 +980,40 @@ const NoteStoryEditor = forwardRef(function NoteStoryEditor(t0, ref) {
|
|
|
1009
980
|
style: t15,
|
|
1010
981
|
children: "×"
|
|
1011
982
|
});
|
|
1012
|
-
$[
|
|
1013
|
-
$[
|
|
1014
|
-
} else t16 = $[
|
|
983
|
+
$[40] = t14;
|
|
984
|
+
$[41] = t16;
|
|
985
|
+
} else t16 = $[41];
|
|
1015
986
|
let t17;
|
|
1016
|
-
if ($[
|
|
987
|
+
if ($[42] !== t13 || $[43] !== t16) {
|
|
1017
988
|
t17 = /* @__PURE__ */ jsxs("div", {
|
|
1018
989
|
style: headerStyle,
|
|
1019
990
|
children: [t13, t16]
|
|
1020
991
|
});
|
|
1021
|
-
$[
|
|
1022
|
-
$[
|
|
1023
|
-
$[
|
|
1024
|
-
} else t17 = $[
|
|
992
|
+
$[42] = t13;
|
|
993
|
+
$[43] = t16;
|
|
994
|
+
$[44] = t17;
|
|
995
|
+
} else t17 = $[44];
|
|
1025
996
|
let t18;
|
|
1026
|
-
if ($[
|
|
997
|
+
if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1027
998
|
t18 = /* @__PURE__ */ jsx("div", {
|
|
1028
999
|
ref: hostRef,
|
|
1029
1000
|
style: hostStyle
|
|
1030
1001
|
});
|
|
1031
|
-
$[
|
|
1032
|
-
} else t18 = $[
|
|
1002
|
+
$[45] = t18;
|
|
1003
|
+
} else t18 = $[45];
|
|
1033
1004
|
let t19;
|
|
1034
|
-
if ($[
|
|
1005
|
+
if ($[46] !== t11 || $[47] !== t17 || $[48] !== title) {
|
|
1035
1006
|
t19 = /* @__PURE__ */ jsxs("aside", {
|
|
1036
1007
|
style: t11,
|
|
1037
1008
|
"aria-label": title,
|
|
1038
1009
|
onKeyDown: t12,
|
|
1039
1010
|
children: [t17, t18]
|
|
1040
1011
|
});
|
|
1041
|
-
$[
|
|
1042
|
-
$[
|
|
1043
|
-
$[
|
|
1044
|
-
$[
|
|
1045
|
-
} else t19 = $[
|
|
1012
|
+
$[46] = t11;
|
|
1013
|
+
$[47] = t17;
|
|
1014
|
+
$[48] = title;
|
|
1015
|
+
$[49] = t19;
|
|
1016
|
+
} else t19 = $[49];
|
|
1046
1017
|
return t19;
|
|
1047
1018
|
});
|
|
1048
1019
|
NoteStoryEditor.displayName = "NoteStoryEditor";
|
|
@@ -1455,15 +1426,9 @@ const HIDDEN_HOST_STYLES = {
|
|
|
1455
1426
|
* HiddenProseMirror - Off-screen ProseMirror editor for keyboard input
|
|
1456
1427
|
*/
|
|
1457
1428
|
const HiddenProseMirror = forwardRef((props, ref) => {
|
|
1458
|
-
const { document, documentIdentity,
|
|
1459
|
-
const hasCollaboration = collaboration !== void 0;
|
|
1460
|
-
const [collaborationLoad, setCollaborationLoad] = useState(() => ({ status: hasCollaboration ? "loading" : "disabled" }));
|
|
1461
|
-
if (hasCollaboration !== (collaborationLoad.status !== "disabled")) setCollaborationLoad({ status: hasCollaboration ? "loading" : "disabled" });
|
|
1462
|
-
const collaborationModules = hasCollaboration && collaborationLoad.status === "ready" ? collaborationLoad.modules : null;
|
|
1463
|
-
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;
|
|
1464
1430
|
const hostRef = useRef(null);
|
|
1465
1431
|
const readOnlyRef = useRef(readOnly);
|
|
1466
|
-
const experimentalSessionRef = useRef(experimentalSession);
|
|
1467
1432
|
const historyShortcutsRef = useRef(historyShortcuts);
|
|
1468
1433
|
const suggestionModeActiveRef = useRef(suggestionModeActive);
|
|
1469
1434
|
const suggestionAuthorRef = useRef(suggestionAuthor);
|
|
@@ -1474,10 +1439,8 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1474
1439
|
const extensionManagerRef = useRef(extensionManager);
|
|
1475
1440
|
const externalPluginsRef = useRef(externalPlugins);
|
|
1476
1441
|
const anonymizationTermsRef = useRef(anonymizationTerms);
|
|
1477
|
-
const
|
|
1478
|
-
const collaborationRef = useRef(collaboration);
|
|
1442
|
+
const derivedFieldsRef = useRef(derivedFields);
|
|
1479
1443
|
const canonicalRoomRef = useRef(canonicalRoom);
|
|
1480
|
-
const collaborationModulesRef = useRef(collaborationModules);
|
|
1481
1444
|
const onTransactionRef = useRef(onTransaction);
|
|
1482
1445
|
const onCanonicalCompositionLayoutRef = useRef(onCanonicalCompositionLayout);
|
|
1483
1446
|
const getEmbeddedFontFamilyMapRef = useRef(getEmbeddedFontFamilyMap);
|
|
@@ -1495,7 +1458,6 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1495
1458
|
const managerRef = useRef(null);
|
|
1496
1459
|
useLayoutEffect(() => {
|
|
1497
1460
|
readOnlyRef.current = readOnly;
|
|
1498
|
-
experimentalSessionRef.current = experimentalSession;
|
|
1499
1461
|
historyShortcutsRef.current = historyShortcuts;
|
|
1500
1462
|
suggestionModeActiveRef.current = suggestionModeActive;
|
|
1501
1463
|
suggestionAuthorRef.current = suggestionAuthor;
|
|
@@ -1504,7 +1466,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1504
1466
|
extensionManagerRef.current = extensionManager;
|
|
1505
1467
|
externalPluginsRef.current = externalPlugins;
|
|
1506
1468
|
anonymizationTermsRef.current = anonymizationTerms;
|
|
1507
|
-
|
|
1469
|
+
derivedFieldsRef.current = derivedFields;
|
|
1508
1470
|
onTransactionRef.current = onTransaction;
|
|
1509
1471
|
onCanonicalCompositionLayoutRef.current = onCanonicalCompositionLayout;
|
|
1510
1472
|
getEmbeddedFontFamilyMapRef.current = getEmbeddedFontFamilyMap;
|
|
@@ -1519,9 +1481,7 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1519
1481
|
onPasteRef.current = onPaste;
|
|
1520
1482
|
onReadOnlyEditAttemptRef.current = onReadOnlyEditAttempt;
|
|
1521
1483
|
onRemoteSelectionsChangeRef.current = onRemoteSelectionsChange;
|
|
1522
|
-
collaborationRef.current = collaboration;
|
|
1523
1484
|
canonicalRoomRef.current = canonicalRoom;
|
|
1524
|
-
collaborationModulesRef.current = collaborationModules;
|
|
1525
1485
|
documentRef.current = document;
|
|
1526
1486
|
documentIdentityRef.current = documentIdentity;
|
|
1527
1487
|
if (managerRef.current === null) managerRef.current = createHiddenEditorManager({
|
|
@@ -1531,12 +1491,9 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1531
1491
|
getExtensionManager: () => extensionManagerRef.current,
|
|
1532
1492
|
getExternalPlugins: () => externalPluginsRef.current,
|
|
1533
1493
|
getAnonymizationTerms: () => anonymizationTermsRef.current ?? NO_ANONYMIZATION_TERMS,
|
|
1534
|
-
|
|
1535
|
-
getCollaborationModules: () => collaborationModulesRef.current,
|
|
1494
|
+
getDerivedFields: () => derivedFieldsRef.current,
|
|
1536
1495
|
getCanonicalRoom: () => canonicalRoomRef.current,
|
|
1537
|
-
getPrecomputedInitialState: () => getPrecomputedInitialStateRef.current?.() ?? null,
|
|
1538
1496
|
getReadOnly: () => readOnlyRef.current,
|
|
1539
|
-
getExperimentalSession: () => experimentalSessionRef.current,
|
|
1540
1497
|
getHistoryShortcuts: () => historyShortcutsRef.current,
|
|
1541
1498
|
onCanonicalHistory: (effect) => onCanonicalHistoryRef.current?.(effect),
|
|
1542
1499
|
onCanonicalHistoryDrop: (drop) => onCanonicalHistoryDropRef.current?.(drop),
|
|
@@ -1564,42 +1521,6 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1564
1521
|
managerRef.current?.syncExternalDocument();
|
|
1565
1522
|
managerRef.current?.syncEditable();
|
|
1566
1523
|
});
|
|
1567
|
-
useEffect(() => {
|
|
1568
|
-
if (!hasCollaboration) return;
|
|
1569
|
-
let cancelled = false;
|
|
1570
|
-
loadCollaborationModules().then((modules) => {
|
|
1571
|
-
if (!cancelled) setCollaborationLoad({
|
|
1572
|
-
status: "ready",
|
|
1573
|
-
modules
|
|
1574
|
-
});
|
|
1575
|
-
}, (error_0) => {
|
|
1576
|
-
if (!cancelled) setCollaborationLoad({
|
|
1577
|
-
status: "failed",
|
|
1578
|
-
error: error_0
|
|
1579
|
-
});
|
|
1580
|
-
});
|
|
1581
|
-
return () => {
|
|
1582
|
-
cancelled = true;
|
|
1583
|
-
};
|
|
1584
|
-
}, [hasCollaboration]);
|
|
1585
|
-
useEffect(() => {
|
|
1586
|
-
const awareness = collaboration?.awareness;
|
|
1587
|
-
if (!awareness || !managerRef.current?.getView() || !collaborationModules) {
|
|
1588
|
-
onRemoteSelectionsChangeRef.current?.([]);
|
|
1589
|
-
return;
|
|
1590
|
-
}
|
|
1591
|
-
const publishRemoteSelections = () => {
|
|
1592
|
-
const view_1 = managerRef.current?.getView();
|
|
1593
|
-
if (!view_1) return;
|
|
1594
|
-
onRemoteSelectionsChangeRef.current?.(collectRemoteSelections(view_1.state, awareness, collaborationModules));
|
|
1595
|
-
};
|
|
1596
|
-
awareness.on("change", publishRemoteSelections);
|
|
1597
|
-
publishRemoteSelections();
|
|
1598
|
-
return () => {
|
|
1599
|
-
awareness.off("change", publishRemoteSelections);
|
|
1600
|
-
onRemoteSelectionsChangeRef.current?.([]);
|
|
1601
|
-
};
|
|
1602
|
-
}, [collaboration, collaborationModules]);
|
|
1603
1524
|
const destroyView = useCallback(() => {
|
|
1604
1525
|
managerRef.current?.destroyView();
|
|
1605
1526
|
}, []);
|
|
@@ -1611,12 +1532,6 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1611
1532
|
refreshFonts: () => managerRef.current?.refreshFonts(),
|
|
1612
1533
|
readCanonicalDocument: () => managerRef.current?.readCanonicalDocument() ?? null
|
|
1613
1534
|
}), []);
|
|
1614
|
-
if (hasCollaboration && collaborationModulesError) {
|
|
1615
|
-
let detail = "unknown error";
|
|
1616
|
-
if (collaborationModulesError instanceof Error) detail = collaborationModulesError.message;
|
|
1617
|
-
else if (typeof collaborationModulesError === "string") detail = collaborationModulesError;
|
|
1618
|
-
panic(`Failed to load collaboration editor modules. Reload the document to retry. Cause: ${detail}`);
|
|
1619
|
-
}
|
|
1620
1535
|
return /* @__PURE__ */ jsx("div", {
|
|
1621
1536
|
className: HIDDEN_EDITOR_WRAPPER_CLASS,
|
|
1622
1537
|
style: HIDDEN_WRAPPER_STYLES,
|
|
@@ -3381,7 +3296,7 @@ function buildFootnoteRenderItems(pageFootnoteMap, footnoteContentMap, doc) {
|
|
|
3381
3296
|
* PagedEditor - Main paginated editing component.
|
|
3382
3297
|
*/
|
|
3383
3298
|
const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
3384
|
-
const { accessibleName, document, documentIO, documentIdentity,
|
|
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;
|
|
3385
3300
|
const styles = document?.package.styles;
|
|
3386
3301
|
const sectionProperties = useMemo(() => resolveEffectiveSectionProperties(document ? readModel(document).package.document : void 0, hasTitlePg) ?? null, [document, hasTitlePg]);
|
|
3387
3302
|
const getScrollContainer = useCallback(() => {
|
|
@@ -3407,7 +3322,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3407
3322
|
const activeNoteStoryRef = useRef(null);
|
|
3408
3323
|
const [noteStoryActive, setNoteStoryActive] = useState(false);
|
|
3409
3324
|
const painterRef = useRef(null);
|
|
3410
|
-
const noteStoryPlugins = useMemo(() => externalPlugins.filter((plugin) => suggestionModeKey.owns(plugin)), [externalPlugins]);
|
|
3411
3325
|
const handleActiveNoteStoryChange = useCallback((story) => {
|
|
3412
3326
|
activeNoteStoryRef.current = story;
|
|
3413
3327
|
setNoteStoryActive(story !== null);
|
|
@@ -3461,9 +3375,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3461
3375
|
const layoutRef = useRef(null);
|
|
3462
3376
|
const [blocks, setBlocks] = useState([]);
|
|
3463
3377
|
const [measures, setMeasures] = useState([]);
|
|
3464
|
-
const [
|
|
3465
|
-
const
|
|
3466
|
-
const shouldFocusHiddenEditorOnReadyRef = useRef(collaboration !== void 0);
|
|
3378
|
+
const [shouldCreateHiddenEditorView, setShouldCreateHiddenEditorView] = useState(false);
|
|
3379
|
+
const shouldFocusHiddenEditorOnReadyRef = useRef(false);
|
|
3467
3380
|
const layoutSessionRef = useRef(createLayoutSession());
|
|
3468
3381
|
const readPrecomputedInitialStateRef = useRef(readNoHiddenEditorState);
|
|
3469
3382
|
const precomputedInitialDocumentRef = useRef(null);
|
|
@@ -3556,18 +3469,16 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3556
3469
|
* a refused seed (or a view not created yet) pays for this conversion.
|
|
3557
3470
|
*/
|
|
3558
3471
|
const readPrecomputedInitialState = useMemo(() => {
|
|
3559
|
-
if (shouldCreateHiddenEditorView ||
|
|
3472
|
+
if (shouldCreateHiddenEditorView || !document) return readNoHiddenEditorState;
|
|
3560
3473
|
return readHiddenEditorStateOnce({
|
|
3561
3474
|
document,
|
|
3562
3475
|
styles,
|
|
3563
3476
|
manager: extensionManager,
|
|
3564
3477
|
externalPlugins,
|
|
3565
|
-
collaborationModules: null,
|
|
3566
3478
|
reason: "mount"
|
|
3567
3479
|
});
|
|
3568
3480
|
}, [
|
|
3569
3481
|
shouldCreateHiddenEditorView,
|
|
3570
|
-
collaboration,
|
|
3571
3482
|
document,
|
|
3572
3483
|
styles,
|
|
3573
3484
|
extensionManager,
|
|
@@ -3638,18 +3549,17 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3638
3549
|
queuedInputBeforeHiddenEditorRef.current = [];
|
|
3639
3550
|
for (const input of queuedInput) {
|
|
3640
3551
|
if (input.type === "text") {
|
|
3641
|
-
|
|
3552
|
+
view_0.dom.dispatchEvent(new InputEvent("beforeinput", {
|
|
3642
3553
|
inputType: "insertText",
|
|
3643
3554
|
data: input.text,
|
|
3644
3555
|
cancelable: true,
|
|
3645
3556
|
bubbles: true
|
|
3646
3557
|
}));
|
|
3647
|
-
else dispatchEditorTextInput(view_0, input.text);
|
|
3648
3558
|
continue;
|
|
3649
3559
|
}
|
|
3650
3560
|
replayDeferredKeyDown(view_0, input.eventInit);
|
|
3651
3561
|
}
|
|
3652
|
-
}, [
|
|
3562
|
+
}, []);
|
|
3653
3563
|
const isResizingColumnRef = useRef(false);
|
|
3654
3564
|
const resizeStartXRef = useRef(0);
|
|
3655
3565
|
const resizeColumnIndexRef = useRef(0);
|
|
@@ -3890,9 +3800,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3890
3800
|
readState: () => hiddenPMRef.current?.getState() ?? readPrecomputedInitialStateRef.current()
|
|
3891
3801
|
});
|
|
3892
3802
|
}, [runtime]);
|
|
3893
|
-
useLayoutEffect(() => {
|
|
3894
|
-
if (collaboration !== void 0) hiddenPMRef.current?.ensureView();
|
|
3895
|
-
}, [collaboration]);
|
|
3896
3803
|
const getActiveEditorStory = useCallback(() => resolveActiveEditorStory({
|
|
3897
3804
|
bodyView: folioEditor.getView(),
|
|
3898
3805
|
headerFooterView: hfEditMode && activeHeaderFooterRId ? hfPMsRef.current?.getView(activeHeaderFooterRId) ?? null : null,
|
|
@@ -3960,16 +3867,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3960
3867
|
* model, with one copy for the host.
|
|
3961
3868
|
*/
|
|
3962
3869
|
const settledDocumentChange = useCallback(() => {
|
|
3963
|
-
const
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
return model === null ? null : settledChangeOf(model);
|
|
3967
|
-
}
|
|
3968
|
-
const built = hidden?.getDocument();
|
|
3969
|
-
const body = hidden?.getState()?.doc;
|
|
3970
|
-
if (!built) return null;
|
|
3971
|
-
return settledChangeOf(body ? noteFollower.reconcile(readModel(built), body) : built);
|
|
3972
|
-
}, [experimentalSession, noteFollower]);
|
|
3870
|
+
const model = hiddenPMRef.current?.readCanonicalDocument() ?? null;
|
|
3871
|
+
return model === null ? null : settledChangeOf(model);
|
|
3872
|
+
}, []);
|
|
3973
3873
|
const flushDocumentChangeNotification = useCallback(() => {
|
|
3974
3874
|
const flush = () => {
|
|
3975
3875
|
if (documentChangeNotifyTimerRef.current !== null) {
|
|
@@ -3989,6 +3889,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3989
3889
|
const change = settledDocumentChange();
|
|
3990
3890
|
if (change) {
|
|
3991
3891
|
cancelNoteChangeNotification();
|
|
3892
|
+
noteEditorRef.current?.sync();
|
|
3893
|
+
hfPMsRef.current?.sync();
|
|
3992
3894
|
onDocumentChangeRef.current?.(change);
|
|
3993
3895
|
folioEmitterRef.current.emit("docChange", change.forHost);
|
|
3994
3896
|
}
|
|
@@ -4596,7 +4498,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4596
4498
|
if (docChanged_0) {
|
|
4597
4499
|
if (!hiddenPMRef.current?.getState() && !readPrecomputedInitialStateRef.current()) ensureHiddenEditorView({ sync: true });
|
|
4598
4500
|
scheduleLayout();
|
|
4599
|
-
|
|
4501
|
+
scheduleDocumentChangeNotification();
|
|
4600
4502
|
}
|
|
4601
4503
|
if (docChanged_0 || selectionChanged) {
|
|
4602
4504
|
const { from: from_0, to: to_0 } = view_3.state.selection;
|
|
@@ -4617,7 +4519,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4617
4519
|
}, [
|
|
4618
4520
|
scheduleLayout,
|
|
4619
4521
|
ensureHiddenEditorView,
|
|
4620
|
-
experimentalSession,
|
|
4621
4522
|
scheduleDocumentChangeNotification,
|
|
4622
4523
|
setHfCaretSelection
|
|
4623
4524
|
]);
|
|
@@ -5840,7 +5741,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5840
5741
|
preHiddenInitialLayoutDoneRef.current = false;
|
|
5841
5742
|
precomputedInitialDocumentRef.current = null;
|
|
5842
5743
|
}
|
|
5843
|
-
if (shouldCreateHiddenEditorView ||
|
|
5744
|
+
if (shouldCreateHiddenEditorView || preHiddenInitialLayoutDoneRef.current) return;
|
|
5844
5745
|
if (!document) {
|
|
5845
5746
|
hiddenPMRef.current?.ensureView();
|
|
5846
5747
|
return;
|
|
@@ -5873,7 +5774,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5873
5774
|
queueMicrotask(runLayoutInputDeferredByFontWait);
|
|
5874
5775
|
};
|
|
5875
5776
|
}, [
|
|
5876
|
-
collaboration,
|
|
5877
5777
|
document,
|
|
5878
5778
|
readPrecomputedInitialState,
|
|
5879
5779
|
runLayoutPipeline$1,
|
|
@@ -6145,10 +6045,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6145
6045
|
},
|
|
6146
6046
|
getDocument() {
|
|
6147
6047
|
if (documentChangeNotifyTimerRef.current !== null) flushDocumentChangeNotification();
|
|
6148
|
-
|
|
6149
|
-
if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return editorDocument;
|
|
6150
|
-
const current_0 = editorDocument ? noteFollower.withPending(readModel(editorDocument)) : null;
|
|
6151
|
-
return current_0 ? noteEditorRef.current?.snapshotDocument(current_0) ?? current_0 : null;
|
|
6048
|
+
return folioEditor.getDocument();
|
|
6152
6049
|
},
|
|
6153
6050
|
getState() {
|
|
6154
6051
|
return folioEditor.getState();
|
|
@@ -6188,34 +6085,28 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6188
6085
|
undo() {
|
|
6189
6086
|
const target_5 = getActiveEditorStory();
|
|
6190
6087
|
if (target_5.type === "none") return false;
|
|
6191
|
-
|
|
6088
|
+
return hiddenPMRef.current?.applyCanonicalStoryHistory({
|
|
6192
6089
|
view: target_5.view,
|
|
6193
6090
|
story: getCanonicalActiveStory(),
|
|
6194
6091
|
direction: "undo"
|
|
6195
6092
|
}) ?? false;
|
|
6196
|
-
if (target_5.type === "body") return hiddenPMRef.current?.undo() ?? false;
|
|
6197
|
-
return undo(target_5.view.state, target_5.view.dispatch);
|
|
6198
6093
|
},
|
|
6199
6094
|
redo() {
|
|
6200
6095
|
const target_6 = getActiveEditorStory();
|
|
6201
6096
|
if (target_6.type === "none") return false;
|
|
6202
|
-
|
|
6097
|
+
return hiddenPMRef.current?.applyCanonicalStoryHistory({
|
|
6203
6098
|
view: target_6.view,
|
|
6204
6099
|
story: getCanonicalActiveStory(),
|
|
6205
6100
|
direction: "redo"
|
|
6206
6101
|
}) ?? false;
|
|
6207
|
-
if (target_6.type === "body") return hiddenPMRef.current?.redo() ?? false;
|
|
6208
|
-
return redo(target_6.view.state, target_6.view.dispatch);
|
|
6209
6102
|
},
|
|
6210
6103
|
canUndo() {
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
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;
|
|
6214
6106
|
},
|
|
6215
6107
|
canRedo() {
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
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;
|
|
6219
6110
|
},
|
|
6220
6111
|
setSelection(anchor_3, head_1) {
|
|
6221
6112
|
folioEditor.setSelection(anchor_3, head_1);
|
|
@@ -6265,14 +6156,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6265
6156
|
folioEditor,
|
|
6266
6157
|
getActiveEditorStory,
|
|
6267
6158
|
getCanonicalActiveStory,
|
|
6268
|
-
noteFollower,
|
|
6269
6159
|
getScrollContainer,
|
|
6270
6160
|
refreshBodyImeCaretAnchor,
|
|
6271
6161
|
scrollToPageImpl,
|
|
6272
6162
|
scrollToParaIdImpl,
|
|
6273
6163
|
scrollToPositionImpl,
|
|
6274
|
-
setPassageHighlightImpl
|
|
6275
|
-
experimentalSession
|
|
6164
|
+
setPassageHighlightImpl
|
|
6276
6165
|
]);
|
|
6277
6166
|
useEffect(() => {
|
|
6278
6167
|
if (!layout) return;
|
|
@@ -6348,9 +6237,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6348
6237
|
getCanonicalApi,
|
|
6349
6238
|
readCanonicalDocument,
|
|
6350
6239
|
onSessionRefusal: handleSessionRefusal,
|
|
6351
|
-
|
|
6352
|
-
...styles !== void 0 ? { styles } : {},
|
|
6353
|
-
..._theme !== void 0 ? { theme: _theme } : {}
|
|
6240
|
+
...styles !== void 0 ? { styles } : {}
|
|
6354
6241
|
}),
|
|
6355
6242
|
/* @__PURE__ */ jsx(NoteStoryEditor, {
|
|
6356
6243
|
ref: noteEditorRef,
|
|
@@ -6359,21 +6246,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6359
6246
|
getCanonicalApi,
|
|
6360
6247
|
readCanonicalDocument,
|
|
6361
6248
|
onSessionRefusal: handleSessionRefusal,
|
|
6362
|
-
experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
|
|
6363
6249
|
onDocumentChange: handleNoteDocumentChange,
|
|
6364
6250
|
onStoryChange: handleNoteStoryTransaction,
|
|
6365
|
-
plugins: noteStoryPlugins,
|
|
6366
6251
|
suggestionModeActive,
|
|
6367
6252
|
...suggestionAuthor !== void 0 ? { suggestionAuthor } : {},
|
|
6368
|
-
...styles !== void 0 ? { styles } : {}
|
|
6369
|
-
..._theme !== void 0 ? { theme: _theme } : {}
|
|
6253
|
+
...styles !== void 0 ? { styles } : {}
|
|
6370
6254
|
}),
|
|
6371
6255
|
/* @__PURE__ */ jsx(HiddenProseMirror, {
|
|
6372
6256
|
ref: hiddenPMRef,
|
|
6373
6257
|
anonymizationTerms,
|
|
6258
|
+
derivedFields,
|
|
6374
6259
|
document,
|
|
6375
6260
|
documentIdentity,
|
|
6376
|
-
experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
|
|
6377
6261
|
...historyShortcuts === void 0 ? {} : { historyShortcuts },
|
|
6378
6262
|
...onCanonicalHistory === void 0 ? {} : { onCanonicalHistory },
|
|
6379
6263
|
...onCanonicalHistoryDrop === void 0 ? {} : { onCanonicalHistoryDrop },
|
|
@@ -6381,7 +6265,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6381
6265
|
...suggestionAuthor !== void 0 ? { suggestionAuthor } : {},
|
|
6382
6266
|
suggestionModeActive,
|
|
6383
6267
|
widthPx: contentWidth,
|
|
6384
|
-
getPrecomputedInitialState: readPrecomputedInitialState,
|
|
6385
6268
|
readOnly,
|
|
6386
6269
|
onTransaction: handleTransaction,
|
|
6387
6270
|
onCanonicalCompositionLayout: layoutCanonicalComposition,
|
|
@@ -6396,7 +6279,6 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
6396
6279
|
...onPaste !== void 0 ? { onPaste } : {},
|
|
6397
6280
|
...styles !== void 0 ? { styles } : {},
|
|
6398
6281
|
externalPlugins,
|
|
6399
|
-
...collaboration !== void 0 ? { collaboration } : {},
|
|
6400
6282
|
...canonicalRoom !== void 0 ? { canonicalRoom } : {},
|
|
6401
6283
|
...extensionManager !== void 0 ? { extensionManager } : {},
|
|
6402
6284
|
...onReadOnlyEditAttempt !== void 0 ? { onReadOnlyEditAttempt } : {}
|
|
@@ -9900,17 +9782,16 @@ function useContextMenu(t0) {
|
|
|
9900
9782
|
* callbacks each render.
|
|
9901
9783
|
*/
|
|
9902
9784
|
const useDocumentLoader = (t0) => {
|
|
9903
|
-
const $ = c(
|
|
9904
|
-
const { documentBuffer, initialDocument, password,
|
|
9785
|
+
const $ = c(42);
|
|
9786
|
+
const { documentBuffer, initialDocument, password, history, onError, onCompatibilityChange, onReset, setDocumentLoadState } = t0;
|
|
9905
9787
|
const originalBufferRef = useRef(null);
|
|
9906
9788
|
const originalBufferIdentityRef = useRef(null);
|
|
9907
9789
|
const [loadedDocumentIdentity, setLoadedDocumentIdentity] = useState("0");
|
|
9908
9790
|
let t1;
|
|
9909
|
-
if ($[0] !==
|
|
9791
|
+
if ($[0] !== history || $[1] !== onCompatibilityChange || $[2] !== onError || $[3] !== onReset || $[4] !== setDocumentLoadState) {
|
|
9910
9792
|
t1 = () => {
|
|
9911
9793
|
const instance = new DocumentLoaderManager({
|
|
9912
9794
|
history,
|
|
9913
|
-
getExperimentalSession: () => experimentalSession,
|
|
9914
9795
|
onError,
|
|
9915
9796
|
onCompatibilityChange,
|
|
9916
9797
|
onReset,
|
|
@@ -9927,23 +9808,21 @@ const useDocumentLoader = (t0) => {
|
|
|
9927
9808
|
}
|
|
9928
9809
|
};
|
|
9929
9810
|
};
|
|
9930
|
-
$[0] =
|
|
9931
|
-
$[1] =
|
|
9932
|
-
$[2] =
|
|
9933
|
-
$[3] =
|
|
9934
|
-
$[4] =
|
|
9935
|
-
$[5] =
|
|
9936
|
-
|
|
9937
|
-
} 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];
|
|
9938
9818
|
const [t2] = useState(t1);
|
|
9939
9819
|
const { manager, api } = t2;
|
|
9940
9820
|
let t3;
|
|
9941
9821
|
let t4;
|
|
9942
|
-
if ($[
|
|
9822
|
+
if ($[6] !== history || $[7] !== manager || $[8] !== onCompatibilityChange || $[9] !== onError || $[10] !== onReset || $[11] !== setDocumentLoadState) {
|
|
9943
9823
|
t3 = () => {
|
|
9944
9824
|
manager.setCallbacks({
|
|
9945
9825
|
history,
|
|
9946
|
-
getExperimentalSession: () => experimentalSession,
|
|
9947
9826
|
onError,
|
|
9948
9827
|
onCompatibilityChange,
|
|
9949
9828
|
onReset,
|
|
@@ -9954,33 +9833,30 @@ const useDocumentLoader = (t0) => {
|
|
|
9954
9833
|
t4 = [
|
|
9955
9834
|
manager,
|
|
9956
9835
|
history,
|
|
9957
|
-
experimentalSession,
|
|
9958
9836
|
onError,
|
|
9959
9837
|
onCompatibilityChange,
|
|
9960
9838
|
onReset,
|
|
9961
9839
|
setDocumentLoadState
|
|
9962
9840
|
];
|
|
9963
|
-
$[
|
|
9964
|
-
$[
|
|
9965
|
-
$[
|
|
9966
|
-
$[
|
|
9967
|
-
$[
|
|
9968
|
-
$[
|
|
9969
|
-
$[
|
|
9970
|
-
$[
|
|
9971
|
-
$[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;
|
|
9972
9849
|
} else {
|
|
9973
|
-
t3 = $[
|
|
9974
|
-
t4 = $[
|
|
9850
|
+
t3 = $[12];
|
|
9851
|
+
t4 = $[13];
|
|
9975
9852
|
}
|
|
9976
9853
|
useLayoutEffect(t3, t4);
|
|
9977
9854
|
let t5;
|
|
9978
|
-
if ($[
|
|
9855
|
+
if ($[14] !== api || $[15] !== history || $[16] !== manager || $[17] !== onCompatibilityChange || $[18] !== onError || $[19] !== onReset || $[20] !== setDocumentLoadState) {
|
|
9979
9856
|
t5 = (t6) => {
|
|
9980
|
-
const {
|
|
9857
|
+
const { source, loadPassword } = t6;
|
|
9981
9858
|
manager.setCallbacks({
|
|
9982
9859
|
history,
|
|
9983
|
-
getExperimentalSession: () => session,
|
|
9984
9860
|
onError,
|
|
9985
9861
|
onCompatibilityChange,
|
|
9986
9862
|
onReset,
|
|
@@ -9994,21 +9870,20 @@ const useDocumentLoader = (t0) => {
|
|
|
9994
9870
|
}
|
|
9995
9871
|
api.loadBuffer(source.buffer, { password: loadPassword });
|
|
9996
9872
|
};
|
|
9997
|
-
$[
|
|
9998
|
-
$[
|
|
9999
|
-
$[
|
|
10000
|
-
$[
|
|
10001
|
-
$[
|
|
10002
|
-
$[
|
|
10003
|
-
$[
|
|
10004
|
-
$[
|
|
10005
|
-
} else t5 = $[
|
|
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];
|
|
10006
9882
|
const loadCommittedSource = useEffectEvent(t5);
|
|
10007
9883
|
let t6;
|
|
10008
|
-
if ($[
|
|
9884
|
+
if ($[22] !== documentBuffer || $[23] !== initialDocument || $[24] !== loadCommittedSource || $[25] !== password) {
|
|
10009
9885
|
t6 = () => {
|
|
10010
9886
|
loadCommittedSource({
|
|
10011
|
-
session: experimentalSession,
|
|
10012
9887
|
source: getDocumentLoadSource({
|
|
10013
9888
|
documentBuffer,
|
|
10014
9889
|
initialDocument
|
|
@@ -10016,31 +9891,28 @@ const useDocumentLoader = (t0) => {
|
|
|
10016
9891
|
loadPassword: password
|
|
10017
9892
|
});
|
|
10018
9893
|
};
|
|
10019
|
-
$[
|
|
10020
|
-
$[
|
|
10021
|
-
$[
|
|
10022
|
-
$[
|
|
10023
|
-
$[
|
|
10024
|
-
|
|
10025
|
-
} else t6 = $[29];
|
|
9894
|
+
$[22] = documentBuffer;
|
|
9895
|
+
$[23] = initialDocument;
|
|
9896
|
+
$[24] = loadCommittedSource;
|
|
9897
|
+
$[25] = password;
|
|
9898
|
+
$[26] = t6;
|
|
9899
|
+
} else t6 = $[26];
|
|
10026
9900
|
let t7;
|
|
10027
|
-
if ($[
|
|
9901
|
+
if ($[27] !== documentBuffer || $[28] !== initialDocument || $[29] !== password) {
|
|
10028
9902
|
t7 = [
|
|
10029
9903
|
documentBuffer,
|
|
10030
9904
|
initialDocument,
|
|
10031
|
-
password
|
|
10032
|
-
experimentalSession
|
|
9905
|
+
password
|
|
10033
9906
|
];
|
|
10034
|
-
$[
|
|
10035
|
-
$[
|
|
10036
|
-
$[
|
|
10037
|
-
$[
|
|
10038
|
-
|
|
10039
|
-
} else t7 = $[34];
|
|
9907
|
+
$[27] = documentBuffer;
|
|
9908
|
+
$[28] = initialDocument;
|
|
9909
|
+
$[29] = password;
|
|
9910
|
+
$[30] = t7;
|
|
9911
|
+
} else t7 = $[30];
|
|
10040
9912
|
useEffect(t6, t7);
|
|
10041
9913
|
let t8;
|
|
10042
9914
|
let t9;
|
|
10043
|
-
if ($[
|
|
9915
|
+
if ($[31] !== documentBuffer || $[32] !== history.state || $[33] !== loadedDocumentIdentity) {
|
|
10044
9916
|
t8 = () => {
|
|
10045
9917
|
if (originalBufferIdentityRef.current === loadedDocumentIdentity) return;
|
|
10046
9918
|
originalBufferIdentityRef.current = loadedDocumentIdentity;
|
|
@@ -10055,18 +9927,18 @@ const useDocumentLoader = (t0) => {
|
|
|
10055
9927
|
documentBuffer,
|
|
10056
9928
|
loadedDocumentIdentity
|
|
10057
9929
|
];
|
|
10058
|
-
$[
|
|
10059
|
-
$[
|
|
10060
|
-
$[
|
|
10061
|
-
$[
|
|
10062
|
-
$[
|
|
9930
|
+
$[31] = documentBuffer;
|
|
9931
|
+
$[32] = history.state;
|
|
9932
|
+
$[33] = loadedDocumentIdentity;
|
|
9933
|
+
$[34] = t8;
|
|
9934
|
+
$[35] = t9;
|
|
10063
9935
|
} else {
|
|
10064
|
-
t8 = $[
|
|
10065
|
-
t9 = $[
|
|
9936
|
+
t8 = $[34];
|
|
9937
|
+
t9 = $[35];
|
|
10066
9938
|
}
|
|
10067
9939
|
useEffect(t8, t9);
|
|
10068
9940
|
let t10;
|
|
10069
|
-
if ($[
|
|
9941
|
+
if ($[36] !== api.heldUnreferencedNotes || $[37] !== api.loadBuffer || $[38] !== api.loadParsedDocument || $[39] !== api.resetForNewDocument || $[40] !== loadedDocumentIdentity) {
|
|
10070
9942
|
t10 = {
|
|
10071
9943
|
loadBuffer: api.loadBuffer,
|
|
10072
9944
|
loadParsedDocument: api.loadParsedDocument,
|
|
@@ -10075,13 +9947,13 @@ const useDocumentLoader = (t0) => {
|
|
|
10075
9947
|
originalBufferRef,
|
|
10076
9948
|
loadedDocumentIdentity
|
|
10077
9949
|
};
|
|
10078
|
-
$[
|
|
10079
|
-
$[
|
|
10080
|
-
$[
|
|
10081
|
-
$[
|
|
10082
|
-
$[
|
|
10083
|
-
$[
|
|
10084
|
-
} else t10 = $[
|
|
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];
|
|
10085
9957
|
return t10;
|
|
10086
9958
|
};
|
|
10087
9959
|
// src/components/hooks/useEditorMode.ts
|
|
@@ -10678,30 +10550,13 @@ function useFindReplace(t0) {
|
|
|
10678
10550
|
return t34;
|
|
10679
10551
|
}
|
|
10680
10552
|
// src/components/hooks/useHeaderFooterEditor.ts
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
}
|
|
10686
|
-
const document = cloneDocumentWithParagraphPropertySources(model);
|
|
10687
|
-
const source = (editPosition === "header" ? document.package.headers : document.package.footers)?.get(activeRId);
|
|
10688
|
-
if (!source) {
|
|
10689
|
-
setEditPosition(null);
|
|
10690
|
-
return;
|
|
10691
|
-
}
|
|
10692
|
-
const newDocument = saveHeaderFooterContent({
|
|
10693
|
-
document,
|
|
10694
|
-
position: editPosition,
|
|
10695
|
-
isFirstPage,
|
|
10696
|
-
activeRId,
|
|
10697
|
-
blocks: proseDocToBlocks(view.state.doc, source.content)
|
|
10698
|
-
});
|
|
10699
|
-
if (newDocument) pushDocument(newDocument);
|
|
10700
|
-
setEditPosition(null);
|
|
10701
|
-
};
|
|
10553
|
+
/**
|
|
10554
|
+
* Hook encapsulating header/footer editing state, content resolution, and
|
|
10555
|
+
* the canonical operations that create and remove a header or footer.
|
|
10556
|
+
*/
|
|
10702
10557
|
const useHeaderFooterEditor = (t0) => {
|
|
10703
|
-
const $ = c(
|
|
10704
|
-
const { history,
|
|
10558
|
+
const $ = c(37);
|
|
10559
|
+
const { history, getCanonicalApi } = t0;
|
|
10705
10560
|
const [hfEditPosition, setHfEditPosition] = useState(null);
|
|
10706
10561
|
const [hfEditIsFirstPage, setHfEditIsFirstPage] = useState(false);
|
|
10707
10562
|
let t1;
|
|
@@ -10728,7 +10583,7 @@ const useHeaderFooterEditor = (t0) => {
|
|
|
10728
10583
|
} else t4 = $[4];
|
|
10729
10584
|
const effectiveSectionProperties = t4;
|
|
10730
10585
|
let t5;
|
|
10731
|
-
if ($[5] !==
|
|
10586
|
+
if ($[5] !== firstPageFooterContent || $[6] !== firstPageHeaderContent || $[7] !== footerContent || $[8] !== getCanonicalApi || $[9] !== hasTitlePg || $[10] !== headerContent) {
|
|
10732
10587
|
t5 = (position, pageNumber) => {
|
|
10733
10588
|
const isFirstPage = hasTitlePg && (pageNumber ?? 1) === 1;
|
|
10734
10589
|
let hf = position === "header" ? headerContent : footerContent;
|
|
@@ -10738,119 +10593,71 @@ const useHeaderFooterEditor = (t0) => {
|
|
|
10738
10593
|
setHfEditPosition(position);
|
|
10739
10594
|
return;
|
|
10740
10595
|
}
|
|
10741
|
-
|
|
10742
|
-
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
if (api.applyCanonicalOperations([operation])) setHfEditPosition(position);
|
|
10752
|
-
return;
|
|
10753
|
-
}
|
|
10754
|
-
if (!history.state) return;
|
|
10755
|
-
const newDoc = createEmptyHeaderFooter(cloneDocumentWithParagraphPropertySources(history.state), position, isFirstPage);
|
|
10756
|
-
if (!newDoc) return;
|
|
10757
|
-
pushDocument(newDoc);
|
|
10758
|
-
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);
|
|
10759
10606
|
};
|
|
10760
|
-
$[5] =
|
|
10761
|
-
$[6] =
|
|
10762
|
-
$[7] =
|
|
10763
|
-
$[8] =
|
|
10764
|
-
$[9] =
|
|
10765
|
-
$[10] =
|
|
10766
|
-
$[11] =
|
|
10767
|
-
|
|
10768
|
-
$[13] = pushDocument;
|
|
10769
|
-
$[14] = t5;
|
|
10770
|
-
} 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];
|
|
10771
10615
|
const handleHeaderFooterDoubleClick = t5;
|
|
10772
10616
|
let t6;
|
|
10773
|
-
if ($[
|
|
10617
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
10774
10618
|
t6 = () => {
|
|
10775
|
-
|
|
10776
|
-
setHfEditPosition(null);
|
|
10777
|
-
return;
|
|
10778
|
-
}
|
|
10779
|
-
if (!hfEditPosition || !history.state?.package) {
|
|
10780
|
-
setHfEditPosition(null);
|
|
10781
|
-
return;
|
|
10782
|
-
}
|
|
10783
|
-
const activeRId = pickActiveHeaderFooterRId(resolution, hfEditPosition, hfEditIsFirstPage);
|
|
10784
|
-
const view = activeRId ? getHfView(activeRId) : null;
|
|
10785
|
-
saveAndCloseHeaderFooterEdit({
|
|
10786
|
-
activeRId,
|
|
10787
|
-
document: history.state,
|
|
10788
|
-
editPosition: hfEditPosition,
|
|
10789
|
-
isFirstPage: hfEditIsFirstPage,
|
|
10790
|
-
pushDocument,
|
|
10791
|
-
setEditPosition: setHfEditPosition,
|
|
10792
|
-
view
|
|
10793
|
-
});
|
|
10619
|
+
setHfEditPosition(null);
|
|
10794
10620
|
};
|
|
10795
|
-
$[
|
|
10796
|
-
|
|
10797
|
-
$[17] = hfEditIsFirstPage;
|
|
10798
|
-
$[18] = hfEditPosition;
|
|
10799
|
-
$[19] = history.state;
|
|
10800
|
-
$[20] = pushDocument;
|
|
10801
|
-
$[21] = resolution;
|
|
10802
|
-
$[22] = t6;
|
|
10803
|
-
} else t6 = $[22];
|
|
10621
|
+
$[12] = t6;
|
|
10622
|
+
} else t6 = $[12];
|
|
10804
10623
|
const handleHeaderFooterSave = t6;
|
|
10805
10624
|
let t7;
|
|
10806
|
-
if ($[
|
|
10625
|
+
if ($[13] !== hfEditPosition) {
|
|
10807
10626
|
t7 = () => {
|
|
10808
10627
|
if (!hfEditPosition) return;
|
|
10809
10628
|
handleHeaderFooterSave();
|
|
10810
10629
|
};
|
|
10811
|
-
$[
|
|
10812
|
-
$[
|
|
10813
|
-
|
|
10814
|
-
} else t7 = $[25];
|
|
10630
|
+
$[13] = hfEditPosition;
|
|
10631
|
+
$[14] = t7;
|
|
10632
|
+
} else t7 = $[14];
|
|
10815
10633
|
const handleBodyClick = t7;
|
|
10816
10634
|
let t8;
|
|
10817
|
-
if ($[
|
|
10635
|
+
if ($[15] !== getCanonicalApi || $[16] !== hfEditIsFirstPage || $[17] !== hfEditPosition || $[18] !== history.state?.package || $[19] !== resolution) {
|
|
10818
10636
|
t8 = () => {
|
|
10819
10637
|
if (!hfEditPosition || !history.state?.package) {
|
|
10820
10638
|
setHfEditPosition(null);
|
|
10821
10639
|
return;
|
|
10822
10640
|
}
|
|
10823
|
-
const
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
document: canonical_0,
|
|
10829
|
-
position: hfEditPosition,
|
|
10830
|
-
rId: activeRId_0
|
|
10831
|
-
}));
|
|
10832
|
-
setHfEditPosition(null);
|
|
10833
|
-
return;
|
|
10834
|
-
}
|
|
10835
|
-
if (activeRId_0) pushDocument(removeHeaderFooter({
|
|
10836
|
-
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,
|
|
10837
10646
|
position: hfEditPosition,
|
|
10838
|
-
|
|
10647
|
+
rId: activeRId
|
|
10839
10648
|
}));
|
|
10840
10649
|
setHfEditPosition(null);
|
|
10841
10650
|
};
|
|
10842
|
-
$[
|
|
10843
|
-
$[
|
|
10844
|
-
$[
|
|
10845
|
-
$[
|
|
10846
|
-
$[
|
|
10847
|
-
$[
|
|
10848
|
-
|
|
10849
|
-
$[33] = t8;
|
|
10850
|
-
} 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];
|
|
10851
10658
|
const handleRemoveHeaderFooter = t8;
|
|
10852
10659
|
let t9;
|
|
10853
|
-
if ($[
|
|
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) {
|
|
10854
10661
|
t9 = {
|
|
10855
10662
|
hfEditPosition,
|
|
10856
10663
|
setHfEditPosition,
|
|
@@ -10870,24 +10677,23 @@ const useHeaderFooterEditor = (t0) => {
|
|
|
10870
10677
|
handleBodyClick,
|
|
10871
10678
|
handleRemoveHeaderFooter
|
|
10872
10679
|
};
|
|
10873
|
-
$[
|
|
10874
|
-
$[
|
|
10875
|
-
$[
|
|
10876
|
-
$[
|
|
10877
|
-
$[
|
|
10878
|
-
$[
|
|
10879
|
-
$[
|
|
10880
|
-
$[
|
|
10881
|
-
$[
|
|
10882
|
-
$[
|
|
10883
|
-
$[
|
|
10884
|
-
$[
|
|
10885
|
-
$[
|
|
10886
|
-
$[
|
|
10887
|
-
$[
|
|
10888
|
-
$[
|
|
10889
|
-
|
|
10890
|
-
} 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];
|
|
10891
10697
|
return t9;
|
|
10892
10698
|
};
|
|
10893
10699
|
// src/components/hooks/useHyperlinkHandlers.ts
|
|
@@ -11526,34 +11332,6 @@ function _temp$3(prev) {
|
|
|
11526
11332
|
visible: false
|
|
11527
11333
|
};
|
|
11528
11334
|
}
|
|
11529
|
-
// src/components/hostDocument.ts
|
|
11530
|
-
/**
|
|
11531
|
-
* The host's own copy of the document the editor shows: the committed
|
|
11532
|
-
* document with the live body, numbering and notes in place of its own.
|
|
11533
|
-
*
|
|
11534
|
-
* Both inputs share objects with the editor's model, so neither is written:
|
|
11535
|
-
* the document is put together over them one level deep, and that whole is
|
|
11536
|
-
* copied once by the copy owner. The copy shares no object with either.
|
|
11537
|
-
*/
|
|
11538
|
-
const copyHostDocument = (committed, live) => {
|
|
11539
|
-
const model = readModel(committed);
|
|
11540
|
-
const stories = readModel(live).package;
|
|
11541
|
-
const documentPackage = {
|
|
11542
|
-
...model.package,
|
|
11543
|
-
document: {
|
|
11544
|
-
...model.package.document,
|
|
11545
|
-
content: stories.document.content
|
|
11546
|
-
}
|
|
11547
|
-
};
|
|
11548
|
-
if (stories.numbering) documentPackage.numbering = stories.numbering;
|
|
11549
|
-
else delete documentPackage.numbering;
|
|
11550
|
-
if (stories.footnotes) documentPackage.footnotes = stories.footnotes;
|
|
11551
|
-
if (stories.endnotes) documentPackage.endnotes = stories.endnotes;
|
|
11552
|
-
return cloneDocumentWithParagraphPropertySources({
|
|
11553
|
-
...model,
|
|
11554
|
-
package: documentPackage
|
|
11555
|
-
});
|
|
11556
|
-
};
|
|
11557
11335
|
// src/components/InlineHeaderFooterEditor.tsx
|
|
11558
11336
|
/**
|
|
11559
11337
|
* InlineHeaderFooterEditor — UI chrome for HF editing.
|
|
@@ -14190,16 +13968,8 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
|
|
|
14190
13968
|
// src/components/DocxEditor.tsx
|
|
14191
13969
|
/** No headings to track while the outline is not shown. */
|
|
14192
13970
|
const NO_HEADINGS = [];
|
|
14193
|
-
const CommentsSidebar = lazy(() => import("./CommentsSidebar-
|
|
13971
|
+
const CommentsSidebar = lazy(() => import("./CommentsSidebar-CjRWDQe6.js").then((m) => ({ default: m.CommentsSidebar })));
|
|
14194
13972
|
const TextContextMenu = lazy(() => import("./TextContextMenu-jOBgICwD.js").then((m) => ({ default: m.TextContextMenu })));
|
|
14195
|
-
const loadAttemptSelectiveSave = async () => {
|
|
14196
|
-
const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
|
|
14197
|
-
return attemptSelectiveSave;
|
|
14198
|
-
};
|
|
14199
|
-
const loadRepackDocx = async () => {
|
|
14200
|
-
const { repackDocx } = await import("@stll/folio-core/docx/rezip");
|
|
14201
|
-
return repackDocx;
|
|
14202
|
-
};
|
|
14203
13973
|
/** Translation key for each display mode's label (trigger and popup). */
|
|
14204
13974
|
const DISPLAY_MODE_LABEL_KEYS = {
|
|
14205
13975
|
"all-markup": "markupView.allMarkup",
|
|
@@ -14283,10 +14053,8 @@ const createPagedEditorBinding = () => {
|
|
|
14283
14053
|
/**
|
|
14284
14054
|
* DocxEditor - Complete DOCX editor component
|
|
14285
14055
|
*/
|
|
14286
|
-
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, onAutocompleteChange, selectedAnonymizationCanonical = null, anonymizationSelectionSeq, showTemplateDirectives = false, onSlashMenuChange, onSlashMenuKeyAction, customContextMenuItems, onCustomContextAction, comments: commentsProp, onCommentsChange, collaboration, plugins, featureFlags,
|
|
14287
|
-
const
|
|
14288
|
-
const canonicalRoom = collaboration !== void 0 && isCanonicalRoomCollaboration(collaboration) ? collaboration : void 0;
|
|
14289
|
-
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;
|
|
14290
14058
|
const pagedEditorRef = useRef(null);
|
|
14291
14059
|
const [pagedEditorBinding] = useState(createPagedEditorBinding);
|
|
14292
14060
|
const scrollContainerRef = useRef(null);
|
|
@@ -14399,10 +14167,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14399
14167
|
const history = useDocumentHistory(initialDocument || null, {
|
|
14400
14168
|
maxEntries: 100,
|
|
14401
14169
|
groupingInterval: 500,
|
|
14402
|
-
enableKeyboardShortcuts:
|
|
14170
|
+
enableKeyboardShortcuts: false
|
|
14403
14171
|
});
|
|
14404
14172
|
const refuseCanonicalModelEdit = useCallback((gap, message) => {
|
|
14405
|
-
if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return false;
|
|
14406
14173
|
const error = new CanonicalSessionRefusalError({
|
|
14407
14174
|
ground: { gap },
|
|
14408
14175
|
message: canonicalRefusalMessage(gap, message)
|
|
@@ -14410,7 +14177,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14410
14177
|
toast(error.message);
|
|
14411
14178
|
onError?.(error);
|
|
14412
14179
|
return true;
|
|
14413
|
-
}, [
|
|
14180
|
+
}, [onError]);
|
|
14414
14181
|
const extensionManager = useMemo(() => {
|
|
14415
14182
|
const mgr = new ExtensionManager(createStarterKit({ historyShortcuts }));
|
|
14416
14183
|
mgr.buildSchema();
|
|
@@ -14439,7 +14206,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14439
14206
|
const [hostPlugins] = useState(() => plugins ?? []);
|
|
14440
14207
|
const editorPlugins = useMemo(() => [
|
|
14441
14208
|
...hostPlugins,
|
|
14442
|
-
...yjsCollaboration?.plugins ?? [],
|
|
14443
14209
|
suggestionPlugin,
|
|
14444
14210
|
aiSuggestionPlugin,
|
|
14445
14211
|
aiCitationPlugin,
|
|
@@ -14447,7 +14213,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14447
14213
|
templatePreviewPlugin
|
|
14448
14214
|
], [
|
|
14449
14215
|
hostPlugins,
|
|
14450
|
-
yjsCollaboration?.plugins,
|
|
14451
14216
|
suggestionPlugin,
|
|
14452
14217
|
aiSuggestionPlugin,
|
|
14453
14218
|
aiCitationPlugin,
|
|
@@ -14636,7 +14401,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14636
14401
|
bodyView: bodyEditorView
|
|
14637
14402
|
});
|
|
14638
14403
|
const comments = canonicalComments ?? legacyComments;
|
|
14639
|
-
const commentDraftMode = usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "prosemirror";
|
|
14640
14404
|
const documentOperationUndoEntriesRef = useRef([]);
|
|
14641
14405
|
const pendingSuggestionRegistryRef = useRef(new FolioPendingSuggestionRegistry());
|
|
14642
14406
|
const styleResolverCacheRef = useRef(null);
|
|
@@ -14684,10 +14448,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14684
14448
|
}, [setBodyHistoryAvailability]);
|
|
14685
14449
|
const { hfEditPosition, setHfEditPosition, hfEditIsFirstPage, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, activeHeaderRId, activeFooterRId, activeFirstHeaderRId, activeFirstFooterRId, hasTitlePg, effectiveSectionProperties, handleHeaderFooterDoubleClick, handleBodyClick, handleRemoveHeaderFooter } = useHeaderFooterEditor({
|
|
14686
14450
|
history,
|
|
14687
|
-
|
|
14688
|
-
getCanonicalApi,
|
|
14689
|
-
experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
|
|
14690
|
-
getHfView: pagedEditorBinding.getHfView
|
|
14451
|
+
getCanonicalApi
|
|
14691
14452
|
});
|
|
14692
14453
|
useLayoutEffect(() => {
|
|
14693
14454
|
if (readOnly && hfEditPosition) handleBodyClick();
|
|
@@ -14741,27 +14502,13 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14741
14502
|
});
|
|
14742
14503
|
const focusActiveEditor = focusCallback.invoke;
|
|
14743
14504
|
const undoActiveEditor = useCallback(() => {
|
|
14744
|
-
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
14748
|
-
}
|
|
14749
|
-
}, [
|
|
14750
|
-
getActiveEditorStory,
|
|
14751
|
-
refreshBodyHistoryAvailability,
|
|
14752
|
-
experimentalSession
|
|
14753
|
-
]);
|
|
14505
|
+
pagedEditorRef.current?.undo();
|
|
14506
|
+
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
14507
|
+
}, [refreshBodyHistoryAvailability]);
|
|
14754
14508
|
const redoActiveEditor = useCallback(() => {
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
14759
|
-
}
|
|
14760
|
-
}, [
|
|
14761
|
-
getActiveEditorStory,
|
|
14762
|
-
refreshBodyHistoryAvailability,
|
|
14763
|
-
experimentalSession
|
|
14764
|
-
]);
|
|
14509
|
+
pagedEditorRef.current?.redo();
|
|
14510
|
+
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
14511
|
+
}, [refreshBodyHistoryAvailability]);
|
|
14765
14512
|
const handleActiveNoteStoryChange = useCallback((story) => {
|
|
14766
14513
|
setActiveNoteStory(story);
|
|
14767
14514
|
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
@@ -14798,11 +14545,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14798
14545
|
builtChangeNotifyRef.current = null;
|
|
14799
14546
|
}, []);
|
|
14800
14547
|
useEffect(() => cancelBuiltChangeNotification, [cancelBuiltChangeNotification]);
|
|
14801
|
-
const { loadBuffer, loadParsedDocument,
|
|
14548
|
+
const { loadBuffer, loadParsedDocument, loadedDocumentIdentity } = useDocumentLoader({
|
|
14802
14549
|
documentBuffer: documentBuffer ?? null,
|
|
14803
14550
|
initialDocument: initialDocument ?? null,
|
|
14804
14551
|
password,
|
|
14805
|
-
experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
|
|
14806
14552
|
history,
|
|
14807
14553
|
onError,
|
|
14808
14554
|
onCompatibilityChange,
|
|
@@ -14912,33 +14658,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14912
14658
|
* and hand the host one copy of it it owns. A document built outside the
|
|
14913
14659
|
* paged editor's notification arrives as `built` and is the model; the
|
|
14914
14660
|
* host gets its copy now or, for a change still in progress, once the
|
|
14915
|
-
* change settles.
|
|
14916
|
-
* comment list, and the host's document a copy of it.
|
|
14661
|
+
* change settles.
|
|
14917
14662
|
*/
|
|
14918
14663
|
const applyDocumentChange = useCallback((change) => {
|
|
14919
|
-
const canonical = usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting);
|
|
14920
|
-
const held = (model_0) => canonical ? model_0 : {
|
|
14921
|
-
...model_0,
|
|
14922
|
-
package: {
|
|
14923
|
-
...model_0.package,
|
|
14924
|
-
document: {
|
|
14925
|
-
...model_0.package.document,
|
|
14926
|
-
comments: commentsRef.current
|
|
14927
|
-
}
|
|
14928
|
-
}
|
|
14929
|
-
};
|
|
14930
|
-
const owned = (copy) => canonical ? copy : {
|
|
14931
|
-
...copy,
|
|
14932
|
-
package: {
|
|
14933
|
-
...copy.package,
|
|
14934
|
-
document: {
|
|
14935
|
-
...copy.package.document,
|
|
14936
|
-
comments: cloneCommentsWithParagraphPropertySources(commentsRef.current)
|
|
14937
|
-
}
|
|
14938
|
-
}
|
|
14939
|
-
};
|
|
14940
14664
|
if ("built" in change) {
|
|
14941
|
-
const built =
|
|
14665
|
+
const built = change.built;
|
|
14942
14666
|
pushDocument(built);
|
|
14943
14667
|
cancelBuiltChangeNotification();
|
|
14944
14668
|
if (change.settles === "later") builtChangeNotifyRef.current = window.setTimeout(() => {
|
|
@@ -14947,10 +14671,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14947
14671
|
}, DOCUMENT_CHANGE_NOTIFY_DELAY_MS);
|
|
14948
14672
|
else onChange?.(cloneDocumentWithParagraphPropertySources(built));
|
|
14949
14673
|
} else {
|
|
14950
|
-
if (change.model) pushDocument(
|
|
14674
|
+
if (change.model) pushDocument(change.model);
|
|
14951
14675
|
if (change.forHost) {
|
|
14952
14676
|
cancelBuiltChangeNotification();
|
|
14953
|
-
onChange?.(
|
|
14677
|
+
onChange?.(change.forHost);
|
|
14954
14678
|
}
|
|
14955
14679
|
if (!change.model) return;
|
|
14956
14680
|
}
|
|
@@ -14962,36 +14686,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
14962
14686
|
pushDocument,
|
|
14963
14687
|
extractTrackedChanges,
|
|
14964
14688
|
refreshBodyHistoryAvailability,
|
|
14965
|
-
commentsRef,
|
|
14966
|
-
experimentalSession,
|
|
14967
14689
|
cancelBuiltChangeNotification
|
|
14968
14690
|
]);
|
|
14969
14691
|
/** A document changed outside the paged editor's own notification. */
|
|
14970
14692
|
const handleDocumentChange = useCallback((newDocument) => applyDocumentChange({ built: newDocument }), [applyDocumentChange]);
|
|
14971
14693
|
const buildCurrentDocument = useCallback(() => {
|
|
14972
|
-
|
|
14973
|
-
|
|
14974
|
-
|
|
14975
|
-
if (canonical_0) return canonical_0;
|
|
14976
|
-
if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return null;
|
|
14977
|
-
const live = pagedEditorRef.current?.getDocument();
|
|
14978
|
-
let doc_0 = live ? copyHostDocument(committed, live) : cloneDocumentWithParagraphPropertySources(committed);
|
|
14979
|
-
if (!live) doc_0 = normalizeBaseDirection(doc_0);
|
|
14980
|
-
const editor_0 = pagedEditorRef.current;
|
|
14981
|
-
if (editor_0) {
|
|
14982
|
-
const flushBag = (bag) => {
|
|
14983
|
-
if (!bag) return;
|
|
14984
|
-
for (const [rId, hf] of bag) {
|
|
14985
|
-
const view_6 = editor_0.getHfView(rId);
|
|
14986
|
-
if (view_6) hf.content = proseDocToBlocks(view_6.state.doc, hf.content);
|
|
14987
|
-
}
|
|
14988
|
-
};
|
|
14989
|
-
flushBag(doc_0.package.headers);
|
|
14990
|
-
flushBag(doc_0.package.footers);
|
|
14991
|
-
}
|
|
14992
|
-
const editorDoc = pagedEditorRef.current?.getView()?.state.doc;
|
|
14993
|
-
return withHostCommentThreads(doc_0, commentsRef.current, { anchoredInEditor: editorDoc ? commentIdsNamedIn(editorDoc) : null });
|
|
14994
|
-
}, [commentsRef, experimentalSession]);
|
|
14694
|
+
if (!historyStateRef.current) return null;
|
|
14695
|
+
return pagedEditorRef.current?.getEditor().getCanonicalDocument() ?? null;
|
|
14696
|
+
}, []);
|
|
14995
14697
|
const applyCanonicalComment = useCallback((request) => {
|
|
14996
14698
|
return getCanonicalApi()?.applyCanonicalComment(request) ?? null;
|
|
14997
14699
|
}, [getCanonicalApi]);
|
|
@@ -15037,9 +14739,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15037
14739
|
return;
|
|
15038
14740
|
}
|
|
15039
14741
|
if (result?.status !== "refused" || result.retry !== "afterComposition") return;
|
|
15040
|
-
const
|
|
15041
|
-
if (!
|
|
15042
|
-
return afterCanonicalCompositionSettles(
|
|
14742
|
+
const view_6 = getCanonicalApi()?.getView();
|
|
14743
|
+
if (!view_6) return;
|
|
14744
|
+
return afterCanonicalCompositionSettles(view_6, () => setControlledCommentsRetry((attempt) => attempt + 1));
|
|
15043
14745
|
});
|
|
15044
14746
|
useEffect(() => synchronizeControlledComments({
|
|
15045
14747
|
commentsProp,
|
|
@@ -15115,15 +14817,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15115
14817
|
}, [refreshFind]);
|
|
15116
14818
|
useEffect(() => {
|
|
15117
14819
|
if (bodyViewEpoch === 0) return;
|
|
15118
|
-
const
|
|
15119
|
-
if (!
|
|
14820
|
+
const editor_0 = pagedEditorRef.current?.getEditor();
|
|
14821
|
+
if (!editor_0) return;
|
|
15120
14822
|
let timer_0 = null;
|
|
15121
14823
|
const schedule = () => {
|
|
15122
14824
|
if (timer_0 !== null) clearTimeout(timer_0);
|
|
15123
14825
|
timer_0 = setTimeout(() => refreshFindRef.current(), 200);
|
|
15124
14826
|
};
|
|
15125
|
-
const unsubscribe =
|
|
15126
|
-
const unsubscribeLayout =
|
|
14827
|
+
const unsubscribe = editor_0.on("docChange", schedule);
|
|
14828
|
+
const unsubscribeLayout = editor_0.on("layoutComplete", schedule);
|
|
15127
14829
|
return () => {
|
|
15128
14830
|
unsubscribe();
|
|
15129
14831
|
unsubscribeLayout();
|
|
@@ -15141,17 +14843,17 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15141
14843
|
resetFindResultRef.current = resetFindResult;
|
|
15142
14844
|
}, [resetFindResult]);
|
|
15143
14845
|
const handleSelectionChange = useCallback((selectionState) => {
|
|
15144
|
-
const
|
|
15145
|
-
if (
|
|
15146
|
-
const { from, to } =
|
|
14846
|
+
const view_7 = getActiveEditorView();
|
|
14847
|
+
if (view_7) {
|
|
14848
|
+
const { from, to } = view_7.state.selection;
|
|
15147
14849
|
lastSelectionRef.current = {
|
|
15148
14850
|
from,
|
|
15149
14851
|
to
|
|
15150
14852
|
};
|
|
15151
14853
|
}
|
|
15152
14854
|
let pmTableCtx = null;
|
|
15153
|
-
if (
|
|
15154
|
-
pmTableCtx = getTableContext(
|
|
14855
|
+
if (view_7) {
|
|
14856
|
+
pmTableCtx = getTableContext(view_7.state);
|
|
15155
14857
|
if (!pmTableCtx.isInTable) pmTableCtx = null;
|
|
15156
14858
|
}
|
|
15157
14859
|
if (pmTableCtx?.cellBorderColor) {
|
|
@@ -15163,8 +14865,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15163
14865
|
color: { rgb }
|
|
15164
14866
|
};
|
|
15165
14867
|
}
|
|
15166
|
-
const pmImageCtx =
|
|
15167
|
-
const detectedChange =
|
|
14868
|
+
const pmImageCtx = view_7 ? detectImageContext(view_7.state) : null;
|
|
14869
|
+
const detectedChange = view_7 ? detectActiveTrackedChange(view_7.state) : null;
|
|
15168
14870
|
const trackedChange = detectedChange === null ? null : {
|
|
15169
14871
|
type: detectedChange.type,
|
|
15170
14872
|
author: detectedChange.author,
|
|
@@ -15234,10 +14936,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15234
14936
|
activeTrackedChange: activeTrackedChange_0
|
|
15235
14937
|
};
|
|
15236
14938
|
});
|
|
15237
|
-
if (
|
|
14939
|
+
if (view_7 && selectionState.hasSelection && !isAddingComment && !readOnly) {
|
|
15238
14940
|
const container = scrollContainerRef.current;
|
|
15239
14941
|
const parentEl = editorContentRef.current;
|
|
15240
|
-
const { from: selFrom } =
|
|
14942
|
+
const { from: selFrom } = view_7.state.selection;
|
|
15241
14943
|
const top = findSelectionYPosition(container, parentEl, selFrom);
|
|
15242
14944
|
if (top !== null && container && parentEl) {
|
|
15243
14945
|
const pagesEl = container.querySelector(".paged-editor__pages");
|
|
@@ -15245,7 +14947,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15245
14947
|
const parentRect = parentEl.getBoundingClientRect();
|
|
15246
14948
|
const rawLeft = pageEl ? pageEl.getBoundingClientRect().right - parentRect.left + 12 : parentRect.width / 2 + 408;
|
|
15247
14949
|
const left = Math.max(16, Math.min(rawLeft, parentRect.width - 16));
|
|
15248
|
-
const { from: from_0, to: to_0 } =
|
|
14950
|
+
const { from: from_0, to: to_0 } = view_7.state.selection;
|
|
15249
14951
|
if (from_0 !== to_0) setFloatingCommentBtn({
|
|
15250
14952
|
top,
|
|
15251
14953
|
left,
|
|
@@ -15408,10 +15110,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15408
15110
|
refuseCanonicalModelEdit
|
|
15409
15111
|
]);
|
|
15410
15112
|
const handleTableAction = useCallback((action_0) => {
|
|
15411
|
-
const
|
|
15412
|
-
if (!
|
|
15113
|
+
const view_8 = getActiveEditorView();
|
|
15114
|
+
if (!view_8) return;
|
|
15413
15115
|
const commands = extensionManager;
|
|
15414
|
-
const run = (command) => executeEditorCommand(
|
|
15116
|
+
const run = (command) => executeEditorCommand(view_8, command);
|
|
15415
15117
|
switch (action_0) {
|
|
15416
15118
|
case "addRowAbove":
|
|
15417
15119
|
run(commands.requireCommand("addRowAbove")());
|
|
@@ -15597,86 +15299,86 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15597
15299
|
}, { pointer: null });
|
|
15598
15300
|
}, [openContextMenu]);
|
|
15599
15301
|
const handleFormat = useCallback((action_1) => {
|
|
15600
|
-
const
|
|
15601
|
-
if (!
|
|
15602
|
-
|
|
15603
|
-
const isBodyEditor =
|
|
15604
|
-
const { from: from_1, to: to_1 } =
|
|
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;
|
|
15605
15307
|
const savedSelection = lastSelectionRef.current;
|
|
15606
15308
|
if (isBodyEditor && savedSelection && (from_1 !== savedSelection.from || to_1 !== savedSelection.to)) try {
|
|
15607
|
-
const tr =
|
|
15608
|
-
|
|
15309
|
+
const tr = view_9.state.tr.setSelection(TextSelection.create(view_9.state.doc, savedSelection.from, savedSelection.to));
|
|
15310
|
+
view_9.dispatch(tr);
|
|
15609
15311
|
} catch {}
|
|
15610
15312
|
if (action_1 === "bold") {
|
|
15611
|
-
executeEditorCommand(
|
|
15313
|
+
executeEditorCommand(view_9, toggleBold);
|
|
15612
15314
|
return;
|
|
15613
15315
|
}
|
|
15614
15316
|
if (action_1 === "italic") {
|
|
15615
|
-
executeEditorCommand(
|
|
15317
|
+
executeEditorCommand(view_9, toggleItalic);
|
|
15616
15318
|
return;
|
|
15617
15319
|
}
|
|
15618
15320
|
if (action_1 === "underline") {
|
|
15619
|
-
executeEditorCommand(
|
|
15321
|
+
executeEditorCommand(view_9, toggleUnderline);
|
|
15620
15322
|
return;
|
|
15621
15323
|
}
|
|
15622
15324
|
if (action_1 === "strikethrough") {
|
|
15623
|
-
executeEditorCommand(
|
|
15325
|
+
executeEditorCommand(view_9, toggleStrike);
|
|
15624
15326
|
return;
|
|
15625
15327
|
}
|
|
15626
15328
|
if (action_1 === "superscript") {
|
|
15627
|
-
executeEditorCommand(
|
|
15329
|
+
executeEditorCommand(view_9, toggleSuperscript);
|
|
15628
15330
|
return;
|
|
15629
15331
|
}
|
|
15630
15332
|
if (action_1 === "subscript") {
|
|
15631
|
-
executeEditorCommand(
|
|
15333
|
+
executeEditorCommand(view_9, toggleSubscript);
|
|
15632
15334
|
return;
|
|
15633
15335
|
}
|
|
15634
15336
|
if (action_1 === "bulletList") {
|
|
15635
|
-
executeEditorCommand(
|
|
15337
|
+
executeEditorCommand(view_9, toggleBulletList);
|
|
15636
15338
|
return;
|
|
15637
15339
|
}
|
|
15638
15340
|
if (action_1 === "numberedList") {
|
|
15639
|
-
executeEditorCommand(
|
|
15341
|
+
executeEditorCommand(view_9, toggleNumberedList);
|
|
15640
15342
|
return;
|
|
15641
15343
|
}
|
|
15642
15344
|
if (action_1 === "indent") {
|
|
15643
|
-
executeFirstEditorCommand(
|
|
15345
|
+
executeFirstEditorCommand(view_9, [increaseListLevel, increaseIndent()]);
|
|
15644
15346
|
return;
|
|
15645
15347
|
}
|
|
15646
15348
|
if (action_1 === "outdent") {
|
|
15647
|
-
executeFirstEditorCommand(
|
|
15349
|
+
executeFirstEditorCommand(view_9, [decreaseListLevel, decreaseIndent()]);
|
|
15648
15350
|
return;
|
|
15649
15351
|
}
|
|
15650
15352
|
if (action_1 === "clearFormatting") {
|
|
15651
|
-
executeEditorCommand(
|
|
15353
|
+
executeEditorCommand(view_9, clearFormatting);
|
|
15652
15354
|
return;
|
|
15653
15355
|
}
|
|
15654
15356
|
if (action_1 === "setRtl") {
|
|
15655
|
-
executeEditorCommand(
|
|
15357
|
+
executeEditorCommand(view_9, setRtl);
|
|
15656
15358
|
return;
|
|
15657
15359
|
}
|
|
15658
15360
|
if (action_1 === "setLtr") {
|
|
15659
|
-
executeEditorCommand(
|
|
15361
|
+
executeEditorCommand(view_9, setLtr);
|
|
15660
15362
|
return;
|
|
15661
15363
|
}
|
|
15662
15364
|
if (action_1 === "insertPageBreak") {
|
|
15663
|
-
executeEditorCommand(
|
|
15365
|
+
executeEditorCommand(view_9, insertPageBreak);
|
|
15664
15366
|
return;
|
|
15665
15367
|
}
|
|
15666
15368
|
if (typeof action_1 === "object") switch (action_1.type) {
|
|
15667
15369
|
case "alignment":
|
|
15668
|
-
executeEditorCommand(
|
|
15370
|
+
executeEditorCommand(view_9, setAlignment(action_1.value));
|
|
15669
15371
|
break;
|
|
15670
15372
|
case "toggleDirection":
|
|
15671
|
-
executeEditorCommand(
|
|
15373
|
+
executeEditorCommand(view_9, toggleBidi);
|
|
15672
15374
|
break;
|
|
15673
15375
|
case "textColor": {
|
|
15674
15376
|
const colorVal_0 = action_1.value;
|
|
15675
|
-
if (typeof colorVal_0 === "string") executeEditorCommand(
|
|
15676
|
-
else if (colorVal_0.auto) executeEditorCommand(
|
|
15377
|
+
if (typeof colorVal_0 === "string") executeEditorCommand(view_9, setTextColor({ rgb: colorVal_0.replace("#", "") }));
|
|
15378
|
+
else if (colorVal_0.auto) executeEditorCommand(view_9, clearTextColor);
|
|
15677
15379
|
else {
|
|
15678
15380
|
const themeColor = typeof colorVal_0.themeColor === "string" ? colorVal_0.themeColor : void 0;
|
|
15679
|
-
executeEditorCommand(
|
|
15381
|
+
executeEditorCommand(view_9, setTextColor({
|
|
15680
15382
|
...colorVal_0.rgb === void 0 ? {} : { rgb: colorVal_0.rgb },
|
|
15681
15383
|
...themeColor ? { themeColor } : {},
|
|
15682
15384
|
...colorVal_0.themeTint === void 0 ? {} : { themeTint: colorVal_0.themeTint },
|
|
@@ -15687,17 +15389,17 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15687
15389
|
}
|
|
15688
15390
|
case "highlightColor": {
|
|
15689
15391
|
const highlightName = action_1.value ? mapHexToHighlightName(action_1.value) : "";
|
|
15690
|
-
executeEditorCommand(
|
|
15392
|
+
executeEditorCommand(view_9, setHighlight(highlightName || action_1.value));
|
|
15691
15393
|
break;
|
|
15692
15394
|
}
|
|
15693
15395
|
case "fontSize":
|
|
15694
|
-
executeEditorCommand(
|
|
15396
|
+
executeEditorCommand(view_9, setFontSize(pointsToHalfPoints(action_1.value)));
|
|
15695
15397
|
break;
|
|
15696
15398
|
case "fontFamily":
|
|
15697
|
-
executeEditorCommand(
|
|
15399
|
+
executeEditorCommand(view_9, setFontFamily(action_1.value));
|
|
15698
15400
|
break;
|
|
15699
15401
|
case "lineSpacing":
|
|
15700
|
-
executeEditorCommand(
|
|
15402
|
+
executeEditorCommand(view_9, setLineSpacing(action_1.value));
|
|
15701
15403
|
break;
|
|
15702
15404
|
case "applyStyle": {
|
|
15703
15405
|
const committed_2 = historyStateRef.current;
|
|
@@ -15711,21 +15413,21 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15711
15413
|
const styleName = styleResolver_0.getStyle(action_1.value)?.name;
|
|
15712
15414
|
if (styleName) styleAttrs.styleName = styleName;
|
|
15713
15415
|
styleAttrs.numbering = currentDoc_0?.package.numbering ? getCachedNumberingMap(currentDoc_0.package.numbering) : null;
|
|
15714
|
-
executeEditorCommand(
|
|
15715
|
-
} else executeEditorCommand(
|
|
15416
|
+
executeEditorCommand(view_9, applyStyle(action_1.value, styleAttrs));
|
|
15417
|
+
} else executeEditorCommand(view_9, applyStyle(action_1.value));
|
|
15716
15418
|
break;
|
|
15717
15419
|
}
|
|
15718
15420
|
}
|
|
15719
15421
|
}, [getActiveEditorView, getCachedStyleResolver]);
|
|
15720
15422
|
const captureFormatPainter = useCallback(() => {
|
|
15721
|
-
const
|
|
15722
|
-
capturedFormatMarksRef.current =
|
|
15423
|
+
const view_10 = getActiveEditorView();
|
|
15424
|
+
capturedFormatMarksRef.current = view_10 ? captureFormatMarks(view_10.state) : null;
|
|
15723
15425
|
}, [getActiveEditorView]);
|
|
15724
15426
|
const paintFormatToSelection = useCallback(() => {
|
|
15725
|
-
const
|
|
15726
|
-
if (!
|
|
15727
|
-
const applied = applyFormatMarks(capturedFormatMarksRef.current)(
|
|
15728
|
-
if (applied) requestAnimationFrame(() =>
|
|
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());
|
|
15729
15431
|
return applied;
|
|
15730
15432
|
}, [getActiveEditorView]);
|
|
15731
15433
|
const handleFormatPainter = useCallback((sticky) => {
|
|
@@ -15785,14 +15487,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15785
15487
|
setFormatPainterMode
|
|
15786
15488
|
]);
|
|
15787
15489
|
const handleContextMenu = useCallback((data) => {
|
|
15788
|
-
const
|
|
15490
|
+
const view_12 = getActiveEditorView();
|
|
15789
15491
|
openContextMenu({
|
|
15790
15492
|
x: data.x,
|
|
15791
15493
|
y: data.y
|
|
15792
15494
|
}, {
|
|
15793
15495
|
hasSelectionOverride: data.hasSelection,
|
|
15794
|
-
pointer:
|
|
15795
|
-
state:
|
|
15496
|
+
pointer: view_12 && data.position !== null ? {
|
|
15497
|
+
state: view_12.state,
|
|
15796
15498
|
position: data.position
|
|
15797
15499
|
} : null
|
|
15798
15500
|
});
|
|
@@ -15875,12 +15577,12 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15875
15577
|
dividerAfter: true
|
|
15876
15578
|
});
|
|
15877
15579
|
if (contextMenu.trackedChange) {
|
|
15878
|
-
const
|
|
15580
|
+
const held = contextMenu.trackedChange.heldByLock;
|
|
15879
15581
|
const reason = t("trackedChanges.heldByLock");
|
|
15880
15582
|
items.push({
|
|
15881
15583
|
action: "acceptChange",
|
|
15882
15584
|
label: t("acceptChange"),
|
|
15883
|
-
...
|
|
15585
|
+
...held.accept && {
|
|
15884
15586
|
disabled: true,
|
|
15885
15587
|
disabledReason: reason
|
|
15886
15588
|
}
|
|
@@ -15888,7 +15590,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15888
15590
|
action: "rejectChange",
|
|
15889
15591
|
label: t("rejectChange"),
|
|
15890
15592
|
dividerAfter: true,
|
|
15891
|
-
...
|
|
15593
|
+
...held.reject && {
|
|
15892
15594
|
disabled: true,
|
|
15893
15595
|
disabledReason: reason
|
|
15894
15596
|
}
|
|
@@ -15924,15 +15626,15 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15924
15626
|
const { from: contextSelectionFrom, to: contextSelectionTo } = contextMenu.selectionRange;
|
|
15925
15627
|
const contextTrackedChange = contextMenu.trackedChange;
|
|
15926
15628
|
const handleContextMenuAction = useCallback(async (action_2) => {
|
|
15927
|
-
const
|
|
15928
|
-
if (!
|
|
15629
|
+
const view_13 = getActiveEditorView();
|
|
15630
|
+
if (!view_13) return;
|
|
15929
15631
|
focusActiveEditor();
|
|
15930
15632
|
if (readOnly && action_2 !== "copy" && action_2 !== "selectAll") return;
|
|
15931
15633
|
if (action_2.startsWith("custom:")) {
|
|
15932
15634
|
const { from: from_2, to: to_2 } = contextSelectionFrom !== contextSelectionTo ? {
|
|
15933
15635
|
from: contextSelectionFrom,
|
|
15934
15636
|
to: contextSelectionTo
|
|
15935
|
-
} :
|
|
15637
|
+
} : view_13.state.selection;
|
|
15936
15638
|
onCustomContextAction?.(action_2.slice(7), {
|
|
15937
15639
|
from: from_2,
|
|
15938
15640
|
to: to_2
|
|
@@ -15942,10 +15644,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15942
15644
|
switch (action_2) {
|
|
15943
15645
|
case "cut": {
|
|
15944
15646
|
if (readOnly) return;
|
|
15945
|
-
const { from: from_5, to: to_5 } =
|
|
15946
|
-
const text_2 =
|
|
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");
|
|
15947
15649
|
navigator.clipboard.writeText(text_2).catch(() => void 0);
|
|
15948
|
-
executeEditorCommand(
|
|
15650
|
+
executeEditorCommand(view_13, replaceRangeText({
|
|
15949
15651
|
from: from_5,
|
|
15950
15652
|
to: to_5,
|
|
15951
15653
|
text: ""
|
|
@@ -15954,8 +15656,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15954
15656
|
break;
|
|
15955
15657
|
}
|
|
15956
15658
|
case "copy": {
|
|
15957
|
-
const { from: cf, to: ct } =
|
|
15958
|
-
const copied =
|
|
15659
|
+
const { from: cf, to: ct } = view_13.state.selection;
|
|
15660
|
+
const copied = view_13.state.doc.textBetween(cf, ct, "\n");
|
|
15959
15661
|
navigator.clipboard.writeText(copied).catch(() => void 0);
|
|
15960
15662
|
onCopy?.();
|
|
15961
15663
|
break;
|
|
@@ -15978,12 +15680,12 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15978
15680
|
bubbles: true,
|
|
15979
15681
|
cancelable: true
|
|
15980
15682
|
});
|
|
15981
|
-
|
|
15683
|
+
view_13.dom.dispatchEvent(pasteEvent);
|
|
15982
15684
|
} catch {
|
|
15983
15685
|
try {
|
|
15984
15686
|
const text_0 = await navigator.clipboard.readText();
|
|
15985
|
-
if (text_0 && !
|
|
15986
|
-
pastePlainTextSlice(
|
|
15687
|
+
if (text_0 && !view_13.isDestroyed) {
|
|
15688
|
+
pastePlainTextSlice(view_13, buildPlainTextSlice(text_0, view_13.state.schema));
|
|
15987
15689
|
onPaste?.();
|
|
15988
15690
|
}
|
|
15989
15691
|
} catch {}
|
|
@@ -15992,8 +15694,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
15992
15694
|
case "pasteAsPlainText":
|
|
15993
15695
|
try {
|
|
15994
15696
|
const text = await navigator.clipboard.readText();
|
|
15995
|
-
if (text && !
|
|
15996
|
-
pastePlainTextSlice(
|
|
15697
|
+
if (text && !view_13.isDestroyed) {
|
|
15698
|
+
pastePlainTextSlice(view_13, buildPlainTextSlice(text, view_13.state.schema));
|
|
15997
15699
|
onPaste?.();
|
|
15998
15700
|
}
|
|
15999
15701
|
} catch {
|
|
@@ -16001,8 +15703,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16001
15703
|
}
|
|
16002
15704
|
break;
|
|
16003
15705
|
case "delete": {
|
|
16004
|
-
const { from: from_4, to: to_4 } =
|
|
16005
|
-
if (from_4 !== to_4) executeEditorCommand(
|
|
15706
|
+
const { from: from_4, to: to_4 } = view_13.state.selection;
|
|
15707
|
+
if (from_4 !== to_4) executeEditorCommand(view_13, replaceRangeText({
|
|
16006
15708
|
from: from_4,
|
|
16007
15709
|
to: to_4,
|
|
16008
15710
|
text: ""
|
|
@@ -16010,49 +15712,43 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16010
15712
|
break;
|
|
16011
15713
|
}
|
|
16012
15714
|
case "selectAll":
|
|
16013
|
-
|
|
15715
|
+
view_13.dispatch(view_13.state.tr.setSelection(TextSelection.create(view_13.state.doc, 0, view_13.state.doc.content.size)));
|
|
16014
15716
|
break;
|
|
16015
15717
|
case "addRowAbove":
|
|
16016
|
-
executeEditorCommand(
|
|
15718
|
+
executeEditorCommand(view_13, extensionManager.requireCommand("addRowAbove")());
|
|
16017
15719
|
break;
|
|
16018
15720
|
case "addRowBelow":
|
|
16019
|
-
executeEditorCommand(
|
|
15721
|
+
executeEditorCommand(view_13, extensionManager.requireCommand("addRowBelow")());
|
|
16020
15722
|
break;
|
|
16021
15723
|
case "deleteRow":
|
|
16022
|
-
executeEditorCommand(
|
|
15724
|
+
executeEditorCommand(view_13, extensionManager.requireCommand("deleteRow")());
|
|
16023
15725
|
break;
|
|
16024
15726
|
case "addColumnLeft":
|
|
16025
|
-
executeEditorCommand(
|
|
15727
|
+
executeEditorCommand(view_13, extensionManager.requireCommand("addColumnLeft")());
|
|
16026
15728
|
break;
|
|
16027
15729
|
case "addColumnRight":
|
|
16028
|
-
executeEditorCommand(
|
|
15730
|
+
executeEditorCommand(view_13, extensionManager.requireCommand("addColumnRight")());
|
|
16029
15731
|
break;
|
|
16030
15732
|
case "deleteColumn":
|
|
16031
|
-
executeEditorCommand(
|
|
15733
|
+
executeEditorCommand(view_13, extensionManager.requireCommand("deleteColumn")());
|
|
16032
15734
|
break;
|
|
16033
15735
|
case "tableBordersAll":
|
|
16034
|
-
executeEditorCommand(
|
|
15736
|
+
executeEditorCommand(view_13, extensionManager.requireCommand("setTableBorderPreset")("all"));
|
|
16035
15737
|
break;
|
|
16036
15738
|
case "tableBordersNone":
|
|
16037
|
-
executeEditorCommand(
|
|
15739
|
+
executeEditorCommand(view_13, extensionManager.requireCommand("setTableBorderPreset")("none"));
|
|
16038
15740
|
break;
|
|
16039
15741
|
case "addComment": {
|
|
16040
15742
|
const { from: from_3, to: to_3 } = contextSelectionFrom !== contextSelectionTo ? {
|
|
16041
15743
|
from: contextSelectionFrom,
|
|
16042
15744
|
to: contextSelectionTo
|
|
16043
|
-
} :
|
|
15745
|
+
} : view_13.state.selection;
|
|
16044
15746
|
if (from_3 === to_3) break;
|
|
16045
15747
|
const commentY = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, from_3) ?? getFallbackCommentYPosition(scrollContainerRef.current);
|
|
16046
15748
|
setCommentSelectionRange({
|
|
16047
15749
|
from: from_3,
|
|
16048
15750
|
to: to_3
|
|
16049
15751
|
});
|
|
16050
|
-
if (commentDraftMode === "prosemirror") {
|
|
16051
|
-
if (!markPendingComment(view_14, {
|
|
16052
|
-
from: from_3,
|
|
16053
|
-
to: to_3
|
|
16054
|
-
}, { selectEnd: true })) break;
|
|
16055
|
-
}
|
|
16056
15752
|
setAddCommentYPosition(commentY);
|
|
16057
15753
|
setShowCommentsSidebar(true);
|
|
16058
15754
|
setIsAddingComment(true);
|
|
@@ -16066,7 +15762,7 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16066
15762
|
editor: pagedEditorRef.current?.getEditor(),
|
|
16067
15763
|
...range_0,
|
|
16068
15764
|
resolution: "accept"
|
|
16069
|
-
}) === null) acceptChange(range_0.from, range_0.to)(
|
|
15765
|
+
}) === null) acceptChange(range_0.from, range_0.to)(view_13.state, view_13.dispatch);
|
|
16070
15766
|
break;
|
|
16071
15767
|
}
|
|
16072
15768
|
case "rejectChange": {
|
|
@@ -16076,14 +15772,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16076
15772
|
editor: pagedEditorRef.current?.getEditor(),
|
|
16077
15773
|
...range,
|
|
16078
15774
|
resolution: "reject"
|
|
16079
|
-
}) === null) rejectChange(range.from, range.to)(
|
|
15775
|
+
}) === null) rejectChange(range.from, range.to)(view_13.state, view_13.dispatch);
|
|
16080
15776
|
break;
|
|
16081
15777
|
}
|
|
16082
15778
|
case "restartNumbering":
|
|
16083
|
-
executeEditorCommand(
|
|
15779
|
+
executeEditorCommand(view_13, restartNumbering);
|
|
16084
15780
|
break;
|
|
16085
15781
|
case "continueNumbering":
|
|
16086
|
-
executeEditorCommand(
|
|
15782
|
+
executeEditorCommand(view_13, continueNumbering);
|
|
16087
15783
|
break;
|
|
16088
15784
|
case "setNumberingValue": setNumberingValueDialogOpen(true);
|
|
16089
15785
|
}
|
|
@@ -16099,7 +15795,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16099
15795
|
contextSelectionFrom,
|
|
16100
15796
|
contextSelectionTo,
|
|
16101
15797
|
contextTrackedChange,
|
|
16102
|
-
commentDraftMode,
|
|
16103
15798
|
setAddCommentYPosition,
|
|
16104
15799
|
setCommentSelectionRange,
|
|
16105
15800
|
setFloatingCommentBtn,
|
|
@@ -16116,13 +15811,13 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16116
15811
|
}
|
|
16117
15812
|
if (api_0.applyCanonicalSectionProperties(props) !== null) return;
|
|
16118
15813
|
if (!history.state || readOnly) return;
|
|
16119
|
-
const
|
|
16120
|
-
const body =
|
|
15814
|
+
const model_0 = history.state;
|
|
15815
|
+
const body = model_0.package.document;
|
|
16121
15816
|
applyDocumentChange({
|
|
16122
15817
|
built: {
|
|
16123
|
-
...
|
|
15818
|
+
...model_0,
|
|
16124
15819
|
package: {
|
|
16125
|
-
...
|
|
15820
|
+
...model_0.package,
|
|
16126
15821
|
document: {
|
|
16127
15822
|
...body,
|
|
16128
15823
|
finalSectionProperties: {
|
|
@@ -16146,9 +15841,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16146
15841
|
const handleTopMarginChange = useCallback((twips_1) => handlePageSetupApply({ marginTop: twips_1 }), [handlePageSetupApply]);
|
|
16147
15842
|
const handleBottomMarginChange = useCallback((twips_2) => handlePageSetupApply({ marginBottom: twips_2 }), [handlePageSetupApply]);
|
|
16148
15843
|
const applyRulerEdit = useCallback((edit) => {
|
|
16149
|
-
const
|
|
16150
|
-
if (!
|
|
16151
|
-
applyRulerParagraphEdit(
|
|
15844
|
+
const view_14 = getActiveEditorView();
|
|
15845
|
+
if (!view_14) return;
|
|
15846
|
+
applyRulerParagraphEdit(view_14, edit);
|
|
16152
15847
|
}, [getActiveEditorView]);
|
|
16153
15848
|
const handleIndentLeftChange = useCallback((twips_3) => applyRulerEdit({
|
|
16154
15849
|
type: "indentLeft",
|
|
@@ -16170,11 +15865,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16170
15865
|
let tripwireResult = null;
|
|
16171
15866
|
let savedBuffer = null;
|
|
16172
15867
|
try {
|
|
16173
|
-
const
|
|
16174
|
-
const snapshot_0 =
|
|
16175
|
-
if (snapshot_0 &&
|
|
16176
|
-
const
|
|
16177
|
-
const editorState =
|
|
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;
|
|
16178
15873
|
const result_2 = await serializeCanonicalSave({
|
|
16179
15874
|
snapshot: snapshot_0,
|
|
16180
15875
|
options,
|
|
@@ -16182,70 +15877,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16182
15877
|
});
|
|
16183
15878
|
for (const diagnostic of result_2.diagnostics) if (!options?.onDiagnostic) onError?.(canonicalSaveDiagnosticError(diagnostic));
|
|
16184
15879
|
tripwireResult = result_2.tripwireResult;
|
|
16185
|
-
if (
|
|
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);
|
|
16186
15881
|
savedBuffer = result_2.buffer;
|
|
16187
|
-
} else
|
|
16188
|
-
if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.save)) return null;
|
|
16189
|
-
const view_17 = pagedEditorRef.current?.getView();
|
|
16190
|
-
const editorState_0 = view_17?.state;
|
|
16191
|
-
const baselineBuffer = originalBufferRef.current;
|
|
16192
|
-
const current_0 = buildCurrentDocument();
|
|
16193
|
-
const doc_1 = current_0 ? withoutUnreferencedNotes(current_0, heldUnreferencedNotes()) : null;
|
|
16194
|
-
if (!doc_1) return null;
|
|
16195
|
-
const { resolveSelectiveSaveFlags } = await import("@stll/folio-core/docx/selectiveSaveFlags");
|
|
16196
|
-
const flags = resolveSelectiveSaveFlags(featureFlags);
|
|
16197
|
-
const useSelectiveForSave = flags.selectiveSave && options?.mode !== FOLIO_DOCX_SERIALIZATION_MODE.full;
|
|
16198
|
-
const shouldAttemptSelective = useSelectiveForSave || flags.selectiveSaveTripwire;
|
|
16199
|
-
let selectiveBuffer = null;
|
|
16200
|
-
if (shouldAttemptSelective && editorState_0 && baselineBuffer) selectiveBuffer = await (await loadAttemptSelectiveSave())(doc_1, baselineBuffer, {
|
|
16201
|
-
changedParaIds: getChangedParagraphIds(editorState_0),
|
|
16202
|
-
structuralChange: hasStructuralChanges(editorState_0),
|
|
16203
|
-
hasUntrackedChanges: hasUntrackedChanges(editorState_0),
|
|
16204
|
-
maxBytes: flags.selectiveSaveMaxBytes,
|
|
16205
|
-
onSelectiveDecline: options?.onSelectiveDecline,
|
|
16206
|
-
onDiagnostic: options?.onDiagnostic
|
|
16207
|
-
});
|
|
16208
|
-
let buffer = useSelectiveForSave ? selectiveBuffer : null;
|
|
16209
|
-
let fullBuffer = null;
|
|
16210
|
-
let path = "selective";
|
|
16211
|
-
const repackSourceDoc = baselineBuffer ? {
|
|
16212
|
-
...doc_1,
|
|
16213
|
-
originalBuffer: baselineBuffer
|
|
16214
|
-
} : doc_1;
|
|
16215
|
-
const fullDiagnostics = [];
|
|
16216
|
-
const collectFullDiagnostic = (diagnostic_0) => fullDiagnostics.push(diagnostic_0);
|
|
16217
|
-
const repackFull = async () => {
|
|
16218
|
-
if (!baselineBuffer) {
|
|
16219
|
-
const { createDocx } = await import("@stll/folio-core/docx/rezip");
|
|
16220
|
-
return createDocx(repackSourceDoc, { onDiagnostic: collectFullDiagnostic });
|
|
16221
|
-
}
|
|
16222
|
-
const repackDocx = await loadRepackDocx();
|
|
16223
|
-
const repack = () => repackDocx(repackSourceDoc, { onDiagnostic: collectFullDiagnostic });
|
|
16224
|
-
return editorState_0 ? repackWithEditorSectionRemovals({
|
|
16225
|
-
state: editorState_0,
|
|
16226
|
-
document: repackSourceDoc,
|
|
16227
|
-
repack
|
|
16228
|
-
}) : repack();
|
|
16229
|
-
};
|
|
16230
|
-
if (!buffer) {
|
|
16231
|
-
fullBuffer = await repackFull();
|
|
16232
|
-
buffer = fullBuffer;
|
|
16233
|
-
path = "full-repack";
|
|
16234
|
-
} else if (flags.selectiveSaveTripwire) try {
|
|
16235
|
-
fullBuffer = await repackFull();
|
|
16236
|
-
} catch {}
|
|
16237
|
-
if (flags.selectiveSaveTripwire && fullBuffer && onSelectiveSaveTripwire) try {
|
|
16238
|
-
const { compareSelectiveVsFull } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
|
|
16239
|
-
tripwireResult = await compareSelectiveVsFull(selectiveBuffer, fullBuffer);
|
|
16240
|
-
} catch {}
|
|
16241
|
-
for (const diagnostic_1 of fullDiagnostics) options?.onDiagnostic?.(diagnostic_1);
|
|
16242
|
-
options?.onSerializationPath?.(path);
|
|
16243
|
-
if (view_17 && pagedEditorRef.current?.getView() === view_17 && view_17.state.doc === editorState_0?.doc) {
|
|
16244
|
-
originalBufferRef.current = buffer;
|
|
16245
|
-
view_17.dispatch(clearTrackedChanges(view_17.state));
|
|
16246
|
-
}
|
|
16247
|
-
savedBuffer = buffer;
|
|
16248
|
-
}
|
|
15882
|
+
} else return null;
|
|
16249
15883
|
} catch (error_0) {
|
|
16250
15884
|
onError?.(error_0 instanceof Error ? error_0 : /* @__PURE__ */ new Error("Failed to save document"));
|
|
16251
15885
|
return null;
|
|
@@ -16253,27 +15887,23 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16253
15887
|
if (tripwireResult && onSelectiveSaveTripwire) onSelectiveSaveTripwire(tripwireResult);
|
|
16254
15888
|
return savedBuffer;
|
|
16255
15889
|
}, [
|
|
16256
|
-
buildCurrentDocument,
|
|
16257
|
-
heldUnreferencedNotes,
|
|
16258
15890
|
onError,
|
|
16259
|
-
originalBufferRef,
|
|
16260
15891
|
featureFlags,
|
|
16261
|
-
onSelectiveSaveTripwire
|
|
16262
|
-
experimentalSession
|
|
15892
|
+
onSelectiveSaveTripwire
|
|
16263
15893
|
]);
|
|
16264
15894
|
const handleSave = useCallback(async (options_0) => {
|
|
16265
|
-
const
|
|
15895
|
+
const editor_2 = pagedEditorRef.current?.getEditor();
|
|
16266
15896
|
const serializationOptions = {
|
|
16267
15897
|
onDiagnostic: options_0?.onDiagnostic,
|
|
16268
15898
|
onSelectiveDecline: options_0?.onSelectiveDecline,
|
|
16269
15899
|
onSerializationPath: options_0?.onSerializationPath,
|
|
16270
15900
|
mode: options_0?.selective === false ? FOLIO_DOCX_SERIALIZATION_MODE.full : FOLIO_DOCX_SERIALIZATION_MODE.preferSelective
|
|
16271
15901
|
};
|
|
16272
|
-
const
|
|
16273
|
-
if (!
|
|
15902
|
+
const buffer = editor_2 ? await editor_2.getDocx(serializationOptions) : await serializeCurrentDocx(serializationOptions);
|
|
15903
|
+
if (!buffer) return null;
|
|
16274
15904
|
setCommentsDirty(false);
|
|
16275
|
-
onSave?.(
|
|
16276
|
-
return
|
|
15905
|
+
onSave?.(buffer);
|
|
15906
|
+
return buffer;
|
|
16277
15907
|
}, [
|
|
16278
15908
|
setCommentsDirty,
|
|
16279
15909
|
onSave,
|
|
@@ -16304,11 +15934,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16304
15934
|
getFindResult,
|
|
16305
15935
|
clearFind: resetFindResult,
|
|
16306
15936
|
hasPendingChanges: () => {
|
|
16307
|
-
const
|
|
16308
|
-
if (!
|
|
16309
|
-
const
|
|
16310
|
-
if (
|
|
16311
|
-
return getCommentsDirty() || getChangedParagraphIds(
|
|
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);
|
|
16312
15942
|
},
|
|
16313
15943
|
getEditorRef: () => pagedEditorRef.current,
|
|
16314
15944
|
getEditor: () => pagedEditorRef.current?.getEditor() ?? null,
|
|
@@ -16338,28 +15968,28 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16338
15968
|
},
|
|
16339
15969
|
loadDocument: (document_0) => {
|
|
16340
15970
|
pendingSuggestionRegistryRef.current.clear();
|
|
16341
|
-
const
|
|
16342
|
-
if (
|
|
16343
|
-
|
|
15971
|
+
const editor_3 = pagedEditorRef.current?.getEditor();
|
|
15972
|
+
if (editor_3) {
|
|
15973
|
+
editor_3.loadDocument(document_0);
|
|
16344
15974
|
return;
|
|
16345
15975
|
}
|
|
16346
15976
|
loadParsedDocument(document_0);
|
|
16347
15977
|
},
|
|
16348
|
-
loadDocumentBuffer: (
|
|
15978
|
+
loadDocumentBuffer: (buffer_0) => {
|
|
16349
15979
|
pendingSuggestionRegistryRef.current.clear();
|
|
16350
|
-
return pagedEditorRef.current?.getEditor().loadDocx(
|
|
15980
|
+
return pagedEditorRef.current?.getEditor().loadDocx(buffer_0) ?? loadBuffer(buffer_0);
|
|
16351
15981
|
},
|
|
16352
15982
|
ensureEditorView: (options_3) => {
|
|
16353
15983
|
pagedEditorRef.current?.ensureView(options_3);
|
|
16354
15984
|
},
|
|
16355
15985
|
createAIEditSnapshot: () => {
|
|
16356
|
-
const
|
|
16357
|
-
return
|
|
15986
|
+
const view_17 = pagedEditorRef.current?.getView();
|
|
15987
|
+
return view_17 ? createFolioAIEditSnapshot(view_17.state.doc) : null;
|
|
16358
15988
|
},
|
|
16359
15989
|
applyDocumentOperations: ({ undefinedReferences, snapshot: snapshot_1, batch, author: operationAuthor = author }) => {
|
|
16360
15990
|
assertSupportedFolioDocumentOperationVersion(batch.version);
|
|
16361
|
-
const
|
|
16362
|
-
if (!
|
|
15991
|
+
const view_18 = pagedEditorRef.current?.getView();
|
|
15992
|
+
if (!view_18) {
|
|
16363
15993
|
let status = "committed";
|
|
16364
15994
|
if (batch.dryRun === true) status = "previewed";
|
|
16365
15995
|
else if (batch.atomic === true) status = "rejected";
|
|
@@ -16377,36 +16007,36 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16377
16007
|
undoHandle: null
|
|
16378
16008
|
};
|
|
16379
16009
|
}
|
|
16380
|
-
const activeBeforeCanonical = new Set(getSuggestions(
|
|
16381
|
-
const
|
|
16010
|
+
const activeBeforeCanonical = new Set(getSuggestions(view_18.state).map((s_0) => s_0.suggestionId));
|
|
16011
|
+
const canonical_0 = getCanonicalApi()?.applyCanonicalDocumentOperations({
|
|
16382
16012
|
undefinedReferences,
|
|
16383
16013
|
snapshot: snapshot_1,
|
|
16384
16014
|
batch,
|
|
16385
16015
|
author: operationAuthor
|
|
16386
16016
|
});
|
|
16387
|
-
if (
|
|
16388
|
-
if (batch.mode === "suggested" &&
|
|
16017
|
+
if (canonical_0) {
|
|
16018
|
+
if (batch.mode === "suggested" && canonical_0.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
|
|
16389
16019
|
snapshot: snapshot_1,
|
|
16390
16020
|
story: { type: "main" },
|
|
16391
16021
|
operations: batch.operations,
|
|
16392
|
-
applied:
|
|
16022
|
+
applied: canonical_0.applied,
|
|
16393
16023
|
author: operationAuthor,
|
|
16394
16024
|
activeSuggestionIds: activeBeforeCanonical
|
|
16395
16025
|
});
|
|
16396
|
-
return
|
|
16026
|
+
return canonical_0;
|
|
16397
16027
|
}
|
|
16398
16028
|
const existingUndoEntry = documentOperationUndoEntriesRef.current.at(-1);
|
|
16399
|
-
if (existingUndoEntry && (!
|
|
16029
|
+
if (existingUndoEntry && (!view_18.state.doc.eq(existingUndoEntry.afterState.doc) || canonicalJson(commentRecordsOf(view_18.state)) !== existingUndoEntry.commentsAfterJson)) documentOperationUndoEntriesRef.current.length = 0;
|
|
16400
16030
|
const createdComments = [];
|
|
16401
|
-
const recordingView = recordingCommentsView(
|
|
16031
|
+
const recordingView = recordingCommentsView(view_18, createdComments);
|
|
16402
16032
|
const operationView = {
|
|
16403
|
-
state:
|
|
16033
|
+
state: view_18.state,
|
|
16404
16034
|
dispatch: (transaction) => {
|
|
16405
16035
|
recordingView.dispatch(closeHistory(transaction));
|
|
16406
|
-
operationView.state =
|
|
16036
|
+
operationView.state = view_18.state;
|
|
16407
16037
|
}
|
|
16408
16038
|
};
|
|
16409
|
-
const activeSuggestionIds = new Set(getSuggestions(
|
|
16039
|
+
const activeSuggestionIds = new Set(getSuggestions(view_18.state).map((s_1) => s_1.suggestionId));
|
|
16410
16040
|
const result_3 = applyFolioDocumentOperations({
|
|
16411
16041
|
undefinedReferences,
|
|
16412
16042
|
view: operationView,
|
|
@@ -16433,14 +16063,14 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16433
16063
|
});
|
|
16434
16064
|
if (result_3.undoHandle !== null) documentOperationUndoEntriesRef.current.push({
|
|
16435
16065
|
undoHandle: result_3.undoHandle,
|
|
16436
|
-
afterState:
|
|
16437
|
-
commentsAfterJson: canonicalJson(commentRecordsOf(
|
|
16066
|
+
afterState: view_18.state,
|
|
16067
|
+
commentsAfterJson: canonicalJson(commentRecordsOf(view_18.state))
|
|
16438
16068
|
});
|
|
16439
16069
|
return result_3;
|
|
16440
16070
|
},
|
|
16441
16071
|
undoDocumentOperations: (undoHandle) => {
|
|
16442
|
-
const
|
|
16443
|
-
if (
|
|
16072
|
+
const canonical_1 = getCanonicalApi()?.undoCanonicalDocumentOperations(undoHandle);
|
|
16073
|
+
if (canonical_1) return canonical_1;
|
|
16444
16074
|
const entries_0 = documentOperationUndoEntriesRef.current;
|
|
16445
16075
|
const entryIndex = entries_0.findIndex((entry_2) => entry_2.undoHandle.type === undoHandle.type && entry_2.undoHandle.id === undoHandle.id);
|
|
16446
16076
|
if (entryIndex === -1) return {
|
|
@@ -16454,18 +16084,18 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16454
16084
|
reason: "notLatest"
|
|
16455
16085
|
};
|
|
16456
16086
|
const entry_3 = entries_0.at(-1);
|
|
16457
|
-
const
|
|
16458
|
-
if (!entry_3 || !
|
|
16087
|
+
const view_19 = pagedEditorRef.current?.getView();
|
|
16088
|
+
if (!entry_3 || !view_19) return {
|
|
16459
16089
|
status: "rejected",
|
|
16460
16090
|
undoHandle,
|
|
16461
16091
|
reason: "unknownHandle"
|
|
16462
16092
|
};
|
|
16463
|
-
if (!
|
|
16093
|
+
if (!view_19.state.doc.eq(entry_3.afterState.doc) || canonicalJson(commentRecordsOf(view_19.state)) !== entry_3.commentsAfterJson) return {
|
|
16464
16094
|
status: "rejected",
|
|
16465
16095
|
undoHandle,
|
|
16466
16096
|
reason: "documentChanged"
|
|
16467
16097
|
};
|
|
16468
|
-
if (!undo(
|
|
16098
|
+
if (!undo(view_19.state, view_19.dispatch)) return {
|
|
16469
16099
|
status: "rejected",
|
|
16470
16100
|
undoHandle,
|
|
16471
16101
|
reason: "documentChanged"
|
|
@@ -16478,16 +16108,16 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16478
16108
|
};
|
|
16479
16109
|
},
|
|
16480
16110
|
applyAIEditOperations: ({ undefinedReferences: undefinedReferences_0, snapshot: snapshot_2, operations, mode = "tracked-changes", author: operationAuthor_0 = author }) => {
|
|
16481
|
-
const
|
|
16482
|
-
if (!
|
|
16111
|
+
const view_20 = pagedEditorRef.current?.getView();
|
|
16112
|
+
if (!view_20) return {
|
|
16483
16113
|
applied: [],
|
|
16484
16114
|
skipped: operations.map((operation_0) => ({
|
|
16485
16115
|
id: operation_0.id,
|
|
16486
16116
|
reason: "unsupportedBlock"
|
|
16487
16117
|
}))
|
|
16488
16118
|
};
|
|
16489
|
-
const activeSuggestionIds_0 = new Set(getSuggestions(
|
|
16490
|
-
const
|
|
16119
|
+
const activeSuggestionIds_0 = new Set(getSuggestions(view_20.state).map((s_2) => s_2.suggestionId));
|
|
16120
|
+
const canonical_2 = getCanonicalApi()?.applyCanonicalDocumentOperations({
|
|
16491
16121
|
undefinedReferences: undefinedReferences_0,
|
|
16492
16122
|
snapshot: snapshot_2,
|
|
16493
16123
|
batch: {
|
|
@@ -16497,21 +16127,21 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16497
16127
|
},
|
|
16498
16128
|
author: operationAuthor_0
|
|
16499
16129
|
});
|
|
16500
|
-
if (
|
|
16501
|
-
if (mode === "suggested" &&
|
|
16130
|
+
if (canonical_2) {
|
|
16131
|
+
if (mode === "suggested" && canonical_2.status === "committed") pendingSuggestionRegistryRef.current.recordApplied({
|
|
16502
16132
|
snapshot: snapshot_2,
|
|
16503
16133
|
story: { type: "main" },
|
|
16504
16134
|
operations,
|
|
16505
|
-
applied:
|
|
16135
|
+
applied: canonical_2.applied,
|
|
16506
16136
|
author: operationAuthor_0,
|
|
16507
16137
|
activeSuggestionIds: activeSuggestionIds_0
|
|
16508
16138
|
});
|
|
16509
|
-
return
|
|
16139
|
+
return canonical_2;
|
|
16510
16140
|
}
|
|
16511
16141
|
const createdComments_0 = [];
|
|
16512
16142
|
const { applied: applied_0, skipped: skipped_0 } = applyFolioDocumentOperations({
|
|
16513
16143
|
undefinedReferences: undefinedReferences_0,
|
|
16514
|
-
view: recordingCommentsView(
|
|
16144
|
+
view: recordingCommentsView(view_20, createdComments_0),
|
|
16515
16145
|
snapshot: snapshot_2,
|
|
16516
16146
|
batch: {
|
|
16517
16147
|
version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
|
|
@@ -16539,70 +16169,68 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16539
16169
|
};
|
|
16540
16170
|
},
|
|
16541
16171
|
acceptAIEditOperation: (revisionId) => {
|
|
16542
|
-
const
|
|
16543
|
-
if (!
|
|
16544
|
-
const
|
|
16545
|
-
if (
|
|
16546
|
-
return acceptAIEditRevision(revisionId)(
|
|
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);
|
|
16547
16177
|
},
|
|
16548
16178
|
rejectAIEditOperation: (revisionId_0) => {
|
|
16549
|
-
const
|
|
16550
|
-
if (!
|
|
16551
|
-
const
|
|
16552
|
-
if (
|
|
16553
|
-
return rejectAIEditRevision(revisionId_0)(
|
|
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);
|
|
16554
16184
|
},
|
|
16555
16185
|
undo: () => {
|
|
16556
|
-
if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.undo();
|
|
16557
16186
|
const undone = pagedEditorRef.current?.undo() ?? false;
|
|
16558
16187
|
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
16559
16188
|
return undone;
|
|
16560
16189
|
},
|
|
16561
16190
|
redo: () => {
|
|
16562
|
-
if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.redo();
|
|
16563
16191
|
const redone = pagedEditorRef.current?.redo() ?? false;
|
|
16564
16192
|
requestAnimationFrame(refreshBodyHistoryAvailability);
|
|
16565
16193
|
return redone;
|
|
16566
16194
|
},
|
|
16567
16195
|
scrollToAIEditOperation: (revisionId_1) => {
|
|
16568
|
-
const
|
|
16569
|
-
if (!
|
|
16570
|
-
const range_1 = findAIEditRevisionRange(
|
|
16196
|
+
const view_23 = pagedEditorRef.current?.getView();
|
|
16197
|
+
if (!view_23) return false;
|
|
16198
|
+
const range_1 = findAIEditRevisionRange(view_23.state, revisionId_1);
|
|
16571
16199
|
if (!range_1) return false;
|
|
16572
|
-
const { from: from_6, to: to_6 } = clampRangeToDocSize(
|
|
16573
|
-
const $from =
|
|
16574
|
-
const $to =
|
|
16575
|
-
|
|
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)));
|
|
16576
16204
|
requestAnimationFrame(() => {
|
|
16577
16205
|
pagedEditorRef.current?.scrollToPosition(from_6);
|
|
16578
16206
|
});
|
|
16579
16207
|
return true;
|
|
16580
16208
|
},
|
|
16581
16209
|
scrollToBlock: (blockId, snapshot_3) => {
|
|
16582
|
-
const
|
|
16583
|
-
if (!
|
|
16210
|
+
const view_24 = pagedEditorRef.current?.getView();
|
|
16211
|
+
if (!view_24) return false;
|
|
16584
16212
|
const range_2 = resolveFolioAIBlockRange({
|
|
16585
16213
|
blockId,
|
|
16586
|
-
doc:
|
|
16214
|
+
doc: view_24.state.doc,
|
|
16587
16215
|
snapshot: snapshot_3
|
|
16588
16216
|
});
|
|
16589
16217
|
if (range_2 === null) return false;
|
|
16590
16218
|
const { from: from_7, to: to_7 } = range_2;
|
|
16591
|
-
const $from_0 =
|
|
16592
|
-
const $to_0 =
|
|
16593
|
-
|
|
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)));
|
|
16594
16222
|
requestAnimationFrame(() => {
|
|
16595
16223
|
pagedEditorRef.current?.scrollToPosition(from_7);
|
|
16596
16224
|
});
|
|
16597
16225
|
return true;
|
|
16598
16226
|
},
|
|
16599
16227
|
highlightPassage: ({ blockId: blockId_0, text: text_5, snapshot: snapshot_4 }) => {
|
|
16600
|
-
const
|
|
16601
|
-
if (!
|
|
16228
|
+
const view_25 = pagedEditorRef.current?.getView();
|
|
16229
|
+
if (!view_25) return "none";
|
|
16602
16230
|
const passageRange = resolvePassageRange({
|
|
16603
16231
|
blockId: blockId_0,
|
|
16604
16232
|
text: text_5,
|
|
16605
|
-
doc:
|
|
16233
|
+
doc: view_25.state.doc,
|
|
16606
16234
|
snapshot: snapshot_4
|
|
16607
16235
|
});
|
|
16608
16236
|
if (passageRange !== null) {
|
|
@@ -16615,16 +16243,16 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16615
16243
|
pagedEditorRef.current?.setPassageHighlight(null);
|
|
16616
16244
|
const blockRange = resolveFolioAIBlockRange({
|
|
16617
16245
|
blockId: blockId_0,
|
|
16618
|
-
doc:
|
|
16246
|
+
doc: view_25.state.doc,
|
|
16619
16247
|
snapshot: snapshot_4
|
|
16620
16248
|
});
|
|
16621
16249
|
if (blockRange === null) return "none";
|
|
16622
16250
|
const paraId_0 = getFolioParaIdFromBlockId(blockId_0);
|
|
16623
16251
|
if (paraId_0 !== null && pagedEditorRef.current?.scrollToParaId(paraId_0, { highlight: {} })) return "block";
|
|
16624
16252
|
const { from: from_8, to: to_8 } = blockRange;
|
|
16625
|
-
const $from_1 =
|
|
16626
|
-
const $to_1 =
|
|
16627
|
-
|
|
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)));
|
|
16628
16256
|
requestAnimationFrame(() => {
|
|
16629
16257
|
pagedEditorRef.current?.scrollToPosition(from_8);
|
|
16630
16258
|
});
|
|
@@ -16634,56 +16262,56 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16634
16262
|
pagedEditorRef.current?.setPassageHighlight(null);
|
|
16635
16263
|
},
|
|
16636
16264
|
showInDocument: (target_1, snapshot_5) => {
|
|
16637
|
-
const
|
|
16638
|
-
if (!
|
|
16265
|
+
const view_26 = pagedEditorRef.current?.getView();
|
|
16266
|
+
if (!view_26) return false;
|
|
16639
16267
|
const range_3 = target_1.type === "textRange" ? resolveFolioAITextRange({
|
|
16640
16268
|
range: target_1,
|
|
16641
|
-
doc:
|
|
16269
|
+
doc: view_26.state.doc,
|
|
16642
16270
|
snapshot: snapshot_5
|
|
16643
16271
|
}) : resolveFolioAIBlockRange({
|
|
16644
16272
|
blockId: target_1.blockId,
|
|
16645
|
-
doc:
|
|
16273
|
+
doc: view_26.state.doc,
|
|
16646
16274
|
snapshot: snapshot_5
|
|
16647
16275
|
});
|
|
16648
16276
|
if (range_3 === null) return false;
|
|
16649
16277
|
const { from: from_9, to: to_9 } = range_3;
|
|
16650
|
-
const $from_2 =
|
|
16651
|
-
const $to_2 =
|
|
16652
|
-
|
|
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)));
|
|
16653
16281
|
requestAnimationFrame(() => {
|
|
16654
16282
|
pagedEditorRef.current?.scrollToPosition(from_9);
|
|
16655
16283
|
});
|
|
16656
16284
|
return true;
|
|
16657
16285
|
},
|
|
16658
16286
|
getSuggestions: () => {
|
|
16659
|
-
const
|
|
16660
|
-
return
|
|
16287
|
+
const view_27 = pagedEditorRef.current?.getView();
|
|
16288
|
+
return view_27 ? getSuggestions(view_27.state) : [];
|
|
16661
16289
|
},
|
|
16662
16290
|
exportPendingSuggestions: () => {
|
|
16663
|
-
const
|
|
16664
|
-
const activeIds = new Set(
|
|
16291
|
+
const view_28 = pagedEditorRef.current?.getView();
|
|
16292
|
+
const activeIds = new Set(view_28 ? getSuggestions(view_28.state).map((s_3) => s_3.suggestionId) : []);
|
|
16665
16293
|
return pendingSuggestionRegistryRef.current.exportPendingSuggestions({
|
|
16666
16294
|
activeSuggestionIds: activeIds,
|
|
16667
|
-
snapshotForStory: (story_0, commentIds) => story_0.type === "main" &&
|
|
16295
|
+
snapshotForStory: (story_0, commentIds) => story_0.type === "main" && view_28 ? createPendingSuggestionSourceSnapshot(view_28.state, commentIds) : null
|
|
16668
16296
|
});
|
|
16669
16297
|
},
|
|
16670
16298
|
loadPendingSuggestions: (records) => pendingSuggestionRegistryRef.current.loadPendingSuggestions({
|
|
16671
16299
|
records,
|
|
16672
16300
|
snapshotForStory: (story_1) => {
|
|
16673
|
-
const
|
|
16674
|
-
return story_1.type === "main" &&
|
|
16301
|
+
const view_29 = pagedEditorRef.current?.getView();
|
|
16302
|
+
return story_1.type === "main" && view_29 ? createFolioAIEditSnapshot(view_29.state.doc) : null;
|
|
16675
16303
|
},
|
|
16676
16304
|
sourceSnapshotForStory: (story_2, commentIds_0) => {
|
|
16677
|
-
const
|
|
16678
|
-
return story_2.type === "main" &&
|
|
16305
|
+
const view_30 = pagedEditorRef.current?.getView();
|
|
16306
|
+
return story_2.type === "main" && view_30 ? createPendingSuggestionSourceSnapshot(view_30.state, commentIds_0) : null;
|
|
16679
16307
|
},
|
|
16680
16308
|
apply: (record, snapshot_6) => {
|
|
16681
|
-
const
|
|
16682
|
-
if (!
|
|
16309
|
+
const view_31 = pagedEditorRef.current?.getView();
|
|
16310
|
+
if (!view_31) return {
|
|
16683
16311
|
applied: [],
|
|
16684
16312
|
skipped: []
|
|
16685
16313
|
};
|
|
16686
|
-
const
|
|
16314
|
+
const canonical_3 = getCanonicalApi()?.applyCanonicalDocumentOperations({
|
|
16687
16315
|
undefinedReferences: "refuse",
|
|
16688
16316
|
snapshot: snapshot_6,
|
|
16689
16317
|
batch: {
|
|
@@ -16693,11 +16321,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16693
16321
|
},
|
|
16694
16322
|
author: record.author
|
|
16695
16323
|
});
|
|
16696
|
-
if (
|
|
16324
|
+
if (canonical_3) return canonical_3;
|
|
16697
16325
|
const createdComments_1 = [];
|
|
16698
16326
|
const result_4 = applyFolioDocumentOperations({
|
|
16699
16327
|
undefinedReferences: "refuse",
|
|
16700
|
-
view: recordingCommentsView(
|
|
16328
|
+
view: recordingCommentsView(view_31, createdComments_1),
|
|
16701
16329
|
snapshot: snapshot_6,
|
|
16702
16330
|
batch: {
|
|
16703
16331
|
version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
|
|
@@ -16717,78 +16345,78 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16717
16345
|
};
|
|
16718
16346
|
},
|
|
16719
16347
|
activeSuggestionIds: () => {
|
|
16720
|
-
const
|
|
16721
|
-
return new Set(
|
|
16348
|
+
const view_32 = pagedEditorRef.current?.getView();
|
|
16349
|
+
return new Set(view_32 ? getSuggestions(view_32.state).map((s_4) => s_4.suggestionId) : []);
|
|
16722
16350
|
}
|
|
16723
16351
|
}),
|
|
16724
16352
|
acceptSuggestion: (suggestionId, options_4) => {
|
|
16725
|
-
const
|
|
16726
|
-
if (!
|
|
16353
|
+
const view_33 = pagedEditorRef.current?.getView();
|
|
16354
|
+
if (!view_33) return {
|
|
16727
16355
|
accepted: false,
|
|
16728
16356
|
appliedAs: null
|
|
16729
16357
|
};
|
|
16730
|
-
const appliedAs = getSuggestions(
|
|
16731
|
-
const
|
|
16732
|
-
const accepted =
|
|
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);
|
|
16733
16361
|
return {
|
|
16734
16362
|
accepted,
|
|
16735
16363
|
appliedAs: accepted ? appliedAs : null
|
|
16736
16364
|
};
|
|
16737
16365
|
},
|
|
16738
16366
|
rejectSuggestion: (suggestionId_0) => {
|
|
16739
|
-
const
|
|
16740
|
-
if (!
|
|
16741
|
-
const
|
|
16742
|
-
if (
|
|
16743
|
-
return rejectSuggestion(suggestionId_0)(
|
|
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);
|
|
16744
16372
|
},
|
|
16745
16373
|
scrollToSuggestion: (suggestionId_1) => {
|
|
16746
|
-
const
|
|
16747
|
-
if (!
|
|
16748
|
-
const range_4 = findSuggestionRange(
|
|
16374
|
+
const view_35 = pagedEditorRef.current?.getView();
|
|
16375
|
+
if (!view_35) return false;
|
|
16376
|
+
const range_4 = findSuggestionRange(view_35.state, suggestionId_1);
|
|
16749
16377
|
if (!range_4) return false;
|
|
16750
|
-
const { from: from_10, to: to_10 } = clampRangeToDocSize(
|
|
16751
|
-
const $from_3 =
|
|
16752
|
-
const $to_3 =
|
|
16753
|
-
|
|
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)));
|
|
16754
16382
|
requestAnimationFrame(() => {
|
|
16755
16383
|
pagedEditorRef.current?.scrollToPosition(from_10);
|
|
16756
16384
|
});
|
|
16757
16385
|
return true;
|
|
16758
16386
|
},
|
|
16759
16387
|
getTrackedChanges: () => {
|
|
16760
|
-
const
|
|
16761
|
-
return
|
|
16388
|
+
const view_36 = pagedEditorRef.current?.getView();
|
|
16389
|
+
return view_36 ? getTrackedChangesFromDoc(view_36.state.doc) : [];
|
|
16762
16390
|
},
|
|
16763
16391
|
getCommentAnchors: () => {
|
|
16764
|
-
const
|
|
16765
|
-
return
|
|
16392
|
+
const view_37 = pagedEditorRef.current?.getView();
|
|
16393
|
+
return view_37 ? getCommentAnchorsFromDoc(view_37.state.doc) : [];
|
|
16766
16394
|
},
|
|
16767
16395
|
getSelectionText: () => {
|
|
16768
|
-
const
|
|
16769
|
-
return
|
|
16396
|
+
const view_38 = pagedEditorRef.current?.getView();
|
|
16397
|
+
return view_38 ? getSelectedText(view_38.state) : "";
|
|
16770
16398
|
},
|
|
16771
16399
|
getPageText: (page_0) => {
|
|
16772
|
-
const
|
|
16773
|
-
if (!
|
|
16400
|
+
const view_39 = pagedEditorRef.current?.getView();
|
|
16401
|
+
if (!view_39) return null;
|
|
16774
16402
|
const layout_0 = pagedEditorRef.current?.getEditor()?.getLayout() ?? null;
|
|
16775
16403
|
return getPageTextFromLayout({
|
|
16776
16404
|
layout: layout_0,
|
|
16777
|
-
doc:
|
|
16405
|
+
doc: view_39.state.doc,
|
|
16778
16406
|
page: page_0,
|
|
16779
|
-
projection: projectMarkupView(
|
|
16407
|
+
projection: projectMarkupView(view_39.state, displayMode)
|
|
16780
16408
|
});
|
|
16781
16409
|
},
|
|
16782
16410
|
getTargetPage: (target_2, snapshot_7) => {
|
|
16783
|
-
const
|
|
16784
|
-
if (!
|
|
16411
|
+
const view_40 = pagedEditorRef.current?.getView();
|
|
16412
|
+
if (!view_40) return null;
|
|
16785
16413
|
const range_5 = target_2.type === "textRange" ? resolveFolioAITextRange({
|
|
16786
16414
|
range: target_2,
|
|
16787
|
-
doc:
|
|
16415
|
+
doc: view_40.state.doc,
|
|
16788
16416
|
snapshot: snapshot_7
|
|
16789
16417
|
}) : resolveFolioAIBlockRange({
|
|
16790
16418
|
blockId: target_2.blockId,
|
|
16791
|
-
doc:
|
|
16419
|
+
doc: view_40.state.doc,
|
|
16792
16420
|
snapshot: snapshot_7
|
|
16793
16421
|
});
|
|
16794
16422
|
const layout_1 = pagedEditorRef.current?.getEditor()?.getLayout() ?? null;
|
|
@@ -16798,54 +16426,55 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16798
16426
|
getPositionPage: (position_1) => pagedEditorRef.current?.getEditor()?.getPositionPage(position_1) ?? null,
|
|
16799
16427
|
autocomplete: delegateAutocomplete(() => pagedEditorRef.current?.getEditor()?.autocomplete ?? NO_AUTOCOMPLETE),
|
|
16800
16428
|
getAnonymizationMatches: () => pagedEditorRef.current?.getEditor()?.getAnonymizationHighlights().matches ?? NO_ANONYMIZATION_HIGHLIGHTS.matches,
|
|
16429
|
+
insertField: (field) => getActiveEditorStory().type === "body" && (pagedEditorRef.current?.getEditor()?.insertField(field) ?? false),
|
|
16801
16430
|
getBlockRect: (blockId_1) => pagedEditorRef.current?.getBlockRect(blockId_1) ?? null,
|
|
16802
16431
|
getBlockRects: (blockIds) => pagedEditorRef.current?.getBlockRects(blockIds) ?? /* @__PURE__ */ new Map(),
|
|
16803
16432
|
getScrollRoot: () => pagedEditorRef.current?.getScrollRoot() ?? null,
|
|
16804
16433
|
onLayoutChange: (listener) => pagedEditorRef.current?.onLayoutChange(listener) ?? (() => {}),
|
|
16805
16434
|
getContentControls: (filter = {}) => {
|
|
16806
|
-
const
|
|
16807
|
-
if (!
|
|
16808
|
-
return findBlockSdtMatches(
|
|
16435
|
+
const view_41 = pagedEditorRef.current?.getView();
|
|
16436
|
+
if (!view_41) return [];
|
|
16437
|
+
return findBlockSdtMatches(view_41.state.doc, filter).map((match_0) => ({
|
|
16809
16438
|
properties: blockSdtAttrsToSdtProperties(match_0.node),
|
|
16810
16439
|
path: match_0.path,
|
|
16811
16440
|
pmPos: match_0.pos
|
|
16812
16441
|
}));
|
|
16813
16442
|
},
|
|
16814
16443
|
scrollToContentControl: (filter_0) => {
|
|
16815
|
-
const
|
|
16816
|
-
if (!
|
|
16817
|
-
const match_1 = findBlockSdtMatch(
|
|
16444
|
+
const view_42 = pagedEditorRef.current?.getView();
|
|
16445
|
+
if (!view_42) return false;
|
|
16446
|
+
const match_1 = findBlockSdtMatch(view_42.state.doc, filter_0);
|
|
16818
16447
|
if (!match_1) return false;
|
|
16819
16448
|
const inside = match_1.pos + 1;
|
|
16820
|
-
const $pos =
|
|
16821
|
-
|
|
16449
|
+
const $pos = view_42.state.doc.resolve(inside);
|
|
16450
|
+
view_42.dispatch(view_42.state.tr.setSelection(TextSelection.near($pos)));
|
|
16822
16451
|
requestAnimationFrame(() => {
|
|
16823
16452
|
pagedEditorRef.current?.scrollToPosition(inside);
|
|
16824
16453
|
});
|
|
16825
16454
|
return true;
|
|
16826
16455
|
},
|
|
16827
16456
|
setContentControlContent: (filter_1, input, options_5 = {}) => {
|
|
16828
|
-
const
|
|
16829
|
-
if (!
|
|
16830
|
-
const tr_0 = typeof input === "string" ? setContentControlContentTr(
|
|
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);
|
|
16831
16460
|
if (!tr_0) return false;
|
|
16832
|
-
|
|
16461
|
+
view_43.dispatch(tr_0);
|
|
16833
16462
|
return true;
|
|
16834
16463
|
},
|
|
16835
16464
|
setContentControlValue: (filter_2, input_0, options_6 = {}) => {
|
|
16836
|
-
const
|
|
16837
|
-
if (!
|
|
16838
|
-
const tr_1 = setContentControlValueTr(
|
|
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);
|
|
16839
16468
|
if (!tr_1) return false;
|
|
16840
|
-
|
|
16469
|
+
view_44.dispatch(tr_1);
|
|
16841
16470
|
return true;
|
|
16842
16471
|
},
|
|
16843
16472
|
removeContentControl: (filter_3, options_7 = {}) => {
|
|
16844
|
-
const
|
|
16845
|
-
if (!
|
|
16846
|
-
const tr_2 = removeContentControlTr(
|
|
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);
|
|
16847
16476
|
if (!tr_2) return false;
|
|
16848
|
-
|
|
16477
|
+
view_45.dispatch(tr_2);
|
|
16849
16478
|
return true;
|
|
16850
16479
|
}
|
|
16851
16480
|
}), [
|
|
@@ -16875,28 +16504,13 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16875
16504
|
commentsRef,
|
|
16876
16505
|
getCommentsDirty,
|
|
16877
16506
|
getActiveEditorStory,
|
|
16878
|
-
refreshBodyHistoryAvailability
|
|
16879
|
-
experimentalSession
|
|
16507
|
+
refreshBodyHistoryAvailability
|
|
16880
16508
|
]);
|
|
16881
16509
|
const displayModeItems = useMemo(() => DISPLAY_MODES.map((mode_0) => ({
|
|
16882
16510
|
value: mode_0,
|
|
16883
16511
|
label: t(DISPLAY_MODE_LABEL_KEYS[mode_0])
|
|
16884
16512
|
})), [t]);
|
|
16885
|
-
const activeHistoryAvailability =
|
|
16886
|
-
if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting)) return {
|
|
16887
|
-
canRedo: bodyHistoryAvailability.canRedo,
|
|
16888
|
-
canUndo: bodyHistoryAvailability.canUndo
|
|
16889
|
-
};
|
|
16890
|
-
if (activeNoteStory) return {
|
|
16891
|
-
canRedo: bodyHistoryAvailability.canRedo,
|
|
16892
|
-
canUndo: bodyHistoryAvailability.canUndo
|
|
16893
|
-
};
|
|
16894
|
-
if (hfEditPosition) return {
|
|
16895
|
-
canRedo: history.canRedo,
|
|
16896
|
-
canUndo: history.canUndo
|
|
16897
|
-
};
|
|
16898
|
-
return bodyHistoryAvailability;
|
|
16899
|
-
})();
|
|
16513
|
+
const activeHistoryAvailability = bodyHistoryAvailability;
|
|
16900
16514
|
const toolbarChildren = toolbarExtra ?? null;
|
|
16901
16515
|
const visibleCommentAuthorCount = commentAuthors.filter((commentAuthor) => visibleCommentAuthorSet.has(commentAuthor)).length;
|
|
16902
16516
|
const allCommentAuthorsVisible = commentAuthors.length > 0 && showCommentsSidebar && visibleCommentAuthorCount === commentAuthors.length;
|
|
@@ -16938,47 +16552,47 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
16938
16552
|
if (isDisplayMode(value)) setDisplayMode(value);
|
|
16939
16553
|
}, [setDisplayMode]);
|
|
16940
16554
|
const handleAcceptActiveChange = useCallback(() => {
|
|
16941
|
-
const
|
|
16942
|
-
if (!
|
|
16943
|
-
const { from: from_11, to: to_11 } =
|
|
16944
|
-
const range_6 = findChangeAtPosition(
|
|
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);
|
|
16945
16559
|
if (resolveCanonicalReviewRange({
|
|
16946
16560
|
editor: pagedEditorRef.current?.getEditor(),
|
|
16947
16561
|
...range_6,
|
|
16948
16562
|
resolution: "accept"
|
|
16949
|
-
}) === null) acceptChange(range_6.from, range_6.to)(
|
|
16563
|
+
}) === null) acceptChange(range_6.from, range_6.to)(view_46.state, view_46.dispatch);
|
|
16950
16564
|
}, []);
|
|
16951
16565
|
const handleRejectActiveChange = useCallback(() => {
|
|
16952
|
-
const
|
|
16953
|
-
if (!
|
|
16954
|
-
const { from: from_12, to: to_12 } =
|
|
16955
|
-
const range_7 = findChangeAtPosition(
|
|
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);
|
|
16956
16570
|
if (resolveCanonicalReviewRange({
|
|
16957
16571
|
editor: pagedEditorRef.current?.getEditor(),
|
|
16958
16572
|
...range_7,
|
|
16959
16573
|
resolution: "reject"
|
|
16960
|
-
}) === null) rejectChange(range_7.from, range_7.to)(
|
|
16574
|
+
}) === null) rejectChange(range_7.from, range_7.to)(view_47.state, view_47.dispatch);
|
|
16961
16575
|
}, []);
|
|
16962
16576
|
const handlePreviousChange = useCallback(() => {
|
|
16963
|
-
const
|
|
16964
|
-
if (!
|
|
16965
|
-
const { from: from_13 } =
|
|
16966
|
-
const change_0 = findPreviousChange(
|
|
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);
|
|
16967
16581
|
if (!change_0) return;
|
|
16968
|
-
|
|
16969
|
-
|
|
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();
|
|
16970
16584
|
requestAnimationFrame(() => {
|
|
16971
16585
|
pagedEditorRef.current?.scrollToPosition(change_0.from);
|
|
16972
16586
|
});
|
|
16973
16587
|
}, []);
|
|
16974
16588
|
const handleNextChange = useCallback(() => {
|
|
16975
|
-
const
|
|
16976
|
-
if (!
|
|
16977
|
-
const { to: to_13 } =
|
|
16978
|
-
const change_1 = findNextChange(
|
|
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);
|
|
16979
16593
|
if (!change_1) return;
|
|
16980
|
-
|
|
16981
|
-
|
|
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();
|
|
16982
16596
|
requestAnimationFrame(() => {
|
|
16983
16597
|
pagedEditorRef.current?.scrollToPosition(change_1.from);
|
|
16984
16598
|
});
|
|
@@ -17148,8 +16762,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17148
16762
|
requestAnimationFrame(syncCommentHighlightStyles);
|
|
17149
16763
|
}, [onScrollTopChange, syncCommentHighlightStyles]);
|
|
17150
16764
|
const handlePagedSelectionChange = useCallback((_from, _to) => {
|
|
17151
|
-
const
|
|
17152
|
-
handleSelectionChange(
|
|
16765
|
+
const view_50 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
|
|
16766
|
+
handleSelectionChange(view_50 ? extractSelectionState(view_50.state) : null);
|
|
17153
16767
|
}, [getActiveEditorView, handleSelectionChange]);
|
|
17154
16768
|
const handleTotalPagesChange = useCallback((totalPages) => {
|
|
17155
16769
|
setScrollPageInfo((previous_0) => updateScrollPageTotal(previous_0, totalPages));
|
|
@@ -17188,10 +16802,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17188
16802
|
notifyReadonlyEditAttempt();
|
|
17189
16803
|
return;
|
|
17190
16804
|
}
|
|
17191
|
-
const
|
|
17192
|
-
if (
|
|
17193
|
-
const deleted = deleteCommentThread(
|
|
17194
|
-
if (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);
|
|
17195
16809
|
} else {
|
|
17196
16810
|
const thread = commentThreadIds(commentsRef.current, id_2);
|
|
17197
16811
|
updateComments((previous_2) => previous_2.filter((comment_3) => !thread.has(comment_3.id)));
|
|
@@ -17230,8 +16844,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17230
16844
|
updateComments
|
|
17231
16845
|
]);
|
|
17232
16846
|
const handleAddComment = useCallback((addText) => {
|
|
17233
|
-
const
|
|
17234
|
-
if (!
|
|
16847
|
+
const view_52 = pagedEditorRef.current?.getView();
|
|
16848
|
+
if (!view_52 || !commentSelectionRange) return false;
|
|
17235
16849
|
const result_6 = applyCanonicalComment({
|
|
17236
16850
|
type: "create",
|
|
17237
16851
|
text: addText,
|
|
@@ -17244,9 +16858,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17244
16858
|
});
|
|
17245
16859
|
if (result_6 !== null) {
|
|
17246
16860
|
if (result_6?.status !== "applied") return false;
|
|
17247
|
-
setVisibleCommentAuthors((
|
|
17248
|
-
if (
|
|
17249
|
-
const next_1 = new Set(
|
|
16861
|
+
setVisibleCommentAuthors((current_0) => {
|
|
16862
|
+
if (current_0 === null) return null;
|
|
16863
|
+
const next_1 = new Set(current_0);
|
|
17250
16864
|
const created = result_6.comments.find(({ id: id_4 }) => id_4 === result_6.commentId);
|
|
17251
16865
|
if (created) next_1.add(getCommentAuthorKey(created.author));
|
|
17252
16866
|
return next_1;
|
|
@@ -17262,11 +16876,11 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17262
16876
|
return false;
|
|
17263
16877
|
}
|
|
17264
16878
|
const comment_4 = createComment(addText, author);
|
|
17265
|
-
if (!commitCommentThread(
|
|
16879
|
+
if (!commitCommentThread(view_52, commentSelectionRange, comment_4)) return false;
|
|
17266
16880
|
const commentAuthor_2 = getCommentAuthorKey(comment_4.author);
|
|
17267
|
-
setVisibleCommentAuthors((
|
|
17268
|
-
if (
|
|
17269
|
-
const next_2 = new Set(
|
|
16881
|
+
setVisibleCommentAuthors((current_1) => {
|
|
16882
|
+
if (current_1 === null) return null;
|
|
16883
|
+
const next_2 = new Set(current_1);
|
|
17270
16884
|
next_2.add(commentAuthor_2);
|
|
17271
16885
|
return next_2;
|
|
17272
16886
|
});
|
|
@@ -17319,14 +16933,10 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17319
16933
|
updateComments
|
|
17320
16934
|
]);
|
|
17321
16935
|
const handleCancelAddComment = useCallback(() => {
|
|
17322
|
-
const view_55 = pagedEditorRef.current?.getView();
|
|
17323
|
-
if (view_55 && commentSelectionRange && commentDraftMode === "prosemirror") clearPendingComment(view_55, commentSelectionRange);
|
|
17324
16936
|
setIsAddingComment(false);
|
|
17325
16937
|
setCommentSelectionRange(null);
|
|
17326
16938
|
setAddCommentYPosition(null);
|
|
17327
16939
|
}, [
|
|
17328
|
-
commentSelectionRange,
|
|
17329
|
-
commentDraftMode,
|
|
17330
16940
|
setAddCommentYPosition,
|
|
17331
16941
|
setCommentSelectionRange,
|
|
17332
16942
|
setIsAddingComment
|
|
@@ -17337,23 +16947,23 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17337
16947
|
})?.revisionId ?? null;
|
|
17338
16948
|
}, []);
|
|
17339
16949
|
const handleSidebarAcceptChange = useCallback((from_15, to_15) => {
|
|
17340
|
-
const
|
|
17341
|
-
if (!
|
|
16950
|
+
const view_53 = pagedEditorRef.current?.getView();
|
|
16951
|
+
if (!view_53) return;
|
|
17342
16952
|
const revisionId_3 = resolveSidebarChangeRevisionId(from_15, to_15);
|
|
17343
16953
|
if (revisionId_3 === null) return;
|
|
17344
|
-
const
|
|
17345
|
-
if (
|
|
17346
|
-
else acceptAIEditRevision(revisionId_3)(
|
|
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);
|
|
17347
16957
|
extractTrackedChanges();
|
|
17348
16958
|
}, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
|
|
17349
16959
|
const handleSidebarRejectChange = useCallback((from_16, to_16) => {
|
|
17350
|
-
const
|
|
17351
|
-
if (!
|
|
16960
|
+
const view_54 = pagedEditorRef.current?.getView();
|
|
16961
|
+
if (!view_54) return;
|
|
17352
16962
|
const revisionId_4 = resolveSidebarChangeRevisionId(from_16, to_16);
|
|
17353
16963
|
if (revisionId_4 === null) return;
|
|
17354
|
-
const
|
|
17355
|
-
if (
|
|
17356
|
-
else rejectAIEditRevision(revisionId_4)(
|
|
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);
|
|
17357
16967
|
extractTrackedChanges();
|
|
17358
16968
|
}, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
|
|
17359
16969
|
const commentsPageWidth = history.state?.package.document.finalSectionProperties?.pageWidth;
|
|
@@ -17506,8 +17116,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17506
17116
|
}, [readOnly]);
|
|
17507
17117
|
const closeTableProperties = useCallback(() => setTablePropsOpen(false), []);
|
|
17508
17118
|
const applyTableProperties = useCallback((props_0) => {
|
|
17509
|
-
const
|
|
17510
|
-
if (
|
|
17119
|
+
const view_55 = getActiveEditorView();
|
|
17120
|
+
if (view_55) executeEditorCommand(view_55, setTableProperties(props_0));
|
|
17511
17121
|
}, [getActiveEditorView]);
|
|
17512
17122
|
const closeImagePosition = useCallback(() => setImagePositionOpen(false), [setImagePositionOpen]);
|
|
17513
17123
|
const closeImageProperties = useCallback(() => setImagePropsOpen(false), [setImagePropsOpen]);
|
|
@@ -17515,8 +17125,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17515
17125
|
const closeFootnoteProperties = useCallback(() => setFootnotePropsOpen(false), []);
|
|
17516
17126
|
const closeInsertSymbol = useCallback(() => setShowInsertSymbol(false), []);
|
|
17517
17127
|
const insertSymbol = useCallback((symbol) => {
|
|
17518
|
-
const
|
|
17519
|
-
if (
|
|
17128
|
+
const view_56 = getActiveEditorView();
|
|
17129
|
+
if (view_56) view_56.dispatch(view_56.state.tr.insertText(symbol).scrollIntoView());
|
|
17520
17130
|
}, [getActiveEditorView]);
|
|
17521
17131
|
const imagePropertiesCurrentData = useMemo(() => buildImagePropertiesData(state.pmImageContext), [state.pmImageContext]);
|
|
17522
17132
|
const { close: closeFindDialog } = findReplace;
|
|
@@ -17607,8 +17217,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17607
17217
|
]);
|
|
17608
17218
|
const closeNumberingValueDialog = useCallback(() => setNumberingValueDialogOpen(false), []);
|
|
17609
17219
|
const applyNumberingValue = useCallback((value_0) => {
|
|
17610
|
-
const
|
|
17611
|
-
if (
|
|
17220
|
+
const view_57 = getActiveEditorView();
|
|
17221
|
+
if (view_57) executeEditorCommand(view_57, setNumberingValue(value_0));
|
|
17612
17222
|
}, [getActiveEditorView]);
|
|
17613
17223
|
const numberingValueDialog = useMemo(() => ({
|
|
17614
17224
|
isOpen: numberingValueDialogOpen,
|
|
@@ -17876,7 +17486,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17876
17486
|
showMarginGuides,
|
|
17877
17487
|
...marginGuideColor !== void 0 ? { marginGuideColor } : {},
|
|
17878
17488
|
readOnly,
|
|
17879
|
-
experimentalSession: usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) ? "canonical" : "legacy",
|
|
17880
17489
|
onDocumentChange: applyDocumentChange,
|
|
17881
17490
|
extensionManager,
|
|
17882
17491
|
suggestionModeActive: editingMode === "suggesting",
|
|
@@ -17890,13 +17499,13 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17890
17499
|
onEditorViewReady: handleBodyViewReady,
|
|
17891
17500
|
externalPlugins: editorPlugins,
|
|
17892
17501
|
showTemplateDirectives,
|
|
17893
|
-
...yjsCollaboration !== void 0 ? { collaboration: yjsCollaboration } : {},
|
|
17894
17502
|
...canonicalRoom !== void 0 ? { canonicalRoom } : {},
|
|
17895
17503
|
onHyperlinkClick: handleHyperlinkClick,
|
|
17896
17504
|
onContextMenu: handleContextMenu,
|
|
17897
17505
|
pageEndGutter: panelLayout.commentsGutter,
|
|
17898
17506
|
anchorPositionMode: "comments",
|
|
17899
17507
|
anonymizationTerms,
|
|
17508
|
+
derivedFields,
|
|
17900
17509
|
onAnonymizationMatchesChange,
|
|
17901
17510
|
onAnonymizationTermClick,
|
|
17902
17511
|
onAutocompleteChange,
|
|
@@ -17918,8 +17527,8 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17918
17527
|
onMouseDown: (e_1) => {
|
|
17919
17528
|
e_1.preventDefault();
|
|
17920
17529
|
e_1.stopPropagation();
|
|
17921
|
-
const
|
|
17922
|
-
if (!
|
|
17530
|
+
const view_58 = pagedEditorRef.current?.getView();
|
|
17531
|
+
if (!view_58) {
|
|
17923
17532
|
setFloatingCommentBtn(null);
|
|
17924
17533
|
return;
|
|
17925
17534
|
}
|
|
@@ -17927,9 +17536,9 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17927
17536
|
from: floatingCommentBtn.from,
|
|
17928
17537
|
to: floatingCommentBtn.to
|
|
17929
17538
|
};
|
|
17930
|
-
const currentSelection =
|
|
17539
|
+
const currentSelection = view_58.state.selection;
|
|
17931
17540
|
const safeRange = resolveCommentCreationRange({
|
|
17932
|
-
docSize:
|
|
17541
|
+
docSize: view_58.state.doc.content.size,
|
|
17933
17542
|
capturedRange,
|
|
17934
17543
|
currentRange: {
|
|
17935
17544
|
from: currentSelection.from,
|
|
@@ -17943,13 +17552,6 @@ const DocxEditor = forwardRef(function DocxEditor({ accessibleName, documentBuff
|
|
|
17943
17552
|
return;
|
|
17944
17553
|
}
|
|
17945
17554
|
setCommentSelectionRange(safeRange);
|
|
17946
|
-
if (commentDraftMode === "prosemirror") {
|
|
17947
|
-
if (!markPendingComment(view_61, safeRange, { selectEnd: true })) {
|
|
17948
|
-
setCommentSelectionRange(null);
|
|
17949
|
-
setFloatingCommentBtn(null);
|
|
17950
|
-
return;
|
|
17951
|
-
}
|
|
17952
|
-
}
|
|
17953
17555
|
const yPos_0 = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, safeRange.from);
|
|
17954
17556
|
setAddCommentYPosition(yPos_0 ?? floatingCommentBtn.top);
|
|
17955
17557
|
setShowCommentsSidebar(true);
|