@stll/folio-react 0.4.0 → 0.6.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.
@@ -0,0 +1,915 @@
1
+ import React$1, { CSSProperties, ComponentProps, ComponentType, ReactNode, RefAttributes, RefObject } from "react";
2
+ import { EditorState, Plugin, Transaction } from "prosemirror-state";
3
+ import { EditorView } from "prosemirror-view";
4
+ import { XmlFragment } from "yjs";
5
+ import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioCommentAnchor, FolioReviewChange } from "@stll/folio-core/ai-edits";
6
+ import { ContentControlFilter, SetContentControlContentInput, SetContentControlValueInput } from "@stll/folio-core/content-controls";
7
+ import { FolioEditor } from "@stll/folio-core/controller/folioEditor";
8
+ import { DocxCompatibility } from "@stll/folio-core/docx/compatibility";
9
+ import { FolioSelectiveSaveFlags } from "@stll/folio-core/docx/selectiveSaveFlags";
10
+ import { TripwireResult } from "@stll/folio-core/docx/selectiveSaveTripwire";
11
+ import { SelectionState } from "@stll/folio-core/prosemirror";
12
+ import { AnonymizationMatch } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations";
13
+ import { TemplateSlashMenuKeyAction, TemplateSlashMenuState } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
14
+ import { ColorValue, Document, ParagraphAlignment, SdtProperties, SectionProperties, Style, Theme } from "@stll/folio-core/types/document";
15
+ import { Comment } from "@stll/folio-core/types/content";
16
+ import { DocxInput } from "@stll/folio-core/utils/docxInput";
17
+ import { ScrollToParaIdOptions } from "@stll/folio-core/paged-layout/paragraphFlash";
18
+ import { Layout } from "@stll/folio-core/layout-engine/types";
19
+ import { Checkbox } from "@base-ui/react/checkbox";
20
+ import { Dialog } from "@base-ui/react/dialog";
21
+ import { Menu } from "@base-ui/react/menu";
22
+ import { Popover } from "@base-ui/react/popover";
23
+ import { Select } from "@base-ui/react/select";
24
+ import { EditorMode } from "@stll/folio-core/managers/EditorModeManager";
25
+ import { TableAction } from "@stll/folio-core/utils/tableOperations";
26
+
27
+ //#region src/paged-editor/hostFonts.d.ts
28
+ /**
29
+ * Host-app custom fonts — the `fonts` prop on `DocxEditor`.
30
+ *
31
+ * The host passes its own brand/web font faces; they register with the browser
32
+ * through the same best-effort `FontFace` path as embedded document fonts
33
+ * ({@link registerFontFace}), so a bad entry is skipped rather than throwing.
34
+ * Once registered, the family name is available for rendering and can be listed
35
+ * in the font-family picker via the `fontFamilies` prop.
36
+ *
37
+ * The prop normalizer ({@link toFontFaceInputs}) is pure (no DOM), so it is
38
+ * unit-tested directly; the DOM registration is visual-only.
39
+ */
40
+ /**
41
+ * Declarative description of one custom font face the host registers with the
42
+ * editor. Multiple entries can share `family` to register distinct weights.
43
+ */
44
+ type FontDefinition = {
45
+ /** CSS `font-family` name to expose; match the family your documents reference. */family: string; /** URL to the font file (woff2, woff, ttf, or otf). */
46
+ src: string; /** CSS `font-weight` for this face (a number like `700`, or a keyword). Defaults to `normal`. */
47
+ weight?: number | string;
48
+ };
49
+ //#endregion
50
+ //#region src/paged-editor/PagedEditor.d.ts
51
+ type PagedEditorRef = {
52
+ /** The headless editor controller (imperative API + events; Seam 6). */getEditor: () => FolioEditor; /** Get the current document. */
53
+ getDocument: () => Document | null; /** Get the ProseMirror EditorState. */
54
+ getState: () => EditorState | null; /** Get the ProseMirror EditorView. */
55
+ getView: () => EditorView | null;
56
+ /**
57
+ * Look up the persistent hidden HF EditorView by `rId`. Returns null when
58
+ * the slot isn't mounted (e.g. document has no HF for that rId, or the
59
+ * hidden host hasn't mounted yet).
60
+ */
61
+ getHfView: (rId: string) => EditorView | null;
62
+ /**
63
+ * Force-create the hidden editor view if it has been deferred.
64
+ * Use from surfaces that need a live view before any user
65
+ * interaction (e.g. AI chat reading a snapshot of the doc).
66
+ */
67
+ ensureView: (options?: {
68
+ focus?: boolean;
69
+ }) => void; /** Focus the editor. */
70
+ focus: () => void; /** Blur the editor. */
71
+ blur: () => void; /** Check if focused. */
72
+ isFocused: () => boolean; /** Dispatch a transaction. */
73
+ dispatch: (tr: Transaction) => void; /** Undo. */
74
+ undo: () => boolean; /** Redo. */
75
+ redo: () => boolean; /** Check whether undo is available. */
76
+ canUndo: () => boolean; /** Check whether redo is available. */
77
+ canRedo: () => boolean; /** Set selection by PM position. */
78
+ setSelection: (anchor: number, head?: number) => void; /** Get current layout. */
79
+ getLayout: () => Layout | null; /** Force re-layout. */
80
+ relayout: () => void; /** Scroll the visible pages to bring a PM position into view. */
81
+ scrollToPosition: (pmPos: number) => void; /** Scroll the visible pages to bring a page into view. */
82
+ scrollToPage: (pageNumber: number) => void;
83
+ /**
84
+ * Scroll the paginated view to the paragraph with the given Word `w14:paraId`.
85
+ * Returns whether a matching paragraph exists in the ProseMirror document.
86
+ */
87
+ scrollToParaId: (paraId: string, options?: ScrollToParaIdOptions) => boolean;
88
+ /** Resolve the page number (1-indexed) that contains the given PM position,
89
+ * or null if no layout is available yet. Works for unrendered pages too via
90
+ * the page shell map. */
91
+ getPageNumberForPmPos: (pmPos: number) => number | null;
92
+ };
93
+ //#endregion
94
+ //#region src/ui/folio-ui.d.ts
95
+ /**
96
+ * Folio chrome (toolbars, dialogs, pickers, find/replace) renders UI primitives
97
+ * that a consumer can override with its own design system. Each entry in
98
+ * {@link FolioUIComponents} is a React component (or a part-object of compound
99
+ * sub-components) folio's chrome renders; the contract grows as more primitives
100
+ * are decoupled from a hard design-system dependency.
101
+ *
102
+ * Compound primitives (Dialog, Select, Menu, Popover) are modeled as
103
+ * part-objects: a typed record of their sub-parts (`Root`, `Popup`, …). Chrome
104
+ * destructures the parts it needs from {@link useFolioUI}; the part shape keeps
105
+ * one key per primitive in the contract and lets the app inject a flat
106
+ * design-system module as a small adapter object. Each part's props are the
107
+ * subset of the underlying `@base-ui/react` part's props folio relies on, so an
108
+ * external component (which accepts a superset) stays assignable as an override.
109
+ *
110
+ * Standalone folio uses {@link DEFAULT_COMPONENTS} (built on `@base-ui/react`,
111
+ * the neutral primitive the app design system also wraps); consumers inject
112
+ * overrides through `DocxEditor`'s `components` prop.
113
+ */
114
+ /**
115
+ * The Button prop subset folio's chrome actually relies on. `variant` and
116
+ * `size` are deliberately narrow string-literal unions: each is a subset of the
117
+ * design-system Button's options so an external Button stays assignable as an
118
+ * override. Native attributes are picked from `<button>` so their types match
119
+ * exactly.
120
+ */
121
+ type FolioButtonProps = Pick<ComponentProps<"button">, "onClick" | "onMouseDown" | "className" | "disabled" | "type" | "title" | "aria-label" | "aria-pressed" | "children"> & {
122
+ variant?: "default" | "ghost";
123
+ size?: "sm" | "xs" | "icon-xs";
124
+ };
125
+ type FolioDialogRootProps = Pick<Dialog.Root.Props, "open" | "onOpenChange"> & {
126
+ children?: ReactNode;
127
+ };
128
+ type FolioDialogPortalProps = {
129
+ children?: ReactNode;
130
+ };
131
+ type FolioDialogBackdropProps = {
132
+ className?: string;
133
+ };
134
+ type FolioDialogPopupProps = {
135
+ className?: string;
136
+ children?: ReactNode;
137
+ };
138
+ type FolioDialogTitleProps = {
139
+ className?: string;
140
+ children?: ReactNode;
141
+ };
142
+ type FolioDialogCloseProps = {
143
+ className?: string;
144
+ children?: ReactNode;
145
+ };
146
+ type FolioDialog = {
147
+ Root: ComponentType<FolioDialogRootProps>;
148
+ Portal: ComponentType<FolioDialogPortalProps>;
149
+ Backdrop: ComponentType<FolioDialogBackdropProps>;
150
+ Popup: ComponentType<FolioDialogPopupProps>;
151
+ Title: ComponentType<FolioDialogTitleProps>;
152
+ Close: ComponentType<FolioDialogCloseProps>;
153
+ };
154
+ type FolioSelectRootProps = Pick<Select.Root.Props<string>, "value" | "onValueChange" | "disabled" | "items"> & {
155
+ children?: ReactNode;
156
+ };
157
+ type FolioSelectTriggerProps = Pick<Select.Trigger.Props, "style" | "aria-label"> & {
158
+ className?: string;
159
+ children?: ReactNode;
160
+ size?: "sm" | "default" | "lg";
161
+ };
162
+ type FolioSelectValueProps = Pick<Select.Value.Props, "placeholder"> & {
163
+ className?: string;
164
+ children?: ReactNode;
165
+ };
166
+ type FolioSelectPopupProps = {
167
+ className?: string;
168
+ children?: ReactNode;
169
+ };
170
+ type FolioSelectItemProps = Pick<Select.Item.Props, "value"> & {
171
+ className?: string;
172
+ children?: ReactNode;
173
+ };
174
+ type FolioSelect = {
175
+ Root: ComponentType<FolioSelectRootProps>;
176
+ Trigger: ComponentType<FolioSelectTriggerProps>;
177
+ Value: ComponentType<FolioSelectValueProps>;
178
+ Popup: ComponentType<FolioSelectPopupProps>;
179
+ Item: ComponentType<FolioSelectItemProps>;
180
+ };
181
+ type FolioMenuRootProps = {
182
+ children?: ReactNode;
183
+ };
184
+ type FolioMenuTriggerProps = Pick<Menu.Trigger.Props, "render" | "disabled" | "type" | "aria-label" | "onMouseDown"> & {
185
+ className?: string;
186
+ children?: ReactNode;
187
+ nativeButton?: boolean;
188
+ };
189
+ type FolioMenuPopupProps = {
190
+ className?: string;
191
+ children?: ReactNode;
192
+ align?: Menu.Positioner.Props["align"];
193
+ side?: Menu.Positioner.Props["side"];
194
+ sideOffset?: Menu.Positioner.Props["sideOffset"];
195
+ alignOffset?: Menu.Positioner.Props["alignOffset"];
196
+ };
197
+ type FolioMenuItemProps = Pick<Menu.Item.Props, "onClick"> & {
198
+ className?: string;
199
+ children?: ReactNode;
200
+ };
201
+ type FolioMenuCheckboxItemProps = Pick<Menu.CheckboxItem.Props, "checked" | "onCheckedChange"> & {
202
+ className?: string;
203
+ children?: ReactNode;
204
+ };
205
+ type FolioMenuGroupProps = {
206
+ children?: ReactNode;
207
+ };
208
+ type FolioMenuGroupLabelProps = {
209
+ className?: string;
210
+ children?: ReactNode;
211
+ };
212
+ type FolioMenuSeparatorProps = {
213
+ className?: string;
214
+ };
215
+ type FolioMenu = {
216
+ Root: ComponentType<FolioMenuRootProps>;
217
+ Trigger: ComponentType<FolioMenuTriggerProps>;
218
+ Popup: ComponentType<FolioMenuPopupProps>;
219
+ Item: ComponentType<FolioMenuItemProps>;
220
+ CheckboxItem: ComponentType<FolioMenuCheckboxItemProps>;
221
+ Group: ComponentType<FolioMenuGroupProps>;
222
+ GroupLabel: ComponentType<FolioMenuGroupLabelProps>;
223
+ Separator: ComponentType<FolioMenuSeparatorProps>;
224
+ };
225
+ type FolioPopoverRootProps = {
226
+ children?: ReactNode;
227
+ };
228
+ type FolioPopoverTriggerProps = Pick<Popover.Trigger.Props, "disabled" | "render"> & {
229
+ className?: string;
230
+ children?: ReactNode;
231
+ "data-testid"?: string;
232
+ };
233
+ type FolioPopoverPopupProps = Pick<Popover.Popup.Props, "onMouseDown"> & {
234
+ className?: string;
235
+ children?: ReactNode;
236
+ side?: Popover.Positioner.Props["side"];
237
+ align?: Popover.Positioner.Props["align"];
238
+ sideOffset?: Popover.Positioner.Props["sideOffset"];
239
+ alignOffset?: Popover.Positioner.Props["alignOffset"];
240
+ };
241
+ type FolioPopoverCloseProps = Pick<Popover.Close.Props, "render"> & {
242
+ className?: string;
243
+ children?: ReactNode;
244
+ };
245
+ type FolioPopover = {
246
+ Root: ComponentType<FolioPopoverRootProps>;
247
+ Trigger: ComponentType<FolioPopoverTriggerProps>;
248
+ Popup: ComponentType<FolioPopoverPopupProps>;
249
+ Close: ComponentType<FolioPopoverCloseProps>;
250
+ };
251
+ type FolioInputProps = Omit<ComponentProps<"input">, "size" | "ref" | "style"> & RefAttributes<HTMLInputElement> & {
252
+ style?: CSSProperties;
253
+ size?: "sm" | "default" | "lg" | number;
254
+ nativeInput?: boolean;
255
+ };
256
+ type FolioCheckboxProps = Pick<Checkbox.Root.Props, "checked" | "onCheckedChange"> & {
257
+ className?: string;
258
+ };
259
+ /**
260
+ * A color preset rendered as a swatch in the picker. Mirrors the design
261
+ * system's preset shape so an external ColorPicker stays assignable as an
262
+ * override; `color` is the optional CSS color for the swatch (falls back to
263
+ * `#${value}`), and `value` is what `onSelect` emits.
264
+ */
265
+ type ColorPreset = {
266
+ label: string;
267
+ value: string;
268
+ color?: string;
269
+ };
270
+ /**
271
+ * The ColorPicker prop subset folio's chrome relies on. The picker wraps a
272
+ * trigger (`children`) in a popover exposing the `presets` plus a custom-color
273
+ * input; `onSelect` fires with a preset value or a 6-char hex (no `#`), and
274
+ * `onClear` clears the color. The design-system ColorPicker accepts a superset
275
+ * (placement, expansion, className) so it stays assignable as an override.
276
+ */
277
+ type FolioColorPickerProps = {
278
+ value?: string | undefined;
279
+ onSelect?: (value: string) => void;
280
+ onClear?: () => void;
281
+ presets?: ColorPreset[];
282
+ columns?: number;
283
+ children: ReactNode;
284
+ };
285
+ /**
286
+ * The DatePickerPopover prop subset folio's chrome relies on. `value` accepts
287
+ * an ISO string, a `Date`, or `null`; `onChange` emits an ISO `yyyy-mm-dd`
288
+ * string (or `null` when cleared). The design-system picker accepts a superset
289
+ * (locale, min/max, overdue styling) so it stays assignable as an override.
290
+ */
291
+ type FolioDatePickerPopoverProps = {
292
+ value: string | Date | null;
293
+ onChange: (value: string | null) => void;
294
+ clearLabel?: string;
295
+ defaultOpen?: boolean;
296
+ showIcon?: boolean;
297
+ };
298
+ /**
299
+ * One entry in the document outline. Mirrors the design system's item shape so
300
+ * an external OutlineRail stays assignable as an override.
301
+ */
302
+ type OutlineItem = {
303
+ id: string;
304
+ label: string; /** Nesting depth; drives indent + tick taper. */
305
+ level: number; /** Optional trailing annotation in the panel (e.g. a page number). */
306
+ meta?: string; /** Optional CSS custom-property name colouring this entry. */
307
+ color?: string;
308
+ };
309
+ /**
310
+ * The OutlineRail prop subset folio's chrome relies on. The rail resolves each
311
+ * item's vertical position via `resolvePct` and navigates via `onJump` (both
312
+ * receive the resolved scroll container). `activeId` controls the highlighted
313
+ * entry. The design-system rail accepts a superset so it stays assignable as an
314
+ * override.
315
+ */
316
+ type FolioOutlineRailProps = {
317
+ items: OutlineItem[];
318
+ scrollContainerRef: RefObject<HTMLElement | null>;
319
+ resolvePct: (id: string, container: HTMLElement) => number | null;
320
+ onJump: (id: string, container: HTMLElement) => void;
321
+ activeId?: string | null;
322
+ topOffset?: number;
323
+ panelWidth?: number;
324
+ ariaLabel?: string;
325
+ };
326
+ type FolioUIComponents = {
327
+ Button: ComponentType<FolioButtonProps>;
328
+ Dialog: FolioDialog;
329
+ Select: FolioSelect;
330
+ Menu: FolioMenu;
331
+ Popover: FolioPopover;
332
+ Input: ComponentType<FolioInputProps>;
333
+ Checkbox: ComponentType<FolioCheckboxProps>;
334
+ ColorPicker: ComponentType<FolioColorPickerProps>;
335
+ DatePickerPopover: ComponentType<FolioDatePickerPopoverProps>;
336
+ OutlineRail: ComponentType<FolioOutlineRailProps>;
337
+ };
338
+ declare function FolioUIProvider({
339
+ components,
340
+ children
341
+ }: {
342
+ components?: Partial<FolioUIComponents> | undefined;
343
+ children: ReactNode;
344
+ }): import("react").JSX.Element;
345
+ //#endregion
346
+ //#region src/components/ui/FontPicker.d.ts
347
+ /**
348
+ * Font Picker — uses Stella's Select component.
349
+ * Each item rendered in its own font for preview.
350
+ */
351
+ type FontOption = {
352
+ name: string;
353
+ fontFamily: string;
354
+ category?: "sans-serif" | "serif" | "monospace" | "other";
355
+ };
356
+ //#endregion
357
+ //#region src/components/ui/ListButtons.d.ts
358
+ /**
359
+ * List formatting buttons: bullet, numbered, indent, outdent.
360
+ */
361
+ type ListType = "bullet" | "numbered" | "none";
362
+ type ListState = {
363
+ type: ListType;
364
+ level: number;
365
+ isInList: boolean;
366
+ numId?: number;
367
+ };
368
+ //#endregion
369
+ //#region src/components/toolbarPrimitives.d.ts
370
+ /**
371
+ * Current formatting state of the selection
372
+ */
373
+ type SelectionFormatting = {
374
+ /** Whether selected text is bold */bold?: boolean | undefined; /** Whether selected text is italic */
375
+ italic?: boolean | undefined; /** Whether selected text is underlined */
376
+ underline?: boolean | undefined; /** Whether selected text has strikethrough */
377
+ strike?: boolean | undefined; /** Whether selected text is superscript */
378
+ superscript?: boolean | undefined; /** Whether selected text is subscript */
379
+ subscript?: boolean | undefined; /** Font family of selected text */
380
+ fontFamily?: string | undefined; /** Font size of selected text (in half-points) */
381
+ fontSize?: number | undefined; /** Text color */
382
+ color?: string | undefined; /** Highlight color */
383
+ highlight?: string | undefined; /** Paragraph alignment */
384
+ alignment?: ParagraphAlignment | undefined; /** List state of the current paragraph */
385
+ listState?: ListState | undefined; /** Line spacing in twips (OOXML value, 240 = single spacing) */
386
+ lineSpacing?: number | undefined; /** Paragraph style ID */
387
+ styleId?: string | undefined; /** Paragraph left indentation in twips */
388
+ indentLeft?: number | undefined; /** Whether the paragraph is RTL (bidi) */
389
+ bidi?: boolean | undefined;
390
+ };
391
+ /**
392
+ * Formatting action types
393
+ */
394
+ type FormattingAction = "bold" | "italic" | "underline" | "strikethrough" | "superscript" | "subscript" | "clearFormatting" | "bulletList" | "numberedList" | "indent" | "outdent" | "insertPageBreak" | "setRtl" | "setLtr" | {
395
+ type: "toggleDirection";
396
+ } | {
397
+ type: "fontFamily";
398
+ value: string;
399
+ } | {
400
+ type: "fontSize";
401
+ value: number;
402
+ } | {
403
+ type: "textColor";
404
+ value: ColorValue | string;
405
+ } | {
406
+ type: "highlightColor";
407
+ value: string;
408
+ } | {
409
+ type: "alignment";
410
+ value: ParagraphAlignment;
411
+ } | {
412
+ type: "lineSpacing";
413
+ value: number;
414
+ } | {
415
+ type: "applyStyle";
416
+ value: string;
417
+ };
418
+ /**
419
+ * Props for the Toolbar component
420
+ */
421
+ type ToolbarProps = {
422
+ /** Current formatting of the selection */currentFormatting?: SelectionFormatting | undefined; /** Callback when a formatting action is triggered */
423
+ onFormat?: ((action: FormattingAction) => void) | undefined; /** Callback for undo action */
424
+ onUndo?: (() => void) | undefined; /** Callback for redo action */
425
+ onRedo?: (() => void) | undefined; /** Whether undo is available */
426
+ canUndo?: boolean | undefined; /** Whether redo is available */
427
+ canRedo?: boolean | undefined; /** Whether the toolbar is disabled */
428
+ disabled?: boolean | undefined; /** Additional CSS class name */
429
+ className?: string | undefined; /** Additional inline styles */
430
+ style?: CSSProperties | undefined; /** Whether to enable keyboard shortcuts (default: true) */
431
+ enableShortcuts?: boolean | undefined; /** Ref to the editor container for keyboard events */
432
+ editorRef?: React$1.RefObject<HTMLElement | null> | undefined; /** Custom toolbar items to render */
433
+ children?: ReactNode | undefined; /** Whether to show font family picker (default: true) */
434
+ showFontPicker?: boolean | undefined;
435
+ /**
436
+ * Custom families for the font-family dropdown (strings and/or `FontOption`
437
+ * objects). Omit to use the built-in defaults; an empty array renders an
438
+ * empty dropdown. Normalized to `FontOption[]` before reaching the picker.
439
+ */
440
+ fontFamilies?: ReadonlyArray<string | FontOption> | undefined; /** Whether to show font size picker (default: true) */
441
+ showFontSizePicker?: boolean | undefined; /** Whether to show text color picker (default: true) */
442
+ showTextColorPicker?: boolean | undefined; /** Whether to show highlight color picker (default: true) */
443
+ showHighlightColorPicker?: boolean | undefined; /** Whether to show alignment buttons (default: true) */
444
+ showAlignmentButtons?: boolean | undefined; /** Whether to show list buttons (default: true) */
445
+ showListButtons?: boolean | undefined; /** Whether to show line spacing picker (default: true) */
446
+ showLineSpacingPicker?: boolean | undefined; /** Whether to show style picker (default: true) */
447
+ showStylePicker?: boolean | undefined; /** Whether to show the format painter button (default: true) */
448
+ showFormatPainter?: boolean | undefined; /** Whether the format painter is armed (drives the button's active state) */
449
+ formatPainterActive?: boolean | undefined;
450
+ /**
451
+ * Arm the format painter: capture the current selection's formatting so the
452
+ * next selection is painted. `sticky` (double-click) keeps it armed until Esc
453
+ * or a toggle off; a single click disarms after one paint.
454
+ */
455
+ onFormatPainter?: ((sticky: boolean) => void) | undefined; /** Document styles for the style picker */
456
+ documentStyles?: Style[] | undefined; /** Theme for the style picker */
457
+ theme?: Theme | null | undefined; /** Callback for print action */
458
+ onPrint?: (() => void) | undefined; /** Whether to show print button (default: true) */
459
+ showPrintButton?: boolean | undefined; /** Whether to show zoom control (default: true) */
460
+ showZoomControl?: boolean | undefined; /** Current zoom level (1.0 = 100%) */
461
+ zoom?: number | undefined; /** Callback when zoom changes */
462
+ onZoomChange?: ((zoom: number) => void) | undefined; /** Whether the rulers are currently visible (drives the toggle's active state) */
463
+ rulerVisible?: boolean | undefined; /** Toggle the rulers on/off. The ruler control renders only when this is provided. */
464
+ onToggleRuler?: (() => void) | undefined; /** Callback to refocus the editor after toolbar interactions */
465
+ onRefocusEditor?: (() => void) | undefined; /** Callback when a table should be inserted */
466
+ onInsertTable?: ((rows: number, columns: number) => void) | undefined; /** Whether to show table insert button (default: true) */
467
+ showTableInsert?: boolean | undefined; /** Callback when user wants to insert an image */
468
+ onInsertImage?: (() => void) | undefined; /** Callback when user wants to insert a page break */
469
+ onInsertPageBreak?: (() => void) | undefined; /** Callback when user wants to insert a table of contents */
470
+ onInsertTOC?: (() => void) | undefined; /** Callback when user wants to insert a shape */
471
+ onInsertShape?: (data: {
472
+ shapeType: string;
473
+ width: number;
474
+ height: number;
475
+ fillColor?: string | undefined;
476
+ fillType?: string | undefined;
477
+ outlineWidth?: number | undefined;
478
+ outlineColor?: string | undefined;
479
+ }) => void; /** Image context when an image is selected */
480
+ imageContext?: {
481
+ wrapType: string;
482
+ displayMode: string;
483
+ cssFloat: string | null;
484
+ } | null; /** Callback when image wrap type changes */
485
+ onImageWrapType?: ((wrapType: string) => void) | undefined; /** Callback for image transform (rotate/flip) */
486
+ onImageTransform?: (action: "rotateCW" | "rotateCCW" | "flipH" | "flipV") => void; /** Callback to open image properties dialog (alt text + border) */
487
+ onOpenImageProperties?: (() => void) | undefined; /** Callback to open page setup dialog */
488
+ onPageSetup?: (() => void) | undefined; /** Table context when cursor is in a table */
489
+ tableContext?: {
490
+ isInTable: boolean;
491
+ rowCount?: number | undefined;
492
+ columnCount?: number | undefined;
493
+ canSplitCell?: boolean | undefined;
494
+ hasMultiCellSelection?: boolean | undefined;
495
+ cellBorderColor?: ColorValue | undefined;
496
+ cellBackgroundColor?: string | undefined;
497
+ } | null; /** Callback when a table action is triggered */
498
+ onTableAction?: ((action: TableAction) => void) | undefined;
499
+ };
500
+ //#endregion
501
+ //#region src/components/DocxEditor.props.d.ts
502
+ type DocxEditorProps = {
503
+ /** Document data — ArrayBuffer, Uint8Array, Blob, or File */documentBuffer?: DocxInput | null; /** Password for Agile-encrypted .docx files (Office 2010+). */
504
+ password?: string | undefined; /** Pre-parsed document (alternative to documentBuffer) */
505
+ document?: Document | null;
506
+ /**
507
+ * Stable identity of the loaded document (same across internal edits, distinct
508
+ * per loaded file, e.g. a file/document id). Used to distinguish a genuine
509
+ * external load from an edited document round-tripped back through state.
510
+ * Falls back to a document-metadata signature when omitted.
511
+ */
512
+ documentKey?: string; /** Callback when document is saved */
513
+ onSave?: (buffer: ArrayBuffer) => void; /** Author name used for comments and track changes */
514
+ author?: string; /** Callback when document changes */
515
+ onChange?: (document: Document) => void; /** Callback when selection changes */
516
+ onSelectionChange?: (state: SelectionState | null) => void;
517
+ /**
518
+ * Callback fired with the resolved PM positions and the
519
+ * selected plain text on every selection-bearing
520
+ * transaction. Useful for consumers (e.g. the inspector
521
+ * "Term to anonymize" prefill) that want the selected
522
+ * phrase without holding a reference to the editor view.
523
+ * Atom inline nodes (tab, hard_break) collapse to a
524
+ * single space in the returned text. Empty string when
525
+ * the selection is collapsed.
526
+ */
527
+ onSelectionTextChange?: (selection: {
528
+ from: number;
529
+ to: number;
530
+ text: string;
531
+ }) => void; /** Callback on error */
532
+ onError?: (error: Error) => void; /** Callback when fonts are loaded */
533
+ onFontsLoaded?: () => void;
534
+ /**
535
+ * Custom families shown in the toolbar's font-family dropdown. Strings render
536
+ * as plain family names; pass `FontOption` objects for a CSS fallback chain
537
+ * and category grouping. Omit to use folio's built-in defaults; an empty
538
+ * array renders an empty (but enabled) dropdown. Pass a stable reference — an
539
+ * inline array is a fresh identity every render.
540
+ */
541
+ fontFamilies?: ReadonlyArray<string | FontOption>;
542
+ /**
543
+ * Custom font faces the host registers with the browser (its own brand/web
544
+ * fonts) so runs render in them. Each entry injects one face via the
545
+ * `FontFace` API; multiple entries can share `family` for different weights.
546
+ * Registration is best-effort: a malformed entry is skipped, never thrown.
547
+ * Match `family` to the `fontFamilies` name a user applies. Pass a stable
548
+ * reference — a new array identity re-registers on every render.
549
+ */
550
+ fonts?: ReadonlyArray<FontDefinition>; /** Theme for styling */
551
+ theme?: Theme | null; /** Whether to show toolbar (default: true) */
552
+ showToolbar?: boolean; /** Whether to show zoom control (default: true) */
553
+ showZoomControl?: boolean;
554
+ /**
555
+ * Whether to show the review controls — the track-changes toggle and the
556
+ * markup display-mode selector (All Markup / Simple / No Markup / Original)
557
+ * (default: true). Turn off for plain-markdown editing, where tracked changes
558
+ * and markup views are meaningless.
559
+ */
560
+ showReviewControls?: boolean;
561
+ /**
562
+ * Whether the page header/footer can be edited — the double-click-to-edit
563
+ * behavior and the "Double-click to add header/footer" hover hints
564
+ * (default: true). Turn off for plain-markdown editing, which has no running
565
+ * header/footer.
566
+ */
567
+ showHeaderFooterEditing?: boolean; /** Whether to show page margin guides/boundaries (default: false) */
568
+ showMarginGuides?: boolean; /** Color for margin guides (default: '#c0c0c0') */
569
+ marginGuideColor?: string;
570
+ /**
571
+ * Whether the horizontal and vertical rulers start visible (default: false).
572
+ * Seeds the initial state of the toolbar's ruler toggle; users show/hide the
573
+ * rulers at runtime from there (like Word's View > Ruler).
574
+ */
575
+ showRuler?: boolean; /** Measurement unit shown on the rulers (default: 'inch'). */
576
+ rulerUnit?: "inch" | "cm"; /** Initial zoom level (default: 1.0) */
577
+ initialZoom?: number; /** Whether Ctrl/Cmd+wheel and trackpad-pinch zoom are enabled (default: true) */
578
+ enableWheelZoom?: boolean; /** Whether the editor is read-only. When true, hides toolbar and rulers */
579
+ readOnly?: boolean; /** Whether comments/tracked changes should auto-open the review sidebar (default: true) */
580
+ autoOpenReviewSidebar?: boolean;
581
+ /**
582
+ * Override folio's built-in chrome UI primitives (Button, …) with a
583
+ * consumer's design-system components. Omitted entries fall back to folio's
584
+ * built-in defaults, so standalone folio works without any injection.
585
+ */
586
+ components?: Partial<FolioUIComponents>; /** Custom toolbar actions */
587
+ toolbarExtra?: ReactNode; /** Additional CSS class name */
588
+ className?: string; /** Additional inline styles */
589
+ style?: CSSProperties; /** Placeholder when no document */
590
+ placeholder?: ReactNode; /** Loading indicator */
591
+ loadingIndicator?: ReactNode; /** Keep the current parsed document visible while a new buffer is loading. */
592
+ preserveDocumentWhileLoading?: boolean; /** Initial scroll offset for the editor's document scroll container. */
593
+ initialScrollTop?: number; /** Callback when the editor's document scroll container scrolls. */
594
+ onScrollTopChange?: (scrollTop: number) => void; /** Whether to show the document outline sidebar (default: false) */
595
+ showOutline?: boolean; /** Whether to show print button in toolbar (default: true) */
596
+ showPrintButton?: boolean; /** Callback when print is triggered */
597
+ onPrint?: () => void;
598
+ /**
599
+ * Insert controls are opt-in: each toolbar control renders only when its
600
+ * handler is provided (and, for tables, `showTableInsert` is not false). Omit
601
+ * a handler to keep that control out of the toolbar. Wire these to the
602
+ * view-level helpers exported from the package (`insertTableInView`,
603
+ * `insertPageBreakInView`, `insertTableOfContentsInView`, `insertImageFromFile`).
604
+ */
605
+ onInsertImage?: (() => void) | undefined; /** Insert a `rows × columns` table at the current selection. */
606
+ onInsertTable?: ((rows: number, columns: number) => void) | undefined; /** Whether the Insert Table control is shown when `onInsertTable` is set (default: true). */
607
+ showTableInsert?: boolean | undefined; /** Insert a page break at the current selection. */
608
+ onInsertPageBreak?: (() => void) | undefined; /** Insert a table of contents generated from the document's headings. */
609
+ onInsertTOC?: (() => void) | undefined; /** Callback when content is copied */
610
+ onCopy?: () => void; /** Callback when content is cut */
611
+ onCut?: () => void; /** Callback when content is pasted */
612
+ onPaste?: () => void; /** Editor mode: 'editing' (direct edits), 'suggesting' (track changes), or 'viewing' (read-only). Default: 'editing' */
613
+ mode?: EditorMode; /** Callback when the editing mode changes */
614
+ onModeChange?: (mode: EditorMode) => void; /** Callback when a readonly user action would mutate the document. */
615
+ onReadonlyEditAttempt?: () => void;
616
+ /**
617
+ * Controlled comments array. When provided, the editor reads comment thread
618
+ * metadata from this prop and emits every change through `onCommentsChange`.
619
+ * Use with collaboration backends (Yjs, etc.) so comment threads sync across
620
+ * peers; PM carries range markers, thread metadata lives outside the doc.
621
+ */
622
+ comments?: Comment[]; /** Fires whenever the comments array changes (controlled and uncontrolled). */
623
+ onCommentsChange?: (comments: Comment[]) => void; /** Callback with the parsed document's editing compatibility report. */
624
+ onCompatibilityChange?: (compatibility: DocxCompatibility) => void;
625
+ /**
626
+ * Fires when the live ProseMirror view is captured (or torn down).
627
+ * The host wires this so it can drive the AI suggestion overlay
628
+ * (decoration meta, apply, scroll-to) from outside the editor.
629
+ */
630
+ onEditorViewReady?: (view: EditorView | null) => void; /** Yjs-backed collaboration owner. Experimental and opt-in. */
631
+ collaboration?: DocxEditorCollaboration | undefined;
632
+ /**
633
+ * Fires with the current anonymization match list every time
634
+ * the decoration plugin recomputes it (initial mount, term
635
+ * push, doc edit, async DOCX load). The host uses this to
636
+ * mirror per-document counts and "matching workspace terms"
637
+ * to the inspector facet without polling the plugin state.
638
+ */
639
+ onAnonymizationMatchesChange?: (matches: readonly AnonymizationMatch[]) => void;
640
+ /**
641
+ * Fires when the user clicks an anonymization highlight in
642
+ * the rendered document. Hosts use this to push the
643
+ * selection into a sidebar bridge so the inspector facet can
644
+ * scroll/flash the matching row.
645
+ */
646
+ onAnonymizationTermClick?: ((canonical: string, label: string) => void) | undefined;
647
+ /**
648
+ * Canonical to mark as selected in the rendered document.
649
+ * The first matching rect scrolls into view whenever
650
+ * `anonymizationSelectionSeq` increments (so repeated
651
+ * sidebar clicks of the same term re-trigger the scroll).
652
+ */
653
+ selectedAnonymizationCanonical?: string | null | undefined; /** Monotonic counter from the bridge store; drives the re-scroll. */
654
+ anonymizationSelectionSeq?: number | undefined;
655
+ /**
656
+ * Render legal-template markers ({{field}}, {{@clause:..}},
657
+ * {{#if}}/{{#each}}) as rich widgets on the page instead of raw
658
+ * text. Off for ordinary documents; on for the template editor.
659
+ */
660
+ showTemplateDirectives?: boolean | undefined;
661
+ /**
662
+ * Fires when the template editor's `/` slash-command trigger opens, its
663
+ * typed query changes, or it closes. Only active alongside
664
+ * `showTemplateDirectives`. The host renders the floating menu and inserts
665
+ * the chosen marker; the plugin owns only the trigger state.
666
+ */
667
+ onSlashMenuChange?: ((state: TemplateSlashMenuState) => void) | undefined;
668
+ /**
669
+ * Resolves a navigation/commit key (Up / Down / Enter) while the slash menu
670
+ * is open. Return `true` to let the editor swallow the key (the host moved
671
+ * the highlight or performed the insertion). Escape is handled inside the
672
+ * plugin and never reaches this callback.
673
+ */
674
+ onSlashMenuKeyAction?: ((action: TemplateSlashMenuKeyAction) => boolean) | undefined;
675
+ /**
676
+ * Host-provided text context-menu entries, appended after the built-ins.
677
+ * `requiresSelection` items only render when text is selected. Selecting one
678
+ * fires `onCustomContextAction` with the item id and the selection range
679
+ * captured when the menu opened (right-click can collapse the live PM
680
+ * selection, so the captured range is the reliable one).
681
+ */
682
+ customContextMenuItems?: readonly {
683
+ id: string;
684
+ label: string;
685
+ requiresSelection?: boolean;
686
+ icon?: ReactNode;
687
+ }[] | undefined;
688
+ onCustomContextAction?: ((id: string, selectionRange: {
689
+ from: number;
690
+ to: number;
691
+ }) => void) | undefined;
692
+ /**
693
+ * Operational flags for save-path features. Selective save and its tripwire
694
+ * mode are OFF by default; hosts opt in once their rollout pipeline is ready.
695
+ */
696
+ featureFlags?: FolioSelectiveSaveFlags;
697
+ /**
698
+ * Receives the structured comparison between selective save and full repack
699
+ * whenever {@link FolioSelectiveSaveFlags.selectiveSaveTripwire} is enabled.
700
+ * Saves are never blocked by the tripwire; this is observability only.
701
+ */
702
+ onSelectiveSaveTripwire?: (result: TripwireResult) => void;
703
+ };
704
+ type DocxEditorCollaboration = {
705
+ awareness?: {
706
+ clientID: number;
707
+ getStates: () => Map<number, unknown>;
708
+ off: (event: "change" | "update", handler: () => void) => void;
709
+ on: (event: "change" | "update", handler: () => void) => void;
710
+ } | undefined;
711
+ onSeeded?: (() => void) | undefined;
712
+ plugins?: Plugin[] | undefined;
713
+ shouldSeed?: boolean | undefined;
714
+ yXmlFragment: XmlFragment;
715
+ };
716
+ /**
717
+ * Imperative handle exposed by the DocxEditor component.
718
+ */
719
+ type DocxEditorRef = {
720
+ /** Get the current document */getDocument: () => Document | null; /** Whether the live ProseMirror state has edits that have not been serialized. */
721
+ hasPendingChanges: () => boolean; /** Get the editor ref */
722
+ getEditorRef: () => PagedEditorRef | null; /** The headless editor controller (Seam 6), or null before the editor mounts. */
723
+ getEditor: () => FolioEditor | null; /** Save the document to buffer. Pass { selective: false } to force full repack. */
724
+ save: (options?: {
725
+ selective?: boolean;
726
+ }) => Promise<ArrayBuffer | null>; /** Set zoom level */
727
+ setZoom: (zoom: number) => void; /** Get current zoom level */
728
+ getZoom: () => number; /** Focus the editor */
729
+ focus: () => void; /** Get current page number */
730
+ getCurrentPage: () => number; /** Get total page count */
731
+ getTotalPages: () => number; /** Scroll to a specific page */
732
+ scrollToPage: (pageNumber: number) => void;
733
+ /**
734
+ * Scroll the paginated view to the paragraph with the given Word `w14:paraId`.
735
+ * Pass `options.highlight` to briefly flash it in a custom color.
736
+ */
737
+ scrollToParaId: (paraId: string, options?: ScrollToParaIdOptions) => boolean; /** Open print preview */
738
+ openPrintPreview: () => void; /** Print the document directly */
739
+ print: () => void; /** Load a pre-parsed document programmatically */
740
+ loadDocument: (doc: Document) => void; /** Load a DOCX buffer programmatically (ArrayBuffer, Uint8Array, Blob, or File) */
741
+ loadDocumentBuffer: (buffer: DocxInput) => Promise<void>;
742
+ /**
743
+ * Force-create the underlying editor view if it has been deferred.
744
+ * Surfaces that need a live view before the user interacts with the
745
+ * document body (notably the AI chat composer, which gates "send"
746
+ * on snapshot availability) must call this once on mount with
747
+ * `focus: false`; otherwise the perf deferral keeps the view null
748
+ * and they wait forever.
749
+ */
750
+ ensureEditorView: (options?: {
751
+ focus?: boolean;
752
+ }) => void; /** Create the block snapshot that an external AI editor should reference. */
753
+ createAIEditSnapshot: () => FolioAIEditSnapshot | null; /** Apply AI-authored operations against a previously created block snapshot. */
754
+ applyAIEditOperations: (options: {
755
+ snapshot: FolioAIEditSnapshot;
756
+ operations: FolioAIEditOperation[];
757
+ mode?: FolioAIEditApplyMode;
758
+ author?: string;
759
+ }) => FolioAIEditApplyResult;
760
+ /**
761
+ * Accept the tracked-change marks belonging to a previously applied AI edit.
762
+ * Pass a single id for inserts/standalone deletions, or the full id list
763
+ * (`applied.revisionIds`) for a replace, which has separate ids for its
764
+ * deletion and insertion sides. Returns whether a matching range was found.
765
+ */
766
+ acceptAIEditOperation: (revisionIds: number | readonly number[]) => boolean;
767
+ /**
768
+ * Reject the tracked-change marks belonging to a previously applied AI edit.
769
+ * Same id semantics as `acceptAIEditOperation`.
770
+ */
771
+ rejectAIEditOperation: (revisionIds: number | readonly number[]) => boolean;
772
+ /**
773
+ * Undo / redo the last history-recorded edit IN PLACE — e.g. an
774
+ * `acceptAIEditOperation` / `rejectAIEditOperation` resolution — without
775
+ * reloading the document, so the view and scroll position are preserved.
776
+ * Routes to whichever surface is active: the inline header/footer editor
777
+ * when one is being edited, otherwise the document body. Only edits that
778
+ * produce document changes are recorded; selection-only changes (scroll /
779
+ * locate) carry no steps and are never undone. Returns `false` when there
780
+ * is nothing to undo / redo.
781
+ *
782
+ * Ports upstream docx-editor `feat(react): accept/reject and undo/redo
783
+ * tracked changes via the editor ref` (ff971a7b): folio already exposes
784
+ * id-scoped accept/reject through `acceptAIEditOperation` /
785
+ * `rejectAIEditOperation`, so only the in-place undo/redo surface is new.
786
+ */
787
+ undo: () => boolean;
788
+ redo: () => boolean;
789
+ /**
790
+ * Scroll the editor viewport so the tracked-change marks belonging to the
791
+ * given `revisionIds` come into view, and select them. No-op when none of the
792
+ * revisions are present.
793
+ */
794
+ scrollToAIEditOperation: (revisionIds: number | readonly number[]) => boolean;
795
+ /**
796
+ * Scroll the editor viewport so the block referenced by `blockId` is in view,
797
+ * and place the selection inside it. Returns `false` when the block can't be
798
+ * resolved on the live document (e.g. it was edited away).
799
+ *
800
+ * When `snapshot` is supplied, ids resolve against it — required for review
801
+ * panel pending-suggestion navigation, because block ids are sequential and
802
+ * a freshly recomputed snapshot would re-number blocks after a structural
803
+ * accept (insertAfterBlock / deleteBlock). Without `snapshot`, falls back to
804
+ * a fresh-from-live-doc snapshot.
805
+ */
806
+ scrollToBlock: (blockId: string, snapshot?: FolioAIEditSnapshot) => boolean;
807
+ /**
808
+ * The tracked changes (insertions and deletions) present in the live
809
+ * document, read from the current ProseMirror `state.doc`. Empty array
810
+ * before the editor view mounts.
811
+ */
812
+ getTrackedChanges: () => FolioReviewChange[];
813
+ /**
814
+ * The comment anchors present in the live document, read from the current
815
+ * ProseMirror `state.doc`. Empty array before the editor view mounts.
816
+ */
817
+ getCommentAnchors: () => FolioCommentAnchor[];
818
+ /**
819
+ * The plain text of the current selection, or `""` when the editor has no
820
+ * view or the selection is collapsed.
821
+ */
822
+ getSelectionText: () => string;
823
+ /**
824
+ * The plain text of a single rendered page (1-based), joining each of its
825
+ * layout fragments with a newline. Returns `null` when the page number is
826
+ * out of range or the layout hasn't been computed yet.
827
+ */
828
+ getPageText: (page: number) => string | null;
829
+ /**
830
+ * List every block-level content control in the live document, filtered by
831
+ * tag / alias / id / sdtType. Returns the modeled SdtProperties projection
832
+ * plus a synthetic identifier so callers can address each control by
833
+ * insertion order even if tag/alias collide.
834
+ *
835
+ * IMPORTANT: the returned `pmPos` values are valid only for the document
836
+ * state at fetch time. After any mutation that changes earlier content's
837
+ * size (`setContentControlContent`, `setContentControlValue`,
838
+ * `removeContentControl`, etc.), later controls shift and stored
839
+ * `pmPos` values become stale. For batch-fill flows over duplicate-tag
840
+ * controls, either refetch via `getContentControls()` after each
841
+ * mutation, or address by stable `{ tag }` / `{ id }` / `{ alias }` so
842
+ * the lookup uses the document's current shape on every call.
843
+ */
844
+ getContentControls: (filter?: ContentControlFilter) => {
845
+ properties: SdtProperties; /** Index in the PM document tree, outer→inner. */
846
+ path: number[];
847
+ /**
848
+ * PM position of the control's open token in the SOURCE document state.
849
+ * Disambiguates duplicates within one snapshot, but does not survive
850
+ * mutations that resize earlier content — see `getContentControls`
851
+ * for the refetch / address-by-tag guidance.
852
+ */
853
+ pmPos: number;
854
+ }[];
855
+ /**
856
+ * Scroll to the first content control matching the filter and place the
857
+ * caret inside it. Returns false when no match is present.
858
+ */
859
+ scrollToContentControl: (filter: ContentControlFilter) => boolean;
860
+ /**
861
+ * Replace a control's inner content with plain text or pre-built block
862
+ * content. Locked controls throw `ContentControlLockedError` unless
863
+ * `{ force: true }` is passed. Writes go through a normal undoable
864
+ * transaction.
865
+ */
866
+ setContentControlContent: (filter: ContentControlFilter, input: SetContentControlContentInput, options?: {
867
+ force?: boolean;
868
+ }) => boolean;
869
+ /**
870
+ * Set a structured value on a typed control (dropdown / checkbox / date).
871
+ * Throws `ContentControlTypeError` when the input shape does not match the
872
+ * control's sdtType. Writes go through a normal undoable transaction.
873
+ */
874
+ setContentControlValue: (filter: ContentControlFilter, input: SetContentControlValueInput, options?: {
875
+ force?: boolean;
876
+ }) => boolean;
877
+ /**
878
+ * Remove a control. With `{ keepContent: true }` the inner blocks survive
879
+ * in-place; otherwise the wrapper and its children are dropped. Refuses to
880
+ * unwrap a `w15:repeatingSection` (would orphan its row items) unless
881
+ * `{ force: true }` is passed.
882
+ */
883
+ removeContentControl: (filter: ContentControlFilter, options?: {
884
+ keepContent?: boolean;
885
+ force?: boolean;
886
+ }) => boolean;
887
+ };
888
+ //#endregion
889
+ //#region src/renderAsync.d.ts
890
+ /** Framework-agnostic handle for an imperatively mounted editor instance. */
891
+ type EditorHandle = {
892
+ /** Save the document and return the DOCX as a Blob. */save: () => Promise<Blob | null>; /** Get the current parsed document model. */
893
+ getDocument: () => Document | null; /** Focus the editor. */
894
+ focus: () => void; /** Unmount the editor and clean up. */
895
+ destroy: () => void;
896
+ };
897
+ /** React-specific handle with zoom and scroll helpers. */
898
+ type DocxEditorHandle = EditorHandle & {
899
+ /** Set zoom level (1.0 = 100%). */setZoom: (zoom: number) => void; /** Scroll the visible pages to a raw ProseMirror document position. */
900
+ scrollToPosition: (pmPos: number) => void; /** Scroll the visible pages to a 1-indexed page number. */
901
+ scrollToPage: (pageNumber: number) => void;
902
+ };
903
+ /** Options for {@link renderAsync}. */
904
+ type RenderAsyncOptions = Omit<DocxEditorProps, "documentBuffer" | "document"> & {
905
+ /** BCP-47 locale for bundled folio UI strings (default: `en`). */locale?: string;
906
+ };
907
+ /**
908
+ * Render a DOCX editor into a container element.
909
+ *
910
+ * Resolves once the document has parsed and the first `onChange` fires.
911
+ * Rejects if `onError` runs before that milestone.
912
+ */
913
+ declare const renderAsync: (input: DocxInput, container: HTMLElement, options?: RenderAsyncOptions) => Promise<DocxEditorHandle>;
914
+ //#endregion
915
+ export { DocxEditorCollaboration as a, ToolbarProps as c, ColorPreset as d, FolioButtonProps as f, FontDefinition as g, OutlineItem as h, renderAsync as i, EditorMode as l, FolioUIProvider as m, EditorHandle as n, DocxEditorProps as o, FolioUIComponents as p, RenderAsyncOptions as r, DocxEditorRef as s, DocxEditorHandle as t, FontOption as u };