@stll/folio-react 0.0.1-placeholder.0 → 0.1.1

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