@stll/folio-react 0.34.1 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/{CommentsSidebar-myF8qhju.js → CommentsSidebar-CMNMCb-Y.js} +31 -39
- package/dist/{FindReplaceDialog-DbbzquBV.js → FindReplaceDialog-DTK6xana.js} +2 -2
- package/dist/{FootnotePropertiesDialog-BBq9iBzN.js → FootnotePropertiesDialog-mDtUjPE_.js} +2 -2
- package/dist/{ImagePositionDialog-CznMopDr.js → ImagePositionDialog-ZJQNtqFy.js} +2 -2
- package/dist/{ImagePropertiesDialog-TAm7NKLM.js → ImagePropertiesDialog-DChYHwgl.js} +2 -2
- package/dist/{InsertSymbolDialog-CrHgjUTz.js → InsertSymbolDialog-J_pp6t9O.js} +2 -2
- package/dist/{PageSetupDialog-DpTPXo9U.js → PageSetupDialog-CS6fgx2j.js} +2 -2
- package/dist/{SetNumberingValueDialog-BzUWmoaZ.js → SetNumberingValueDialog-D7pc4iaY.js} +1 -1
- package/dist/{TablePropertiesDialog-fDJc5_NR.js → TablePropertiesDialog-CrVVT48x.js} +2 -2
- package/dist/compat/eigenpal.d.ts +1 -1
- package/dist/compat/eigenpal.js +2 -2
- package/dist/{dialogs-BQ-7aAfV.js → dialogs-BgWQFSlU.js} +1 -1
- package/dist/{dialogs-CQHVbEgA.d.ts → dialogs-BjWjcllk.d.ts} +12 -11
- package/dist/dialogs.d.ts +1 -1
- package/dist/dialogs.js +8 -8
- package/dist/{folio-ui-CEFqJgCh.js → folio-ui-DNlnaoih.js} +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.js +11 -13
- package/dist/{messages-DjrCTI3y.js → messages-BmWt6Yeu.js} +2 -2
- package/dist/messages.js +1 -1
- package/dist/{renderAsync-CRk3aj3J.d.ts → renderAsync-CUKCee5z.d.ts} +110 -38
- package/dist/{renderAsync-k1iPk-aX.js → renderAsync-CzkaClhN.js} +1659 -1326
- package/dist/{rolldown-runtime-782esTHO.js → rolldown-runtime-BKpuH2hG.js} +4 -4
- package/dist/standalone.css +1 -1
- package/package.json +7 -7
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import React$1, { CSSProperties, ComponentProps, ComponentType,
|
|
1
|
+
import React$1, { CSSProperties, ComponentProps, ComponentType, JSX, ReactElement, ReactNode, RefAttributes, RefObject } from "react";
|
|
2
2
|
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
3
3
|
import { EditorView } from "prosemirror-view";
|
|
4
4
|
import { XmlFragment } from "yjs";
|
|
5
5
|
import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioCommentAnchor, FolioDocumentNavigationTarget, FolioPendingSuggestionLoadResult, FolioPendingSuggestionRecord, FolioReviewChange, FolioUndefinedReferencePolicy } from "@stll/folio-core/ai-edits";
|
|
6
|
+
import { CanonicalHistoryDrop, CanonicalHistoryEffect } from "@stll/folio-core/canonical/canonicalSession";
|
|
6
7
|
import { ContentControlFilter, SetContentControlContentInput, SetContentControlValueInput } from "@stll/folio-core/content-controls";
|
|
7
|
-
import {
|
|
8
|
+
import { FolioAnonymizationMatch, FolioAnonymizationTerm } from "@stll/folio-core/controller/anonymizationHighlights";
|
|
9
|
+
import { FolioAutocompleteApi, FolioAutocompleteState } from "@stll/folio-core/controller/autocompleteSuggestion";
|
|
10
|
+
import { CanonicalRoomCollaboration } from "@stll/folio-core/controller/canonicalRoomEditor";
|
|
11
|
+
import { FolioEditor, FolioSaveOptions, TextPosition } from "@stll/folio-core/controller/folioEditor";
|
|
8
12
|
import { PageRendererName } from "@stll/folio-core/display-list/editor/pageRenderer";
|
|
9
13
|
import { DocxCompatibility } from "@stll/folio-core/docx/compatibility";
|
|
10
14
|
import { FolioSelectiveSaveFlags } from "@stll/folio-core/docx/selectiveSaveFlags";
|
|
@@ -16,29 +20,23 @@ import { BlockRect } from "@stll/folio-core/paged-layout/blockGeometry";
|
|
|
16
20
|
import { ScrollToParaIdOptions } from "@stll/folio-core/paged-layout/paragraphFlash";
|
|
17
21
|
import { ListState, SelectionState } from "@stll/folio-core/prosemirror";
|
|
18
22
|
import { FolioSuggestion, SuggestionAppliedAs } from "@stll/folio-core/prosemirror/commands/comments";
|
|
19
|
-
import { AnonymizationMatch } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations";
|
|
20
23
|
import { TemplateSlashMenuKeyAction, TemplateSlashMenuState } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
|
|
21
24
|
import { FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult } from "@stll/folio-core/server";
|
|
25
|
+
import { EditorSession } from "@stll/folio-core/types/canonicalCapabilities";
|
|
22
26
|
import { Comment } from "@stll/folio-core/types/content";
|
|
23
|
-
import { ColorValue, Document, ParagraphAlignment, SdtProperties,
|
|
27
|
+
import { ColorValue, Document, ParagraphAlignment, SdtProperties, Style, Theme } from "@stll/folio-core/types/document";
|
|
28
|
+
import { DeepReadonly, ReadonlyDocument } from "@stll/folio-core/types/documentModel";
|
|
29
|
+
import { FolioDerivedFields, FolioFieldInsertion } from "@stll/folio-core/types/fields";
|
|
24
30
|
import { DocxInput } from "@stll/folio-core/utils/docxInput";
|
|
25
31
|
import { FindMatch, FindOptions, FindResult } from "@stll/folio-core/utils/findReplace";
|
|
26
32
|
import { OutlineDepth } from "@stll/folio-core/utils/outlineDepth";
|
|
27
|
-
import "@stll/folio-core/controller/noteEditorManager";
|
|
28
33
|
import { Layout } from "@stll/folio-core/layout-engine/types";
|
|
29
|
-
import "@stll/folio-core/prosemirror/extensions/ExtensionManager";
|
|
30
|
-
import "@stll/folio-core/controller/hiddenEditorApi";
|
|
31
|
-
import "@stll/folio-core/controller/hiddenEditorManager";
|
|
32
|
-
import "@stll/folio-core/types/canonicalCapabilities";
|
|
33
34
|
import { Checkbox } from "@base-ui/react/checkbox";
|
|
34
35
|
import { Dialog } from "@base-ui/react/dialog";
|
|
35
36
|
import { Menu } from "@base-ui/react/menu";
|
|
36
37
|
import { Popover } from "@base-ui/react/popover";
|
|
37
38
|
import { Select } from "@base-ui/react/select";
|
|
38
|
-
import "@stll/folio-core/managers/DocumentLoaderManager";
|
|
39
|
-
import "@stll/folio-core/managers/HistoryManager";
|
|
40
39
|
import { TableAction } from "@stll/folio-core/utils/tableOperations";
|
|
41
|
-
import "react/jsx-runtime";
|
|
42
40
|
/**
|
|
43
41
|
* Declarative description of one custom font face the host registers with the
|
|
44
42
|
* editor. Multiple entries can share `family` to register distinct weights.
|
|
@@ -56,8 +54,16 @@ type FontDefinition = {
|
|
|
56
54
|
type PagedEditorRef = {
|
|
57
55
|
/** The headless editor controller (imperative API + events; Seam 6). */
|
|
58
56
|
getEditor: () => FolioEditor;
|
|
59
|
-
/**
|
|
60
|
-
|
|
57
|
+
/**
|
|
58
|
+
* The current document, built over the editor's model and sharing its
|
|
59
|
+
* parts: read it, never write it (`DocxEditorRef.getDocument` hands a copy).
|
|
60
|
+
*/
|
|
61
|
+
getDocument: () => ReadonlyDocument | null;
|
|
62
|
+
/**
|
|
63
|
+
* The editor's document model, without a copy: in a canonical session the
|
|
64
|
+
* session's own document (read it, never write it); otherwise null.
|
|
65
|
+
*/
|
|
66
|
+
readDocumentModel: () => ReadonlyDocument | null;
|
|
61
67
|
/** Get the ProseMirror EditorState. */
|
|
62
68
|
getState: () => EditorState | null;
|
|
63
69
|
/** Get the ProseMirror EditorView. */
|
|
@@ -121,10 +127,6 @@ type PagedEditorRef = {
|
|
|
121
127
|
from: number;
|
|
122
128
|
to: number;
|
|
123
129
|
} | null) => void;
|
|
124
|
-
/** Resolve the page number (1-indexed) that contains the given PM position,
|
|
125
|
-
* or null if no layout is available yet. Works for unrendered pages too via
|
|
126
|
-
* the page shell map. */
|
|
127
|
-
getPageNumberForPmPos: (pmPos: number) => number | null;
|
|
128
130
|
/** Painted geometry for one AI-snapshot block. */
|
|
129
131
|
getBlockRect: (blockId: string) => BlockRect | null;
|
|
130
132
|
/** Painted geometry for many AI-snapshot blocks in one layout read. */
|
|
@@ -532,9 +534,9 @@ type ToolbarProps = {
|
|
|
532
534
|
*/
|
|
533
535
|
onFormatPainter?: ((sticky: boolean) => void) | undefined;
|
|
534
536
|
/** Document styles for the style picker */
|
|
535
|
-
documentStyles?: Style[] | undefined;
|
|
537
|
+
documentStyles?: DeepReadonly<Style[]> | undefined;
|
|
536
538
|
/** Theme for the style picker */
|
|
537
|
-
theme?: Theme | null | undefined;
|
|
539
|
+
theme?: DeepReadonly<Theme> | null | undefined;
|
|
538
540
|
/** Callback for print action */
|
|
539
541
|
onPrint?: (() => void) | undefined;
|
|
540
542
|
/** Whether to show print button (default: true) */
|
|
@@ -594,7 +596,7 @@ type ToolbarProps = {
|
|
|
594
596
|
columnCount?: number | undefined;
|
|
595
597
|
canSplitCell?: boolean | undefined;
|
|
596
598
|
hasMultiCellSelection?: boolean | undefined;
|
|
597
|
-
cellBorderColor?: ColorValue | undefined;
|
|
599
|
+
cellBorderColor?: DeepReadonly<ColorValue> | undefined;
|
|
598
600
|
cellBackgroundColor?: string | undefined;
|
|
599
601
|
} | null;
|
|
600
602
|
/** Callback when a table action is triggered */
|
|
@@ -609,10 +611,25 @@ type DocxEditorProps = {
|
|
|
609
611
|
documentBuffer?: DocxInput | null;
|
|
610
612
|
/** Password for Agile-encrypted .docx files (Office 2010+). */
|
|
611
613
|
password?: string | undefined;
|
|
614
|
+
/**
|
|
615
|
+
* Fields whose display text the host derives from the document (numbered
|
|
616
|
+
* references, for one). After each local edit the owned fields show what
|
|
617
|
+
* `displayTexts` gives them, in the same undo step as the edit; a peer in a
|
|
618
|
+
* shared room receives the update with it.
|
|
619
|
+
*/
|
|
620
|
+
derivedFields?: FolioDerivedFields | undefined;
|
|
612
621
|
/** Pre-parsed document (alternative to documentBuffer) */
|
|
613
622
|
document?: Document | null;
|
|
614
|
-
/**
|
|
615
|
-
|
|
623
|
+
/**
|
|
624
|
+
* The editing engine. Unset, the editor runs the canonical session, which
|
|
625
|
+
* refuses unsupported edits with a notice, or the legacy session when
|
|
626
|
+
* `collaboration` is a Yjs fragment. `"legacy"` selects the
|
|
627
|
+
* ProseMirror-owned engine.
|
|
628
|
+
* A host plugin's transaction or a direct dispatch that changes the
|
|
629
|
+
* document is refused too, its refusal naming the transaction's meta keys:
|
|
630
|
+
* express such an edit as document operations (`applyDocumentOperations`).
|
|
631
|
+
*/
|
|
632
|
+
experimentalSession?: EditorSession;
|
|
616
633
|
/** Callback when document is saved */
|
|
617
634
|
onSave?: (buffer: ArrayBuffer) => void;
|
|
618
635
|
/** Author name used for comments and track changes */
|
|
@@ -658,7 +675,7 @@ type DocxEditorProps = {
|
|
|
658
675
|
*/
|
|
659
676
|
fonts?: ReadonlyArray<FontDefinition>;
|
|
660
677
|
/** Theme for styling */
|
|
661
|
-
theme?: Theme | null;
|
|
678
|
+
theme?: DeepReadonly<Theme> | null;
|
|
662
679
|
/** Whether to show toolbar (default: true) */
|
|
663
680
|
showToolbar?: boolean;
|
|
664
681
|
/** Whether to show zoom control (default: true) */
|
|
@@ -823,8 +840,9 @@ type DocxEditorProps = {
|
|
|
823
840
|
/**
|
|
824
841
|
* Controlled comments array. When provided, the editor reads comment thread
|
|
825
842
|
* metadata from this prop and emits every change through `onCommentsChange`.
|
|
826
|
-
*
|
|
827
|
-
*
|
|
843
|
+
* In a canonical room the comments are operations of the room's journal:
|
|
844
|
+
* the editor reports them through `onCommentsChange` and never reads this
|
|
845
|
+
* prop back.
|
|
828
846
|
*/
|
|
829
847
|
comments?: Comment[];
|
|
830
848
|
/** Fires whenever the comments array changes (controlled and uncontrolled). */
|
|
@@ -837,6 +855,21 @@ type DocxEditorProps = {
|
|
|
837
855
|
* (decoration meta, apply, scroll-to) from outside the editor.
|
|
838
856
|
*/
|
|
839
857
|
onEditorViewReady?: (view: EditorView | null) => void;
|
|
858
|
+
/**
|
|
859
|
+
* With the canonical session: called after each edit, undo or redo is
|
|
860
|
+
* published in any story, with what it did to the session's undo history.
|
|
861
|
+
* A host that keeps its own undo stack (and owns `hostShortcuts`'
|
|
862
|
+
* `"history"`) adds one entry per `opened` and sends undo / redo back
|
|
863
|
+
* through `DocxEditorRef.undo` / `redo`.
|
|
864
|
+
*/
|
|
865
|
+
onCanonicalHistory?: (effect: CanonicalHistoryEffect) => void;
|
|
866
|
+
/**
|
|
867
|
+
* With the canonical session: called when a peer's edit in a canonical
|
|
868
|
+
* room left local history steps unusable, with how many of each stack it
|
|
869
|
+
* dropped, counted from the bottom. A host that mirrors the steps in its
|
|
870
|
+
* own undo stack removes as many.
|
|
871
|
+
*/
|
|
872
|
+
onCanonicalHistoryDrop?: (drop: CanonicalHistoryDrop) => void;
|
|
840
873
|
/**
|
|
841
874
|
* Host ProseMirror plugins for the body editor, retained across document
|
|
842
875
|
* replacements. Keep the array and plugin instances stable for a mounted
|
|
@@ -844,16 +877,30 @@ type DocxEditorProps = {
|
|
|
844
877
|
* host, collaboration, and built-in plugins.
|
|
845
878
|
*/
|
|
846
879
|
plugins?: readonly Plugin[] | undefined;
|
|
847
|
-
/**
|
|
880
|
+
/**
|
|
881
|
+
* Edit together with other editors. With the canonical session, the
|
|
882
|
+
* canonical room the session joins; with the legacy session, the Yjs
|
|
883
|
+
* fragment it edits. Experimental and opt-in.
|
|
884
|
+
*/
|
|
848
885
|
collaboration?: DocxEditorCollaboration | undefined;
|
|
849
886
|
/**
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
*
|
|
887
|
+
* Terms to highlight wherever they occur in the shown text of every story
|
|
888
|
+
* (body, table cells, headers, footers, notes), in either session. A term
|
|
889
|
+
* matches literally, case-insensitively and on word boundaries, across
|
|
890
|
+
* formatting runs; text inside a tracked deletion is matched too.
|
|
891
|
+
* Highlights are view state: they never change the document, its undo
|
|
892
|
+
* history or its pending changes, and they follow every edit, a peer's
|
|
893
|
+
* included. Pass a new array to change the terms.
|
|
855
894
|
*/
|
|
856
|
-
|
|
895
|
+
anonymizationTerms?: readonly FolioAnonymizationTerm[] | undefined;
|
|
896
|
+
/** Called with the inline autocomplete suggestion each time it changes. */
|
|
897
|
+
onAutocompleteChange?: ((state: FolioAutocompleteState) => void) | undefined;
|
|
898
|
+
/**
|
|
899
|
+
* Fires with every occurrence, as text positions, each time the set of
|
|
900
|
+
* occurrences changes (new terms, an edit, a load). An edit elsewhere in
|
|
901
|
+
* the document does not fire it.
|
|
902
|
+
*/
|
|
903
|
+
onAnonymizationMatchesChange?: (matches: readonly FolioAnonymizationMatch[]) => void;
|
|
857
904
|
/**
|
|
858
905
|
* Fires when the user clicks an anonymization highlight in
|
|
859
906
|
* the rendered document. Hosts use this to push the
|
|
@@ -921,7 +968,9 @@ type DocxEditorProps = {
|
|
|
921
968
|
*/
|
|
922
969
|
onSelectiveSaveTripwire?: (result: TripwireResult) => void;
|
|
923
970
|
};
|
|
924
|
-
type DocxEditorCollaboration =
|
|
971
|
+
type DocxEditorCollaboration = CanonicalRoomCollaboration | DocxEditorYjsCollaboration;
|
|
972
|
+
/** A Yjs fragment the legacy session edits, and the plugins that bind it. */
|
|
973
|
+
type DocxEditorYjsCollaboration = {
|
|
925
974
|
awareness?: {
|
|
926
975
|
clientID: number;
|
|
927
976
|
getStates: () => Map<number, unknown>;
|
|
@@ -932,6 +981,8 @@ type DocxEditorCollaboration = {
|
|
|
932
981
|
plugins?: Plugin[] | undefined;
|
|
933
982
|
shouldSeed?: boolean | undefined;
|
|
934
983
|
yXmlFragment: XmlFragment;
|
|
984
|
+
/** A canonical room is reached through `connect`; a Yjs fragment has none. */
|
|
985
|
+
connect?: never;
|
|
935
986
|
};
|
|
936
987
|
type DocxEditorApplyDocumentOperationsOptions = {
|
|
937
988
|
undefinedReferences: FolioUndefinedReferencePolicy;
|
|
@@ -975,9 +1026,7 @@ type DocxEditorRef = {
|
|
|
975
1026
|
/** The headless editor controller (Seam 6), or null before the editor mounts. */
|
|
976
1027
|
getEditor: () => FolioEditor | null;
|
|
977
1028
|
/** Save the document to buffer. Pass { selective: false } to force full repack. */
|
|
978
|
-
save: (options?:
|
|
979
|
-
selective?: boolean;
|
|
980
|
-
}) => Promise<ArrayBuffer | null>;
|
|
1029
|
+
save: (options?: FolioSaveOptions) => Promise<ArrayBuffer | null>;
|
|
981
1030
|
/** Set zoom level */
|
|
982
1031
|
setZoom: (zoom: number) => void;
|
|
983
1032
|
/** Get current zoom level */
|
|
@@ -1153,6 +1202,29 @@ type DocxEditorRef = {
|
|
|
1153
1202
|
getPageText: (page: number) => string | null;
|
|
1154
1203
|
/** Resolve a stable block or text range to its real 1-based rendered page. */
|
|
1155
1204
|
getTargetPage: (target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot) => number | null;
|
|
1205
|
+
/**
|
|
1206
|
+
* The 1-based rendered page that shows a body text position (story,
|
|
1207
|
+
* paragraph id, offset), or null before layout or when no paragraph in the
|
|
1208
|
+
* body has that id.
|
|
1209
|
+
*/
|
|
1210
|
+
getPositionPage: (position: TextPosition) => number | null;
|
|
1211
|
+
/**
|
|
1212
|
+
* The inline autocomplete suggestion: ghost text streamed in at a text
|
|
1213
|
+
* position and shown beside the caret, in either session. It is view
|
|
1214
|
+
* state: it never changes the document, its undo history or its pending
|
|
1215
|
+
* changes, and it stays on its text when a peer edits. Typing its next
|
|
1216
|
+
* characters consumes them; any other edit dismisses it. Tab accepts it,
|
|
1217
|
+
* Mod-ArrowRight its next word, Escape dismisses it.
|
|
1218
|
+
*/
|
|
1219
|
+
autocomplete: FolioAutocompleteApi;
|
|
1220
|
+
/** Every occurrence of the `anonymizationTerms`, as text positions. */
|
|
1221
|
+
getAnonymizationMatches: () => readonly FolioAnonymizationMatch[];
|
|
1222
|
+
/**
|
|
1223
|
+
* Insert a field in place of the body selection: one undo step, a tracked
|
|
1224
|
+
* insertion when suggesting. False when nothing was inserted, as while a
|
|
1225
|
+
* header, footer or note is being edited.
|
|
1226
|
+
*/
|
|
1227
|
+
insertField: (field: FolioFieldInsertion) => boolean;
|
|
1156
1228
|
/** Painted geometry for one block, relative to this editor's scroll root. */
|
|
1157
1229
|
getBlockRect: (blockId: string) => BlockRect | null;
|
|
1158
1230
|
/** Painted geometry for many blocks in one layout read; missing ids are omitted. */
|
|
@@ -1253,4 +1325,4 @@ type RenderAsyncOptions = Omit<DocxEditorProps, "documentBuffer" | "document"> &
|
|
|
1253
1325
|
* Rejects if `onError` runs before that milestone.
|
|
1254
1326
|
*/
|
|
1255
1327
|
declare const renderAsync: (input: DocxInput, container: HTMLElement, options: RenderAsyncOptions) => Promise<DocxEditorHandle>;
|
|
1256
|
-
export {
|
|
1328
|
+
export { FolioUIComponents as _, DocxEditorApplyDocumentOperationsOptions as a, FontDefinition as b, DocxEditorRef as c, HighlightPassageResult as d, ToolbarProps as f, FolioButtonProps as g, ColorPreset as h, renderAsync as i, DocxEditorYjsCollaboration as l, EditorMode as m, EditorHandle as n, DocxEditorCollaboration as o, FontOption as p, RenderAsyncOptions as r, DocxEditorProps as s, DocxEditorHandle as t, HighlightPassageOptions as u, FolioUIProvider as v, OutlineItem as y };
|