@stll/folio-react 0.12.1 → 0.12.3
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/compat/eigenpal.d.ts +2 -7
- package/dist/{dialogs-auOIiNGI.d.ts → dialogs-lCOx21mG.d.ts} +40 -105
- package/dist/dialogs.d.ts +1 -1
- package/dist/editor.css +1 -1
- package/dist/index.d.ts +68 -46
- package/dist/{renderAsync-D2OJupOm.d.ts → renderAsync-CH8S7yqU.d.ts} +324 -160
- package/dist/standalone.css +1 -1
- package/package.json +5 -5
|
@@ -17,15 +17,19 @@ import { ColorValue, Document, ParagraphAlignment, SdtProperties, SectionPropert
|
|
|
17
17
|
import { Comment } from "@stll/folio-core/types/content";
|
|
18
18
|
import { DocxInput } from "@stll/folio-core/utils/docxInput";
|
|
19
19
|
import { ScrollToParaIdOptions } from "@stll/folio-core/paged-layout/paragraphFlash";
|
|
20
|
+
import "@stll/folio-core/controller/noteEditorManager";
|
|
20
21
|
import { Layout } from "@stll/folio-core/layout-engine/types";
|
|
22
|
+
import "@stll/folio-core/prosemirror/extensions/ExtensionManager";
|
|
23
|
+
import "@stll/folio-core/controller/hiddenEditorManager";
|
|
21
24
|
import { Checkbox } from "@base-ui/react/checkbox";
|
|
22
25
|
import { Dialog } from "@base-ui/react/dialog";
|
|
23
26
|
import { Menu } from "@base-ui/react/menu";
|
|
24
27
|
import { Popover } from "@base-ui/react/popover";
|
|
25
28
|
import { Select } from "@base-ui/react/select";
|
|
29
|
+
import "@stll/folio-core/managers/DocumentLoaderManager";
|
|
30
|
+
import "@stll/folio-core/managers/HistoryManager";
|
|
26
31
|
import { EditorMode } from "@stll/folio-core/managers/EditorModeManager";
|
|
27
32
|
import { TableAction } from "@stll/folio-core/utils/tableOperations";
|
|
28
|
-
|
|
29
33
|
//#region src/paged-editor/hostFonts.d.ts
|
|
30
34
|
/**
|
|
31
35
|
* Host-app custom fonts — the `fonts` prop on `DocxEditor`.
|
|
@@ -44,19 +48,29 @@ import { TableAction } from "@stll/folio-core/utils/tableOperations";
|
|
|
44
48
|
* editor. Multiple entries can share `family` to register distinct weights.
|
|
45
49
|
*/
|
|
46
50
|
type FontDefinition = {
|
|
47
|
-
/** CSS `font-family` name to expose; match the family your documents reference. */
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
/** CSS `font-family` name to expose; match the family your documents reference. */
|
|
52
|
+
family: string;
|
|
53
|
+
/** URL to the font file (woff2, woff, ttf, or otf). */
|
|
54
|
+
src: string;
|
|
55
|
+
/** CSS `font-weight` for this face (a number like `700`, or a keyword). Defaults to `normal`. */
|
|
56
|
+
weight?: number | string;
|
|
57
|
+
/** CSS `font-style` for this face (for example `italic`). Defaults to `normal`. */
|
|
50
58
|
style?: string;
|
|
51
59
|
};
|
|
52
60
|
//#endregion
|
|
53
61
|
//#region src/paged-editor/PagedEditor.d.ts
|
|
54
62
|
type PagedEditorRef = {
|
|
55
|
-
/** The headless editor controller (imperative API + events; Seam 6). */
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
/** The headless editor controller (imperative API + events; Seam 6). */
|
|
64
|
+
getEditor: () => FolioEditor;
|
|
65
|
+
/** Get the current document. */
|
|
66
|
+
getDocument: () => Document | null;
|
|
67
|
+
/** Get the ProseMirror EditorState. */
|
|
68
|
+
getState: () => EditorState | null;
|
|
69
|
+
/** Get the ProseMirror EditorView. */
|
|
70
|
+
getView: () => EditorView | null;
|
|
71
|
+
/** Get the active body, header/footer, or note-story view. */
|
|
72
|
+
getActiveView: () => EditorView | null;
|
|
73
|
+
/** Close the visible note story, if one is active. */
|
|
60
74
|
closeNoteStory: () => void;
|
|
61
75
|
/**
|
|
62
76
|
* Look up the persistent hidden HF EditorView by `rId`. Returns null when
|
|
@@ -71,19 +85,32 @@ type PagedEditorRef = {
|
|
|
71
85
|
*/
|
|
72
86
|
ensureView: (options?: {
|
|
73
87
|
focus?: boolean;
|
|
74
|
-
}) => void;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
}) => void;
|
|
89
|
+
/** Focus the editor. */
|
|
90
|
+
focus: () => void;
|
|
91
|
+
/** Blur the editor. */
|
|
92
|
+
blur: () => void;
|
|
93
|
+
/** Check if focused. */
|
|
94
|
+
isFocused: () => boolean;
|
|
95
|
+
/** Dispatch a transaction. */
|
|
96
|
+
dispatch: (tr: Transaction) => void;
|
|
97
|
+
/** Undo. */
|
|
98
|
+
undo: () => boolean;
|
|
99
|
+
/** Redo. */
|
|
100
|
+
redo: () => boolean;
|
|
101
|
+
/** Check whether undo is available. */
|
|
102
|
+
canUndo: () => boolean;
|
|
103
|
+
/** Check whether redo is available. */
|
|
104
|
+
canRedo: () => boolean;
|
|
105
|
+
/** Set selection by PM position. */
|
|
106
|
+
setSelection: (anchor: number, head?: number) => void;
|
|
107
|
+
/** Get current layout. */
|
|
108
|
+
getLayout: () => Layout | null;
|
|
109
|
+
/** Force re-layout. */
|
|
110
|
+
relayout: () => void;
|
|
111
|
+
/** Scroll the visible pages to bring a PM position into view. */
|
|
112
|
+
scrollToPosition: (pmPos: number) => void;
|
|
113
|
+
/** Scroll the visible pages to bring a page into view. */
|
|
87
114
|
scrollToPage: (pageNumber: number) => void;
|
|
88
115
|
/**
|
|
89
116
|
* Scroll the paginated view to the paragraph with the given Word `w14:paraId`.
|
|
@@ -316,9 +343,12 @@ type FolioDatePickerPopoverProps = {
|
|
|
316
343
|
*/
|
|
317
344
|
type OutlineItem = {
|
|
318
345
|
id: string;
|
|
319
|
-
label: string;
|
|
320
|
-
|
|
321
|
-
|
|
346
|
+
label: string;
|
|
347
|
+
/** Nesting depth; drives indent + tick taper. */
|
|
348
|
+
level: number;
|
|
349
|
+
/** Optional trailing annotation in the panel (e.g. a page number). */
|
|
350
|
+
meta?: string;
|
|
351
|
+
/** Optional CSS custom-property name colouring this entry. */
|
|
322
352
|
color?: string;
|
|
323
353
|
};
|
|
324
354
|
/**
|
|
@@ -350,10 +380,7 @@ type FolioUIComponents = {
|
|
|
350
380
|
DatePickerPopover: ComponentType<FolioDatePickerPopoverProps>;
|
|
351
381
|
OutlineRail: ComponentType<FolioOutlineRailProps>;
|
|
352
382
|
};
|
|
353
|
-
declare function FolioUIProvider({
|
|
354
|
-
components,
|
|
355
|
-
children
|
|
356
|
-
}: {
|
|
383
|
+
declare function FolioUIProvider({ components, children }: {
|
|
357
384
|
components?: Partial<FolioUIComponents> | undefined;
|
|
358
385
|
children: ReactNode;
|
|
359
386
|
}): import("react").JSX.Element;
|
|
@@ -386,21 +413,37 @@ type ListState = {
|
|
|
386
413
|
* Current formatting state of the selection
|
|
387
414
|
*/
|
|
388
415
|
type SelectionFormatting = {
|
|
389
|
-
/** Whether selected text is bold */
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
416
|
+
/** Whether selected text is bold */
|
|
417
|
+
bold?: boolean | undefined;
|
|
418
|
+
/** Whether selected text is italic */
|
|
419
|
+
italic?: boolean | undefined;
|
|
420
|
+
/** Whether selected text is underlined */
|
|
421
|
+
underline?: boolean | undefined;
|
|
422
|
+
/** Whether selected text has strikethrough */
|
|
423
|
+
strike?: boolean | undefined;
|
|
424
|
+
/** Whether selected text is superscript */
|
|
425
|
+
superscript?: boolean | undefined;
|
|
426
|
+
/** Whether selected text is subscript */
|
|
427
|
+
subscript?: boolean | undefined;
|
|
428
|
+
/** Font family of selected text */
|
|
429
|
+
fontFamily?: string | undefined;
|
|
430
|
+
/** Font size of selected text (in half-points) */
|
|
431
|
+
fontSize?: number | undefined;
|
|
432
|
+
/** Text color */
|
|
433
|
+
color?: string | undefined;
|
|
434
|
+
/** Highlight color */
|
|
435
|
+
highlight?: string | undefined;
|
|
436
|
+
/** Paragraph alignment */
|
|
437
|
+
alignment?: ParagraphAlignment | undefined;
|
|
438
|
+
/** List state of the current paragraph */
|
|
439
|
+
listState?: ListState | undefined;
|
|
440
|
+
/** Line spacing in twips (OOXML value, 240 = single spacing) */
|
|
441
|
+
lineSpacing?: number | undefined;
|
|
442
|
+
/** Paragraph style ID */
|
|
443
|
+
styleId?: string | undefined;
|
|
444
|
+
/** Paragraph left indentation in twips */
|
|
445
|
+
indentLeft?: number | undefined;
|
|
446
|
+
/** Whether the paragraph is RTL (bidi) */
|
|
404
447
|
bidi?: boolean | undefined;
|
|
405
448
|
};
|
|
406
449
|
/**
|
|
@@ -434,56 +477,95 @@ type FormattingAction = "bold" | "italic" | "underline" | "strikethrough" | "sup
|
|
|
434
477
|
* Props for the Toolbar component
|
|
435
478
|
*/
|
|
436
479
|
type ToolbarProps = {
|
|
437
|
-
/** Current formatting of the selection */
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
480
|
+
/** Current formatting of the selection */
|
|
481
|
+
currentFormatting?: SelectionFormatting | undefined;
|
|
482
|
+
/** Callback when a formatting action is triggered */
|
|
483
|
+
onFormat?: ((action: FormattingAction) => void) | undefined;
|
|
484
|
+
/** Callback for undo action */
|
|
485
|
+
onUndo?: (() => void) | undefined;
|
|
486
|
+
/** Callback for redo action */
|
|
487
|
+
onRedo?: (() => void) | undefined;
|
|
488
|
+
/** Whether undo is available */
|
|
489
|
+
canUndo?: boolean | undefined;
|
|
490
|
+
/** Whether redo is available */
|
|
491
|
+
canRedo?: boolean | undefined;
|
|
492
|
+
/** Whether the toolbar is disabled */
|
|
493
|
+
disabled?: boolean | undefined;
|
|
494
|
+
/** Additional CSS class name */
|
|
495
|
+
className?: string | undefined;
|
|
496
|
+
/** Additional inline styles */
|
|
497
|
+
style?: CSSProperties | undefined;
|
|
498
|
+
/** Whether to enable keyboard shortcuts (default: true) */
|
|
499
|
+
enableShortcuts?: boolean | undefined;
|
|
500
|
+
/** Ref to the editor container for keyboard events */
|
|
501
|
+
editorRef?: React$1.RefObject<HTMLElement | null> | undefined;
|
|
502
|
+
/** Custom toolbar items to render */
|
|
503
|
+
children?: ReactNode | undefined;
|
|
504
|
+
/** Whether to show font family picker (default: true) */
|
|
449
505
|
showFontPicker?: boolean | undefined;
|
|
450
506
|
/**
|
|
451
507
|
* Custom families for the font-family dropdown (strings and/or `FontOption`
|
|
452
508
|
* objects). Omit to use the built-in defaults; an empty array renders an
|
|
453
509
|
* empty dropdown. Normalized to `FontOption[]` before reaching the picker.
|
|
454
510
|
*/
|
|
455
|
-
fontFamilies?: ReadonlyArray<string | FontOption> | undefined;
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
511
|
+
fontFamilies?: ReadonlyArray<string | FontOption> | undefined;
|
|
512
|
+
/** Whether to show font size picker (default: true) */
|
|
513
|
+
showFontSizePicker?: boolean | undefined;
|
|
514
|
+
/** Whether to show text color picker (default: true) */
|
|
515
|
+
showTextColorPicker?: boolean | undefined;
|
|
516
|
+
/** Whether to show highlight color picker (default: true) */
|
|
517
|
+
showHighlightColorPicker?: boolean | undefined;
|
|
518
|
+
/** Whether to show alignment buttons (default: true) */
|
|
519
|
+
showAlignmentButtons?: boolean | undefined;
|
|
520
|
+
/** Whether to show list buttons (default: true) */
|
|
521
|
+
showListButtons?: boolean | undefined;
|
|
522
|
+
/** Whether to show line spacing picker (default: true) */
|
|
523
|
+
showLineSpacingPicker?: boolean | undefined;
|
|
524
|
+
/** Whether to show style picker (default: true) */
|
|
525
|
+
showStylePicker?: boolean | undefined;
|
|
526
|
+
/** Whether to show the format painter button (default: true) */
|
|
527
|
+
showFormatPainter?: boolean | undefined;
|
|
528
|
+
/** Whether the format painter is armed (drives the button's active state) */
|
|
464
529
|
formatPainterActive?: boolean | undefined;
|
|
465
530
|
/**
|
|
466
531
|
* Arm the format painter: capture the current selection's formatting so the
|
|
467
532
|
* next selection is painted. `sticky` (double-click) keeps it armed until Esc
|
|
468
533
|
* or a toggle off; a single click disarms after one paint.
|
|
469
534
|
*/
|
|
470
|
-
onFormatPainter?: ((sticky: boolean) => void) | undefined;
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
535
|
+
onFormatPainter?: ((sticky: boolean) => void) | undefined;
|
|
536
|
+
/** Document styles for the style picker */
|
|
537
|
+
documentStyles?: Style[] | undefined;
|
|
538
|
+
/** Theme for the style picker */
|
|
539
|
+
theme?: Theme | null | undefined;
|
|
540
|
+
/** Callback for print action */
|
|
541
|
+
onPrint?: (() => void) | undefined;
|
|
542
|
+
/** Whether to show print button (default: true) */
|
|
543
|
+
showPrintButton?: boolean | undefined;
|
|
544
|
+
/** Whether to show zoom control (default: true) */
|
|
545
|
+
showZoomControl?: boolean | undefined;
|
|
546
|
+
/** Current zoom level (1.0 = 100%) */
|
|
547
|
+
zoom?: number | undefined;
|
|
548
|
+
/** Callback when zoom changes */
|
|
549
|
+
onZoomChange?: ((zoom: number) => void) | undefined;
|
|
550
|
+
/** Whether the rulers are currently visible (drives the toggle's active state) */
|
|
551
|
+
rulerVisible?: boolean | undefined;
|
|
552
|
+
/** Toggle the rulers on/off. The ruler control renders only when this is provided. */
|
|
553
|
+
onToggleRuler?: (() => void) | undefined;
|
|
554
|
+
/** Callback to refocus the editor after toolbar interactions */
|
|
555
|
+
onRefocusEditor?: (() => void) | undefined;
|
|
556
|
+
/** Callback when a table should be inserted */
|
|
557
|
+
onInsertTable?: ((rows: number, columns: number) => void) | undefined;
|
|
558
|
+
/** Whether to show table insert button (default: true) */
|
|
559
|
+
showTableInsert?: boolean | undefined;
|
|
560
|
+
/** Callback when user wants to insert an image */
|
|
561
|
+
onInsertImage?: (() => void) | undefined;
|
|
562
|
+
/** Callback when user wants to insert a page break */
|
|
563
|
+
onInsertPageBreak?: (() => void) | undefined;
|
|
564
|
+
/** Callback when user wants to insert a table of contents */
|
|
565
|
+
onInsertTOC?: (() => void) | undefined;
|
|
566
|
+
/** Callback when user wants to insert a symbol/special character */
|
|
567
|
+
onInsertSymbol?: (() => void) | undefined;
|
|
568
|
+
/** Callback when user wants to insert a shape */
|
|
487
569
|
onInsertShape?: (data: {
|
|
488
570
|
shapeType: string;
|
|
489
571
|
width: number;
|
|
@@ -492,16 +574,22 @@ type ToolbarProps = {
|
|
|
492
574
|
fillType?: string | undefined;
|
|
493
575
|
outlineWidth?: number | undefined;
|
|
494
576
|
outlineColor?: string | undefined;
|
|
495
|
-
}) => void;
|
|
577
|
+
}) => void;
|
|
578
|
+
/** Image context when an image is selected */
|
|
496
579
|
imageContext?: {
|
|
497
580
|
wrapType: string;
|
|
498
581
|
displayMode: string;
|
|
499
582
|
cssFloat: string | null;
|
|
500
|
-
} | null;
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
583
|
+
} | null;
|
|
584
|
+
/** Callback when image wrap type changes */
|
|
585
|
+
onImageWrapType?: ((wrapType: string) => void) | undefined;
|
|
586
|
+
/** Callback for image transform (rotate/flip) */
|
|
587
|
+
onImageTransform?: (action: "rotateCW" | "rotateCCW" | "flipH" | "flipV") => void;
|
|
588
|
+
/** Callback to open image properties dialog (alt text + border) */
|
|
589
|
+
onOpenImageProperties?: (() => void) | undefined;
|
|
590
|
+
/** Callback to open page setup dialog */
|
|
591
|
+
onPageSetup?: (() => void) | undefined;
|
|
592
|
+
/** Table context when cursor is in a table */
|
|
505
593
|
tableContext?: {
|
|
506
594
|
isInTable: boolean;
|
|
507
595
|
rowCount?: number | undefined;
|
|
@@ -510,14 +598,18 @@ type ToolbarProps = {
|
|
|
510
598
|
hasMultiCellSelection?: boolean | undefined;
|
|
511
599
|
cellBorderColor?: ColorValue | undefined;
|
|
512
600
|
cellBackgroundColor?: string | undefined;
|
|
513
|
-
} | null;
|
|
601
|
+
} | null;
|
|
602
|
+
/** Callback when a table action is triggered */
|
|
514
603
|
onTableAction?: ((action: TableAction) => void) | undefined;
|
|
515
604
|
};
|
|
516
605
|
//#endregion
|
|
517
606
|
//#region src/components/DocxEditor.props.d.ts
|
|
518
607
|
type DocxEditorProps = {
|
|
519
|
-
/** Document data — ArrayBuffer, Uint8Array, Blob, or File */
|
|
520
|
-
|
|
608
|
+
/** Document data — ArrayBuffer, Uint8Array, Blob, or File */
|
|
609
|
+
documentBuffer?: DocxInput | null;
|
|
610
|
+
/** Password for Agile-encrypted .docx files (Office 2010+). */
|
|
611
|
+
password?: string | undefined;
|
|
612
|
+
/** Pre-parsed document (alternative to documentBuffer) */
|
|
521
613
|
document?: Document | null;
|
|
522
614
|
/**
|
|
523
615
|
* Stable identity of the loaded document (same across internal edits, distinct
|
|
@@ -525,10 +617,14 @@ type DocxEditorProps = {
|
|
|
525
617
|
* external load from an edited document round-tripped back through state.
|
|
526
618
|
* Falls back to a document-metadata signature when omitted.
|
|
527
619
|
*/
|
|
528
|
-
documentKey?: string;
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
620
|
+
documentKey?: string;
|
|
621
|
+
/** Callback when document is saved */
|
|
622
|
+
onSave?: (buffer: ArrayBuffer) => void;
|
|
623
|
+
/** Author name used for comments and track changes */
|
|
624
|
+
author?: string;
|
|
625
|
+
/** Callback when document changes */
|
|
626
|
+
onChange?: (document: Document) => void;
|
|
627
|
+
/** Callback when selection changes */
|
|
532
628
|
onSelectionChange?: (state: SelectionState | null) => void;
|
|
533
629
|
/**
|
|
534
630
|
* Callback fired with the resolved PM positions and the
|
|
@@ -544,8 +640,10 @@ type DocxEditorProps = {
|
|
|
544
640
|
from: number;
|
|
545
641
|
to: number;
|
|
546
642
|
text: string;
|
|
547
|
-
}) => void;
|
|
548
|
-
|
|
643
|
+
}) => void;
|
|
644
|
+
/** Callback on error */
|
|
645
|
+
onError?: (error: Error) => void;
|
|
646
|
+
/** Callback when fonts are loaded */
|
|
549
647
|
onFontsLoaded?: () => void;
|
|
550
648
|
/**
|
|
551
649
|
* Custom families shown in the toolbar's font-family dropdown. Strings render
|
|
@@ -563,9 +661,12 @@ type DocxEditorProps = {
|
|
|
563
661
|
* Match `family` to the `fontFamilies` name a user applies. Pass a stable
|
|
564
662
|
* reference — a new array identity re-registers on every render.
|
|
565
663
|
*/
|
|
566
|
-
fonts?: ReadonlyArray<FontDefinition>;
|
|
567
|
-
|
|
568
|
-
|
|
664
|
+
fonts?: ReadonlyArray<FontDefinition>;
|
|
665
|
+
/** Theme for styling */
|
|
666
|
+
theme?: Theme | null;
|
|
667
|
+
/** Whether to show toolbar (default: true) */
|
|
668
|
+
showToolbar?: boolean;
|
|
669
|
+
/** Whether to show zoom control (default: true) */
|
|
569
670
|
showZoomControl?: boolean;
|
|
570
671
|
/**
|
|
571
672
|
* Whether to show the review controls — the track-changes toggle and the
|
|
@@ -580,36 +681,54 @@ type DocxEditorProps = {
|
|
|
580
681
|
* (default: true). Turn off for plain-markdown editing, which has no running
|
|
581
682
|
* header/footer.
|
|
582
683
|
*/
|
|
583
|
-
showHeaderFooterEditing?: boolean;
|
|
584
|
-
|
|
684
|
+
showHeaderFooterEditing?: boolean;
|
|
685
|
+
/** Whether to show page margin guides/boundaries (default: false) */
|
|
686
|
+
showMarginGuides?: boolean;
|
|
687
|
+
/** Color for margin guides (default: '#c0c0c0') */
|
|
585
688
|
marginGuideColor?: string;
|
|
586
689
|
/**
|
|
587
690
|
* Whether the horizontal and vertical rulers start visible (default: false).
|
|
588
691
|
* Seeds the initial state of the toolbar's ruler toggle; users show/hide the
|
|
589
692
|
* rulers at runtime from there (like Word's View > Ruler).
|
|
590
693
|
*/
|
|
591
|
-
showRuler?: boolean;
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
694
|
+
showRuler?: boolean;
|
|
695
|
+
/** Measurement unit shown on the rulers (default: 'inch'). */
|
|
696
|
+
rulerUnit?: "inch" | "cm";
|
|
697
|
+
/** Initial zoom level (default: 1.0) */
|
|
698
|
+
initialZoom?: number;
|
|
699
|
+
/** Whether Ctrl/Cmd+wheel and trackpad-pinch zoom are enabled (default: true) */
|
|
700
|
+
enableWheelZoom?: boolean;
|
|
701
|
+
/** Whether the editor is read-only. When true, hides toolbar and rulers */
|
|
702
|
+
readOnly?: boolean;
|
|
703
|
+
/** Whether comments/tracked changes should auto-open the review sidebar (default: true) */
|
|
596
704
|
autoOpenReviewSidebar?: boolean;
|
|
597
705
|
/**
|
|
598
706
|
* Override folio's built-in chrome UI primitives (Button, …) with a
|
|
599
707
|
* consumer's design-system components. Omitted entries fall back to folio's
|
|
600
708
|
* built-in defaults, so standalone folio works without any injection.
|
|
601
709
|
*/
|
|
602
|
-
components?: Partial<FolioUIComponents>;
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
710
|
+
components?: Partial<FolioUIComponents>;
|
|
711
|
+
/** Custom toolbar actions */
|
|
712
|
+
toolbarExtra?: ReactNode;
|
|
713
|
+
/** Additional CSS class name */
|
|
714
|
+
className?: string;
|
|
715
|
+
/** Additional inline styles */
|
|
716
|
+
style?: CSSProperties;
|
|
717
|
+
/** Placeholder when no document */
|
|
718
|
+
placeholder?: ReactNode;
|
|
719
|
+
/** Loading indicator */
|
|
720
|
+
loadingIndicator?: ReactNode;
|
|
721
|
+
/** Keep the current parsed document visible while a new buffer is loading. */
|
|
722
|
+
preserveDocumentWhileLoading?: boolean;
|
|
723
|
+
/** Initial scroll offset for the editor's document scroll container. */
|
|
724
|
+
initialScrollTop?: number;
|
|
725
|
+
/** Callback when the editor's document scroll container scrolls. */
|
|
726
|
+
onScrollTopChange?: (scrollTop: number) => void;
|
|
727
|
+
/** Whether to show the document outline sidebar (default: false) */
|
|
728
|
+
showOutline?: boolean;
|
|
729
|
+
/** Whether to show print button in toolbar (default: true) */
|
|
730
|
+
showPrintButton?: boolean;
|
|
731
|
+
/** Callback when print is triggered */
|
|
613
732
|
onPrint?: () => void;
|
|
614
733
|
/**
|
|
615
734
|
* Insert controls are opt-in: each toolbar control renders only when its
|
|
@@ -618,16 +737,26 @@ type DocxEditorProps = {
|
|
|
618
737
|
* view-level helpers exported from the package (`insertTableInView`,
|
|
619
738
|
* `insertPageBreakInView`, `insertTableOfContentsInView`, `insertImageFromFile`).
|
|
620
739
|
*/
|
|
621
|
-
onInsertImage?: (() => void) | undefined;
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
740
|
+
onInsertImage?: (() => void) | undefined;
|
|
741
|
+
/** Insert a `rows × columns` table at the current selection. */
|
|
742
|
+
onInsertTable?: ((rows: number, columns: number) => void) | undefined;
|
|
743
|
+
/** Whether the Insert Table control is shown when `onInsertTable` is set (default: true). */
|
|
744
|
+
showTableInsert?: boolean | undefined;
|
|
745
|
+
/** Insert a page break at the current selection. */
|
|
746
|
+
onInsertPageBreak?: (() => void) | undefined;
|
|
747
|
+
/** Insert a table of contents generated from the document's headings. */
|
|
748
|
+
onInsertTOC?: (() => void) | undefined;
|
|
749
|
+
/** Callback when content is copied */
|
|
750
|
+
onCopy?: () => void;
|
|
751
|
+
/** Callback when content is cut */
|
|
752
|
+
onCut?: () => void;
|
|
753
|
+
/** Callback when content is pasted */
|
|
754
|
+
onPaste?: () => void;
|
|
755
|
+
/** Editor mode: 'editing' (direct edits), 'suggesting' (track changes), or 'viewing' (read-only). Default: 'editing' */
|
|
756
|
+
mode?: EditorMode;
|
|
757
|
+
/** Callback when the editing mode changes */
|
|
758
|
+
onModeChange?: (mode: EditorMode) => void;
|
|
759
|
+
/** Callback when a readonly user action would mutate the document. */
|
|
631
760
|
onReadonlyEditAttempt?: () => void;
|
|
632
761
|
/**
|
|
633
762
|
* Controlled comments array. When provided, the editor reads comment thread
|
|
@@ -635,15 +764,18 @@ type DocxEditorProps = {
|
|
|
635
764
|
* Use with collaboration backends (Yjs, etc.) so comment threads sync across
|
|
636
765
|
* peers; PM carries range markers, thread metadata lives outside the doc.
|
|
637
766
|
*/
|
|
638
|
-
comments?: Comment[];
|
|
639
|
-
|
|
767
|
+
comments?: Comment[];
|
|
768
|
+
/** Fires whenever the comments array changes (controlled and uncontrolled). */
|
|
769
|
+
onCommentsChange?: (comments: Comment[]) => void;
|
|
770
|
+
/** Callback with the parsed document's editing compatibility report. */
|
|
640
771
|
onCompatibilityChange?: (compatibility: DocxCompatibility) => void;
|
|
641
772
|
/**
|
|
642
773
|
* Fires when the live ProseMirror view is captured (or torn down).
|
|
643
774
|
* The host wires this so it can drive the AI suggestion overlay
|
|
644
775
|
* (decoration meta, apply, scroll-to) from outside the editor.
|
|
645
776
|
*/
|
|
646
|
-
onEditorViewReady?: (view: EditorView | null) => void;
|
|
777
|
+
onEditorViewReady?: (view: EditorView | null) => void;
|
|
778
|
+
/** Yjs-backed collaboration owner. Experimental and opt-in. */
|
|
647
779
|
collaboration?: DocxEditorCollaboration | undefined;
|
|
648
780
|
/**
|
|
649
781
|
* Fires with the current anonymization match list every time
|
|
@@ -666,7 +798,8 @@ type DocxEditorProps = {
|
|
|
666
798
|
* `anonymizationSelectionSeq` increments (so repeated
|
|
667
799
|
* sidebar clicks of the same term re-trigger the scroll).
|
|
668
800
|
*/
|
|
669
|
-
selectedAnonymizationCanonical?: string | null | undefined;
|
|
801
|
+
selectedAnonymizationCanonical?: string | null | undefined;
|
|
802
|
+
/** Monotonic counter from the bridge store; drives the re-scroll. */
|
|
670
803
|
anonymizationSelectionSeq?: number | undefined;
|
|
671
804
|
/**
|
|
672
805
|
* Render legal-template markers ({{field}}, {{@clause:..}},
|
|
@@ -753,27 +886,42 @@ type HighlightPassageOptions = {
|
|
|
753
886
|
* Imperative handle exposed by the DocxEditor component.
|
|
754
887
|
*/
|
|
755
888
|
type DocxEditorRef = {
|
|
756
|
-
/** Get the current document */
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
889
|
+
/** Get the current document */
|
|
890
|
+
getDocument: () => Document | null;
|
|
891
|
+
/** Whether the live ProseMirror state has edits that have not been serialized. */
|
|
892
|
+
hasPendingChanges: () => boolean;
|
|
893
|
+
/** Get the editor ref */
|
|
894
|
+
getEditorRef: () => PagedEditorRef | null;
|
|
895
|
+
/** The headless editor controller (Seam 6), or null before the editor mounts. */
|
|
896
|
+
getEditor: () => FolioEditor | null;
|
|
897
|
+
/** Save the document to buffer. Pass { selective: false } to force full repack. */
|
|
760
898
|
save: (options?: {
|
|
761
899
|
selective?: boolean;
|
|
762
|
-
}) => Promise<ArrayBuffer | null>;
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
900
|
+
}) => Promise<ArrayBuffer | null>;
|
|
901
|
+
/** Set zoom level */
|
|
902
|
+
setZoom: (zoom: number) => void;
|
|
903
|
+
/** Get current zoom level */
|
|
904
|
+
getZoom: () => number;
|
|
905
|
+
/** Focus the editor */
|
|
906
|
+
focus: () => void;
|
|
907
|
+
/** Get current page number */
|
|
908
|
+
getCurrentPage: () => number;
|
|
909
|
+
/** Get total page count */
|
|
910
|
+
getTotalPages: () => number;
|
|
911
|
+
/** Scroll to a specific page */
|
|
768
912
|
scrollToPage: (pageNumber: number) => void;
|
|
769
913
|
/**
|
|
770
914
|
* Scroll the paginated view to the paragraph with the given Word `w14:paraId`.
|
|
771
915
|
* Pass `options.highlight` to briefly flash it in a custom color.
|
|
772
916
|
*/
|
|
773
|
-
scrollToParaId: (paraId: string, options?: ScrollToParaIdOptions) => boolean;
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
917
|
+
scrollToParaId: (paraId: string, options?: ScrollToParaIdOptions) => boolean;
|
|
918
|
+
/** Open print preview */
|
|
919
|
+
openPrintPreview: () => void;
|
|
920
|
+
/** Print the document directly */
|
|
921
|
+
print: () => void;
|
|
922
|
+
/** Load a pre-parsed document programmatically */
|
|
923
|
+
loadDocument: (doc: Document) => void;
|
|
924
|
+
/** Load a DOCX buffer programmatically (ArrayBuffer, Uint8Array, Blob, or File) */
|
|
777
925
|
loadDocumentBuffer: (buffer: DocxInput) => Promise<void>;
|
|
778
926
|
/**
|
|
779
927
|
* Force-create the underlying editor view if it has been deferred.
|
|
@@ -785,10 +933,14 @@ type DocxEditorRef = {
|
|
|
785
933
|
*/
|
|
786
934
|
ensureEditorView: (options?: {
|
|
787
935
|
focus?: boolean;
|
|
788
|
-
}) => void;
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
936
|
+
}) => void;
|
|
937
|
+
/** Create the block snapshot that an external AI editor should reference. */
|
|
938
|
+
createAIEditSnapshot: () => FolioAIEditSnapshot | null;
|
|
939
|
+
/** Apply a versioned document-operation batch against a previously created block snapshot. */
|
|
940
|
+
applyDocumentOperations: (options: DocxEditorApplyDocumentOperationsOptions) => FolioDocumentOperationResult;
|
|
941
|
+
/** Undo the latest unchanged document-operation batch. */
|
|
942
|
+
undoDocumentOperations: (undoHandle: FolioDocumentOperationUndoHandle) => FolioDocumentOperationUndoResult;
|
|
943
|
+
/** Apply AI-authored operations against a previously created block snapshot. */
|
|
792
944
|
applyAIEditOperations: (options: {
|
|
793
945
|
snapshot: FolioAIEditSnapshot;
|
|
794
946
|
operations: FolioAIEditOperation[];
|
|
@@ -851,8 +1003,10 @@ type DocxEditorRef = {
|
|
|
851
1003
|
* ephemeral view state: cleared on the next doc-changing transaction and by
|
|
852
1004
|
* {@link clearPassageHighlight}.
|
|
853
1005
|
*/
|
|
854
|
-
highlightPassage: (options: HighlightPassageOptions) => HighlightPassageResult;
|
|
855
|
-
|
|
1006
|
+
highlightPassage: (options: HighlightPassageOptions) => HighlightPassageResult;
|
|
1007
|
+
/** Clear the passage highlight painted by {@link highlightPassage}, if any. */
|
|
1008
|
+
clearPassageHighlight: () => void;
|
|
1009
|
+
/** Resolve a stable block or text-range target and reveal it in the editor. */
|
|
856
1010
|
showInDocument: (target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot) => boolean;
|
|
857
1011
|
/**
|
|
858
1012
|
* The pending suggestions in the live document: AI-proposed tracked changes
|
|
@@ -907,7 +1061,8 @@ type DocxEditorRef = {
|
|
|
907
1061
|
* layout fragments with a newline. Returns `null` when the page number is
|
|
908
1062
|
* out of range or the layout hasn't been computed yet.
|
|
909
1063
|
*/
|
|
910
|
-
getPageText: (page: number) => string | null;
|
|
1064
|
+
getPageText: (page: number) => string | null;
|
|
1065
|
+
/** Resolve a stable block or text range to its real 1-based rendered page. */
|
|
911
1066
|
getTargetPage: (target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot) => number | null;
|
|
912
1067
|
/**
|
|
913
1068
|
* List every block-level content control in the live document, filtered by
|
|
@@ -925,7 +1080,8 @@ type DocxEditorRef = {
|
|
|
925
1080
|
* the lookup uses the document's current shape on every call.
|
|
926
1081
|
*/
|
|
927
1082
|
getContentControls: (filter?: ContentControlFilter) => {
|
|
928
|
-
properties: SdtProperties;
|
|
1083
|
+
properties: SdtProperties;
|
|
1084
|
+
/** Index in the PM document tree, outer→inner. */
|
|
929
1085
|
path: number[];
|
|
930
1086
|
/**
|
|
931
1087
|
* PM position of the control's open token in the SOURCE document state.
|
|
@@ -972,20 +1128,28 @@ type DocxEditorRef = {
|
|
|
972
1128
|
//#region src/renderAsync.d.ts
|
|
973
1129
|
/** Framework-agnostic handle for an imperatively mounted editor instance. */
|
|
974
1130
|
type EditorHandle = {
|
|
975
|
-
/** Save the document and return the DOCX as a Blob. */
|
|
976
|
-
|
|
977
|
-
|
|
1131
|
+
/** Save the document and return the DOCX as a Blob. */
|
|
1132
|
+
save: () => Promise<Blob | null>;
|
|
1133
|
+
/** Get the current parsed document model. */
|
|
1134
|
+
getDocument: () => Document | null;
|
|
1135
|
+
/** Focus the editor. */
|
|
1136
|
+
focus: () => void;
|
|
1137
|
+
/** Unmount the editor and clean up. */
|
|
978
1138
|
destroy: () => void;
|
|
979
1139
|
};
|
|
980
1140
|
/** React-specific handle with zoom and scroll helpers. */
|
|
981
1141
|
type DocxEditorHandle = EditorHandle & {
|
|
982
|
-
/** Set zoom level (1.0 = 100%). */
|
|
983
|
-
|
|
1142
|
+
/** Set zoom level (1.0 = 100%). */
|
|
1143
|
+
setZoom: (zoom: number) => void;
|
|
1144
|
+
/** Scroll the visible pages to a raw ProseMirror document position. */
|
|
1145
|
+
scrollToPosition: (pmPos: number) => void;
|
|
1146
|
+
/** Scroll the visible pages to a 1-indexed page number. */
|
|
984
1147
|
scrollToPage: (pageNumber: number) => void;
|
|
985
1148
|
};
|
|
986
1149
|
/** Options for {@link renderAsync}. */
|
|
987
1150
|
type RenderAsyncOptions = Omit<DocxEditorProps, "documentBuffer" | "document"> & {
|
|
988
|
-
/** BCP-47 locale for bundled folio UI strings (default: `en`). */
|
|
1151
|
+
/** BCP-47 locale for bundled folio UI strings (default: `en`). */
|
|
1152
|
+
locale?: string;
|
|
989
1153
|
};
|
|
990
1154
|
/**
|
|
991
1155
|
* Render a DOCX editor into a container element.
|