@stll/folio-react 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as containedHandler } from "./renderAsync-
|
|
1
|
+
import { d as containedHandler } from "./renderAsync-vD-j-sjQ.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";
|
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-vD-j-sjQ.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.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-vD-j-sjQ.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";
|
|
@@ -52,7 +52,8 @@ import { documentFontsAreLoaded, getDocumentFontSet, waitForInitialLayoutFonts }
|
|
|
52
52
|
import { getFootnoteText } from "@stll/folio-core/docx/footnoteParser";
|
|
53
53
|
import { convertHeaderFooterPmDocToContent, convertHeaderFooterToContent } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
|
|
54
54
|
import { templatePreviewDirtyRange } from "@stll/folio-core/layout-bridge/convert/templatePreviewFlow";
|
|
55
|
-
import { clickToPositionDom } from "@stll/folio-core/layout-bridge/dom/clickToPositionDom";
|
|
55
|
+
import { clickToPositionDom, getCollapsedLineEdgeCaretGeometry } from "@stll/folio-core/layout-bridge/dom/clickToPositionDom";
|
|
56
|
+
import { resetImeCaretAnchor, syncImeCaretAnchor } from "@stll/folio-core/layout-bridge/dom/imeCaretAnchor";
|
|
56
57
|
import { findBodyEmptyRuns, findBodyPmAnchor, findBodyPmAnchors, findBodyPmSpans } from "@stll/folio-core/layout-bridge/dom/findBodyPmSpans";
|
|
57
58
|
import { clickToPositionInHfSlot, findHfCaretSpan, findHfPmSpans, findHfSlotForTarget, findHfSlotKindForTarget } from "@stll/folio-core/layout-bridge/dom/findHfPmSpans";
|
|
58
59
|
import { findNoteStoryForTarget } from "@stll/folio-core/layout-bridge/dom/noteStoryDom";
|
|
@@ -357,11 +358,13 @@ const HiddenHeaderFooterPMs = memo(forwardRef(function HiddenHeaderFooterPMs({ d
|
|
|
357
358
|
managerRef.current?.destroy();
|
|
358
359
|
}, []);
|
|
359
360
|
useImperativeHandle(ref, () => ({
|
|
361
|
+
getHostElement: () => hostRef.current,
|
|
360
362
|
getView: (rId) => managerRef.current?.getView(rId) ?? null,
|
|
361
363
|
listSlots: () => managerRef.current?.listSlots() ?? []
|
|
362
364
|
}), []);
|
|
363
365
|
return /* @__PURE__ */ jsx("div", {
|
|
364
366
|
ref: hostRef,
|
|
367
|
+
className: "paged-editor__hidden-hf-pm",
|
|
365
368
|
style: HOST_STYLES
|
|
366
369
|
});
|
|
367
370
|
}));
|
|
@@ -1318,7 +1321,10 @@ const HiddenProseMirror = forwardRef((props, ref) => {
|
|
|
1318
1321
|
useEffect(() => {
|
|
1319
1322
|
managerRef.current?.syncEditable();
|
|
1320
1323
|
}, [readOnly]);
|
|
1321
|
-
useImperativeHandle(ref, () =>
|
|
1324
|
+
useImperativeHandle(ref, () => ({
|
|
1325
|
+
...managerRef.current.api,
|
|
1326
|
+
getHostElement: () => hostRef.current
|
|
1327
|
+
}), []);
|
|
1322
1328
|
if (hasCollaboration && collaborationModulesError) {
|
|
1323
1329
|
let detail = "unknown error";
|
|
1324
1330
|
if (collaborationModulesError instanceof Error) detail = collaborationModulesError.message;
|
|
@@ -2576,8 +2582,8 @@ const loadSelectionGeometry = () => {
|
|
|
2576
2582
|
return selectionGeometryPromise;
|
|
2577
2583
|
};
|
|
2578
2584
|
function HfCaretOverlay(t0) {
|
|
2579
|
-
const $ = c(
|
|
2580
|
-
const { selection, pagesContainer, zoom } = t0;
|
|
2585
|
+
const $ = c(22);
|
|
2586
|
+
const { selection, pagesContainer, hiddenHost, editorView, zoom } = t0;
|
|
2581
2587
|
const [caret, setCaret] = useState(null);
|
|
2582
2588
|
let t1;
|
|
2583
2589
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
@@ -2587,7 +2593,7 @@ function HfCaretOverlay(t0) {
|
|
|
2587
2593
|
const [rangeRects, setRangeRects] = useState(t1);
|
|
2588
2594
|
let t2;
|
|
2589
2595
|
let t3;
|
|
2590
|
-
if ($[1] !==
|
|
2596
|
+
if ($[1] !== editorView || $[2] !== hiddenHost || $[3] !== pagesContainer || $[4] !== selection.from || $[5] !== selection.kind || $[6] !== selection.pageNumber || $[7] !== selection.rId || $[8] !== selection.to || $[9] !== zoom) {
|
|
2591
2597
|
t2 = () => {
|
|
2592
2598
|
if (!pagesContainer) return;
|
|
2593
2599
|
const recompute = () => {
|
|
@@ -2597,6 +2603,11 @@ function HfCaretOverlay(t0) {
|
|
|
2597
2603
|
if (selection.from === selection.to) {
|
|
2598
2604
|
const hit = findHfCaretSpan(pageScope, selection.kind, selection.rId, selection.from);
|
|
2599
2605
|
if (!hit) {
|
|
2606
|
+
syncImeCaretAnchor({
|
|
2607
|
+
hiddenHost,
|
|
2608
|
+
editorView,
|
|
2609
|
+
visibleCaret: null
|
|
2610
|
+
});
|
|
2600
2611
|
setCaret(null);
|
|
2601
2612
|
setRangeRects([]);
|
|
2602
2613
|
return;
|
|
@@ -2628,9 +2639,22 @@ function HfCaretOverlay(t0) {
|
|
|
2628
2639
|
y: (absY - cr.top) / zoomDivisor,
|
|
2629
2640
|
height: absHeight / zoomDivisor
|
|
2630
2641
|
});
|
|
2642
|
+
syncImeCaretAnchor({
|
|
2643
|
+
hiddenHost,
|
|
2644
|
+
editorView,
|
|
2645
|
+
visibleCaret: {
|
|
2646
|
+
left: absX,
|
|
2647
|
+
top: absY
|
|
2648
|
+
}
|
|
2649
|
+
});
|
|
2631
2650
|
setRangeRects([]);
|
|
2632
2651
|
return;
|
|
2633
2652
|
}
|
|
2653
|
+
syncImeCaretAnchor({
|
|
2654
|
+
hiddenHost,
|
|
2655
|
+
editorView,
|
|
2656
|
+
visibleCaret: null
|
|
2657
|
+
});
|
|
2634
2658
|
const spans = findHfPmSpans(pageScope, selection.kind, selection.rId);
|
|
2635
2659
|
const rects = [];
|
|
2636
2660
|
for (const span of spans) {
|
|
@@ -2669,9 +2693,25 @@ function HfCaretOverlay(t0) {
|
|
|
2669
2693
|
};
|
|
2670
2694
|
recompute();
|
|
2671
2695
|
const onPainted = () => recompute();
|
|
2696
|
+
let animationFrame = null;
|
|
2697
|
+
const scheduleRecompute = () => {
|
|
2698
|
+
if (animationFrame !== null) cancelAnimationFrame(animationFrame);
|
|
2699
|
+
animationFrame = requestAnimationFrame(() => {
|
|
2700
|
+
animationFrame = null;
|
|
2701
|
+
recompute();
|
|
2702
|
+
});
|
|
2703
|
+
};
|
|
2672
2704
|
pagesContainer.addEventListener(PAINTER_PAINTED_EVENT, onPainted);
|
|
2705
|
+
hiddenHost?.addEventListener("focusin", recompute);
|
|
2706
|
+
hiddenHost?.addEventListener("compositionend", scheduleRecompute);
|
|
2707
|
+
window.addEventListener("scroll", scheduleRecompute, true);
|
|
2673
2708
|
return () => {
|
|
2709
|
+
if (animationFrame !== null) cancelAnimationFrame(animationFrame);
|
|
2674
2710
|
pagesContainer.removeEventListener(PAINTER_PAINTED_EVENT, onPainted);
|
|
2711
|
+
hiddenHost?.removeEventListener("focusin", recompute);
|
|
2712
|
+
hiddenHost?.removeEventListener("compositionend", scheduleRecompute);
|
|
2713
|
+
window.removeEventListener("scroll", scheduleRecompute, true);
|
|
2714
|
+
resetImeCaretAnchor(hiddenHost);
|
|
2675
2715
|
};
|
|
2676
2716
|
};
|
|
2677
2717
|
t3 = [
|
|
@@ -2681,31 +2721,35 @@ function HfCaretOverlay(t0) {
|
|
|
2681
2721
|
selection.to,
|
|
2682
2722
|
selection.pageNumber,
|
|
2683
2723
|
pagesContainer,
|
|
2724
|
+
hiddenHost,
|
|
2725
|
+
editorView,
|
|
2684
2726
|
zoom
|
|
2685
2727
|
];
|
|
2686
|
-
$[1] =
|
|
2687
|
-
$[2] =
|
|
2688
|
-
$[3] =
|
|
2689
|
-
$[4] = selection.
|
|
2690
|
-
$[5] = selection.
|
|
2691
|
-
$[6] = selection.
|
|
2692
|
-
$[7] =
|
|
2693
|
-
$[8] =
|
|
2694
|
-
$[9] =
|
|
2728
|
+
$[1] = editorView;
|
|
2729
|
+
$[2] = hiddenHost;
|
|
2730
|
+
$[3] = pagesContainer;
|
|
2731
|
+
$[4] = selection.from;
|
|
2732
|
+
$[5] = selection.kind;
|
|
2733
|
+
$[6] = selection.pageNumber;
|
|
2734
|
+
$[7] = selection.rId;
|
|
2735
|
+
$[8] = selection.to;
|
|
2736
|
+
$[9] = zoom;
|
|
2737
|
+
$[10] = t2;
|
|
2738
|
+
$[11] = t3;
|
|
2695
2739
|
} else {
|
|
2696
|
-
t2 = $[
|
|
2697
|
-
t3 = $[
|
|
2740
|
+
t2 = $[10];
|
|
2741
|
+
t3 = $[11];
|
|
2698
2742
|
}
|
|
2699
2743
|
useEffect(t2, t3);
|
|
2700
2744
|
if (!pagesContainer) return null;
|
|
2701
2745
|
let t4;
|
|
2702
|
-
if ($[
|
|
2746
|
+
if ($[12] !== rangeRects) {
|
|
2703
2747
|
t4 = rangeRects.map(_temp$8);
|
|
2704
|
-
$[
|
|
2705
|
-
$[
|
|
2706
|
-
} else t4 = $[
|
|
2748
|
+
$[12] = rangeRects;
|
|
2749
|
+
$[13] = t4;
|
|
2750
|
+
} else t4 = $[13];
|
|
2707
2751
|
let t5;
|
|
2708
|
-
if ($[
|
|
2752
|
+
if ($[14] !== caret) {
|
|
2709
2753
|
t5 = caret && /* @__PURE__ */ jsx("div", {
|
|
2710
2754
|
"data-testid": "hf-caret",
|
|
2711
2755
|
style: {
|
|
@@ -2720,23 +2764,23 @@ function HfCaretOverlay(t0) {
|
|
|
2720
2764
|
animation: "folio-caret-blink 1060ms steps(1, end) infinite"
|
|
2721
2765
|
}
|
|
2722
2766
|
});
|
|
2723
|
-
$[
|
|
2724
|
-
$[
|
|
2725
|
-
} else t5 = $[
|
|
2767
|
+
$[14] = caret;
|
|
2768
|
+
$[15] = t5;
|
|
2769
|
+
} else t5 = $[15];
|
|
2726
2770
|
let t6;
|
|
2727
|
-
if ($[
|
|
2771
|
+
if ($[16] !== t4 || $[17] !== t5) {
|
|
2728
2772
|
t6 = /* @__PURE__ */ jsxs(Fragment, { children: [t4, t5] });
|
|
2729
|
-
$[
|
|
2730
|
-
$[
|
|
2731
|
-
$[
|
|
2732
|
-
} else t6 = $[
|
|
2773
|
+
$[16] = t4;
|
|
2774
|
+
$[17] = t5;
|
|
2775
|
+
$[18] = t6;
|
|
2776
|
+
} else t6 = $[18];
|
|
2733
2777
|
let t7;
|
|
2734
|
-
if ($[
|
|
2778
|
+
if ($[19] !== pagesContainer || $[20] !== t6) {
|
|
2735
2779
|
t7 = createPortal(t6, pagesContainer);
|
|
2736
|
-
$[
|
|
2737
|
-
$[
|
|
2738
|
-
$[
|
|
2739
|
-
} else t7 = $[
|
|
2780
|
+
$[19] = pagesContainer;
|
|
2781
|
+
$[20] = t6;
|
|
2782
|
+
$[21] = t7;
|
|
2783
|
+
} else t7 = $[21];
|
|
2740
2784
|
return t7;
|
|
2741
2785
|
}
|
|
2742
2786
|
function _temp$8(r_0, i) {
|
|
@@ -3510,6 +3554,13 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3510
3554
|
};
|
|
3511
3555
|
}
|
|
3512
3556
|
if (pmPos_0 >= pmStart && pmPos_0 <= pmEnd && spanEl.firstChild?.nodeType === Node.TEXT_NODE) {
|
|
3557
|
+
const collapsedGeometry = getCollapsedLineEdgeCaretGeometry(spanEl);
|
|
3558
|
+
if (collapsedGeometry) return {
|
|
3559
|
+
x: (collapsedGeometry.left - overlayRect.left) / currentZoom,
|
|
3560
|
+
y: (collapsedGeometry.top - overlayRect.top) / currentZoom,
|
|
3561
|
+
height: getLineHeight(spanEl),
|
|
3562
|
+
pageIndex: getPageIndex(spanEl)
|
|
3563
|
+
};
|
|
3513
3564
|
const textNode = spanEl.firstChild;
|
|
3514
3565
|
const charIndex = Math.min(pmPos_0 - pmStart, textNode.length);
|
|
3515
3566
|
const range = spanEl.ownerDocument.createRange();
|
|
@@ -3555,6 +3606,21 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3555
3606
|
}
|
|
3556
3607
|
return null;
|
|
3557
3608
|
}, []);
|
|
3609
|
+
const refreshBodyImeCaretAnchor = useCallback(() => {
|
|
3610
|
+
const view_1 = hiddenPMRef.current?.getView();
|
|
3611
|
+
if (!view_1) return;
|
|
3612
|
+
const { selection: selection_1 } = view_1.state;
|
|
3613
|
+
const domCaret = selection_1.empty ? getCaretFromDom(selection_1.head, zoom) : null;
|
|
3614
|
+
const overlayRect_0 = (pagesContainerRef.current?.parentElement?.querySelector("[data-testid=\"selection-overlay\"]"))?.getBoundingClientRect();
|
|
3615
|
+
syncImeCaretAnchor({
|
|
3616
|
+
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3617
|
+
editorView: view_1,
|
|
3618
|
+
visibleCaret: domCaret && overlayRect_0 ? {
|
|
3619
|
+
left: overlayRect_0.left + domCaret.x * zoom,
|
|
3620
|
+
top: overlayRect_0.top + domCaret.y * zoom
|
|
3621
|
+
} : null
|
|
3622
|
+
});
|
|
3623
|
+
}, [getCaretFromDom, zoom]);
|
|
3558
3624
|
/**
|
|
3559
3625
|
* Update selection overlay from PM selection.
|
|
3560
3626
|
*/
|
|
@@ -3578,6 +3644,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3578
3644
|
if (suppressSelectionOverlayRef.current) {
|
|
3579
3645
|
setCaretPosition(null);
|
|
3580
3646
|
setSelectionRects([]);
|
|
3647
|
+
syncImeCaretAnchor({
|
|
3648
|
+
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3649
|
+
editorView: hiddenPMRef.current?.getView(),
|
|
3650
|
+
visibleCaret: null
|
|
3651
|
+
});
|
|
3581
3652
|
return;
|
|
3582
3653
|
}
|
|
3583
3654
|
if (pagesContainerRef.current) {
|
|
@@ -3602,36 +3673,89 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3602
3673
|
}
|
|
3603
3674
|
}
|
|
3604
3675
|
}
|
|
3605
|
-
if (!layout || blocks.length === 0)
|
|
3676
|
+
if (!layout || blocks.length === 0) {
|
|
3677
|
+
syncImeCaretAnchor({
|
|
3678
|
+
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3679
|
+
editorView: hiddenPMRef.current?.getView(),
|
|
3680
|
+
visibleCaret: null
|
|
3681
|
+
});
|
|
3682
|
+
return;
|
|
3683
|
+
}
|
|
3606
3684
|
if (from === to) {
|
|
3607
|
-
const
|
|
3608
|
-
if (
|
|
3609
|
-
|
|
3610
|
-
const
|
|
3685
|
+
const domCaret_0 = getCaretFromDom(from, zoom);
|
|
3686
|
+
if (domCaret_0) {
|
|
3687
|
+
setCaretPosition(domCaret_0);
|
|
3688
|
+
const overlayRect_1 = (pagesContainerRef.current?.parentElement?.querySelector("[data-testid=\"selection-overlay\"]"))?.getBoundingClientRect();
|
|
3689
|
+
syncImeCaretAnchor({
|
|
3690
|
+
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3691
|
+
editorView: hiddenPMRef.current?.getView(),
|
|
3692
|
+
visibleCaret: overlayRect_1 ? {
|
|
3693
|
+
left: overlayRect_1.left + domCaret_0.x * zoom,
|
|
3694
|
+
top: overlayRect_1.top + domCaret_0.y * zoom
|
|
3695
|
+
} : null
|
|
3696
|
+
});
|
|
3697
|
+
} else {
|
|
3698
|
+
const overlay_2 = pagesContainerRef.current?.parentElement?.querySelector("[data-testid=\"selection-overlay\"]");
|
|
3611
3699
|
const firstPage = pagesContainerRef.current?.querySelector(".layout-page");
|
|
3612
|
-
if (
|
|
3613
|
-
const
|
|
3700
|
+
if (overlay_2 && firstPage) {
|
|
3701
|
+
const overlayRect_2 = overlay_2.getBoundingClientRect();
|
|
3614
3702
|
const pageRect = firstPage.getBoundingClientRect();
|
|
3615
3703
|
setCaretPosition(null);
|
|
3616
3704
|
loadSelectionGeometry().then(({ getCaretPosition }) => {
|
|
3617
3705
|
if (!isCurrentRequest()) return;
|
|
3618
3706
|
const caret = getCaretPosition(layout, blocks, measures, from);
|
|
3619
|
-
if (caret)
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3707
|
+
if (caret) {
|
|
3708
|
+
const fallbackCaret = {
|
|
3709
|
+
...caret,
|
|
3710
|
+
x: caret.x + (pageRect.left - overlayRect_2.left) / zoom,
|
|
3711
|
+
y: caret.y + (pageRect.top - overlayRect_2.top) / zoom
|
|
3712
|
+
};
|
|
3713
|
+
setCaretPosition(fallbackCaret);
|
|
3714
|
+
syncImeCaretAnchor({
|
|
3715
|
+
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3716
|
+
editorView: hiddenPMRef.current?.getView(),
|
|
3717
|
+
visibleCaret: {
|
|
3718
|
+
left: overlayRect_2.left + fallbackCaret.x * zoom,
|
|
3719
|
+
top: overlayRect_2.top + fallbackCaret.y * zoom
|
|
3720
|
+
}
|
|
3721
|
+
});
|
|
3722
|
+
} else {
|
|
3723
|
+
setCaretPosition(null);
|
|
3724
|
+
syncImeCaretAnchor({
|
|
3725
|
+
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3726
|
+
editorView: hiddenPMRef.current?.getView(),
|
|
3727
|
+
visibleCaret: null
|
|
3728
|
+
});
|
|
3729
|
+
}
|
|
3625
3730
|
}, () => {
|
|
3626
|
-
if (isCurrentRequest())
|
|
3731
|
+
if (isCurrentRequest()) {
|
|
3732
|
+
setCaretPosition(null);
|
|
3733
|
+
syncImeCaretAnchor({
|
|
3734
|
+
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3735
|
+
editorView: hiddenPMRef.current?.getView(),
|
|
3736
|
+
visibleCaret: null
|
|
3737
|
+
});
|
|
3738
|
+
}
|
|
3627
3739
|
});
|
|
3628
|
-
} else
|
|
3740
|
+
} else {
|
|
3741
|
+
setCaretPosition(null);
|
|
3742
|
+
syncImeCaretAnchor({
|
|
3743
|
+
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3744
|
+
editorView: hiddenPMRef.current?.getView(),
|
|
3745
|
+
visibleCaret: null
|
|
3746
|
+
});
|
|
3747
|
+
}
|
|
3629
3748
|
}
|
|
3630
3749
|
setSelectionRects([]);
|
|
3631
3750
|
} else {
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3751
|
+
syncImeCaretAnchor({
|
|
3752
|
+
hiddenHost: hiddenPMRef.current?.getHostElement(),
|
|
3753
|
+
editorView: hiddenPMRef.current?.getView(),
|
|
3754
|
+
visibleCaret: null
|
|
3755
|
+
});
|
|
3756
|
+
const overlay_3 = pagesContainerRef.current?.parentElement?.querySelector("[data-testid=\"selection-overlay\"]");
|
|
3757
|
+
if (overlay_3 && pagesContainerRef.current) {
|
|
3758
|
+
const overlayRect_3 = overlay_3.getBoundingClientRect();
|
|
3635
3759
|
const domRects = [];
|
|
3636
3760
|
const spans_0 = findBodyPmSpans(pagesContainerRef.current);
|
|
3637
3761
|
for (const spanEl_0 of spans_0) {
|
|
@@ -3640,8 +3764,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3640
3764
|
if (spanEl_0.classList.contains("layout-run-tab")) {
|
|
3641
3765
|
const spanRect_3 = spanEl_0.getBoundingClientRect();
|
|
3642
3766
|
domRects.push({
|
|
3643
|
-
x: (spanRect_3.left -
|
|
3644
|
-
y: (spanRect_3.top -
|
|
3767
|
+
x: (spanRect_3.left - overlayRect_3.left) / zoom,
|
|
3768
|
+
y: (spanRect_3.top - overlayRect_3.top) / zoom,
|
|
3645
3769
|
width: spanRect_3.width / zoom,
|
|
3646
3770
|
height: spanRect_3.height / zoom,
|
|
3647
3771
|
pageIndex: getPageIndex(spanEl_0)
|
|
@@ -3662,8 +3786,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3662
3786
|
const clientRects = range_0.getClientRects();
|
|
3663
3787
|
const pageIndex = getPageIndex(spanEl_0);
|
|
3664
3788
|
for (const rect_0 of Array.from(clientRects)) domRects.push({
|
|
3665
|
-
x: (rect_0.left -
|
|
3666
|
-
y: (rect_0.top -
|
|
3789
|
+
x: (rect_0.left - overlayRect_3.left) / zoom,
|
|
3790
|
+
y: (rect_0.top - overlayRect_3.top) / zoom,
|
|
3667
3791
|
width: rect_0.width / zoom,
|
|
3668
3792
|
height: rect_0.height / zoom,
|
|
3669
3793
|
pageIndex
|
|
@@ -3676,8 +3800,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3676
3800
|
const firstPage_0 = pagesContainerRef.current.querySelector(".layout-page");
|
|
3677
3801
|
if (firstPage_0) {
|
|
3678
3802
|
const pageRect_0 = firstPage_0.getBoundingClientRect();
|
|
3679
|
-
const pageOffsetX = (pageRect_0.left -
|
|
3680
|
-
const pageOffsetY = (pageRect_0.top -
|
|
3803
|
+
const pageOffsetX = (pageRect_0.left - overlayRect_3.left) / zoom;
|
|
3804
|
+
const pageOffsetY = (pageRect_0.top - overlayRect_3.top) / zoom;
|
|
3681
3805
|
setSelectionRects([]);
|
|
3682
3806
|
loadSelectionGeometry().then(({ selectionToRects }) => {
|
|
3683
3807
|
if (!isCurrentRequest()) return;
|
|
@@ -3719,16 +3843,16 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3719
3843
|
setAnonymizationRectGroups([]);
|
|
3720
3844
|
return;
|
|
3721
3845
|
}
|
|
3722
|
-
const
|
|
3846
|
+
const overlay_4 = pagesContainer.parentElement?.querySelector("[data-testid=\"selection-overlay\"]");
|
|
3723
3847
|
const firstPage_1 = pagesContainer.querySelector(".layout-page");
|
|
3724
|
-
if (!
|
|
3848
|
+
if (!overlay_4 || !firstPage_1) {
|
|
3725
3849
|
setAnonymizationRectGroups([]);
|
|
3726
3850
|
return;
|
|
3727
3851
|
}
|
|
3728
|
-
const
|
|
3852
|
+
const overlayRect_4 = overlay_4.getBoundingClientRect();
|
|
3729
3853
|
const pageRect_1 = firstPage_1.getBoundingClientRect();
|
|
3730
|
-
const pageOffsetX_0 = (pageRect_1.left -
|
|
3731
|
-
const pageOffsetY_0 = (pageRect_1.top -
|
|
3854
|
+
const pageOffsetX_0 = (pageRect_1.left - overlayRect_4.left) / zoom;
|
|
3855
|
+
const pageOffsetY_0 = (pageRect_1.top - overlayRect_4.top) / zoom;
|
|
3732
3856
|
const pmSpans = findBodyPmSpans(pagesContainer);
|
|
3733
3857
|
const layoutFallbackMatches = [];
|
|
3734
3858
|
const rectsForMatch = (match, from_0, to_0) => {
|
|
@@ -3739,8 +3863,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3739
3863
|
if (spanEl_1.classList.contains("layout-run-tab")) {
|
|
3740
3864
|
const spanRect_4 = spanEl_1.getBoundingClientRect();
|
|
3741
3865
|
domRects_0.push({
|
|
3742
|
-
x: (spanRect_4.left -
|
|
3743
|
-
y: (spanRect_4.top -
|
|
3866
|
+
x: (spanRect_4.left - overlayRect_4.left) / zoom,
|
|
3867
|
+
y: (spanRect_4.top - overlayRect_4.top) / zoom,
|
|
3744
3868
|
width: spanRect_4.width / zoom,
|
|
3745
3869
|
height: spanRect_4.height / zoom,
|
|
3746
3870
|
pageIndex: getPageIndex(spanEl_1)
|
|
@@ -3760,8 +3884,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3760
3884
|
range_1.setEnd(textNode_1, endChar_0);
|
|
3761
3885
|
const pageIndex_0 = getPageIndex(spanEl_1);
|
|
3762
3886
|
for (const rect_2 of Array.from(range_1.getClientRects())) domRects_0.push({
|
|
3763
|
-
x: (rect_2.left -
|
|
3764
|
-
y: (rect_2.top -
|
|
3887
|
+
x: (rect_2.left - overlayRect_4.left) / zoom,
|
|
3888
|
+
y: (rect_2.top - overlayRect_4.top) / zoom,
|
|
3765
3889
|
width: rect_2.width / zoom,
|
|
3766
3890
|
height: rect_2.height / zoom,
|
|
3767
3891
|
pageIndex: pageIndex_0
|
|
@@ -3830,16 +3954,16 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3830
3954
|
return;
|
|
3831
3955
|
}
|
|
3832
3956
|
const pagesContainer_0 = pagesContainerRef.current;
|
|
3833
|
-
const
|
|
3957
|
+
const overlay_5 = pagesContainer_0?.parentElement?.querySelector("[data-testid=\"selection-overlay\"]");
|
|
3834
3958
|
const firstPage_2 = pagesContainer_0?.querySelector(".layout-page");
|
|
3835
|
-
if (!
|
|
3959
|
+
if (!overlay_5 || !firstPage_2) {
|
|
3836
3960
|
setAutocompleteCaret(null);
|
|
3837
3961
|
return;
|
|
3838
3962
|
}
|
|
3839
|
-
const
|
|
3963
|
+
const overlayRect_5 = overlay_5.getBoundingClientRect();
|
|
3840
3964
|
const pageRect_2 = firstPage_2.getBoundingClientRect();
|
|
3841
|
-
const pageOffsetX_1 = (pageRect_2.left -
|
|
3842
|
-
const pageOffsetY_1 = (pageRect_2.top -
|
|
3965
|
+
const pageOffsetX_1 = (pageRect_2.left - overlayRect_5.left) / zoom;
|
|
3966
|
+
const pageOffsetY_1 = (pageRect_2.top - overlayRect_5.top) / zoom;
|
|
3843
3967
|
if (!isCurrentRequest_1()) return;
|
|
3844
3968
|
const caretPage = layout.pages.at(caret_0.pageIndex);
|
|
3845
3969
|
const maxWidth = caretPage ? Math.max(AUTOCOMPLETE_GHOST_MIN_WIDTH, caretPage.size.w - caretPage.margins.right - caret_0.x) : void 0;
|
|
@@ -4076,7 +4200,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4076
4200
|
*/
|
|
4077
4201
|
const [hfCaretSelection, setHfCaretSelection] = useState(null);
|
|
4078
4202
|
const activeHfPageNumberRef = useRef(null);
|
|
4079
|
-
const handleHfPmTransaction = useCallback((rId, kind,
|
|
4203
|
+
const handleHfPmTransaction = useCallback((rId, kind, view_2, docChanged, selectionChanged) => {
|
|
4080
4204
|
if (docChanged) {
|
|
4081
4205
|
let bodyState = hiddenPMRef.current?.getState();
|
|
4082
4206
|
if (!bodyState && precomputedInitialStateRef.current) bodyState = precomputedInitialStateRef.current;
|
|
@@ -4087,7 +4211,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4087
4211
|
if (bodyState) scheduleLayout(bodyState, null);
|
|
4088
4212
|
}
|
|
4089
4213
|
if (docChanged || selectionChanged) {
|
|
4090
|
-
const { from: from_1, to: to_1 } =
|
|
4214
|
+
const { from: from_1, to: to_1 } = view_2.state.selection;
|
|
4091
4215
|
const pageNumber = activeHfPageNumberRef.current;
|
|
4092
4216
|
setHfCaretSelection({
|
|
4093
4217
|
rId,
|
|
@@ -4103,13 +4227,13 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4103
4227
|
});
|
|
4104
4228
|
}
|
|
4105
4229
|
}, [scheduleLayout, ensureHiddenEditorView]);
|
|
4106
|
-
const handleNoteStoryTransaction = useCallback((
|
|
4230
|
+
const handleNoteStoryTransaction = useCallback((view_3, docChanged_0, selectionChanged_0) => {
|
|
4107
4231
|
if (docChanged_0) {
|
|
4108
4232
|
const bodyState_0 = hiddenPMRef.current?.getState();
|
|
4109
4233
|
if (bodyState_0) scheduleLayout(bodyState_0, null);
|
|
4110
4234
|
}
|
|
4111
4235
|
if (docChanged_0 || selectionChanged_0) {
|
|
4112
|
-
const { from: from_2, to: to_2 } =
|
|
4236
|
+
const { from: from_2, to: to_2 } = view_3.state.selection;
|
|
4113
4237
|
onSelectionChangeRef.current?.(from_2, to_2);
|
|
4114
4238
|
folioEmitterRef.current.emit("selectionChange", {
|
|
4115
4239
|
from: from_2,
|
|
@@ -4131,18 +4255,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4131
4255
|
* Handle selection change from PM.
|
|
4132
4256
|
*/
|
|
4133
4257
|
const handleSelectionChange = useCallback((state_5) => {
|
|
4134
|
-
const { selection:
|
|
4135
|
-
if (
|
|
4258
|
+
const { selection: selection_2 } = state_5;
|
|
4259
|
+
if (selection_2 instanceof NodeSelection && selection_2.node.type.name === "image") {
|
|
4136
4260
|
setSelectionRects([]);
|
|
4137
4261
|
setCaretPosition(null);
|
|
4138
4262
|
} else if (syncCoordinator.isSafeToRender()) updateSelectionOverlay(state_5);
|
|
4139
4263
|
requestAnimationFrame(() => {
|
|
4140
|
-
const
|
|
4141
|
-
if (!
|
|
4264
|
+
const view_4 = hiddenPMRef.current?.getView();
|
|
4265
|
+
if (!view_4) {
|
|
4142
4266
|
setSelectedImageInfo(null);
|
|
4143
4267
|
return;
|
|
4144
4268
|
}
|
|
4145
|
-
const { selection: sel_0 } =
|
|
4269
|
+
const { selection: sel_0 } = view_4.state;
|
|
4146
4270
|
if (sel_0 instanceof NodeSelection && sel_0.node.type.name === "image") {
|
|
4147
4271
|
const pmPos_2 = sel_0.from;
|
|
4148
4272
|
const imgEl = pagesContainerRef.current ? findBodyPmAnchor(pagesContainerRef.current, pmPos_2) : null;
|
|
@@ -4218,9 +4342,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4218
4342
|
return null;
|
|
4219
4343
|
}, []);
|
|
4220
4344
|
const findCellPosFromPmPos = useCallback((pmPos_4) => {
|
|
4221
|
-
const
|
|
4222
|
-
if (!
|
|
4223
|
-
return findCellPosInDoc(
|
|
4345
|
+
const view_5 = hiddenPMRef.current?.getView();
|
|
4346
|
+
if (!view_5) return null;
|
|
4347
|
+
return findCellPosInDoc(view_5.state.doc, pmPos_4);
|
|
4224
4348
|
}, [findCellPosInDoc]);
|
|
4225
4349
|
/**
|
|
4226
4350
|
* Find the closest image element from a click target.
|
|
@@ -4282,8 +4406,14 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4282
4406
|
}
|
|
4283
4407
|
if (!hiddenPMRef.current?.getView()) ensureHiddenEditorView();
|
|
4284
4408
|
hiddenPMRef.current?.focus();
|
|
4409
|
+
const view_6 = hiddenPMRef.current?.getView();
|
|
4410
|
+
if (view_6) updateSelectionOverlay(view_6.state);
|
|
4285
4411
|
setIsFocused(true);
|
|
4286
|
-
}, [
|
|
4412
|
+
}, [
|
|
4413
|
+
ensureHiddenEditorView,
|
|
4414
|
+
readOnly,
|
|
4415
|
+
updateSelectionOverlay
|
|
4416
|
+
]);
|
|
4287
4417
|
const startPointerTextSelection = useCallback((clientX_0, clientY_0) => {
|
|
4288
4418
|
const pmPos_6 = getPositionFromMouse(clientX_0, clientY_0);
|
|
4289
4419
|
if (pmPos_6 !== null) {
|
|
@@ -4308,10 +4438,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4308
4438
|
cellDragAnchorPosRef.current = null;
|
|
4309
4439
|
cellDragContentEndRef.current = null;
|
|
4310
4440
|
isCellDraggingRef.current = false;
|
|
4311
|
-
const
|
|
4441
|
+
const view_7 = hiddenPMRef.current?.getView();
|
|
4312
4442
|
let endPos;
|
|
4313
|
-
if (
|
|
4314
|
-
endPos = Math.max(0,
|
|
4443
|
+
if (view_7) {
|
|
4444
|
+
endPos = Math.max(0, view_7.state.doc.content.size - 1);
|
|
4315
4445
|
hiddenPMRef.current?.setSelection(endPos);
|
|
4316
4446
|
} else {
|
|
4317
4447
|
endPos = Math.max(0, (precomputedInitialStateRef.current?.doc.content.size ?? 1) - 1);
|
|
@@ -4331,11 +4461,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4331
4461
|
queueHiddenEditorSelection
|
|
4332
4462
|
]);
|
|
4333
4463
|
const copySelectionText = useCallback(() => {
|
|
4334
|
-
const
|
|
4335
|
-
if (!
|
|
4336
|
-
const { from: from_3, to: to_3 } =
|
|
4464
|
+
const view_8 = hiddenPMRef.current?.getView();
|
|
4465
|
+
if (!view_8) return false;
|
|
4466
|
+
const { from: from_3, to: to_3 } = view_8.state.selection;
|
|
4337
4467
|
if (from_3 === to_3) return false;
|
|
4338
|
-
const text_1 =
|
|
4468
|
+
const text_1 = view_8.state.doc.textBetween(from_3, to_3, "\n");
|
|
4339
4469
|
if (!text_1) return false;
|
|
4340
4470
|
if (navigator.clipboard === void 0) return false;
|
|
4341
4471
|
navigator.clipboard.writeText(text_1).catch(() => void 0);
|
|
@@ -4432,9 +4562,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4432
4562
|
const colIndex = Number.parseInt(target_1.dataset["columnIndex"] ?? "0", 10);
|
|
4433
4563
|
resizeColumnIndexRef.current = colIndex;
|
|
4434
4564
|
resizeTablePmStartRef.current = Number.parseInt(target_1.dataset["tablePmStart"] ?? "0", 10);
|
|
4435
|
-
const
|
|
4436
|
-
if (
|
|
4437
|
-
const $pos_1 =
|
|
4565
|
+
const view_9 = resizeViewForRead;
|
|
4566
|
+
if (view_9) {
|
|
4567
|
+
const $pos_1 = view_9.state.doc.resolve(resizeTablePmStartRef.current + 1);
|
|
4438
4568
|
for (let d_0 = $pos_1.depth; d_0 >= 0; d_0--) {
|
|
4439
4569
|
const node_1 = $pos_1.node(d_0);
|
|
4440
4570
|
if (node_1.type.name === "table") {
|
|
@@ -4464,9 +4594,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4464
4594
|
const rowIndex = Number.parseInt(target_1.dataset["rowIndex"] ?? "0", 10);
|
|
4465
4595
|
resizeRowIndexRef.current = rowIndex;
|
|
4466
4596
|
resizeRowTablePmStartRef.current = Number.parseInt(target_1.dataset["tablePmStart"] ?? "0", 10);
|
|
4467
|
-
const
|
|
4468
|
-
if (
|
|
4469
|
-
const $pos_2 =
|
|
4597
|
+
const view_10 = resizeViewForRead;
|
|
4598
|
+
if (view_10) {
|
|
4599
|
+
const $pos_2 = view_10.state.doc.resolve(resizeRowTablePmStartRef.current + 1);
|
|
4470
4600
|
for (let d_1 = $pos_2.depth; d_1 >= 0; d_1--) {
|
|
4471
4601
|
const node_2 = $pos_2.node(d_1);
|
|
4472
4602
|
if (node_2.type.name === "table") {
|
|
@@ -4499,9 +4629,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4499
4629
|
const colIndex_0 = Number.parseInt(target_1.dataset["columnIndex"] ?? "0", 10);
|
|
4500
4630
|
resizeRightEdgeColIndexRef.current = colIndex_0;
|
|
4501
4631
|
resizeRightEdgePmStartRef.current = Number.parseInt(target_1.dataset["tablePmStart"] ?? "0", 10);
|
|
4502
|
-
const
|
|
4503
|
-
if (
|
|
4504
|
-
const $pos_3 =
|
|
4632
|
+
const view_11 = resizeViewForRead;
|
|
4633
|
+
if (view_11) {
|
|
4634
|
+
const $pos_3 = view_11.state.doc.resolve(resizeRightEdgePmStartRef.current + 1);
|
|
4505
4635
|
for (let d_2 = $pos_3.depth; d_2 >= 0; d_2--) {
|
|
4506
4636
|
const node_3 = $pos_3.node(d_2);
|
|
4507
4637
|
if (node_3.type.name === "table") {
|
|
@@ -4700,18 +4830,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4700
4830
|
resizeHandleRef.current.classList.remove("dragging");
|
|
4701
4831
|
resizeHandleRef.current = null;
|
|
4702
4832
|
}
|
|
4703
|
-
const
|
|
4833
|
+
const view_12 = (resizingHfSurfaceRef.current ? hfPMsRef.current?.getView(resizingHfSurfaceRef.current.rId) : hiddenPMRef.current?.getView()) ?? null;
|
|
4704
4834
|
resizingHfSurfaceRef.current = null;
|
|
4705
|
-
if (
|
|
4835
|
+
if (view_12) {
|
|
4706
4836
|
const pmStart_4 = resizeTablePmStartRef.current;
|
|
4707
4837
|
const colIdx = resizeColumnIndexRef.current;
|
|
4708
4838
|
const { left: newLeft, right: newRight } = resizeOrigWidthsRef.current;
|
|
4709
|
-
const $pos_5 =
|
|
4839
|
+
const $pos_5 = view_12.state.doc.resolve(pmStart_4 + 1);
|
|
4710
4840
|
for (let d_3 = $pos_5.depth; d_3 >= 0; d_3--) {
|
|
4711
4841
|
const node_4 = $pos_5.node(d_3);
|
|
4712
4842
|
if (node_4.type.name === "table") {
|
|
4713
4843
|
const tablePos = $pos_5.before(d_3);
|
|
4714
|
-
const tr =
|
|
4844
|
+
const tr = view_12.state.tr;
|
|
4715
4845
|
const tableAttrs = expectTableAttrs(node_4);
|
|
4716
4846
|
if (!tableAttrs.columnWidths) break;
|
|
4717
4847
|
const widths_1 = [...tableAttrs.columnWidths];
|
|
@@ -4737,7 +4867,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4737
4867
|
});
|
|
4738
4868
|
rowOffset += row.nodeSize;
|
|
4739
4869
|
});
|
|
4740
|
-
|
|
4870
|
+
view_12.dispatch(tr);
|
|
4741
4871
|
break;
|
|
4742
4872
|
}
|
|
4743
4873
|
}
|
|
@@ -4750,18 +4880,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4750
4880
|
resizeRowHandleRef.current.classList.remove("dragging");
|
|
4751
4881
|
resizeRowHandleRef.current = null;
|
|
4752
4882
|
}
|
|
4753
|
-
const
|
|
4883
|
+
const view_13 = (resizingHfSurfaceRef.current ? hfPMsRef.current?.getView(resizingHfSurfaceRef.current.rId) : hiddenPMRef.current?.getView()) ?? null;
|
|
4754
4884
|
resizingHfSurfaceRef.current = null;
|
|
4755
|
-
if (
|
|
4885
|
+
if (view_13) {
|
|
4756
4886
|
const pmStart_5 = resizeRowTablePmStartRef.current;
|
|
4757
4887
|
const rowIdx = resizeRowIndexRef.current;
|
|
4758
4888
|
const newHeight_0 = resizeRowOrigHeightRef.current;
|
|
4759
|
-
const $pos_6 =
|
|
4889
|
+
const $pos_6 = view_13.state.doc.resolve(pmStart_5 + 1);
|
|
4760
4890
|
for (let d_4 = $pos_6.depth; d_4 >= 0; d_4--) {
|
|
4761
4891
|
const node_5 = $pos_6.node(d_4);
|
|
4762
4892
|
if (node_5.type.name === "table") {
|
|
4763
4893
|
const tablePos_0 = $pos_6.before(d_4);
|
|
4764
|
-
const tr_0 =
|
|
4894
|
+
const tr_0 = view_13.state.tr;
|
|
4765
4895
|
let rowOffset_0 = tablePos_0 + 1;
|
|
4766
4896
|
let idx = 0;
|
|
4767
4897
|
node_5.forEach((row_0) => {
|
|
@@ -4772,7 +4902,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4772
4902
|
rowOffset_0 += row_0.nodeSize;
|
|
4773
4903
|
idx++;
|
|
4774
4904
|
});
|
|
4775
|
-
|
|
4905
|
+
view_13.dispatch(tr_0);
|
|
4776
4906
|
break;
|
|
4777
4907
|
}
|
|
4778
4908
|
}
|
|
@@ -4785,18 +4915,18 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4785
4915
|
resizeRightEdgeHandleRef.current.classList.remove("dragging");
|
|
4786
4916
|
resizeRightEdgeHandleRef.current = null;
|
|
4787
4917
|
}
|
|
4788
|
-
const
|
|
4918
|
+
const view_14 = (resizingHfSurfaceRef.current ? hfPMsRef.current?.getView(resizingHfSurfaceRef.current.rId) : hiddenPMRef.current?.getView()) ?? null;
|
|
4789
4919
|
resizingHfSurfaceRef.current = null;
|
|
4790
|
-
if (
|
|
4920
|
+
if (view_14) {
|
|
4791
4921
|
const pmStart_6 = resizeRightEdgePmStartRef.current;
|
|
4792
4922
|
const colIdx_0 = resizeRightEdgeColIndexRef.current;
|
|
4793
4923
|
const newWidth_1 = resizeRightEdgeOrigWidthRef.current;
|
|
4794
|
-
const $pos_7 =
|
|
4924
|
+
const $pos_7 = view_14.state.doc.resolve(pmStart_6 + 1);
|
|
4795
4925
|
for (let d_5 = $pos_7.depth; d_5 >= 0; d_5--) {
|
|
4796
4926
|
const node_6 = $pos_7.node(d_5);
|
|
4797
4927
|
if (node_6.type.name === "table") {
|
|
4798
4928
|
const tablePos_1 = $pos_7.before(d_5);
|
|
4799
|
-
const tr_1 =
|
|
4929
|
+
const tr_1 = view_14.state.tr;
|
|
4800
4930
|
const tableAttrs_0 = expectTableAttrs(node_6);
|
|
4801
4931
|
if (!tableAttrs_0.columnWidths) break;
|
|
4802
4932
|
const widths_2 = [...tableAttrs_0.columnWidths];
|
|
@@ -4818,7 +4948,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4818
4948
|
});
|
|
4819
4949
|
rowOffset_1 += row_1.nodeSize;
|
|
4820
4950
|
});
|
|
4821
|
-
|
|
4951
|
+
view_14.dispatch(tr_1);
|
|
4822
4952
|
break;
|
|
4823
4953
|
}
|
|
4824
4954
|
}
|
|
@@ -4960,13 +5090,13 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4960
5090
|
e_2.preventDefault();
|
|
4961
5091
|
e_2.stopPropagation();
|
|
4962
5092
|
if (!tableInsertButton || !hiddenPMRef.current) return;
|
|
4963
|
-
const
|
|
4964
|
-
if (!
|
|
5093
|
+
const view_15 = hiddenPMRef.current.getView();
|
|
5094
|
+
if (!view_15) return;
|
|
4965
5095
|
const { type, cellPmPos } = tableInsertButton;
|
|
4966
|
-
const tr_2 =
|
|
4967
|
-
|
|
4968
|
-
if (type === "row") addRowBelow(
|
|
4969
|
-
else addColumnRight(
|
|
5096
|
+
const tr_2 = view_15.state.tr.setSelection(TextSelection$1.create(view_15.state.doc, cellPmPos + 1));
|
|
5097
|
+
view_15.dispatch(tr_2);
|
|
5098
|
+
if (type === "row") addRowBelow(view_15.state, view_15.dispatch);
|
|
5099
|
+
else addColumnRight(view_15.state, view_15.dispatch);
|
|
4970
5100
|
setTableInsertButton(null);
|
|
4971
5101
|
hiddenPMRef.current.focus();
|
|
4972
5102
|
}, [tableInsertButton]);
|
|
@@ -4993,10 +5123,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
4993
5123
|
if (href.startsWith("#")) {
|
|
4994
5124
|
const bookmarkName = href.slice(1);
|
|
4995
5125
|
if (bookmarkName && hiddenPMRef.current) {
|
|
4996
|
-
const
|
|
4997
|
-
if (
|
|
5126
|
+
const view_16 = hiddenPMRef.current.getView();
|
|
5127
|
+
if (view_16) {
|
|
4998
5128
|
const targetPos = { value: null };
|
|
4999
|
-
|
|
5129
|
+
view_16.state.doc.descendants((node_7, pos_2) => {
|
|
5000
5130
|
if (targetPos.value !== null) return false;
|
|
5001
5131
|
if (node_7.type.name === "paragraph") {
|
|
5002
5132
|
if (node_7.attrs["bookmarks"]?.some((b) => b.name === bookmarkName)) {
|
|
@@ -5085,9 +5215,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5085
5215
|
if (e_3.detail === 2 && hiddenPMRef.current) {
|
|
5086
5216
|
const pmPos_12 = getPositionFromMouse(e_3.clientX, e_3.clientY);
|
|
5087
5217
|
if (pmPos_12 !== null) {
|
|
5088
|
-
const
|
|
5089
|
-
if (
|
|
5090
|
-
const { doc: doc_0 } =
|
|
5218
|
+
const view_17 = hiddenPMRef.current.getView();
|
|
5219
|
+
if (view_17) {
|
|
5220
|
+
const { doc: doc_0 } = view_17.state;
|
|
5091
5221
|
const $pos_9 = doc_0.resolve(pmPos_12);
|
|
5092
5222
|
const parent_0 = $pos_9.parent;
|
|
5093
5223
|
if (parent_0.isTextblock) {
|
|
@@ -5113,9 +5243,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5113
5243
|
if (e_3.detail === 3 && hiddenPMRef.current) {
|
|
5114
5244
|
const pmPos_13 = getPositionFromMouse(e_3.clientX, e_3.clientY);
|
|
5115
5245
|
if (pmPos_13 !== null) {
|
|
5116
|
-
const
|
|
5117
|
-
if (
|
|
5118
|
-
const { doc: doc_1 } =
|
|
5246
|
+
const view_18 = hiddenPMRef.current.getView();
|
|
5247
|
+
if (view_18) {
|
|
5248
|
+
const { doc: doc_1 } = view_18.state;
|
|
5119
5249
|
const $pos_10 = doc_1.resolve(pmPos_13);
|
|
5120
5250
|
const paragraphStart = $pos_10.start($pos_10.depth);
|
|
5121
5251
|
const paragraphEnd = $pos_10.end($pos_10.depth);
|
|
@@ -5160,9 +5290,9 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5160
5290
|
}
|
|
5161
5291
|
}
|
|
5162
5292
|
}
|
|
5163
|
-
const
|
|
5164
|
-
if (!
|
|
5165
|
-
const { from: from_5, to: to_5 } =
|
|
5293
|
+
const view_19 = hiddenPMRef.current?.getView();
|
|
5294
|
+
if (!view_19) return;
|
|
5295
|
+
const { from: from_5, to: to_5 } = view_19.state.selection;
|
|
5166
5296
|
const pmPos_15 = getPositionFromMouse(e_4.clientX, e_4.clientY);
|
|
5167
5297
|
if (pmPos_15 !== null && (from_5 === to_5 || pmPos_15 < from_5 || pmPos_15 > to_5)) {
|
|
5168
5298
|
hiddenPMRef.current?.setSelection(pmPos_15);
|
|
@@ -5203,16 +5333,16 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5203
5333
|
* Handle image resize from the overlay.
|
|
5204
5334
|
*/
|
|
5205
5335
|
const handleImageResize = useCallback((pmPos_16, newWidth_2, newHeight_1) => {
|
|
5206
|
-
const
|
|
5207
|
-
if (!
|
|
5336
|
+
const view_20 = hiddenPMRef.current?.getView();
|
|
5337
|
+
if (!view_20) return;
|
|
5208
5338
|
try {
|
|
5209
|
-
const node_10 =
|
|
5339
|
+
const node_10 = view_20.state.doc.nodeAt(pmPos_16);
|
|
5210
5340
|
if (!node_10 || node_10.type.name !== "image") return;
|
|
5211
|
-
const tr_3 =
|
|
5341
|
+
const tr_3 = view_20.state.tr.setNodeMarkup(pmPos_16, void 0, mergeImageAttrs(node_10, {
|
|
5212
5342
|
width: newWidth_2,
|
|
5213
5343
|
height: newHeight_1
|
|
5214
5344
|
}));
|
|
5215
|
-
|
|
5345
|
+
view_20.dispatch(tr_3);
|
|
5216
5346
|
hiddenPMRef.current?.setNodeSelection(pmPos_16);
|
|
5217
5347
|
} catch {}
|
|
5218
5348
|
}, []);
|
|
@@ -5233,10 +5363,10 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5233
5363
|
* to the drop position determined by mouse coordinates.
|
|
5234
5364
|
*/
|
|
5235
5365
|
const handleImageDragMove = useCallback((pmPos_17, clientX_1, clientY_1) => {
|
|
5236
|
-
const
|
|
5237
|
-
if (!
|
|
5366
|
+
const view_21 = hiddenPMRef.current?.getView();
|
|
5367
|
+
if (!view_21) return;
|
|
5238
5368
|
try {
|
|
5239
|
-
const node_11 =
|
|
5369
|
+
const node_11 = view_21.state.doc.nodeAt(pmPos_17);
|
|
5240
5370
|
if (!node_11 || node_11.type.name !== "image") return;
|
|
5241
5371
|
const attrs = expectImageAttrs(node_11);
|
|
5242
5372
|
if (attrs.displayMode === "float" || attrs.wrapType === "square" || attrs.wrapType === "tight" || attrs.wrapType === "through") {
|
|
@@ -5271,14 +5401,14 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5271
5401
|
relativeTo: "margin"
|
|
5272
5402
|
}
|
|
5273
5403
|
};
|
|
5274
|
-
const tr_4 =
|
|
5275
|
-
|
|
5404
|
+
const tr_4 = view_21.state.tr.setNodeMarkup(pmPos_17, void 0, mergeImageAttrs(node_11, { position: newPosition }));
|
|
5405
|
+
view_21.dispatch(tr_4);
|
|
5276
5406
|
hiddenPMRef.current?.setNodeSelection(pmPos_17);
|
|
5277
5407
|
} else {
|
|
5278
5408
|
const dropPos = getPositionFromMouse(clientX_1, clientY_1);
|
|
5279
5409
|
if (dropPos === null) return;
|
|
5280
5410
|
if (dropPos === pmPos_17 || dropPos === pmPos_17 + 1) return;
|
|
5281
|
-
let tr_5 =
|
|
5411
|
+
let tr_5 = view_21.state.tr;
|
|
5282
5412
|
tr_5 = tr_5.delete(pmPos_17, pmPos_17 + node_11.nodeSize);
|
|
5283
5413
|
let selectionPos;
|
|
5284
5414
|
if (dropPos <= pmPos_17) {
|
|
@@ -5290,7 +5420,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5290
5420
|
selectionPos = Math.min(adjusted, tr_5.doc.content.size - 1);
|
|
5291
5421
|
}
|
|
5292
5422
|
hiddenPMRef.current?.setNodeSelection(selectionPos);
|
|
5293
|
-
|
|
5423
|
+
view_21.dispatch(tr_5);
|
|
5294
5424
|
}
|
|
5295
5425
|
} catch {}
|
|
5296
5426
|
}, [getPositionFromMouse, zoom]);
|
|
@@ -5318,11 +5448,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5318
5448
|
return;
|
|
5319
5449
|
}
|
|
5320
5450
|
if (e_7.target instanceof HTMLElement && e_7.target.closest("[data-hf-r-id], [data-note-kind][data-note-id]")) return;
|
|
5321
|
-
let
|
|
5322
|
-
if (!
|
|
5451
|
+
let view_22 = hiddenPMRef.current?.getView();
|
|
5452
|
+
if (!view_22) {
|
|
5323
5453
|
ensureHiddenEditorView({ sync: true });
|
|
5324
|
-
|
|
5325
|
-
if (
|
|
5454
|
+
view_22 = hiddenPMRef.current?.getView();
|
|
5455
|
+
if (view_22) {
|
|
5326
5456
|
if (isPlainTextInputEvent(e_7)) {
|
|
5327
5457
|
e_7.preventDefault();
|
|
5328
5458
|
queueHiddenEditorTextInput(e_7.key);
|
|
@@ -5345,11 +5475,11 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5345
5475
|
}
|
|
5346
5476
|
return;
|
|
5347
5477
|
}
|
|
5348
|
-
if (pendingHiddenEditorSelectionRef.current || queuedInputBeforeHiddenEditorRef.current.length > 0) applyPendingHiddenEditorInput(
|
|
5478
|
+
if (pendingHiddenEditorSelectionRef.current || queuedInputBeforeHiddenEditorRef.current.length > 0) applyPendingHiddenEditorInput(view_22);
|
|
5349
5479
|
if (!hiddenPMRef.current?.isFocused()) focusHiddenEditor();
|
|
5350
5480
|
if (e_7.key === " " && !e_7.ctrlKey && !e_7.metaKey && !e_7.nativeEvent.isComposing) {
|
|
5351
5481
|
e_7.preventDefault();
|
|
5352
|
-
dispatchEditorTextInput(
|
|
5482
|
+
dispatchEditorTextInput(view_22, " ");
|
|
5353
5483
|
return;
|
|
5354
5484
|
}
|
|
5355
5485
|
if (["PageUp", "PageDown"].includes(e_7.key) && !e_7.metaKey && !e_7.ctrlKey) {}
|
|
@@ -5443,19 +5573,19 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5443
5573
|
/**
|
|
5444
5574
|
* Run initial layout when document or view changes.
|
|
5445
5575
|
*/
|
|
5446
|
-
const handleEditorViewReady = useCallback((
|
|
5447
|
-
onEditorViewReadyRef.current?.(
|
|
5448
|
-
anonymizationMatchesRef.current = anonymizationDecorationsKey.getState(
|
|
5449
|
-
const initialSuggestion = autocompleteSuggestionKey.getState(
|
|
5576
|
+
const handleEditorViewReady = useCallback((view_23) => {
|
|
5577
|
+
onEditorViewReadyRef.current?.(view_23);
|
|
5578
|
+
anonymizationMatchesRef.current = anonymizationDecorationsKey.getState(view_23.state)?.matches ?? [];
|
|
5579
|
+
const initialSuggestion = autocompleteSuggestionKey.getState(view_23.state)?.suggestion;
|
|
5450
5580
|
if (initialSuggestion !== void 0) autocompleteSuggestionRef.current = initialSuggestion;
|
|
5451
5581
|
updateAutocompleteOverlay();
|
|
5452
|
-
directivesRef.current = templateDirectivesKey.getState(
|
|
5453
|
-
const previewState = templatePreviewValuesKey.getState(
|
|
5582
|
+
directivesRef.current = templateDirectivesKey.getState(view_23.state)?.ranges ?? [];
|
|
5583
|
+
const previewState = templatePreviewValuesKey.getState(view_23.state);
|
|
5454
5584
|
templatePreviewRef.current = {
|
|
5455
5585
|
entries: previewState?.entries ?? EMPTY_TEMPLATE_PREVIEW_ENTRIES,
|
|
5456
5586
|
mode: previewState?.preview?.mode ?? "plain"
|
|
5457
5587
|
};
|
|
5458
|
-
const aiState = aiSuggestionDecorationsKey.getState(
|
|
5588
|
+
const aiState = aiSuggestionDecorationsKey.getState(view_23.state);
|
|
5459
5589
|
aiSuggestionsRef.current = {
|
|
5460
5590
|
suggestions: aiState?.suggestions ?? EMPTY_AI_SUGGESTIONS,
|
|
5461
5591
|
focusedId: aiState?.focusedId ?? null
|
|
@@ -5463,16 +5593,17 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5463
5593
|
const focusReadyView = () => {
|
|
5464
5594
|
if (readOnly || !shouldFocusHiddenEditorOnReadyRef.current) return;
|
|
5465
5595
|
requestAnimationFrame(() => {
|
|
5466
|
-
if (hiddenPMRef.current?.getView() !==
|
|
5467
|
-
applyPendingHiddenEditorInput(
|
|
5468
|
-
|
|
5596
|
+
if (hiddenPMRef.current?.getView() !== view_23) return;
|
|
5597
|
+
applyPendingHiddenEditorInput(view_23);
|
|
5598
|
+
view_23.focus();
|
|
5599
|
+
refreshBodyImeCaretAnchor();
|
|
5469
5600
|
setIsFocused(true);
|
|
5470
5601
|
});
|
|
5471
5602
|
};
|
|
5472
|
-
if (layoutSessionRef.current.lastPmDoc?.eq(
|
|
5603
|
+
if (layoutSessionRef.current.lastPmDoc?.eq(view_23.state.doc)) {
|
|
5473
5604
|
const lastPreview = layoutSessionRef.current.lastTemplatePreview;
|
|
5474
|
-
if (templatePreviewRef.current.mode !== lastPreview.mode || templatePreviewDirtyRange(lastPreview.entries, templatePreviewRef.current.entries) !== null) runLayoutPipeline$1(
|
|
5475
|
-
updateSelectionOverlay(
|
|
5605
|
+
if (templatePreviewRef.current.mode !== lastPreview.mode || templatePreviewDirtyRange(lastPreview.entries, templatePreviewRef.current.entries) !== null) runLayoutPipeline$1(view_23.state, { reason: "manual" });
|
|
5606
|
+
updateSelectionOverlay(view_23.state);
|
|
5476
5607
|
updateAnonymizationOverlay();
|
|
5477
5608
|
updateDirectivesOverlay();
|
|
5478
5609
|
updateAISuggestionsOverlay();
|
|
@@ -5491,7 +5622,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5491
5622
|
const runAfterFontWait_0 = (fontsLoaded_0) => {
|
|
5492
5623
|
pendingInitialFontReadyLayoutRef.current = false;
|
|
5493
5624
|
const currentView_0 = hiddenPMRef.current?.getView();
|
|
5494
|
-
if (currentView_0 !==
|
|
5625
|
+
if (currentView_0 !== view_23) return;
|
|
5495
5626
|
recordLayoutPhase("initial", "initial-fonts", performance.now() - fontWaitStartedAt_0);
|
|
5496
5627
|
resetCanvasContext();
|
|
5497
5628
|
clearAllCaches();
|
|
@@ -5501,7 +5632,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5501
5632
|
suppressFontReadyUntilRef.current = performance.now() + INITIAL_FONT_READY_SUPPRESSION_MS;
|
|
5502
5633
|
}
|
|
5503
5634
|
};
|
|
5504
|
-
waitForInitialLayoutFonts(document,
|
|
5635
|
+
waitForInitialLayoutFonts(document, view_23.state.doc).then(runAfterFontWait_0, () => runAfterFontWait_0(false));
|
|
5505
5636
|
focusReadyView();
|
|
5506
5637
|
}, [
|
|
5507
5638
|
applyPendingHiddenEditorInput,
|
|
@@ -5512,7 +5643,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5512
5643
|
updateAISuggestionsOverlay,
|
|
5513
5644
|
document,
|
|
5514
5645
|
updateAutocompleteOverlay,
|
|
5515
|
-
readOnly
|
|
5646
|
+
readOnly,
|
|
5647
|
+
refreshBodyImeCaretAnchor
|
|
5516
5648
|
]);
|
|
5517
5649
|
const handleEditorViewDestroy = useCallback(() => {
|
|
5518
5650
|
onEditorViewReadyRef.current?.(null);
|
|
@@ -5562,12 +5694,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5562
5694
|
};
|
|
5563
5695
|
const handleFontsLoaded = () => {
|
|
5564
5696
|
if (pendingInitialFontReadyLayoutRef.current || performance.now() < suppressFontReadyUntilRef.current || layoutSessionRef.current.usedLoadedFonts) return;
|
|
5565
|
-
const
|
|
5566
|
-
if (
|
|
5697
|
+
const view_24 = hiddenPMRef.current?.getView();
|
|
5698
|
+
if (view_24) {
|
|
5567
5699
|
resetCanvasContext();
|
|
5568
5700
|
clearAllCaches();
|
|
5569
|
-
runLayoutPipelineRef.current(
|
|
5570
|
-
updateSelectionOverlayRef.current(
|
|
5701
|
+
runLayoutPipelineRef.current(view_24.state, { reason: "font-ready" });
|
|
5702
|
+
updateSelectionOverlayRef.current(view_24.state);
|
|
5571
5703
|
}
|
|
5572
5704
|
};
|
|
5573
5705
|
fontSet.addEventListener("loading", handleFontsLoading);
|
|
@@ -5592,12 +5724,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5592
5724
|
registered = faces;
|
|
5593
5725
|
if (faces.length === 0 && familyMap.size === 0) return;
|
|
5594
5726
|
setEmbeddedFontFamilyMap(familyMap.size > 0 ? familyMap : null);
|
|
5595
|
-
const
|
|
5596
|
-
if (!
|
|
5727
|
+
const view_25 = hiddenPMRef.current?.getView();
|
|
5728
|
+
if (!view_25) return;
|
|
5597
5729
|
resetCanvasContext();
|
|
5598
5730
|
clearAllCaches();
|
|
5599
|
-
runLayoutPipelineRef.current(
|
|
5600
|
-
updateSelectionOverlayRef.current(
|
|
5731
|
+
runLayoutPipelineRef.current(view_25.state, { reason: "font-ready" });
|
|
5732
|
+
updateSelectionOverlayRef.current(view_25.state);
|
|
5601
5733
|
});
|
|
5602
5734
|
return () => {
|
|
5603
5735
|
cancelled_1 = true;
|
|
@@ -5610,12 +5742,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5610
5742
|
let cancelled_2 = false;
|
|
5611
5743
|
let registered_0 = [];
|
|
5612
5744
|
const remeasureForFontChange = () => {
|
|
5613
|
-
const
|
|
5614
|
-
if (!
|
|
5745
|
+
const view_26 = hiddenPMRef.current?.getView();
|
|
5746
|
+
if (!view_26) return;
|
|
5615
5747
|
resetCanvasContext();
|
|
5616
5748
|
clearAllCaches();
|
|
5617
|
-
runLayoutPipelineRef.current(
|
|
5618
|
-
updateSelectionOverlayRef.current(
|
|
5749
|
+
runLayoutPipelineRef.current(view_26.state, { reason: "font-ready" });
|
|
5750
|
+
updateSelectionOverlayRef.current(view_26.state);
|
|
5619
5751
|
};
|
|
5620
5752
|
loadHostFontFaces(hostFonts).then((faces_0) => {
|
|
5621
5753
|
if (cancelled_2) {
|
|
@@ -5641,12 +5773,12 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5641
5773
|
lastLayoutInputSignatureRef.current = layoutInputSignature;
|
|
5642
5774
|
return;
|
|
5643
5775
|
}
|
|
5644
|
-
const
|
|
5645
|
-
if (
|
|
5776
|
+
const view_27 = hiddenPMRef.current?.getView();
|
|
5777
|
+
if (view_27) {
|
|
5646
5778
|
const layoutInputsChanged = lastLayoutInputSignatureRef.current !== layoutInputSignature;
|
|
5647
5779
|
lastLayoutInputSignatureRef.current = layoutInputSignature;
|
|
5648
|
-
if (!layoutInputsChanged &&
|
|
5649
|
-
runLayoutPipelineRef.current(
|
|
5780
|
+
if (!layoutInputsChanged && view_27.state.doc === layoutSessionRef.current.lastPmDoc) return;
|
|
5781
|
+
runLayoutPipelineRef.current(view_27.state, { reason: "layout-input" });
|
|
5650
5782
|
}
|
|
5651
5783
|
}, [document, layoutInputSignature]);
|
|
5652
5784
|
useEffect(() => {
|
|
@@ -5659,6 +5791,28 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5659
5791
|
observer.observe(container);
|
|
5660
5792
|
return () => observer.disconnect();
|
|
5661
5793
|
}, [updateSelectionOverlay]);
|
|
5794
|
+
useEffect(() => {
|
|
5795
|
+
const hiddenHost = hiddenPMRef.current?.getHostElement();
|
|
5796
|
+
if (!hiddenHost) return;
|
|
5797
|
+
let animationFrame = null;
|
|
5798
|
+
const scheduleRefresh = () => {
|
|
5799
|
+
if (animationFrame !== null) cancelAnimationFrame(animationFrame);
|
|
5800
|
+
animationFrame = requestAnimationFrame(() => {
|
|
5801
|
+
animationFrame = null;
|
|
5802
|
+
refreshBodyImeCaretAnchor();
|
|
5803
|
+
});
|
|
5804
|
+
};
|
|
5805
|
+
const refreshOnFocus = () => refreshBodyImeCaretAnchor();
|
|
5806
|
+
hiddenHost.addEventListener("focusin", refreshOnFocus);
|
|
5807
|
+
hiddenHost.addEventListener("compositionend", scheduleRefresh);
|
|
5808
|
+
window.addEventListener("scroll", scheduleRefresh, true);
|
|
5809
|
+
return () => {
|
|
5810
|
+
if (animationFrame !== null) cancelAnimationFrame(animationFrame);
|
|
5811
|
+
hiddenHost.removeEventListener("focusin", refreshOnFocus);
|
|
5812
|
+
hiddenHost.removeEventListener("compositionend", scheduleRefresh);
|
|
5813
|
+
window.removeEventListener("scroll", scheduleRefresh, true);
|
|
5814
|
+
};
|
|
5815
|
+
}, [refreshBodyImeCaretAnchor]);
|
|
5662
5816
|
useImperativeHandle(ref, () => ({
|
|
5663
5817
|
getEditor() {
|
|
5664
5818
|
return folioEditor;
|
|
@@ -5686,12 +5840,14 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5686
5840
|
ensureHiddenEditorView(options_4);
|
|
5687
5841
|
},
|
|
5688
5842
|
focus() {
|
|
5689
|
-
getActiveEditorStory()
|
|
5843
|
+
const target_4 = getActiveEditorStory();
|
|
5844
|
+
target_4.view?.focus();
|
|
5845
|
+
if (target_4.type === "body") refreshBodyImeCaretAnchor();
|
|
5690
5846
|
setIsFocused(true);
|
|
5691
5847
|
},
|
|
5692
5848
|
blur() {
|
|
5693
|
-
const
|
|
5694
|
-
if (
|
|
5849
|
+
const view_28 = getActiveEditorStory().view;
|
|
5850
|
+
if (view_28?.hasFocus() && view_28.dom instanceof HTMLElement) view_28.dom.blur();
|
|
5695
5851
|
setIsFocused(false);
|
|
5696
5852
|
},
|
|
5697
5853
|
isFocused() {
|
|
@@ -5701,22 +5857,22 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5701
5857
|
folioEditor.dispatch(tr_6);
|
|
5702
5858
|
},
|
|
5703
5859
|
undo() {
|
|
5704
|
-
const target_4 = getActiveEditorStory();
|
|
5705
|
-
if (target_4.type === "none") return false;
|
|
5706
|
-
return undo(target_4.view.state, target_4.view.dispatch);
|
|
5707
|
-
},
|
|
5708
|
-
redo() {
|
|
5709
5860
|
const target_5 = getActiveEditorStory();
|
|
5710
5861
|
if (target_5.type === "none") return false;
|
|
5711
|
-
return
|
|
5862
|
+
return undo(target_5.view.state, target_5.view.dispatch);
|
|
5712
5863
|
},
|
|
5713
|
-
|
|
5864
|
+
redo() {
|
|
5714
5865
|
const target_6 = getActiveEditorStory();
|
|
5715
|
-
|
|
5866
|
+
if (target_6.type === "none") return false;
|
|
5867
|
+
return redo(target_6.view.state, target_6.view.dispatch);
|
|
5716
5868
|
},
|
|
5717
|
-
|
|
5869
|
+
canUndo() {
|
|
5718
5870
|
const target_7 = getActiveEditorStory();
|
|
5719
|
-
return target_7.type === "none" ? false :
|
|
5871
|
+
return target_7.type === "none" ? false : undo(target_7.view.state);
|
|
5872
|
+
},
|
|
5873
|
+
canRedo() {
|
|
5874
|
+
const target_8 = getActiveEditorStory();
|
|
5875
|
+
return target_8.type === "none" ? false : redo(target_8.view.state);
|
|
5720
5876
|
},
|
|
5721
5877
|
setSelection(anchor_3, head_1) {
|
|
5722
5878
|
folioEditor.setSelection(anchor_3, head_1);
|
|
@@ -5770,6 +5926,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5770
5926
|
ensureHiddenEditorView,
|
|
5771
5927
|
folioEditor,
|
|
5772
5928
|
getActiveEditorStory,
|
|
5929
|
+
refreshBodyImeCaretAnchor,
|
|
5773
5930
|
scrollToPageImpl,
|
|
5774
5931
|
scrollToParaIdImpl,
|
|
5775
5932
|
scrollToPositionImpl,
|
|
@@ -5920,6 +6077,8 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
5920
6077
|
hfCaretSelection && /* @__PURE__ */ jsx(HfCaretOverlay, {
|
|
5921
6078
|
selection: hfCaretSelection,
|
|
5922
6079
|
pagesContainer: pagesContainerRef.current,
|
|
6080
|
+
hiddenHost: hfPMsRef.current?.getHostElement() ?? null,
|
|
6081
|
+
editorView: hfPMsRef.current?.getView(hfCaretSelection.rId) ?? null,
|
|
5923
6082
|
zoom
|
|
5924
6083
|
}),
|
|
5925
6084
|
layout && remoteSelections.map((remoteSelection) => /* @__PURE__ */ jsx(RemoteSelectionOverlay, {
|
|
@@ -12434,7 +12593,7 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
|
|
|
12434
12593
|
* - Error boundary
|
|
12435
12594
|
* - Loading states
|
|
12436
12595
|
*/
|
|
12437
|
-
const CommentsSidebar = lazy(() => import("./CommentsSidebar-
|
|
12596
|
+
const CommentsSidebar = lazy(() => import("./CommentsSidebar-B7waYgma.js").then((m) => ({ default: m.CommentsSidebar })));
|
|
12438
12597
|
const TextContextMenu = lazy(() => import("./TextContextMenu-Ci7-M4oU.js").then((m) => ({ default: m.TextContextMenu })));
|
|
12439
12598
|
const loadAttemptSelectiveSave = async () => {
|
|
12440
12599
|
const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-react",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
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",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@fontsource/noto-sans-arabic": "^5.2.7",
|
|
69
69
|
"@fontsource/source-sans-3": "^5.2.9",
|
|
70
70
|
"@fontsource/tinos": "^5.2.7",
|
|
71
|
-
"@stll/folio-core": "^0.15.
|
|
71
|
+
"@stll/folio-core": "^0.15.12",
|
|
72
72
|
"better-result": "2.10.0",
|
|
73
73
|
"lucide-react": "1.24.0",
|
|
74
74
|
"prosemirror-history": "^1.5.0",
|