@stll/folio-react 0.21.0 → 0.22.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/dist/{CommentsSidebar-BN6EX4xT.js → CommentsSidebar-D68oqCy8.js} +1 -1
- package/dist/compat/eigenpal.d.ts +1 -1
- package/dist/compat/eigenpal.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{renderAsync-CpeG0afF.d.ts → renderAsync-DuY_uo1B.d.ts} +4 -2
- package/dist/{renderAsync-D5P4hvJg.js → renderAsync-Dxi_koXh.js} +163 -147
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as containedHandler } from "./renderAsync-
|
|
1
|
+
import { d as containedHandler } from "./renderAsync-Dxi_koXh.js";
|
|
2
2
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { CheckIcon, MoreVerticalIcon } from "lucide-react";
|
|
4
4
|
import { useLocale, useTranslations } from "use-intl";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as DocxEditorRef, i as renderAsync, n as EditorHandle, r as RenderAsyncOptions, s as DocxEditorProps, t as DocxEditorHandle } from "../renderAsync-
|
|
1
|
+
import { c as DocxEditorRef, i as renderAsync, n as EditorHandle, r as RenderAsyncOptions, s as DocxEditorProps, t as DocxEditorHandle } from "../renderAsync-DuY_uo1B.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { CreateEmptyDocumentOptions, createDocumentWithText, createEmptyDocument } from "@stll/folio-core/utils/createDocument";
|
|
4
4
|
//#region src/compat/eigenpal.d.ts
|
package/dist/compat/eigenpal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as DocxEditor$1, t as renderAsync } from "../renderAsync-
|
|
1
|
+
import { n as DocxEditor$1, t as renderAsync } from "../renderAsync-Dxi_koXh.js";
|
|
2
2
|
import { t as messages_exports } from "../messages.js";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
4
|
import { forwardRef } from "react";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as FolioUIProvider, a as DocxEditorApplyDocumentOperationsOptions, c as DocxEditorRef, d as ToolbarProps, f as EditorMode, g as FolioUIComponents, h as FolioButtonProps, i as renderAsync, l as HighlightPassageOptions, m as ColorPreset, n as EditorHandle, o as DocxEditorCollaboration, p as FontOption, r as RenderAsyncOptions, s as DocxEditorProps, t as DocxEditorHandle, u as HighlightPassageResult, v as OutlineItem, y as FontDefinition } from "./renderAsync-
|
|
1
|
+
import { _ as FolioUIProvider, a as DocxEditorApplyDocumentOperationsOptions, c as DocxEditorRef, d as ToolbarProps, f as EditorMode, g as FolioUIComponents, h as FolioButtonProps, i as renderAsync, l as HighlightPassageOptions, m as ColorPreset, n as EditorHandle, o as DocxEditorCollaboration, p as FontOption, r as RenderAsyncOptions, s as DocxEditorProps, t as DocxEditorHandle, u as HighlightPassageResult, v as OutlineItem, y as FontDefinition } from "./renderAsync-DuY_uo1B.js";
|
|
2
2
|
import { A as HyperlinkDialog, C as ImagePropertiesData, D as ImagePositionDialog, E as ImagePositionData, F as FindReplaceDialog, I as FindReplaceDialogProps, M as HyperlinkDialogProps, N as FootnotePropertiesDialog, O as ImagePositionDialogProps, P as FootnotePropertiesDialogProps, S as InsertImageDialogProps, T as ImagePropertiesDialogProps, _ as InsertTableStyleOption, a as TablePropertiesDialogProps, b as InsertImageDialog, c as SplitCellDialogProps, d as PasteSpecialMode, f as PageSetupDialog, g as InsertTableDialogProps, h as InsertTableDialogData, i as TablePropertiesDialog, j as HyperlinkDialogData, k as HyperlinkBookmarkOption, l as PasteSpecialDialog, m as InsertTableDialog, n as WatermarkDialogProps, o as SplitCellDialog, p as PageSetupDialogProps, r as TableProperties, s as SplitCellDialogData, t as WatermarkDialog, u as PasteSpecialDialogProps, v as InsertSymbolDialog, w as ImagePropertiesDialog, x as InsertImageDialogData, y as InsertSymbolDialogProps } from "./dialogs-DZz6gVev.js";
|
|
3
3
|
import React, { CSSProperties, ReactNode, RefObject } from "react";
|
|
4
4
|
import { CreateEmptyDocumentOptions, createEmptyDocument } from "@stll/folio-core/utils/createDocument";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as formatZoom, c as FormattingBar, i as clampZoom, l as ZoomControl, n as DocxEditor, o as parseZoom, r as ZOOM_PRESETS, s as useWheelZoom, t as renderAsync, u as AutocompleteCaretOverlay } from "./renderAsync-
|
|
1
|
+
import { a as formatZoom, c as FormattingBar, i as clampZoom, l as ZoomControl, n as DocxEditor, o as parseZoom, r as ZOOM_PRESETS, s as useWheelZoom, t as renderAsync, u as AutocompleteCaretOverlay } from "./renderAsync-Dxi_koXh.js";
|
|
2
2
|
import { n as FolioUIProvider } from "./folio-ui-BgDDRsUX.js";
|
|
3
3
|
import { t as FindReplaceDialog } from "./FindReplaceDialog-CqKK82nE.js";
|
|
4
4
|
import { t as FootnotePropertiesDialog } from "./FootnotePropertiesDialog-CixRdIiT.js";
|
|
@@ -869,8 +869,10 @@ type DocxEditorProps = {
|
|
|
869
869
|
to: number;
|
|
870
870
|
}) => void) | undefined;
|
|
871
871
|
/**
|
|
872
|
-
* Operational flags for save-path features. Selective save
|
|
873
|
-
*
|
|
872
|
+
* Operational flags for save-path features. Selective save is ON by
|
|
873
|
+
* default — a save always succeeds, falling back to a full repack whenever
|
|
874
|
+
* the patch-safety checks refuse. Pass `featureFlags={{ selectiveSave:
|
|
875
|
+
* false }}` to always full-repack. The tripwire mode stays OFF by default.
|
|
874
876
|
*/
|
|
875
877
|
featureFlags?: FolioSelectiveSaveFlags;
|
|
876
878
|
/**
|
|
@@ -52,6 +52,7 @@ import { createLatestRequestGate } from "@stll/folio-core/controller/latestReque
|
|
|
52
52
|
import { runLayoutPipeline } from "@stll/folio-core/controller/layoutPipeline";
|
|
53
53
|
import { browserClock, createLayoutScheduler } from "@stll/folio-core/controller/layoutScheduler";
|
|
54
54
|
import { createLayoutSession } from "@stll/folio-core/controller/layoutSession";
|
|
55
|
+
import { createHyphenationReadiness } from "@stll/folio-core/controller/hyphenationReadiness";
|
|
55
56
|
import { documentFontsAreLoaded, getDocumentFontSet, waitForInitialLayoutFonts } from "@stll/folio-core/controller/fontReadiness";
|
|
56
57
|
import { getFootnoteText } from "@stll/folio-core/docx/footnoteParser";
|
|
57
58
|
import { convertHeaderFooterPmDocToContent, convertHeaderFooterToContent } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
|
|
@@ -2841,7 +2842,7 @@ function buildFootnoteRenderItems(pageFootnoteMap, footnoteContentMap, doc) {
|
|
|
2841
2842
|
* PagedEditor - Main paginated editing component.
|
|
2842
2843
|
*/
|
|
2843
2844
|
const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
2844
|
-
const { document, documentIO, documentIdentity, fonts: hostFonts, styles, theme: _theme, sectionProperties, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, pageRenderer, showMarginGuides = false, marginGuideColor, onDocumentChange, onReadOnlyEditAttempt, onCopy, onCut, onPaste, onSelectionChange, onSelectionTextChange, onEditorViewReady, externalPlugins = EMPTY_PLUGINS, showTemplateDirectives = true, collaboration, extensionManager, suggestionModeActive = false, suggestionAuthor, onActiveNoteStoryChange, onHeaderFooterDoubleClick, hfEditMode, activeHeaderFooterRId, onBodyClick, className, style, commentsSidebarOpen = false, sidebarOverlay, scrollContainerRef: scrollContainerRefProp, onHyperlinkClick, onContextMenu, onAnchorPositionsChange, onTotalPagesChange, anchorPositionMode = "comments-and-revisions", onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
|
|
2845
|
+
const { document, documentIO, documentIdentity, fonts: hostFonts, styles, theme: _theme, sectionProperties, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, readOnly = false, pageGap = 24, zoom = 1, pageRenderer, showMarginGuides = false, marginGuideColor, onDocumentChange, onReadOnlyEditAttempt, onCopy, onCut, onPaste, onSelectionChange, onSelectionTextChange, onEditorViewReady, externalPlugins = EMPTY_PLUGINS, showTemplateDirectives = true, collaboration, extensionManager, suggestionModeActive = false, suggestionAuthor, onActiveNoteStoryChange, onHeaderFooterDoubleClick, hfEditMode, activeHeaderFooterRId, onBodyClick, className, style, commentsSidebarOpen = false, sidebarOverlay, scrollContainerRef: scrollContainerRefProp, onHyperlinkClick, onContextMenu, onAnchorPositionsChange, onTotalPagesChange, onError, anchorPositionMode = "comments-and-revisions", onAnonymizationTermClick, selectedAnonymizationCanonical = null, anonymizationSelectionSeq } = props;
|
|
2845
2846
|
const getScrollContainer = useCallback(() => {
|
|
2846
2847
|
if (scrollContainerRefProp && typeof scrollContainerRefProp === "object") return scrollContainerRefProp.current;
|
|
2847
2848
|
return containerRef.current;
|
|
@@ -2873,12 +2874,14 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
2873
2874
|
const onEditorViewReadyRef = useRef(onEditorViewReady);
|
|
2874
2875
|
const onDocumentChangeRef = useRef(onDocumentChange);
|
|
2875
2876
|
const onTotalPagesChangeRef = useRef(onTotalPagesChange);
|
|
2877
|
+
const onErrorRef = useRef(onError);
|
|
2876
2878
|
const lastTotalPagesRef = useRef(null);
|
|
2877
2879
|
onSelectionChangeRef.current = onSelectionChange;
|
|
2878
2880
|
onSelectionTextChangeRef.current = onSelectionTextChange;
|
|
2879
2881
|
onEditorViewReadyRef.current = onEditorViewReady;
|
|
2880
2882
|
onDocumentChangeRef.current = onDocumentChange;
|
|
2881
2883
|
onTotalPagesChangeRef.current = onTotalPagesChange;
|
|
2884
|
+
onErrorRef.current = onError;
|
|
2882
2885
|
const [layout, setLayout] = useState(null);
|
|
2883
2886
|
const layoutRef = useRef(layout);
|
|
2884
2887
|
layoutRef.current = layout;
|
|
@@ -3110,7 +3113,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3110
3113
|
* 3. Layout blocks onto pages
|
|
3111
3114
|
* 4. Paint pages to DOM
|
|
3112
3115
|
*/
|
|
3113
|
-
const
|
|
3116
|
+
const [hyphenationReadiness] = useState(() => createHyphenationReadiness({
|
|
3117
|
+
relayout: () => {
|
|
3118
|
+
const view_1 = hiddenPMRef.current?.getView();
|
|
3119
|
+
const state = view_1?.state ?? layoutSessionRef.current.lastEditorState;
|
|
3120
|
+
if (!state) return;
|
|
3121
|
+
runLayoutPipelineRef.current(state, { reason: "hyphenation-ready" });
|
|
3122
|
+
if (view_1) updateSelectionOverlayRef.current(view_1.state);
|
|
3123
|
+
},
|
|
3124
|
+
onError: (error) => onErrorRef.current?.(error)
|
|
3125
|
+
}));
|
|
3126
|
+
useEffect(() => hyphenationReadiness.cancel, [hyphenationReadiness]);
|
|
3127
|
+
const runLayoutPipeline$1 = useCallback((state_0, options = {}) => {
|
|
3114
3128
|
const outcome = runLayoutPipeline({
|
|
3115
3129
|
contentWidth,
|
|
3116
3130
|
columns,
|
|
@@ -3147,8 +3161,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3147
3161
|
buildFootnoteRenderItems,
|
|
3148
3162
|
describeInvalidHighlightMarks,
|
|
3149
3163
|
emptyTemplatePreviewEntries: EMPTY_TEMPLATE_PREVIEW_ENTRIES,
|
|
3150
|
-
emptyTemplatePreviewHidden: EMPTY_TEMPLATE_PREVIEW_HIDDEN
|
|
3151
|
-
|
|
3164
|
+
emptyTemplatePreviewHidden: EMPTY_TEMPLATE_PREVIEW_HIDDEN,
|
|
3165
|
+
hyphenationReadiness
|
|
3166
|
+
}, state_0, options);
|
|
3152
3167
|
if (outcome.blocks) setBlocks(outcome.blocks);
|
|
3153
3168
|
if (outcome.measures !== void 0) setMeasures(outcome.measures);
|
|
3154
3169
|
if (outcome.layout) setLayout(outcome.layout);
|
|
@@ -3192,7 +3207,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3192
3207
|
if (!folioEditorRef.current) folioEditorRef.current = createFolioEditor({
|
|
3193
3208
|
getEditorApi: () => hiddenPMRef.current,
|
|
3194
3209
|
getLayout: () => layoutRef.current,
|
|
3195
|
-
runLayout: (
|
|
3210
|
+
runLayout: (state_1, options_0) => runLayoutPipelineRef.current(state_1, options_0),
|
|
3196
3211
|
getDocumentIO: () => documentIORef.current,
|
|
3197
3212
|
emitter: folioEmitterRef.current
|
|
3198
3213
|
});
|
|
@@ -3221,7 +3236,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3221
3236
|
]);
|
|
3222
3237
|
const layoutSchedulerRef = useRef(null);
|
|
3223
3238
|
if (layoutSchedulerRef.current === null) layoutSchedulerRef.current = createLayoutScheduler({
|
|
3224
|
-
runLayout: (
|
|
3239
|
+
runLayout: (state_2, options_1) => runLayoutPipelineRef.current(state_2, options_1),
|
|
3225
3240
|
debounceMs: TRANSACTION_LAYOUT_DEBOUNCE_MS,
|
|
3226
3241
|
leadingFrame: true,
|
|
3227
3242
|
maxDelayMs: TRANSACTION_LAYOUT_MAX_DELAY_MS,
|
|
@@ -3246,8 +3261,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3246
3261
|
flushDocumentChangeNotification();
|
|
3247
3262
|
}, DOCUMENT_CHANGE_NOTIFY_DELAY);
|
|
3248
3263
|
}, [flushDocumentChangeNotification]);
|
|
3249
|
-
const scheduleLayout = useCallback((
|
|
3250
|
-
layoutSchedulerRef.current?.schedule(
|
|
3264
|
+
const scheduleLayout = useCallback((state_3, dirtyRange) => {
|
|
3265
|
+
layoutSchedulerRef.current?.schedule(state_3, dirtyRange);
|
|
3251
3266
|
}, []);
|
|
3252
3267
|
useEffect(() => () => {
|
|
3253
3268
|
layoutSchedulerRef.current?.dispose();
|
|
@@ -3274,14 +3289,14 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3274
3289
|
} : null;
|
|
3275
3290
|
}, []);
|
|
3276
3291
|
const refreshBodyImeCaretAnchor = useCallback(() => {
|
|
3277
|
-
const
|
|
3278
|
-
if (!
|
|
3279
|
-
const { selection: selection_1 } =
|
|
3292
|
+
const view_2 = hiddenPMRef.current?.getView();
|
|
3293
|
+
if (!view_2) return;
|
|
3294
|
+
const { selection: selection_1 } = view_2.state;
|
|
3280
3295
|
const domCaret = selection_1.empty ? getCaretFromDom(selection_1.head, zoom) : null;
|
|
3281
3296
|
const overlayRect_0 = (pagesContainerRef.current?.parentElement?.querySelector("[data-testid=\"selection-overlay\"]"))?.getBoundingClientRect();
|
|
3282
3297
|
syncImeCaretAnchor({
|
|
3283
3298
|
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3284
|
-
editorView:
|
|
3299
|
+
editorView: view_2,
|
|
3285
3300
|
visibleCaret: domCaret && overlayRect_0 ? {
|
|
3286
3301
|
left: overlayRect_0.left + domCaret.x * zoom,
|
|
3287
3302
|
top: overlayRect_0.top + domCaret.y * zoom
|
|
@@ -3291,17 +3306,17 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3291
3306
|
/**
|
|
3292
3307
|
* Update selection overlay from PM selection.
|
|
3293
3308
|
*/
|
|
3294
|
-
const updateSelectionOverlay = useCallback((
|
|
3295
|
-
const { from, to } =
|
|
3309
|
+
const updateSelectionOverlay = useCallback((state_4) => {
|
|
3310
|
+
const { from, to } = state_4.selection;
|
|
3296
3311
|
const isCurrentRequest = selectionOverlayRequestGate.begin();
|
|
3297
|
-
if (directivesRef.current.length > 0) setDirectiveCaretPos(
|
|
3312
|
+
if (directivesRef.current.length > 0) setDirectiveCaretPos(state_4.selection.head);
|
|
3298
3313
|
onSelectionChangeRef.current?.(from, to);
|
|
3299
3314
|
folioEmitterRef.current.emit("selectionChange", {
|
|
3300
3315
|
from,
|
|
3301
3316
|
to
|
|
3302
3317
|
});
|
|
3303
3318
|
if (onSelectionTextChangeRef.current) {
|
|
3304
|
-
const text_0 = from === to ? "" :
|
|
3319
|
+
const text_0 = from === to ? "" : state_4.doc.textBetween(from, to, " ", " ");
|
|
3305
3320
|
onSelectionTextChangeRef.current({
|
|
3306
3321
|
from,
|
|
3307
3322
|
to,
|
|
@@ -3321,7 +3336,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3321
3336
|
if (pagesContainerRef.current) {
|
|
3322
3337
|
const prevSelected = pagesContainerRef.current.querySelectorAll(".layout-table-cell-selected");
|
|
3323
3338
|
for (const el_0 of Array.from(prevSelected)) el_0.classList.remove("layout-table-cell-selected");
|
|
3324
|
-
const sel =
|
|
3339
|
+
const sel = state_4.selection;
|
|
3325
3340
|
if ("$anchorCell" in sel && typeof sel.forEachCell === "function") {
|
|
3326
3341
|
const selectedRanges = [];
|
|
3327
3342
|
sel.forEachCell((node_0, pos) => {
|
|
@@ -3474,8 +3489,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3474
3489
|
if (animationFrame !== null) cancelAnimationFrame(animationFrame);
|
|
3475
3490
|
animationFrame = requestAnimationFrame(() => {
|
|
3476
3491
|
animationFrame = null;
|
|
3477
|
-
const
|
|
3478
|
-
if (
|
|
3492
|
+
const state_5 = hiddenPMRef.current?.getState();
|
|
3493
|
+
if (state_5) updateSelectionOverlayRef.current(state_5);
|
|
3479
3494
|
});
|
|
3480
3495
|
};
|
|
3481
3496
|
pagesContainer_0.addEventListener(PAINTER_PAINTED_EVENT, repaintSelection);
|
|
@@ -3716,7 +3731,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3716
3731
|
}
|
|
3717
3732
|
updatePassageHighlightOverlay();
|
|
3718
3733
|
}, [passageHighlightOverlayRequestGate, updatePassageHighlightOverlay]);
|
|
3719
|
-
const hideSelectionOverlayDuringInput = useCallback((
|
|
3734
|
+
const hideSelectionOverlayDuringInput = useCallback((state_6) => {
|
|
3720
3735
|
selectionOverlayRequestGate.invalidate();
|
|
3721
3736
|
suppressSelectionOverlayRef.current = true;
|
|
3722
3737
|
setCaretPosition(null);
|
|
@@ -3725,7 +3740,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3725
3740
|
revealSelectionOverlayTimerRef.current = window.setTimeout(() => {
|
|
3726
3741
|
revealSelectionOverlayTimerRef.current = null;
|
|
3727
3742
|
suppressSelectionOverlayRef.current = false;
|
|
3728
|
-
updateSelectionOverlay(hiddenPMRef.current?.getState() ??
|
|
3743
|
+
updateSelectionOverlay(hiddenPMRef.current?.getState() ?? state_6);
|
|
3729
3744
|
}, SELECTION_REVEAL_AFTER_INPUT_DELAY);
|
|
3730
3745
|
}, [selectionOverlayRequestGate, updateSelectionOverlay]);
|
|
3731
3746
|
useEffect(() => () => {
|
|
@@ -3834,7 +3849,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3834
3849
|
*/
|
|
3835
3850
|
const [hfCaretSelection, setHfCaretSelection] = useState(null);
|
|
3836
3851
|
const activeHfPageNumberRef = useRef(null);
|
|
3837
|
-
const handleHfPmTransaction = useCallback((rId, kind,
|
|
3852
|
+
const handleHfPmTransaction = useCallback((rId, kind, view_3, docChanged_0, selectionChanged) => {
|
|
3838
3853
|
if (docChanged_0) {
|
|
3839
3854
|
let bodyState = hiddenPMRef.current?.getState();
|
|
3840
3855
|
if (!bodyState && precomputedInitialStateRef.current) bodyState = precomputedInitialStateRef.current;
|
|
@@ -3845,7 +3860,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3845
3860
|
if (bodyState) scheduleLayout(bodyState, null);
|
|
3846
3861
|
}
|
|
3847
3862
|
if (docChanged_0 || selectionChanged) {
|
|
3848
|
-
const { from: from_1, to: to_1 } =
|
|
3863
|
+
const { from: from_1, to: to_1 } = view_3.state.selection;
|
|
3849
3864
|
const pageNumber = activeHfPageNumberRef.current;
|
|
3850
3865
|
setHfCaretSelection({
|
|
3851
3866
|
rId,
|
|
@@ -3861,13 +3876,13 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3861
3876
|
});
|
|
3862
3877
|
}
|
|
3863
3878
|
}, [scheduleLayout, ensureHiddenEditorView]);
|
|
3864
|
-
const handleNoteStoryTransaction = useCallback((
|
|
3879
|
+
const handleNoteStoryTransaction = useCallback((view_4, docChanged_1, selectionChanged_0) => {
|
|
3865
3880
|
if (docChanged_1) {
|
|
3866
3881
|
const bodyState_0 = hiddenPMRef.current?.getState();
|
|
3867
3882
|
if (bodyState_0) scheduleLayout(bodyState_0, null);
|
|
3868
3883
|
}
|
|
3869
3884
|
if (docChanged_1 || selectionChanged_0) {
|
|
3870
|
-
const { from: from_2, to: to_2 } =
|
|
3885
|
+
const { from: from_2, to: to_2 } = view_4.state.selection;
|
|
3871
3886
|
onSelectionChangeRef.current?.(from_2, to_2);
|
|
3872
3887
|
folioEmitterRef.current.emit("selectionChange", {
|
|
3873
3888
|
from: from_2,
|
|
@@ -3888,19 +3903,19 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3888
3903
|
/**
|
|
3889
3904
|
* Handle selection change from PM.
|
|
3890
3905
|
*/
|
|
3891
|
-
const handleSelectionChange = useCallback((
|
|
3892
|
-
const { selection: selection_2 } =
|
|
3906
|
+
const handleSelectionChange = useCallback((state_7) => {
|
|
3907
|
+
const { selection: selection_2 } = state_7;
|
|
3893
3908
|
if (selection_2 instanceof NodeSelection && selection_2.node.type.name === "image") {
|
|
3894
3909
|
setSelectionRects([]);
|
|
3895
3910
|
setCaretPosition(null);
|
|
3896
|
-
} else if (syncCoordinator.isSafeToRender()) updateSelectionOverlay(
|
|
3911
|
+
} else if (syncCoordinator.isSafeToRender()) updateSelectionOverlay(state_7);
|
|
3897
3912
|
requestAnimationFrame(() => {
|
|
3898
|
-
const
|
|
3899
|
-
if (!
|
|
3913
|
+
const view_5 = hiddenPMRef.current?.getView();
|
|
3914
|
+
if (!view_5) {
|
|
3900
3915
|
setSelectedImageInfo(null);
|
|
3901
3916
|
return;
|
|
3902
3917
|
}
|
|
3903
|
-
const { selection: sel_0 } =
|
|
3918
|
+
const { selection: sel_0 } = view_5.state;
|
|
3904
3919
|
if (sel_0 instanceof NodeSelection && sel_0.node.type.name === "image") {
|
|
3905
3920
|
const pmPos_2 = sel_0.from;
|
|
3906
3921
|
const imgEl = pagesContainerRef.current ? findBodyPmAnchor(pagesContainerRef.current, pmPos_2) : null;
|
|
@@ -3976,9 +3991,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3976
3991
|
return null;
|
|
3977
3992
|
}, []);
|
|
3978
3993
|
const findCellPosFromPmPos = useCallback((pmPos_4) => {
|
|
3979
|
-
const
|
|
3980
|
-
if (!
|
|
3981
|
-
return findCellPosInDoc(
|
|
3994
|
+
const view_6 = hiddenPMRef.current?.getView();
|
|
3995
|
+
if (!view_6) return null;
|
|
3996
|
+
return findCellPosInDoc(view_6.state.doc, pmPos_4);
|
|
3982
3997
|
}, [findCellPosInDoc]);
|
|
3983
3998
|
/**
|
|
3984
3999
|
* Find the closest image element from a click target.
|
|
@@ -4015,9 +4030,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4015
4030
|
});
|
|
4016
4031
|
}, [layout, scrollToPositionImpl]);
|
|
4017
4032
|
const scrollToParaIdImpl = useCallback((paraId, options_2) => {
|
|
4018
|
-
const
|
|
4019
|
-
if (!
|
|
4020
|
-
const startPos = findStartPosForParaId(
|
|
4033
|
+
const state_8 = hiddenPMRef.current?.getState();
|
|
4034
|
+
if (!state_8) return false;
|
|
4035
|
+
const startPos = findStartPosForParaId(state_8.doc, paraId);
|
|
4021
4036
|
if (startPos == null || startPos < 0) return false;
|
|
4022
4037
|
scrollToPositionImpl(startPos);
|
|
4023
4038
|
requestAnimationFrame(() => {
|
|
@@ -4025,8 +4040,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4025
4040
|
const pages = pagesContainerRef.current;
|
|
4026
4041
|
if (pages) flashParagraphFragmentsByParaId(pages, paraId, options_2.highlight);
|
|
4027
4042
|
}
|
|
4028
|
-
const targetNode =
|
|
4029
|
-
const inner = targetNode?.isTextblock === true ? Math.min(startPos + 1 + targetNode.content.size,
|
|
4043
|
+
const targetNode = state_8.doc.nodeAt(startPos);
|
|
4044
|
+
const inner = targetNode?.isTextblock === true ? Math.min(startPos + 1 + targetNode.content.size, state_8.doc.content.size) : Math.min(startPos + 1, state_8.doc.content.size);
|
|
4030
4045
|
hiddenPMRef.current?.setSelection(inner);
|
|
4031
4046
|
hiddenPMRef.current?.focus();
|
|
4032
4047
|
});
|
|
@@ -4040,8 +4055,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4040
4055
|
}
|
|
4041
4056
|
if (!hiddenPMRef.current?.getView()) ensureHiddenEditorView();
|
|
4042
4057
|
hiddenPMRef.current?.focus();
|
|
4043
|
-
const
|
|
4044
|
-
if (
|
|
4058
|
+
const view_7 = hiddenPMRef.current?.getView();
|
|
4059
|
+
if (view_7) updateSelectionOverlay(view_7.state);
|
|
4045
4060
|
setIsFocused(true);
|
|
4046
4061
|
}, [
|
|
4047
4062
|
ensureHiddenEditorView,
|
|
@@ -4072,10 +4087,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4072
4087
|
cellDragAnchorPosRef.current = null;
|
|
4073
4088
|
cellDragContentEndRef.current = null;
|
|
4074
4089
|
isCellDraggingRef.current = false;
|
|
4075
|
-
const
|
|
4090
|
+
const view_8 = hiddenPMRef.current?.getView();
|
|
4076
4091
|
let endPos;
|
|
4077
|
-
if (
|
|
4078
|
-
endPos = Math.max(0,
|
|
4092
|
+
if (view_8) {
|
|
4093
|
+
endPos = Math.max(0, view_8.state.doc.content.size - 1);
|
|
4079
4094
|
hiddenPMRef.current?.setSelection(endPos);
|
|
4080
4095
|
} else {
|
|
4081
4096
|
endPos = Math.max(0, (precomputedInitialStateRef.current?.doc.content.size ?? 1) - 1);
|
|
@@ -4095,11 +4110,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4095
4110
|
queueHiddenEditorSelection
|
|
4096
4111
|
]);
|
|
4097
4112
|
const copySelectionText = useCallback(() => {
|
|
4098
|
-
const
|
|
4099
|
-
if (!
|
|
4100
|
-
const { from: from_3, to: to_3 } =
|
|
4113
|
+
const view_9 = hiddenPMRef.current?.getView();
|
|
4114
|
+
if (!view_9) return false;
|
|
4115
|
+
const { from: from_3, to: to_3 } = view_9.state.selection;
|
|
4101
4116
|
if (from_3 === to_3) return false;
|
|
4102
|
-
const text_1 =
|
|
4117
|
+
const text_1 = view_9.state.doc.textBetween(from_3, to_3, "\n");
|
|
4103
4118
|
if (!text_1) return false;
|
|
4104
4119
|
if (navigator.clipboard === void 0) return false;
|
|
4105
4120
|
navigator.clipboard.writeText(text_1).catch(() => void 0);
|
|
@@ -4196,9 +4211,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4196
4211
|
const colIndex = Number.parseInt(target_1.dataset["columnIndex"] ?? "0", 10);
|
|
4197
4212
|
resizeColumnIndexRef.current = colIndex;
|
|
4198
4213
|
resizeTablePmStartRef.current = Number.parseInt(target_1.dataset["tablePmStart"] ?? "0", 10);
|
|
4199
|
-
const
|
|
4200
|
-
if (
|
|
4201
|
-
const $pos_1 =
|
|
4214
|
+
const view_10 = resizeViewForRead;
|
|
4215
|
+
if (view_10) {
|
|
4216
|
+
const $pos_1 = view_10.state.doc.resolve(resizeTablePmStartRef.current + 1);
|
|
4202
4217
|
for (let d_0 = $pos_1.depth; d_0 >= 0; d_0--) {
|
|
4203
4218
|
const node_2 = $pos_1.node(d_0);
|
|
4204
4219
|
if (node_2.type.name === "table") {
|
|
@@ -4228,9 +4243,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4228
4243
|
const rowIndex = Number.parseInt(target_1.dataset["rowIndex"] ?? "0", 10);
|
|
4229
4244
|
resizeRowIndexRef.current = rowIndex;
|
|
4230
4245
|
resizeRowTablePmStartRef.current = Number.parseInt(target_1.dataset["tablePmStart"] ?? "0", 10);
|
|
4231
|
-
const
|
|
4232
|
-
if (
|
|
4233
|
-
const $pos_2 =
|
|
4246
|
+
const view_11 = resizeViewForRead;
|
|
4247
|
+
if (view_11) {
|
|
4248
|
+
const $pos_2 = view_11.state.doc.resolve(resizeRowTablePmStartRef.current + 1);
|
|
4234
4249
|
for (let d_1 = $pos_2.depth; d_1 >= 0; d_1--) {
|
|
4235
4250
|
const node_3 = $pos_2.node(d_1);
|
|
4236
4251
|
if (node_3.type.name === "table") {
|
|
@@ -4263,9 +4278,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4263
4278
|
const colIndex_0 = Number.parseInt(target_1.dataset["columnIndex"] ?? "0", 10);
|
|
4264
4279
|
resizeRightEdgeColIndexRef.current = colIndex_0;
|
|
4265
4280
|
resizeRightEdgePmStartRef.current = Number.parseInt(target_1.dataset["tablePmStart"] ?? "0", 10);
|
|
4266
|
-
const
|
|
4267
|
-
if (
|
|
4268
|
-
const $pos_3 =
|
|
4281
|
+
const view_12 = resizeViewForRead;
|
|
4282
|
+
if (view_12) {
|
|
4283
|
+
const $pos_3 = view_12.state.doc.resolve(resizeRightEdgePmStartRef.current + 1);
|
|
4269
4284
|
for (let d_2 = $pos_3.depth; d_2 >= 0; d_2--) {
|
|
4270
4285
|
const node_4 = $pos_3.node(d_2);
|
|
4271
4286
|
if (node_4.type.name === "table") {
|
|
@@ -4464,18 +4479,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4464
4479
|
resizeHandleRef.current.classList.remove("dragging");
|
|
4465
4480
|
resizeHandleRef.current = null;
|
|
4466
4481
|
}
|
|
4467
|
-
const
|
|
4482
|
+
const view_13 = (resizingHfSurfaceRef.current ? hfPMsRef.current?.getView(resizingHfSurfaceRef.current.rId) : hiddenPMRef.current?.getView()) ?? null;
|
|
4468
4483
|
resizingHfSurfaceRef.current = null;
|
|
4469
|
-
if (
|
|
4484
|
+
if (view_13) {
|
|
4470
4485
|
const pmStart_0 = resizeTablePmStartRef.current;
|
|
4471
4486
|
const colIdx = resizeColumnIndexRef.current;
|
|
4472
4487
|
const { left: newLeft, right: newRight } = resizeOrigWidthsRef.current;
|
|
4473
|
-
const $pos_5 =
|
|
4488
|
+
const $pos_5 = view_13.state.doc.resolve(pmStart_0 + 1);
|
|
4474
4489
|
for (let d_3 = $pos_5.depth; d_3 >= 0; d_3--) {
|
|
4475
4490
|
const node_5 = $pos_5.node(d_3);
|
|
4476
4491
|
if (node_5.type.name === "table") {
|
|
4477
4492
|
const tablePos = $pos_5.before(d_3);
|
|
4478
|
-
const tr =
|
|
4493
|
+
const tr = view_13.state.tr;
|
|
4479
4494
|
const tableAttrs = expectTableAttrs(node_5);
|
|
4480
4495
|
if (!tableAttrs.columnWidths) break;
|
|
4481
4496
|
const widths_1 = [...tableAttrs.columnWidths];
|
|
@@ -4501,7 +4516,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4501
4516
|
});
|
|
4502
4517
|
rowOffset += row.nodeSize;
|
|
4503
4518
|
});
|
|
4504
|
-
|
|
4519
|
+
view_13.dispatch(tr);
|
|
4505
4520
|
break;
|
|
4506
4521
|
}
|
|
4507
4522
|
}
|
|
@@ -4514,18 +4529,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4514
4529
|
resizeRowHandleRef.current.classList.remove("dragging");
|
|
4515
4530
|
resizeRowHandleRef.current = null;
|
|
4516
4531
|
}
|
|
4517
|
-
const
|
|
4532
|
+
const view_14 = (resizingHfSurfaceRef.current ? hfPMsRef.current?.getView(resizingHfSurfaceRef.current.rId) : hiddenPMRef.current?.getView()) ?? null;
|
|
4518
4533
|
resizingHfSurfaceRef.current = null;
|
|
4519
|
-
if (
|
|
4534
|
+
if (view_14) {
|
|
4520
4535
|
const pmStart_1 = resizeRowTablePmStartRef.current;
|
|
4521
4536
|
const rowIdx = resizeRowIndexRef.current;
|
|
4522
4537
|
const newHeight_0 = resizeRowOrigHeightRef.current;
|
|
4523
|
-
const $pos_6 =
|
|
4538
|
+
const $pos_6 = view_14.state.doc.resolve(pmStart_1 + 1);
|
|
4524
4539
|
for (let d_4 = $pos_6.depth; d_4 >= 0; d_4--) {
|
|
4525
4540
|
const node_6 = $pos_6.node(d_4);
|
|
4526
4541
|
if (node_6.type.name === "table") {
|
|
4527
4542
|
const tablePos_0 = $pos_6.before(d_4);
|
|
4528
|
-
const tr_0 =
|
|
4543
|
+
const tr_0 = view_14.state.tr;
|
|
4529
4544
|
let rowOffset_0 = tablePos_0 + 1;
|
|
4530
4545
|
let idx = 0;
|
|
4531
4546
|
node_6.forEach((row_0) => {
|
|
@@ -4536,7 +4551,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4536
4551
|
rowOffset_0 += row_0.nodeSize;
|
|
4537
4552
|
idx++;
|
|
4538
4553
|
});
|
|
4539
|
-
|
|
4554
|
+
view_14.dispatch(tr_0);
|
|
4540
4555
|
break;
|
|
4541
4556
|
}
|
|
4542
4557
|
}
|
|
@@ -4549,18 +4564,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4549
4564
|
resizeRightEdgeHandleRef.current.classList.remove("dragging");
|
|
4550
4565
|
resizeRightEdgeHandleRef.current = null;
|
|
4551
4566
|
}
|
|
4552
|
-
const
|
|
4567
|
+
const view_15 = (resizingHfSurfaceRef.current ? hfPMsRef.current?.getView(resizingHfSurfaceRef.current.rId) : hiddenPMRef.current?.getView()) ?? null;
|
|
4553
4568
|
resizingHfSurfaceRef.current = null;
|
|
4554
|
-
if (
|
|
4569
|
+
if (view_15) {
|
|
4555
4570
|
const pmStart_2 = resizeRightEdgePmStartRef.current;
|
|
4556
4571
|
const colIdx_0 = resizeRightEdgeColIndexRef.current;
|
|
4557
4572
|
const newWidth_1 = resizeRightEdgeOrigWidthRef.current;
|
|
4558
|
-
const $pos_7 =
|
|
4573
|
+
const $pos_7 = view_15.state.doc.resolve(pmStart_2 + 1);
|
|
4559
4574
|
for (let d_5 = $pos_7.depth; d_5 >= 0; d_5--) {
|
|
4560
4575
|
const node_7 = $pos_7.node(d_5);
|
|
4561
4576
|
if (node_7.type.name === "table") {
|
|
4562
4577
|
const tablePos_1 = $pos_7.before(d_5);
|
|
4563
|
-
const tr_1 =
|
|
4578
|
+
const tr_1 = view_15.state.tr;
|
|
4564
4579
|
const tableAttrs_0 = expectTableAttrs(node_7);
|
|
4565
4580
|
if (!tableAttrs_0.columnWidths) break;
|
|
4566
4581
|
const widths_2 = [...tableAttrs_0.columnWidths];
|
|
@@ -4582,7 +4597,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4582
4597
|
});
|
|
4583
4598
|
rowOffset_1 += row_1.nodeSize;
|
|
4584
4599
|
});
|
|
4585
|
-
|
|
4600
|
+
view_15.dispatch(tr_1);
|
|
4586
4601
|
break;
|
|
4587
4602
|
}
|
|
4588
4603
|
}
|
|
@@ -4724,13 +4739,13 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4724
4739
|
e_2.preventDefault();
|
|
4725
4740
|
e_2.stopPropagation();
|
|
4726
4741
|
if (!tableInsertButton || !hiddenPMRef.current) return;
|
|
4727
|
-
const
|
|
4728
|
-
if (!
|
|
4742
|
+
const view_16 = hiddenPMRef.current.getView();
|
|
4743
|
+
if (!view_16) return;
|
|
4729
4744
|
const { type, cellPmPos } = tableInsertButton;
|
|
4730
|
-
const tr_2 =
|
|
4731
|
-
|
|
4732
|
-
if (type === "row") addRowBelow(
|
|
4733
|
-
else addColumnRight(
|
|
4745
|
+
const tr_2 = view_16.state.tr.setSelection(TextSelection$1.create(view_16.state.doc, cellPmPos + 1));
|
|
4746
|
+
view_16.dispatch(tr_2);
|
|
4747
|
+
if (type === "row") addRowBelow(view_16.state, view_16.dispatch);
|
|
4748
|
+
else addColumnRight(view_16.state, view_16.dispatch);
|
|
4734
4749
|
setTableInsertButton(null);
|
|
4735
4750
|
hiddenPMRef.current.focus();
|
|
4736
4751
|
}, [tableInsertButton]);
|
|
@@ -4757,10 +4772,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4757
4772
|
if (href.startsWith("#")) {
|
|
4758
4773
|
const bookmarkName = href.slice(1);
|
|
4759
4774
|
if (bookmarkName && hiddenPMRef.current) {
|
|
4760
|
-
const
|
|
4761
|
-
if (
|
|
4775
|
+
const view_17 = hiddenPMRef.current.getView();
|
|
4776
|
+
if (view_17) {
|
|
4762
4777
|
const targetPos = { value: null };
|
|
4763
|
-
|
|
4778
|
+
view_17.state.doc.descendants((node_8, pos_2) => {
|
|
4764
4779
|
if (targetPos.value !== null) return false;
|
|
4765
4780
|
if (node_8.type.name === "paragraph") {
|
|
4766
4781
|
if (node_8.attrs["bookmarks"]?.some((b) => b.name === bookmarkName)) {
|
|
@@ -4849,9 +4864,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4849
4864
|
if (e_3.detail === 2 && hiddenPMRef.current) {
|
|
4850
4865
|
const pmPos_12 = getPositionFromMouse(e_3.clientX, e_3.clientY);
|
|
4851
4866
|
if (pmPos_12 !== null) {
|
|
4852
|
-
const
|
|
4853
|
-
if (
|
|
4854
|
-
const { doc: doc_0 } =
|
|
4867
|
+
const view_18 = hiddenPMRef.current.getView();
|
|
4868
|
+
if (view_18) {
|
|
4869
|
+
const { doc: doc_0 } = view_18.state;
|
|
4855
4870
|
const $pos_9 = doc_0.resolve(pmPos_12);
|
|
4856
4871
|
const parent_0 = $pos_9.parent;
|
|
4857
4872
|
if (parent_0.isTextblock) {
|
|
@@ -4877,9 +4892,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4877
4892
|
if (e_3.detail === 3 && hiddenPMRef.current) {
|
|
4878
4893
|
const pmPos_13 = getPositionFromMouse(e_3.clientX, e_3.clientY);
|
|
4879
4894
|
if (pmPos_13 !== null) {
|
|
4880
|
-
const
|
|
4881
|
-
if (
|
|
4882
|
-
const { doc: doc_1 } =
|
|
4895
|
+
const view_19 = hiddenPMRef.current.getView();
|
|
4896
|
+
if (view_19) {
|
|
4897
|
+
const { doc: doc_1 } = view_19.state;
|
|
4883
4898
|
const $pos_10 = doc_1.resolve(pmPos_13);
|
|
4884
4899
|
const paragraphStart = $pos_10.start($pos_10.depth);
|
|
4885
4900
|
const paragraphEnd = $pos_10.end($pos_10.depth);
|
|
@@ -4924,9 +4939,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4924
4939
|
}
|
|
4925
4940
|
}
|
|
4926
4941
|
}
|
|
4927
|
-
const
|
|
4928
|
-
if (!
|
|
4929
|
-
const { from: from_5, to: to_5 } =
|
|
4942
|
+
const view_20 = hiddenPMRef.current?.getView();
|
|
4943
|
+
if (!view_20) return;
|
|
4944
|
+
const { from: from_5, to: to_5 } = view_20.state.selection;
|
|
4930
4945
|
const pmPos_15 = getPositionFromMouse(e_4.clientX, e_4.clientY);
|
|
4931
4946
|
if (pmPos_15 !== null && (from_5 === to_5 || pmPos_15 < from_5 || pmPos_15 > to_5)) {
|
|
4932
4947
|
hiddenPMRef.current?.setSelection(pmPos_15);
|
|
@@ -4967,9 +4982,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4967
4982
|
* Handle image resize from the overlay.
|
|
4968
4983
|
*/
|
|
4969
4984
|
const handleImageResize = useCallback((pmPos_16, newWidth_2, newHeight_1) => {
|
|
4970
|
-
const
|
|
4971
|
-
if (!
|
|
4972
|
-
const committed = commitImageResize(
|
|
4985
|
+
const view_21 = hiddenPMRef.current?.getView();
|
|
4986
|
+
if (!view_21) return;
|
|
4987
|
+
const committed = commitImageResize(view_21, pmPos_16, newWidth_2, newHeight_1);
|
|
4973
4988
|
if (committed !== null) hiddenPMRef.current?.setNodeSelection(committed);
|
|
4974
4989
|
}, []);
|
|
4975
4990
|
/**
|
|
@@ -4989,10 +5004,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4989
5004
|
* to the drop position determined by mouse coordinates.
|
|
4990
5005
|
*/
|
|
4991
5006
|
const handleImageDragMove = useCallback((pmPos_17, clientX_1, clientY_1) => {
|
|
4992
|
-
const
|
|
4993
|
-
if (!
|
|
5007
|
+
const view_22 = hiddenPMRef.current?.getView();
|
|
5008
|
+
if (!view_22) return;
|
|
4994
5009
|
try {
|
|
4995
|
-
const node_11 =
|
|
5010
|
+
const node_11 = view_22.state.doc.nodeAt(pmPos_17);
|
|
4996
5011
|
if (!node_11 || node_11.type.name !== "image") return;
|
|
4997
5012
|
let committed_0 = null;
|
|
4998
5013
|
if (isFloatingImage(node_11)) {
|
|
@@ -5015,11 +5030,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5015
5030
|
const dropX = (clientX_1 - contentRect.left) / zoom;
|
|
5016
5031
|
const dropY = (clientY_1 - contentRect.top) / zoom;
|
|
5017
5032
|
const PIXELS_TO_EMU = 914400 / 96;
|
|
5018
|
-
committed_0 = commitImageFloatMove(
|
|
5033
|
+
committed_0 = commitImageFloatMove(view_22, pmPos_17, Math.round(dropX * PIXELS_TO_EMU), Math.round(dropY * PIXELS_TO_EMU));
|
|
5019
5034
|
} else {
|
|
5020
5035
|
const dropPos = getPositionFromMouse(clientX_1, clientY_1);
|
|
5021
5036
|
if (dropPos === null) return;
|
|
5022
|
-
committed_0 = commitImageInlineMove(
|
|
5037
|
+
committed_0 = commitImageInlineMove(view_22, pmPos_17, dropPos);
|
|
5023
5038
|
}
|
|
5024
5039
|
if (committed_0 !== null) hiddenPMRef.current?.setNodeSelection(committed_0);
|
|
5025
5040
|
} catch {}
|
|
@@ -5048,11 +5063,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5048
5063
|
return;
|
|
5049
5064
|
}
|
|
5050
5065
|
if (e_7.target instanceof HTMLElement && e_7.target.closest("[data-hf-r-id], [data-note-kind][data-note-id]")) return;
|
|
5051
|
-
let
|
|
5052
|
-
if (!
|
|
5066
|
+
let view_23 = hiddenPMRef.current?.getView();
|
|
5067
|
+
if (!view_23) {
|
|
5053
5068
|
ensureHiddenEditorView({ sync: true });
|
|
5054
|
-
|
|
5055
|
-
if (
|
|
5069
|
+
view_23 = hiddenPMRef.current?.getView();
|
|
5070
|
+
if (view_23) {
|
|
5056
5071
|
if (isPlainTextInputEvent(e_7)) {
|
|
5057
5072
|
e_7.preventDefault();
|
|
5058
5073
|
queueHiddenEditorTextInput(e_7.key);
|
|
@@ -5075,7 +5090,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5075
5090
|
}
|
|
5076
5091
|
return;
|
|
5077
5092
|
}
|
|
5078
|
-
if (pendingHiddenEditorSelectionRef.current || queuedInputBeforeHiddenEditorRef.current.length > 0) applyPendingHiddenEditorInput(
|
|
5093
|
+
if (pendingHiddenEditorSelectionRef.current || queuedInputBeforeHiddenEditorRef.current.length > 0) applyPendingHiddenEditorInput(view_23);
|
|
5079
5094
|
if (!hiddenPMRef.current?.isFocused()) focusHiddenEditor();
|
|
5080
5095
|
if (["PageUp", "PageDown"].includes(e_7.key) && !e_7.metaKey && !e_7.ctrlKey) {}
|
|
5081
5096
|
if (e_7.key === "Home" && (e_7.metaKey || e_7.ctrlKey)) {
|
|
@@ -5168,20 +5183,20 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5168
5183
|
/**
|
|
5169
5184
|
* Run initial layout when document or view changes.
|
|
5170
5185
|
*/
|
|
5171
|
-
const handleEditorViewReady = useCallback((
|
|
5172
|
-
onEditorViewReadyRef.current?.(
|
|
5173
|
-
anonymizationMatchesRef.current = anonymizationDecorationsKey.getState(
|
|
5174
|
-
const initialSuggestion = autocompleteSuggestionKey.getState(
|
|
5186
|
+
const handleEditorViewReady = useCallback((view_24) => {
|
|
5187
|
+
onEditorViewReadyRef.current?.(view_24);
|
|
5188
|
+
anonymizationMatchesRef.current = anonymizationDecorationsKey.getState(view_24.state)?.matches ?? [];
|
|
5189
|
+
const initialSuggestion = autocompleteSuggestionKey.getState(view_24.state)?.suggestion;
|
|
5175
5190
|
if (initialSuggestion !== void 0) autocompleteSuggestionRef.current = initialSuggestion;
|
|
5176
5191
|
updateAutocompleteOverlay();
|
|
5177
|
-
directivesRef.current = templateDirectivesKey.getState(
|
|
5178
|
-
const previewState = templatePreviewValuesKey.getState(
|
|
5192
|
+
directivesRef.current = templateDirectivesKey.getState(view_24.state)?.ranges ?? [];
|
|
5193
|
+
const previewState = templatePreviewValuesKey.getState(view_24.state);
|
|
5179
5194
|
templatePreviewRef.current = {
|
|
5180
5195
|
entries: previewState?.entries ?? EMPTY_TEMPLATE_PREVIEW_ENTRIES,
|
|
5181
5196
|
hidden: previewState?.hidden ?? EMPTY_TEMPLATE_PREVIEW_HIDDEN,
|
|
5182
5197
|
mode: previewState?.preview?.mode ?? "plain"
|
|
5183
5198
|
};
|
|
5184
|
-
const aiState = aiSuggestionDecorationsKey.getState(
|
|
5199
|
+
const aiState = aiSuggestionDecorationsKey.getState(view_24.state);
|
|
5185
5200
|
aiSuggestionsRef.current = {
|
|
5186
5201
|
suggestions: aiState?.suggestions ?? EMPTY_AI_SUGGESTIONS,
|
|
5187
5202
|
focusedId: aiState?.focusedId ?? null
|
|
@@ -5189,17 +5204,17 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5189
5204
|
const focusReadyView = () => {
|
|
5190
5205
|
if (readOnly || !shouldFocusHiddenEditorOnReadyRef.current) return;
|
|
5191
5206
|
requestAnimationFrame(() => {
|
|
5192
|
-
if (hiddenPMRef.current?.getView() !==
|
|
5193
|
-
applyPendingHiddenEditorInput(
|
|
5194
|
-
|
|
5207
|
+
if (hiddenPMRef.current?.getView() !== view_24) return;
|
|
5208
|
+
applyPendingHiddenEditorInput(view_24);
|
|
5209
|
+
view_24.focus();
|
|
5195
5210
|
refreshBodyImeCaretAnchor();
|
|
5196
5211
|
setIsFocused(true);
|
|
5197
5212
|
});
|
|
5198
5213
|
};
|
|
5199
|
-
if (layoutSessionRef.current.lastPmDoc?.eq(
|
|
5214
|
+
if (layoutSessionRef.current.lastPmDoc?.eq(view_24.state.doc)) {
|
|
5200
5215
|
const lastPreview = layoutSessionRef.current.lastTemplatePreview;
|
|
5201
|
-
if (templatePreviewRef.current.mode !== lastPreview.mode || templatePreviewDirtyRange(lastPreview, templatePreviewRef.current) !== null) runLayoutPipeline$1(
|
|
5202
|
-
updateSelectionOverlay(
|
|
5216
|
+
if (templatePreviewRef.current.mode !== lastPreview.mode || templatePreviewDirtyRange(lastPreview, templatePreviewRef.current) !== null) runLayoutPipeline$1(view_24.state, { reason: "manual" });
|
|
5217
|
+
updateSelectionOverlay(view_24.state);
|
|
5203
5218
|
updateAnonymizationOverlay();
|
|
5204
5219
|
updateDirectivesOverlay();
|
|
5205
5220
|
updateAISuggestionsOverlay();
|
|
@@ -5218,7 +5233,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5218
5233
|
const runAfterFontWait_0 = (fontsLoaded_0) => {
|
|
5219
5234
|
pendingInitialFontReadyLayoutRef.current = false;
|
|
5220
5235
|
const currentView_0 = hiddenPMRef.current?.getView();
|
|
5221
|
-
if (currentView_0 !==
|
|
5236
|
+
if (currentView_0 !== view_24) return;
|
|
5222
5237
|
recordLayoutPhase("initial", "initial-fonts", performance.now() - fontWaitStartedAt_0);
|
|
5223
5238
|
resetCanvasContext();
|
|
5224
5239
|
clearAllCaches();
|
|
@@ -5228,7 +5243,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5228
5243
|
suppressFontReadyUntilRef.current = performance.now() + INITIAL_FONT_READY_SUPPRESSION_MS;
|
|
5229
5244
|
}
|
|
5230
5245
|
};
|
|
5231
|
-
waitForInitialLayoutFonts(document,
|
|
5246
|
+
waitForInitialLayoutFonts(document, view_24.state.doc).then(runAfterFontWait_0, () => runAfterFontWait_0(false));
|
|
5232
5247
|
focusReadyView();
|
|
5233
5248
|
}, [
|
|
5234
5249
|
applyPendingHiddenEditorInput,
|
|
@@ -5290,12 +5305,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5290
5305
|
};
|
|
5291
5306
|
const handleFontsLoaded = () => {
|
|
5292
5307
|
if (pendingInitialFontReadyLayoutRef.current || performance.now() < suppressFontReadyUntilRef.current || layoutSessionRef.current.usedLoadedFonts) return;
|
|
5293
|
-
const
|
|
5294
|
-
if (
|
|
5308
|
+
const view_25 = hiddenPMRef.current?.getView();
|
|
5309
|
+
if (view_25) {
|
|
5295
5310
|
resetCanvasContext();
|
|
5296
5311
|
clearAllCaches();
|
|
5297
|
-
runLayoutPipelineRef.current(
|
|
5298
|
-
updateSelectionOverlayRef.current(
|
|
5312
|
+
runLayoutPipelineRef.current(view_25.state, { reason: "font-ready" });
|
|
5313
|
+
updateSelectionOverlayRef.current(view_25.state);
|
|
5299
5314
|
}
|
|
5300
5315
|
};
|
|
5301
5316
|
fontSet.addEventListener("loading", handleFontsLoading);
|
|
@@ -5320,12 +5335,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5320
5335
|
registered = faces;
|
|
5321
5336
|
if (faces.length === 0 && familyMap.size === 0) return;
|
|
5322
5337
|
setEmbeddedFontFamilyMap(familyMap.size > 0 ? familyMap : null);
|
|
5323
|
-
const
|
|
5324
|
-
if (!
|
|
5338
|
+
const view_26 = hiddenPMRef.current?.getView();
|
|
5339
|
+
if (!view_26) return;
|
|
5325
5340
|
resetCanvasContext();
|
|
5326
5341
|
clearAllCaches();
|
|
5327
|
-
runLayoutPipelineRef.current(
|
|
5328
|
-
updateSelectionOverlayRef.current(
|
|
5342
|
+
runLayoutPipelineRef.current(view_26.state, { reason: "font-ready" });
|
|
5343
|
+
updateSelectionOverlayRef.current(view_26.state);
|
|
5329
5344
|
});
|
|
5330
5345
|
return () => {
|
|
5331
5346
|
cancelled_1 = true;
|
|
@@ -5338,12 +5353,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5338
5353
|
let cancelled_2 = false;
|
|
5339
5354
|
let registered_0 = [];
|
|
5340
5355
|
const remeasureForFontChange = () => {
|
|
5341
|
-
const
|
|
5342
|
-
if (!
|
|
5356
|
+
const view_27 = hiddenPMRef.current?.getView();
|
|
5357
|
+
if (!view_27) return;
|
|
5343
5358
|
resetCanvasContext();
|
|
5344
5359
|
clearAllCaches();
|
|
5345
|
-
runLayoutPipelineRef.current(
|
|
5346
|
-
updateSelectionOverlayRef.current(
|
|
5360
|
+
runLayoutPipelineRef.current(view_27.state, { reason: "font-ready" });
|
|
5361
|
+
updateSelectionOverlayRef.current(view_27.state);
|
|
5347
5362
|
};
|
|
5348
5363
|
loadHostFontFaces(hostFonts).then((faces_0) => {
|
|
5349
5364
|
if (cancelled_2) {
|
|
@@ -5369,20 +5384,20 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5369
5384
|
lastLayoutInputSignatureRef.current = layoutInputSignature;
|
|
5370
5385
|
return;
|
|
5371
5386
|
}
|
|
5372
|
-
const
|
|
5373
|
-
if (
|
|
5387
|
+
const view_28 = hiddenPMRef.current?.getView();
|
|
5388
|
+
if (view_28) {
|
|
5374
5389
|
const layoutInputsChanged = lastLayoutInputSignatureRef.current !== layoutInputSignature;
|
|
5375
5390
|
lastLayoutInputSignatureRef.current = layoutInputSignature;
|
|
5376
|
-
if (!layoutInputsChanged &&
|
|
5377
|
-
runLayoutPipelineRef.current(
|
|
5391
|
+
if (!layoutInputsChanged && view_28.state.doc === layoutSessionRef.current.lastPmDoc) return;
|
|
5392
|
+
runLayoutPipelineRef.current(view_28.state, { reason: "layout-input" });
|
|
5378
5393
|
}
|
|
5379
5394
|
}, [document, layoutInputSignature]);
|
|
5380
5395
|
useEffect(() => {
|
|
5381
5396
|
const container = containerRef.current;
|
|
5382
5397
|
if (!container) return;
|
|
5383
5398
|
const observer = new ResizeObserver(() => {
|
|
5384
|
-
const
|
|
5385
|
-
if (
|
|
5399
|
+
const state_9 = hiddenPMRef.current?.getState();
|
|
5400
|
+
if (state_9) updateSelectionOverlay(state_9);
|
|
5386
5401
|
});
|
|
5387
5402
|
observer.observe(container);
|
|
5388
5403
|
return () => observer.disconnect();
|
|
@@ -5442,8 +5457,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5442
5457
|
setIsFocused(true);
|
|
5443
5458
|
},
|
|
5444
5459
|
blur() {
|
|
5445
|
-
const
|
|
5446
|
-
if (
|
|
5460
|
+
const view_29 = getActiveEditorStory().view;
|
|
5461
|
+
if (view_29?.hasFocus() && view_29.dom instanceof HTMLElement) view_29.dom.blur();
|
|
5447
5462
|
setIsFocused(false);
|
|
5448
5463
|
},
|
|
5449
5464
|
isFocused() {
|
|
@@ -5519,25 +5534,25 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5519
5534
|
return bestNumber;
|
|
5520
5535
|
},
|
|
5521
5536
|
getBlockRect(blockId) {
|
|
5522
|
-
const
|
|
5537
|
+
const state_10 = folioEditor.getState();
|
|
5523
5538
|
const pagesContainer_6 = pagesContainerRef.current;
|
|
5524
5539
|
const scrollRoot = getScrollContainer();
|
|
5525
|
-
if (!
|
|
5540
|
+
if (!state_10 || !pagesContainer_6 || !scrollRoot) return null;
|
|
5526
5541
|
return readBlockRects({
|
|
5527
5542
|
blockIds: [blockId],
|
|
5528
|
-
snapshot: createFolioAIEditSnapshot$1(
|
|
5543
|
+
snapshot: createFolioAIEditSnapshot$1(state_10.doc),
|
|
5529
5544
|
pagesContainer: pagesContainer_6,
|
|
5530
5545
|
scrollRoot
|
|
5531
5546
|
}).get(blockId) ?? null;
|
|
5532
5547
|
},
|
|
5533
5548
|
getBlockRects(blockIds) {
|
|
5534
|
-
const
|
|
5549
|
+
const state_11 = folioEditor.getState();
|
|
5535
5550
|
const pagesContainer_7 = pagesContainerRef.current;
|
|
5536
5551
|
const scrollRoot_0 = getScrollContainer();
|
|
5537
|
-
if (!
|
|
5552
|
+
if (!state_11 || !pagesContainer_7 || !scrollRoot_0) return /* @__PURE__ */ new Map();
|
|
5538
5553
|
return readBlockRects({
|
|
5539
5554
|
blockIds,
|
|
5540
|
-
snapshot: createFolioAIEditSnapshot$1(
|
|
5555
|
+
snapshot: createFolioAIEditSnapshot$1(state_11.doc),
|
|
5541
5556
|
pagesContainer: pagesContainer_7,
|
|
5542
5557
|
scrollRoot: scrollRoot_0
|
|
5543
5558
|
});
|
|
@@ -5566,8 +5581,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5566
5581
|
onTotalPagesChangeRef.current?.(totalPages);
|
|
5567
5582
|
}, [layout]);
|
|
5568
5583
|
useEffect(() => {
|
|
5569
|
-
const
|
|
5570
|
-
if (layout &&
|
|
5584
|
+
const state_12 = hiddenPMRef.current?.getState();
|
|
5585
|
+
if (layout && state_12) updateSelectionOverlay(state_12);
|
|
5571
5586
|
}, [layout, updateSelectionOverlay]);
|
|
5572
5587
|
const totalHeight = useMemo(() => {
|
|
5573
5588
|
if (!layout) return DEFAULT_PAGE_HEIGHT_PX + 48;
|
|
@@ -12260,7 +12275,7 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
|
|
|
12260
12275
|
* - Error boundary
|
|
12261
12276
|
* - Loading states
|
|
12262
12277
|
*/
|
|
12263
|
-
const CommentsSidebar = lazy(() => import("./CommentsSidebar-
|
|
12278
|
+
const CommentsSidebar = lazy(() => import("./CommentsSidebar-D68oqCy8.js").then((m) => ({ default: m.CommentsSidebar })));
|
|
12264
12279
|
const TextContextMenu = lazy(() => import("./TextContextMenu-Ci7-M4oU.js").then((m) => ({ default: m.TextContextMenu })));
|
|
12265
12280
|
const loadAttemptSelectiveSave = async () => {
|
|
12266
12281
|
const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
|
|
@@ -15043,6 +15058,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
15043
15058
|
anonymizationSelectionSeq,
|
|
15044
15059
|
...showCommentsSidebar ? { onAnchorPositionsChange: setAnchorPositions } : {},
|
|
15045
15060
|
onTotalPagesChange: handleTotalPagesChange,
|
|
15061
|
+
onError: handleEditorError,
|
|
15046
15062
|
scrollContainerRef,
|
|
15047
15063
|
sidebarOverlay: commentsSidebarOverlay
|
|
15048
15064
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "React editor for folio: a Word-document (.docx) editor for the browser, built on @stll/folio-core and ProseMirror.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-editor",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@fontsource/noto-sans-arabic": "^5.2.7",
|
|
76
76
|
"@fontsource/source-sans-3": "^5.2.9",
|
|
77
77
|
"@fontsource/tinos": "^5.2.7",
|
|
78
|
-
"@stll/folio-core": "^0.
|
|
78
|
+
"@stll/folio-core": "^0.49.0",
|
|
79
79
|
"better-result": "3.0.1",
|
|
80
80
|
"lucide-react": "1.24.0",
|
|
81
81
|
"prosemirror-history": "^1.5.0",
|