@stll/folio-react 0.8.0 → 0.9.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-Byn5lyrt.js → CommentsSidebar-BsrC2QJe.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-BmxQE7iO.d.ts → renderAsync-7RA6LEtu.d.ts} +5 -3
- package/dist/{renderAsync-BtWYvQMT.js → renderAsync-u9iv6l9J.js} +118 -233
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as containedHandler } from "./renderAsync-
|
|
1
|
+
import { d as containedHandler } from "./renderAsync-u9iv6l9J.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-7RA6LEtu.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { CreateEmptyDocumentOptions, createDocumentWithText, createEmptyDocument } from "@stll/folio-core/utils/createDocument";
|
|
4
4
|
|
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-u9iv6l9J.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 FontDefinition, a as DocxEditorApplyDocumentOperationsOptions, c as DocxEditorRef, d as FontOption, f as ColorPreset, g as OutlineItem, h as FolioUIProvider, i as renderAsync, l as ToolbarProps, m as FolioUIComponents, n as EditorHandle, o as DocxEditorCollaboration, p as FolioButtonProps, r as RenderAsyncOptions, s as DocxEditorProps, t as DocxEditorHandle, u as EditorMode } from "./renderAsync-
|
|
1
|
+
import { _ as FontDefinition, a as DocxEditorApplyDocumentOperationsOptions, c as DocxEditorRef, d as FontOption, f as ColorPreset, g as OutlineItem, h as FolioUIProvider, i as renderAsync, l as ToolbarProps, m as FolioUIComponents, n as EditorHandle, o as DocxEditorCollaboration, p as FolioButtonProps, r as RenderAsyncOptions, s as DocxEditorProps, t as DocxEditorHandle, u as EditorMode } from "./renderAsync-7RA6LEtu.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-DK8OVUT_.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-u9iv6l9J.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";
|
|
@@ -2,7 +2,7 @@ import React$1, { CSSProperties, ComponentProps, ComponentType, ReactNode, RefAt
|
|
|
2
2
|
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
3
3
|
import { EditorView } from "prosemirror-view";
|
|
4
4
|
import { XmlFragment } from "yjs";
|
|
5
|
-
import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioCommentAnchor, FolioReviewChange } from "@stll/folio-core/ai-edits";
|
|
5
|
+
import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioCommentAnchor, FolioDocumentNavigationTarget, FolioReviewChange } from "@stll/folio-core/ai-edits";
|
|
6
6
|
import { FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult } from "@stll/folio-core/server";
|
|
7
7
|
import { ContentControlFilter, SetContentControlContentInput, SetContentControlValueInput } from "@stll/folio-core/content-controls";
|
|
8
8
|
import { FolioEditor } from "@stll/folio-core/controller/folioEditor";
|
|
@@ -812,7 +812,8 @@ type DocxEditorRef = {
|
|
|
812
812
|
* accept (insertAfterBlock / deleteBlock). Without `snapshot`, falls back to
|
|
813
813
|
* a fresh-from-live-doc snapshot.
|
|
814
814
|
*/
|
|
815
|
-
scrollToBlock: (blockId: string, snapshot?: FolioAIEditSnapshot) => boolean;
|
|
815
|
+
scrollToBlock: (blockId: string, snapshot?: FolioAIEditSnapshot) => boolean; /** Resolve a stable block or text-range target and reveal it in the editor. */
|
|
816
|
+
showInDocument: (target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot) => boolean;
|
|
816
817
|
/**
|
|
817
818
|
* The tracked changes (insertions and deletions) present in the live
|
|
818
819
|
* document, read from the current ProseMirror `state.doc`. Empty array
|
|
@@ -834,7 +835,8 @@ type DocxEditorRef = {
|
|
|
834
835
|
* layout fragments with a newline. Returns `null` when the page number is
|
|
835
836
|
* out of range or the layout hasn't been computed yet.
|
|
836
837
|
*/
|
|
837
|
-
getPageText: (page: number) => string | null;
|
|
838
|
+
getPageText: (page: number) => string | null; /** Resolve a stable block or text range to its real 1-based rendered page. */
|
|
839
|
+
getTargetPage: (target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot) => number | null;
|
|
838
840
|
/**
|
|
839
841
|
* List every block-level content control in the live document, filtered by
|
|
840
842
|
* tag / alias / id / sdtType. Returns the modeled SdtProperties projection
|
|
@@ -50,6 +50,7 @@ import { createFolioEditorEmitter } from "@stll/folio-core/controller/folioEdito
|
|
|
50
50
|
import { runLayoutPipeline } from "@stll/folio-core/controller/layoutPipeline";
|
|
51
51
|
import { browserClock, createLayoutScheduler } from "@stll/folio-core/controller/layoutScheduler";
|
|
52
52
|
import { createLayoutSession } from "@stll/folio-core/controller/layoutSession";
|
|
53
|
+
import { documentFontsAreLoaded, getDocumentFontSet, waitForInitialLayoutFonts } from "@stll/folio-core/controller/fontReadiness";
|
|
53
54
|
import { getFootnoteText } from "@stll/folio-core/docx/footnoteParser";
|
|
54
55
|
import { convertHeaderFooterPmDocToContent, convertHeaderFooterToContent } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
|
|
55
56
|
import { templatePreviewDirtyRange } from "@stll/folio-core/layout-bridge/convert/templatePreviewFlow";
|
|
@@ -59,6 +60,7 @@ import { clickToPositionInHfSlot, findHfCaretSpan, findHfPmSpans, findHfSlotForT
|
|
|
59
60
|
import { clickToPosition } from "@stll/folio-core/layout-bridge/engine/clickToPosition";
|
|
60
61
|
import { getPageTop, hitTestFragment, hitTestTableCell } from "@stll/folio-core/layout-bridge/engine/hitTest";
|
|
61
62
|
import { clearAllCaches, resetCanvasContext } from "@stll/folio-core/layout-bridge/engine/measuring";
|
|
63
|
+
import { resolveSectionHeaderFooterRefs } from "@stll/folio-core/layout-engine";
|
|
62
64
|
import { recordLayoutPhase } from "@stll/folio-core/layout-engine/layoutInstrumentation";
|
|
63
65
|
import { LayoutPainter } from "@stll/folio-core/layout-painter";
|
|
64
66
|
import { PAINTER_PAINTED_EVENT, findPageShellForPmPos } from "@stll/folio-core/layout-painter/renderPage";
|
|
@@ -73,11 +75,11 @@ import { resizeColumnPair } from "@stll/folio-core/paged-layout/tableColumnResiz
|
|
|
73
75
|
import { tableInsertButtonOffset } from "@stll/folio-core/paged-layout/tableInsertButtonGeometry";
|
|
74
76
|
import { getTransactionDirtyRange } from "@stll/folio-core/paged-layout/transactionDirtyRange";
|
|
75
77
|
import { findStartPosForParaId } from "@stll/folio-core/prosemirror/utils/findParagraphByParaId";
|
|
76
|
-
import {
|
|
78
|
+
import { expectImageAttrs, expectTableAttrs, expectTableCellAttrs, mergeImageAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "@stll/folio-core/prosemirror/attrs";
|
|
77
79
|
import { extractEmbeddedFonts } from "@stll/folio-core/fonts/embeddedFonts";
|
|
78
80
|
import { panic } from "better-result";
|
|
79
81
|
import { collectRemoteSelections, createHiddenEditorManager, createHiddenEditorState } from "@stll/folio-core/controller/hiddenEditorManager";
|
|
80
|
-
import { clampRangeToDocSize, resolveFolioAIBlockRange } from "@stll/folio-core/ai-edits/blockRange";
|
|
82
|
+
import { clampRangeToDocSize, resolveFolioAIBlockRange, resolveFolioAITextRange } from "@stll/folio-core/ai-edits/blockRange";
|
|
81
83
|
import { getPageTextFromLayout } from "@stll/folio-core/paged-layout/pageText";
|
|
82
84
|
import { CONTENT_CONTROL_WIDGET_EVENT_NAME, dispatchDatePick, dispatchDropdownPick } from "@stll/folio-core/prosemirror/plugins/contentControlWidgets";
|
|
83
85
|
import { ErrorManager } from "@stll/folio-core/managers/ErrorManager";
|
|
@@ -2540,28 +2542,6 @@ function renderHeaderFooterContentByRId(source, hfPMs, contentWidth, metrics, op
|
|
|
2540
2542
|
}
|
|
2541
2543
|
return rendered.size > 0 ? rendered : void 0;
|
|
2542
2544
|
}
|
|
2543
|
-
function getSectionHeaderFooterRefs(documentModel) {
|
|
2544
|
-
const body = documentModel?.package.document;
|
|
2545
|
-
if (!body) return;
|
|
2546
|
-
const documentEvenAndOddHeaders = documentModel.package.settings?.evenAndOddHeaders === true;
|
|
2547
|
-
const sections = body.sections;
|
|
2548
|
-
if (sections && sections.length > 0) return sections.map((section) => getHeaderFooterRefsFromSectionProperties(section.properties, documentEvenAndOddHeaders));
|
|
2549
|
-
const finalProps = body.finalSectionProperties;
|
|
2550
|
-
if (!finalProps) return;
|
|
2551
|
-
return [getHeaderFooterRefsFromSectionProperties(finalProps, documentEvenAndOddHeaders)];
|
|
2552
|
-
}
|
|
2553
|
-
function getHeaderFooterRefsFromSectionProperties(props, documentEvenAndOddHeaders) {
|
|
2554
|
-
const refs = {};
|
|
2555
|
-
if (props.titlePg !== void 0) refs.titlePg = props.titlePg;
|
|
2556
|
-
refs.evenAndOddHeaders = props.evenAndOddHeaders ?? documentEvenAndOddHeaders;
|
|
2557
|
-
for (const ref of props.headerReferences ?? []) if (ref.type === "default") refs.headerDefault = ref.rId;
|
|
2558
|
-
else if (ref.type === "first") refs.headerFirst = ref.rId;
|
|
2559
|
-
else refs.headerEven = ref.rId;
|
|
2560
|
-
for (const ref of props.footerReferences ?? []) if (ref.type === "default") refs.footerDefault = ref.rId;
|
|
2561
|
-
else if (ref.type === "first") refs.footerFirst = ref.rId;
|
|
2562
|
-
else refs.footerEven = ref.rId;
|
|
2563
|
-
return refs;
|
|
2564
|
-
}
|
|
2565
2545
|
const getPageOverlayOffset = (pagesContainer, zoom) => {
|
|
2566
2546
|
const overlay = pagesContainer.parentElement?.querySelector("[data-testid=\"selection-overlay\"]");
|
|
2567
2547
|
const firstPage = pagesContainer.querySelector(".layout-page");
|
|
@@ -2582,139 +2562,7 @@ function stableJsonStringify(value) {
|
|
|
2582
2562
|
return nestedValue;
|
|
2583
2563
|
});
|
|
2584
2564
|
}
|
|
2585
|
-
function getDocumentFontSet() {
|
|
2586
|
-
if (typeof document === "undefined" || !("fonts" in document)) return null;
|
|
2587
|
-
return document.fonts;
|
|
2588
|
-
}
|
|
2589
|
-
function documentFontsAreLoaded() {
|
|
2590
|
-
const fontSet = getDocumentFontSet();
|
|
2591
|
-
return !fontSet || fontSet.status === "loaded";
|
|
2592
|
-
}
|
|
2593
|
-
const INITIAL_LAYOUT_FONT_TIMEOUT_MS = 2e3;
|
|
2594
2565
|
const INITIAL_FONT_READY_SUPPRESSION_MS = 250;
|
|
2595
|
-
const DEFAULT_LAYOUT_FONT_FAMILY = "Calibri";
|
|
2596
|
-
const OFFICE_FONT_FAMILY_MAP = {
|
|
2597
|
-
Arial: "Arimo",
|
|
2598
|
-
Calibri: "Carlito",
|
|
2599
|
-
Cambria: "Caladea",
|
|
2600
|
-
"Times New Roman": "Tinos",
|
|
2601
|
-
"Courier New": "Cousine"
|
|
2602
|
-
};
|
|
2603
|
-
const CSS_GENERIC_FONT_FAMILIES = /* @__PURE__ */ new Set([
|
|
2604
|
-
"serif",
|
|
2605
|
-
"sans-serif",
|
|
2606
|
-
"monospace",
|
|
2607
|
-
"cursive",
|
|
2608
|
-
"fantasy",
|
|
2609
|
-
"system-ui"
|
|
2610
|
-
]);
|
|
2611
|
-
const REGULAR_LAYOUT_FONT_DESCRIPTOR = [
|
|
2612
|
-
{
|
|
2613
|
-
style: "normal",
|
|
2614
|
-
weight: 400
|
|
2615
|
-
},
|
|
2616
|
-
{
|
|
2617
|
-
style: "italic",
|
|
2618
|
-
weight: 400
|
|
2619
|
-
},
|
|
2620
|
-
{
|
|
2621
|
-
style: "normal",
|
|
2622
|
-
weight: 700
|
|
2623
|
-
},
|
|
2624
|
-
{
|
|
2625
|
-
style: "italic",
|
|
2626
|
-
weight: 700
|
|
2627
|
-
}
|
|
2628
|
-
][0];
|
|
2629
|
-
function waitForInitialLayoutFonts(documentModel, pmDoc) {
|
|
2630
|
-
const fontSet = getDocumentFontSet();
|
|
2631
|
-
if (!fontSet) return Promise.resolve(true);
|
|
2632
|
-
const loadChecks = [];
|
|
2633
|
-
for (const face of collectInitialLayoutFontFaces(documentModel, pmDoc)) loadChecks.push(`${face.style} ${face.weight} 16px "${escapeCssFontFamily(face.family)}"`);
|
|
2634
|
-
const loadFonts = Promise.allSettled(loadChecks.map((check) => fontSet.load(check))).then(() => fontSet.ready).then(() => true);
|
|
2635
|
-
return Promise.race([loadFonts, new Promise((resolve) => {
|
|
2636
|
-
window.setTimeout(() => resolve(false), INITIAL_LAYOUT_FONT_TIMEOUT_MS);
|
|
2637
|
-
})]);
|
|
2638
|
-
}
|
|
2639
|
-
function collectInitialLayoutFontFaces(documentModel, pmDoc) {
|
|
2640
|
-
const faces = /* @__PURE__ */ new Map();
|
|
2641
|
-
addLayoutFontFamilyFace(faces, DEFAULT_LAYOUT_FONT_FAMILY, REGULAR_LAYOUT_FONT_DESCRIPTOR);
|
|
2642
|
-
for (const family of documentModel?.requiredFonts ?? []) addLayoutFontFamilyFace(faces, family, REGULAR_LAYOUT_FONT_DESCRIPTOR);
|
|
2643
|
-
addLayoutFontFamilyFace(faces, documentModel?.package.theme?.fontScheme?.majorFont?.latin, REGULAR_LAYOUT_FONT_DESCRIPTOR);
|
|
2644
|
-
addLayoutFontFamilyFace(faces, documentModel?.package.theme?.fontScheme?.minorFont?.latin, REGULAR_LAYOUT_FONT_DESCRIPTOR);
|
|
2645
|
-
addTextFormattingFontFaces(faces, documentModel?.package.styles?.docDefaults?.rPr);
|
|
2646
|
-
for (const style of documentModel?.package.styles?.styles ?? []) addTextFormattingFontFaces(faces, style.rPr);
|
|
2647
|
-
collectProseMirrorFontFaces(faces, pmDoc, void 0);
|
|
2648
|
-
return Array.from(faces.values());
|
|
2649
|
-
}
|
|
2650
|
-
function addTextFormattingFontFaces(faces, formatting) {
|
|
2651
|
-
addLayoutFontFamilyFace(faces, formatting?.fontFamily, layoutDescriptorFromFormatting(formatting));
|
|
2652
|
-
}
|
|
2653
|
-
function collectProseMirrorFontFaces(faces, node, inheritedTextFormatting) {
|
|
2654
|
-
const paragraphDefaults = readParagraphDefaultTextFormatting(node);
|
|
2655
|
-
const textFormatting = paragraphDefaults ?? inheritedTextFormatting;
|
|
2656
|
-
if (paragraphDefaults) addTextFormattingFontFaces(faces, paragraphDefaults);
|
|
2657
|
-
if (node.attrs["listMarkerFontFamily"]) addLayoutFontFamilyFace(faces, node.attrs["listMarkerFontFamily"], REGULAR_LAYOUT_FONT_DESCRIPTOR);
|
|
2658
|
-
if (node.isText) {
|
|
2659
|
-
const descriptor = layoutDescriptorFromFormattingAndMarks(textFormatting, node.marks);
|
|
2660
|
-
addLayoutFontFamilyFace(faces, readFontFamilyMarkAttrs(node.marks) ?? textFormatting?.fontFamily ?? DEFAULT_LAYOUT_FONT_FAMILY, descriptor);
|
|
2661
|
-
}
|
|
2662
|
-
node.forEach((child) => {
|
|
2663
|
-
collectProseMirrorFontFaces(faces, child, textFormatting);
|
|
2664
|
-
});
|
|
2665
|
-
}
|
|
2666
|
-
function readParagraphDefaultTextFormatting(node) {
|
|
2667
|
-
const value = node.attrs["defaultTextFormatting"];
|
|
2668
|
-
if (!value || typeof value !== "object") return;
|
|
2669
|
-
return value;
|
|
2670
|
-
}
|
|
2671
|
-
function readFontFamilyMarkAttrs(marks) {
|
|
2672
|
-
for (const mark of marks) if (mark.type.name === "fontFamily") return expectFontFamilyMarkAttrs(mark);
|
|
2673
|
-
}
|
|
2674
|
-
function layoutDescriptorFromFormatting(formatting) {
|
|
2675
|
-
return {
|
|
2676
|
-
style: formatting?.italic ? "italic" : "normal",
|
|
2677
|
-
weight: formatting?.bold ? 700 : 400
|
|
2678
|
-
};
|
|
2679
|
-
}
|
|
2680
|
-
function layoutDescriptorFromFormattingAndMarks(formatting, marks) {
|
|
2681
|
-
let bold = formatting?.bold === true;
|
|
2682
|
-
let italic = formatting?.italic === true;
|
|
2683
|
-
for (const mark of marks) {
|
|
2684
|
-
if (mark.type.name === "bold") bold = true;
|
|
2685
|
-
if (mark.type.name === "italic") italic = true;
|
|
2686
|
-
}
|
|
2687
|
-
return {
|
|
2688
|
-
style: italic ? "italic" : "normal",
|
|
2689
|
-
weight: bold ? 700 : 400
|
|
2690
|
-
};
|
|
2691
|
-
}
|
|
2692
|
-
function addLayoutFontFamilyFace(faces, value, descriptor) {
|
|
2693
|
-
if (typeof value === "string") {
|
|
2694
|
-
addLayoutFontFamilyNameFace(faces, value, descriptor);
|
|
2695
|
-
return;
|
|
2696
|
-
}
|
|
2697
|
-
if (!value || typeof value !== "object") return;
|
|
2698
|
-
const fontFamily = value;
|
|
2699
|
-
addLayoutFontFamilyFace(faces, fontFamily.ascii, descriptor);
|
|
2700
|
-
addLayoutFontFamilyFace(faces, fontFamily.hAnsi, descriptor);
|
|
2701
|
-
}
|
|
2702
|
-
function addLayoutFontFamilyNameFace(faces, family, descriptor) {
|
|
2703
|
-
const normalized = family.trim();
|
|
2704
|
-
if (!normalized || CSS_GENERIC_FONT_FAMILIES.has(normalized)) return;
|
|
2705
|
-
addLayoutFontFace(faces, normalized, descriptor);
|
|
2706
|
-
const mappedFamily = OFFICE_FONT_FAMILY_MAP[normalized];
|
|
2707
|
-
if (mappedFamily) addLayoutFontFace(faces, mappedFamily, descriptor);
|
|
2708
|
-
}
|
|
2709
|
-
function addLayoutFontFace(faces, family, descriptor) {
|
|
2710
|
-
faces.set(`${family}|${descriptor.style}|${descriptor.weight}`, {
|
|
2711
|
-
family,
|
|
2712
|
-
...descriptor
|
|
2713
|
-
});
|
|
2714
|
-
}
|
|
2715
|
-
function escapeCssFontFamily(family) {
|
|
2716
|
-
return family.replace(/\\/gu, "\\\\").replace(/"/gu, "\\\"");
|
|
2717
|
-
}
|
|
2718
2566
|
function describeInvalidHighlightMarks(doc) {
|
|
2719
2567
|
const invalidHighlights = [];
|
|
2720
2568
|
const validHighlightColors = /* @__PURE__ */ new Set([
|
|
@@ -3190,7 +3038,7 @@ const PagedEditor = forwardRef(function PagedEditor(props, ref) {
|
|
|
3190
3038
|
const defaultTabStop = document?.package.settings?.defaultTabStop;
|
|
3191
3039
|
const documentSettings = document?.package.settings;
|
|
3192
3040
|
const mirrorMargins = documentSettings !== void 0 && "mirrorMargins" in documentSettings && documentSettings.mirrorMargins === true;
|
|
3193
|
-
const sectionHeaderFooterRefs = useMemo(() =>
|
|
3041
|
+
const sectionHeaderFooterRefs = useMemo(() => resolveSectionHeaderFooterRefs(document), [document]);
|
|
3194
3042
|
const layoutInputSignature = useMemo(() => buildLayoutInputSignature({
|
|
3195
3043
|
columns,
|
|
3196
3044
|
contentWidth,
|
|
@@ -12306,7 +12154,7 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
|
|
|
12306
12154
|
* - Error boundary
|
|
12307
12155
|
* - Loading states
|
|
12308
12156
|
*/
|
|
12309
|
-
const CommentsSidebar = lazy(() => import("./CommentsSidebar-
|
|
12157
|
+
const CommentsSidebar = lazy(() => import("./CommentsSidebar-BsrC2QJe.js").then((m) => ({ default: m.CommentsSidebar })));
|
|
12310
12158
|
const TextContextMenu = lazy(() => import("./TextContextMenu-Ci7-M4oU.js").then((m) => ({ default: m.TextContextMenu })));
|
|
12311
12159
|
const loadAttemptSelectiveSave = async () => {
|
|
12312
12160
|
const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
|
|
@@ -14042,67 +13890,104 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14042
13890
|
});
|
|
14043
13891
|
return true;
|
|
14044
13892
|
},
|
|
14045
|
-
|
|
13893
|
+
showInDocument: (target_1, snapshot_2) => {
|
|
14046
13894
|
const view_27 = pagedEditorRef.current?.getView();
|
|
14047
|
-
|
|
13895
|
+
if (!view_27) return false;
|
|
13896
|
+
const range_4 = target_1.type === "textRange" ? resolveFolioAITextRange({
|
|
13897
|
+
range: target_1,
|
|
13898
|
+
doc: view_27.state.doc,
|
|
13899
|
+
snapshot: snapshot_2
|
|
13900
|
+
}) : resolveFolioAIBlockRange({
|
|
13901
|
+
blockId: target_1.blockId,
|
|
13902
|
+
doc: view_27.state.doc,
|
|
13903
|
+
snapshot: snapshot_2
|
|
13904
|
+
});
|
|
13905
|
+
if (range_4 === null) return false;
|
|
13906
|
+
const { from: from_10, to: to_10 } = range_4;
|
|
13907
|
+
const $from_1 = view_27.state.doc.resolve(from_10);
|
|
13908
|
+
const $to_1 = view_27.state.doc.resolve(to_10);
|
|
13909
|
+
view_27.dispatch(view_27.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
|
|
13910
|
+
requestAnimationFrame(() => {
|
|
13911
|
+
pagedEditorRef.current?.scrollToPosition(from_10);
|
|
13912
|
+
});
|
|
13913
|
+
return true;
|
|
14048
13914
|
},
|
|
14049
|
-
|
|
13915
|
+
getTrackedChanges: () => {
|
|
14050
13916
|
const view_28 = pagedEditorRef.current?.getView();
|
|
14051
|
-
return view_28 ?
|
|
13917
|
+
return view_28 ? getTrackedChangesFromDoc(view_28.state.doc) : [];
|
|
14052
13918
|
},
|
|
14053
|
-
|
|
13919
|
+
getCommentAnchors: () => {
|
|
14054
13920
|
const view_29 = pagedEditorRef.current?.getView();
|
|
14055
|
-
return view_29 ?
|
|
13921
|
+
return view_29 ? getCommentAnchorsFromDoc(view_29.state.doc) : [];
|
|
14056
13922
|
},
|
|
14057
|
-
|
|
13923
|
+
getSelectionText: () => {
|
|
14058
13924
|
const view_30 = pagedEditorRef.current?.getView();
|
|
14059
|
-
|
|
14060
|
-
return getPageTextFromLayout(pagedEditorRef.current?.getEditor()?.getLayout() ?? null, view_30.state.doc, page_0);
|
|
13925
|
+
return view_30 ? getSelectedText(view_30.state) : "";
|
|
14061
13926
|
},
|
|
14062
|
-
|
|
13927
|
+
getPageText: (page_0) => {
|
|
14063
13928
|
const view_31 = pagedEditorRef.current?.getView();
|
|
14064
|
-
if (!view_31) return
|
|
14065
|
-
return
|
|
13929
|
+
if (!view_31) return null;
|
|
13930
|
+
return getPageTextFromLayout(pagedEditorRef.current?.getEditor()?.getLayout() ?? null, view_31.state.doc, page_0);
|
|
13931
|
+
},
|
|
13932
|
+
getTargetPage: (target_2, snapshot_3) => {
|
|
13933
|
+
const view_32 = pagedEditorRef.current?.getView();
|
|
13934
|
+
if (!view_32) return null;
|
|
13935
|
+
const range_5 = target_2.type === "textRange" ? resolveFolioAITextRange({
|
|
13936
|
+
range: target_2,
|
|
13937
|
+
doc: view_32.state.doc,
|
|
13938
|
+
snapshot: snapshot_3
|
|
13939
|
+
}) : resolveFolioAIBlockRange({
|
|
13940
|
+
blockId: target_2.blockId,
|
|
13941
|
+
doc: view_32.state.doc,
|
|
13942
|
+
snapshot: snapshot_3
|
|
13943
|
+
});
|
|
13944
|
+
if (range_5 === null) return null;
|
|
13945
|
+
return pagedEditorRef.current?.getPageNumberForPmPos(range_5.from) ?? null;
|
|
13946
|
+
},
|
|
13947
|
+
getContentControls: (filter = {}) => {
|
|
13948
|
+
const view_33 = pagedEditorRef.current?.getView();
|
|
13949
|
+
if (!view_33) return [];
|
|
13950
|
+
return findBlockSdtMatches(view_33.state.doc, filter).map((match_0) => ({
|
|
14066
13951
|
properties: blockSdtAttrsToSdtProperties(match_0.node),
|
|
14067
13952
|
path: match_0.path,
|
|
14068
13953
|
pmPos: match_0.pos
|
|
14069
13954
|
}));
|
|
14070
13955
|
},
|
|
14071
13956
|
scrollToContentControl: (filter_0) => {
|
|
14072
|
-
const
|
|
14073
|
-
if (!
|
|
14074
|
-
const match_1 = findBlockSdtMatch(
|
|
13957
|
+
const view_34 = pagedEditorRef.current?.getView();
|
|
13958
|
+
if (!view_34) return false;
|
|
13959
|
+
const match_1 = findBlockSdtMatch(view_34.state.doc, filter_0);
|
|
14075
13960
|
if (!match_1) return false;
|
|
14076
13961
|
const inside = match_1.pos + 1;
|
|
14077
|
-
const $pos =
|
|
14078
|
-
|
|
13962
|
+
const $pos = view_34.state.doc.resolve(inside);
|
|
13963
|
+
view_34.dispatch(view_34.state.tr.setSelection(TextSelection.near($pos)));
|
|
14079
13964
|
requestAnimationFrame(() => {
|
|
14080
13965
|
pagedEditorRef.current?.scrollToPosition(inside);
|
|
14081
13966
|
});
|
|
14082
13967
|
return true;
|
|
14083
13968
|
},
|
|
14084
13969
|
setContentControlContent: (filter_1, input, options_2 = {}) => {
|
|
14085
|
-
const
|
|
14086
|
-
if (!
|
|
14087
|
-
const tr_0 = typeof input === "string" ? setContentControlContentTr(
|
|
13970
|
+
const view_35 = pagedEditorRef.current?.getView();
|
|
13971
|
+
if (!view_35) return false;
|
|
13972
|
+
const tr_0 = typeof input === "string" ? setContentControlContentTr(view_35.state, filter_1, input, options_2) : setContentControlContentBlocksTr(view_35.state, filter_1, input, options_2);
|
|
14088
13973
|
if (!tr_0) return false;
|
|
14089
|
-
|
|
13974
|
+
view_35.dispatch(tr_0);
|
|
14090
13975
|
return true;
|
|
14091
13976
|
},
|
|
14092
13977
|
setContentControlValue: (filter_2, input_0, options_3 = {}) => {
|
|
14093
|
-
const
|
|
14094
|
-
if (!
|
|
14095
|
-
const tr_1 = setContentControlValueTr(
|
|
13978
|
+
const view_36 = pagedEditorRef.current?.getView();
|
|
13979
|
+
if (!view_36) return false;
|
|
13980
|
+
const tr_1 = setContentControlValueTr(view_36.state, filter_2, input_0, options_3);
|
|
14096
13981
|
if (!tr_1) return false;
|
|
14097
|
-
|
|
13982
|
+
view_36.dispatch(tr_1);
|
|
14098
13983
|
return true;
|
|
14099
13984
|
},
|
|
14100
13985
|
removeContentControl: (filter_3, options_4 = {}) => {
|
|
14101
|
-
const
|
|
14102
|
-
if (!
|
|
14103
|
-
const tr_2 = removeContentControlTr(
|
|
13986
|
+
const view_37 = pagedEditorRef.current?.getView();
|
|
13987
|
+
if (!view_37) return false;
|
|
13988
|
+
const tr_2 = removeContentControlTr(view_37.state, filter_3, options_4);
|
|
14104
13989
|
if (!tr_2) return false;
|
|
14105
|
-
|
|
13990
|
+
view_37.dispatch(tr_2);
|
|
14106
13991
|
return true;
|
|
14107
13992
|
}
|
|
14108
13993
|
}), [
|
|
@@ -14173,39 +14058,39 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14173
14058
|
if (isDisplayMode(value)) setDisplayMode(value);
|
|
14174
14059
|
}, [setDisplayMode]);
|
|
14175
14060
|
const handleAcceptActiveChange = useCallback(() => {
|
|
14176
|
-
const
|
|
14177
|
-
if (!
|
|
14178
|
-
const { from:
|
|
14179
|
-
const
|
|
14180
|
-
acceptChange(
|
|
14061
|
+
const view_38 = pagedEditorRef.current?.getView();
|
|
14062
|
+
if (!view_38) return;
|
|
14063
|
+
const { from: from_11, to: to_11 } = view_38.state.selection;
|
|
14064
|
+
const range_6 = findChangeAtPosition(view_38.state, from_11, to_11);
|
|
14065
|
+
acceptChange(range_6.from, range_6.to)(view_38.state, view_38.dispatch);
|
|
14181
14066
|
}, []);
|
|
14182
14067
|
const handleRejectActiveChange = useCallback(() => {
|
|
14183
|
-
const
|
|
14184
|
-
if (!
|
|
14185
|
-
const { from:
|
|
14186
|
-
const
|
|
14187
|
-
rejectChange(
|
|
14068
|
+
const view_39 = pagedEditorRef.current?.getView();
|
|
14069
|
+
if (!view_39) return;
|
|
14070
|
+
const { from: from_12, to: to_12 } = view_39.state.selection;
|
|
14071
|
+
const range_7 = findChangeAtPosition(view_39.state, from_12, to_12);
|
|
14072
|
+
rejectChange(range_7.from, range_7.to)(view_39.state, view_39.dispatch);
|
|
14188
14073
|
}, []);
|
|
14189
14074
|
const handlePreviousChange = useCallback(() => {
|
|
14190
|
-
const
|
|
14191
|
-
if (!
|
|
14192
|
-
const { from:
|
|
14193
|
-
const change = findPreviousChange(
|
|
14075
|
+
const view_40 = pagedEditorRef.current?.getView();
|
|
14076
|
+
if (!view_40) return;
|
|
14077
|
+
const { from: from_13 } = view_40.state.selection;
|
|
14078
|
+
const change = findPreviousChange(view_40.state, from_13);
|
|
14194
14079
|
if (!change) return;
|
|
14195
|
-
|
|
14196
|
-
|
|
14080
|
+
view_40.dispatch(view_40.state.tr.setSelection(TextSelection.create(view_40.state.doc, change.from, change.to)));
|
|
14081
|
+
view_40.focus();
|
|
14197
14082
|
requestAnimationFrame(() => {
|
|
14198
14083
|
pagedEditorRef.current?.scrollToPosition(change.from);
|
|
14199
14084
|
});
|
|
14200
14085
|
}, []);
|
|
14201
14086
|
const handleNextChange = useCallback(() => {
|
|
14202
|
-
const
|
|
14203
|
-
if (!
|
|
14204
|
-
const { to:
|
|
14205
|
-
const change_0 = findNextChange(
|
|
14087
|
+
const view_41 = pagedEditorRef.current?.getView();
|
|
14088
|
+
if (!view_41) return;
|
|
14089
|
+
const { to: to_13 } = view_41.state.selection;
|
|
14090
|
+
const change_0 = findNextChange(view_41.state, to_13);
|
|
14206
14091
|
if (!change_0) return;
|
|
14207
|
-
|
|
14208
|
-
|
|
14092
|
+
view_41.dispatch(view_41.state.tr.setSelection(TextSelection.create(view_41.state.doc, change_0.from, change_0.to)));
|
|
14093
|
+
view_41.focus();
|
|
14209
14094
|
requestAnimationFrame(() => {
|
|
14210
14095
|
pagedEditorRef.current?.scrollToPosition(change_0.from);
|
|
14211
14096
|
});
|
|
@@ -14375,8 +14260,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14375
14260
|
requestAnimationFrame(syncCommentHighlightStyles);
|
|
14376
14261
|
}, [onScrollTopChange, syncCommentHighlightStyles]);
|
|
14377
14262
|
const handlePagedSelectionChange = useCallback((_from, _to) => {
|
|
14378
|
-
const
|
|
14379
|
-
handleSelectionChange(
|
|
14263
|
+
const view_42 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
|
|
14264
|
+
handleSelectionChange(view_42 ? extractSelectionState(view_42.state) : null);
|
|
14380
14265
|
}, [getActiveEditorView, handleSelectionChange]);
|
|
14381
14266
|
const handleTotalPagesChange = useCallback((totalPages) => {
|
|
14382
14267
|
setScrollPageInfo((previous) => updateScrollPageTotal(previous, totalPages));
|
|
@@ -14401,9 +14286,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14401
14286
|
}, [author, updateComments]);
|
|
14402
14287
|
const handleAddComment = useCallback((addText) => {
|
|
14403
14288
|
const comment_3 = createComment(addText, author);
|
|
14404
|
-
const
|
|
14405
|
-
if (!
|
|
14406
|
-
if (!applyCommentMarkRange(
|
|
14289
|
+
const view_43 = pagedEditorRef.current?.getView();
|
|
14290
|
+
if (!view_43 || !commentSelectionRange) return false;
|
|
14291
|
+
if (!applyCommentMarkRange(view_43, commentSelectionRange, comment_3.id, { replacePending: true })) return false;
|
|
14407
14292
|
const commentAuthor_2 = getCommentAuthorKey(comment_3.author);
|
|
14408
14293
|
setVisibleCommentAuthors((current) => {
|
|
14409
14294
|
if (current === null) return null;
|
|
@@ -14437,8 +14322,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14437
14322
|
updateComments((previous_4) => [...previous_4, createComment(text_6, author, revisionId_2)]);
|
|
14438
14323
|
}, [author, updateComments]);
|
|
14439
14324
|
const handleCancelAddComment = useCallback(() => {
|
|
14440
|
-
const
|
|
14441
|
-
if (
|
|
14325
|
+
const view_44 = pagedEditorRef.current?.getView();
|
|
14326
|
+
if (view_44 && commentSelectionRange) removePendingCommentMarkRange(view_44, commentSelectionRange);
|
|
14442
14327
|
setIsAddingComment(false);
|
|
14443
14328
|
setCommentSelectionRange(null);
|
|
14444
14329
|
setAddCommentYPosition(null);
|
|
@@ -14448,16 +14333,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14448
14333
|
setCommentSelectionRange,
|
|
14449
14334
|
setIsAddingComment
|
|
14450
14335
|
]);
|
|
14451
|
-
const handleSidebarAcceptChange = useCallback((
|
|
14452
|
-
const
|
|
14453
|
-
if (!
|
|
14454
|
-
acceptChange(
|
|
14336
|
+
const handleSidebarAcceptChange = useCallback((from_14, to_14) => {
|
|
14337
|
+
const view_45 = pagedEditorRef.current?.getView();
|
|
14338
|
+
if (!view_45) return;
|
|
14339
|
+
acceptChange(from_14, to_14)(view_45.state, view_45.dispatch);
|
|
14455
14340
|
extractTrackedChanges();
|
|
14456
14341
|
}, [extractTrackedChanges]);
|
|
14457
|
-
const handleSidebarRejectChange = useCallback((
|
|
14458
|
-
const
|
|
14459
|
-
if (!
|
|
14460
|
-
rejectChange(
|
|
14342
|
+
const handleSidebarRejectChange = useCallback((from_15, to_15) => {
|
|
14343
|
+
const view_46 = pagedEditorRef.current?.getView();
|
|
14344
|
+
if (!view_46) return;
|
|
14345
|
+
rejectChange(from_15, to_15)(view_46.state, view_46.dispatch);
|
|
14461
14346
|
extractTrackedChanges();
|
|
14462
14347
|
}, [extractTrackedChanges]);
|
|
14463
14348
|
const commentsPageWidth = history.state?.package.document.finalSectionProperties?.pageWidth;
|
|
@@ -14530,8 +14415,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14530
14415
|
const getBodyEditorView = useCallback(() => pagedEditorRef.current?.getView() ?? null, []);
|
|
14531
14416
|
const closeTableProperties = useCallback(() => setTablePropsOpen(false), []);
|
|
14532
14417
|
const applyTableProperties = useCallback((props_0) => {
|
|
14533
|
-
const
|
|
14534
|
-
if (
|
|
14418
|
+
const view_47 = getActiveEditorView();
|
|
14419
|
+
if (view_47) setTableProperties(props_0)(view_47.state, view_47.dispatch);
|
|
14535
14420
|
}, [getActiveEditorView]);
|
|
14536
14421
|
const closeImagePosition = useCallback(() => setImagePositionOpen(false), [setImagePositionOpen]);
|
|
14537
14422
|
const closeImageProperties = useCallback(() => setImagePropsOpen(false), [setImagePropsOpen]);
|
|
@@ -14539,8 +14424,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14539
14424
|
const closeFootnoteProperties = useCallback(() => setFootnotePropsOpen(false), []);
|
|
14540
14425
|
const closeInsertSymbol = useCallback(() => setShowInsertSymbol(false), []);
|
|
14541
14426
|
const insertSymbol = useCallback((symbol) => {
|
|
14542
|
-
const
|
|
14543
|
-
if (
|
|
14427
|
+
const view_48 = getActiveEditorView();
|
|
14428
|
+
if (view_48) view_48.dispatch(view_48.state.tr.insertText(symbol).scrollIntoView());
|
|
14544
14429
|
}, [getActiveEditorView]);
|
|
14545
14430
|
const imagePropertiesCurrentData = useMemo(() => buildImagePropertiesData(state.pmImageContext), [state.pmImageContext]);
|
|
14546
14431
|
const currentFindResult = findResultRef.current;
|
|
@@ -14866,8 +14751,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14866
14751
|
onMouseDown: (e_1) => {
|
|
14867
14752
|
e_1.preventDefault();
|
|
14868
14753
|
e_1.stopPropagation();
|
|
14869
|
-
const
|
|
14870
|
-
if (!
|
|
14754
|
+
const view_49 = pagedEditorRef.current?.getView();
|
|
14755
|
+
if (!view_49) {
|
|
14871
14756
|
setFloatingCommentBtn(null);
|
|
14872
14757
|
return;
|
|
14873
14758
|
}
|
|
@@ -14875,9 +14760,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14875
14760
|
from: floatingCommentBtn.from,
|
|
14876
14761
|
to: floatingCommentBtn.to
|
|
14877
14762
|
};
|
|
14878
|
-
const currentSelection =
|
|
14763
|
+
const currentSelection = view_49.state.selection;
|
|
14879
14764
|
const safeRange = resolveCommentCreationRange({
|
|
14880
|
-
docSize:
|
|
14765
|
+
docSize: view_49.state.doc.content.size,
|
|
14881
14766
|
capturedRange,
|
|
14882
14767
|
currentRange: {
|
|
14883
14768
|
from: currentSelection.from,
|
|
@@ -14891,7 +14776,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
|
|
|
14891
14776
|
return;
|
|
14892
14777
|
}
|
|
14893
14778
|
setCommentSelectionRange(safeRange);
|
|
14894
|
-
if (!applyCommentMarkRange(
|
|
14779
|
+
if (!applyCommentMarkRange(view_49, safeRange, -1, { selectEnd: true })) {
|
|
14895
14780
|
setCommentSelectionRange(null);
|
|
14896
14781
|
setFloatingCommentBtn(null);
|
|
14897
14782
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@fontsource/noto-sans-arabic": "^5.2.7",
|
|
68
68
|
"@fontsource/source-sans-3": "^5.2.9",
|
|
69
69
|
"@fontsource/tinos": "^5.2.7",
|
|
70
|
-
"@stll/folio-core": "^0.
|
|
70
|
+
"@stll/folio-core": "^0.6.0",
|
|
71
71
|
"better-result": "2.9.2",
|
|
72
72
|
"lucide-react": "1.24.0",
|
|
73
73
|
"prosemirror-history": "^1.5.0",
|