@stll/folio-react 0.4.0 → 0.5.0

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