@extend-ai/react-docx 0.8.4 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/dist/{chunk-KB6YHU6O.js → chunk-6NVXVLTW.js} +2 -2
- package/dist/{chunk-THNPK4N7.js → chunk-AKDFE4ZH.js} +33 -2
- package/dist/chunk-AKDFE4ZH.js.map +1 -0
- package/dist/{chunk-4CPXLVFB.js → chunk-GRQPIBJJ.js} +22 -9
- package/dist/{chunk-4CPXLVFB.js.map → chunk-GRQPIBJJ.js.map} +1 -1
- package/dist/docx-import-worker.cjs +97 -172
- package/dist/docx-import-worker.cjs.map +1 -1
- package/dist/docx-import-worker.js +41 -14
- package/dist/docx-import-worker.js.map +1 -1
- package/dist/docx_wasm_bg.wasm +0 -0
- package/dist/index.cjs +4795 -3304
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +144 -7
- package/dist/index.d.ts +144 -7
- package/dist/index.js +5192 -3747
- package/dist/index.js.map +1 -1
- package/dist/{src-KC2H22CB.js → src-D3NRHPLE.js} +3 -3
- package/dist/{src-JS3OX73I.js → src-DEWCGIL2.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-THNPK4N7.js.map +0 -1
- /package/dist/{chunk-KB6YHU6O.js.map → chunk-6NVXVLTW.js.map} +0 -0
- /package/dist/{src-JS3OX73I.js.map → src-D3NRHPLE.js.map} +0 -0
- /package/dist/{src-KC2H22CB.js.map → src-DEWCGIL2.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -547,6 +547,11 @@ declare function buildDocModel(pkg: OoxmlPackage): Promise<DocModel>;
|
|
|
547
547
|
declare function buildDocModelFromBytes(bytes: ArrayBuffer | Uint8Array): Promise<{
|
|
548
548
|
package: OoxmlPackage;
|
|
549
549
|
model: DocModel;
|
|
550
|
+
timings: {
|
|
551
|
+
parseMs: number;
|
|
552
|
+
buildModelMs: number;
|
|
553
|
+
totalMs: number;
|
|
554
|
+
};
|
|
550
555
|
}>;
|
|
551
556
|
|
|
552
557
|
interface LayoutOptions {
|
|
@@ -614,6 +619,50 @@ interface LayoutPage {
|
|
|
614
619
|
}
|
|
615
620
|
declare function layoutDocument(model: DocModel, options?: LayoutOptions): LayoutPage[];
|
|
616
621
|
|
|
622
|
+
declare function setWasmSource(source: WasmSource): void;
|
|
623
|
+
declare function initWasm(source?: WasmSource): ReturnType<typeof initWasm$1>;
|
|
624
|
+
|
|
625
|
+
interface DocxImportResult {
|
|
626
|
+
package: OoxmlPackage;
|
|
627
|
+
model: DocModel;
|
|
628
|
+
source: "worker" | "main-thread";
|
|
629
|
+
timings?: DocxImportWorkerTimings;
|
|
630
|
+
}
|
|
631
|
+
interface DocxImportOptions {
|
|
632
|
+
signal?: AbortSignal;
|
|
633
|
+
transferBuffer?: boolean;
|
|
634
|
+
useWorker?: boolean | "required";
|
|
635
|
+
}
|
|
636
|
+
interface DocxImportWorkerTimings {
|
|
637
|
+
totalMs: number;
|
|
638
|
+
parseMs: number;
|
|
639
|
+
buildModelMs: number;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
type DocxViewerSource = ArrayBuffer | ArrayBufferView | Blob;
|
|
643
|
+
interface ParseDocxForViewerOptions extends DocxImportOptions {
|
|
644
|
+
loadEmbeddedFonts?: boolean | "defer";
|
|
645
|
+
fileName?: string;
|
|
646
|
+
}
|
|
647
|
+
interface ParsedDocxPerformanceTimings {
|
|
648
|
+
fileReadMs: number;
|
|
649
|
+
parseMs: number;
|
|
650
|
+
modelConstructionMs: number;
|
|
651
|
+
fontLoadingMs: number;
|
|
652
|
+
totalMs: number;
|
|
653
|
+
}
|
|
654
|
+
interface ParsedDocxDocument {
|
|
655
|
+
readonly model: DocModel;
|
|
656
|
+
readonly package: OoxmlPackage;
|
|
657
|
+
readonly source: DocxImportResult["source"];
|
|
658
|
+
readonly fileName?: string;
|
|
659
|
+
readonly timings: ParsedDocxPerformanceTimings;
|
|
660
|
+
readonly embeddedFontsLoaded: boolean;
|
|
661
|
+
loadEmbeddedFonts(): Promise<void>;
|
|
662
|
+
dispose(): void;
|
|
663
|
+
}
|
|
664
|
+
declare function parseDocxForViewer(source: DocxViewerSource, options?: ParseDocxForViewerOptions): Promise<ParsedDocxDocument>;
|
|
665
|
+
|
|
617
666
|
type AnnotationMutationFailureReason = "stale" | "unsupported" | "unsafe-xml";
|
|
618
667
|
type AnnotationMutationResult = {
|
|
619
668
|
ok: true;
|
|
@@ -767,6 +816,7 @@ interface DocxHistoryRestoreRequest {
|
|
|
767
816
|
nonce: number;
|
|
768
817
|
selection: DocxEditorSelection;
|
|
769
818
|
activeTextRange?: DocxTextRange;
|
|
819
|
+
textInput?: boolean;
|
|
770
820
|
}
|
|
771
821
|
type ParagraphLocation = DocxTextRangeLocation;
|
|
772
822
|
type DocxImageLocation = ParagraphLocation & {
|
|
@@ -793,6 +843,8 @@ interface DocxSelectedFormField {
|
|
|
793
843
|
}
|
|
794
844
|
type DocxImageDropTarget = ParagraphLocation & {
|
|
795
845
|
childIndex: number;
|
|
846
|
+
/** UTF-16 offset inside the target text run. */
|
|
847
|
+
textOffset?: number;
|
|
796
848
|
};
|
|
797
849
|
type DocxTrackedChangeKind = "insertion" | "deletion" | "move-from" | "move-to" | "format-change" | "paragraph-format-change";
|
|
798
850
|
interface DocxTrackedChange {
|
|
@@ -881,6 +933,17 @@ type DocxBorderPresetState = Record<DocxBorderPreset, boolean>;
|
|
|
881
933
|
* imports update the controller through `editor.importDocxFile`.
|
|
882
934
|
*/
|
|
883
935
|
interface UseDocxEditorOptions {
|
|
936
|
+
/**
|
|
937
|
+
* Parsed document to use as the initial editor state without reading or
|
|
938
|
+
* parsing the source again.
|
|
939
|
+
*/
|
|
940
|
+
document?: ParsedDocxDocument;
|
|
941
|
+
/**
|
|
942
|
+
* Loads embedded fonts when an initial parsed document deferred them.
|
|
943
|
+
*
|
|
944
|
+
* @defaultValue `true`
|
|
945
|
+
*/
|
|
946
|
+
loadEmbeddedFonts?: boolean;
|
|
884
947
|
/**
|
|
885
948
|
* Model used for `editor.newDocument()` and for the initial empty editor.
|
|
886
949
|
*
|
|
@@ -1028,6 +1091,7 @@ interface DocxEditorController {
|
|
|
1028
1091
|
setImageWrapMode: (location: DocxImageLocation, mode: DocxImageWrapMode, seedFloating?: Partial<NonNullable<ImageRunNode["floating"]>>) => void;
|
|
1029
1092
|
moveFloatingImage: (location: DocxImageLocation, patch: Partial<NonNullable<ImageRunNode["floating"]>>, options?: {
|
|
1030
1093
|
reparentToParagraphNodeIndex?: number;
|
|
1094
|
+
anchorTextOffset?: number;
|
|
1031
1095
|
}) => void;
|
|
1032
1096
|
moveSectionFloatingImage: (location: DocxSectionImageLocation, patch: Partial<NonNullable<ImageRunNode["floating"]>>) => void;
|
|
1033
1097
|
moveParagraphDropCap: (nodeIndex: number, patch: Partial<NonNullable<NonNullable<ParagraphNode["style"]>["dropCap"]>>) => void;
|
|
@@ -1049,6 +1113,7 @@ interface DocxEditorController {
|
|
|
1049
1113
|
moveTable: (tableIndex: number, targetNodeIndex: number) => void;
|
|
1050
1114
|
setTableFloating: (tableIndex: number, patch: Partial<NonNullable<NonNullable<TableNode["style"]>["floating"]>>, options?: {
|
|
1051
1115
|
moveToNodeIndex?: number;
|
|
1116
|
+
anchorTextOffset?: number;
|
|
1052
1117
|
}) => void;
|
|
1053
1118
|
moveEmbeddedTableToBody: (tableRuntimeKey: string, targetNodeIndex: number) => void;
|
|
1054
1119
|
replaceExpandedSelection: (text: string, range?: DocxTextRange) => DocxTextRange | undefined;
|
|
@@ -1309,6 +1374,11 @@ interface DocxEditorViewerProps {
|
|
|
1309
1374
|
* range is rendered.
|
|
1310
1375
|
*/
|
|
1311
1376
|
visiblePageRange?: DocxVisiblePageRange;
|
|
1377
|
+
/**
|
|
1378
|
+
* Hard set of zero-based pages to mount. Unlike `visiblePageRange`, omitted
|
|
1379
|
+
* pages remain metadata-only even when they fall between requested pages.
|
|
1380
|
+
*/
|
|
1381
|
+
pageIndexes?: readonly number[];
|
|
1312
1382
|
/**
|
|
1313
1383
|
* Called whenever the viewer's resolved page count changes.
|
|
1314
1384
|
*/
|
|
@@ -1609,6 +1679,17 @@ interface UseDocxPageThumbnailsOptions {
|
|
|
1609
1679
|
* Prioritizes thumbnails for consumer-owned virtualized thumbnail rails.
|
|
1610
1680
|
*/
|
|
1611
1681
|
renderWindow?: DocxPageThumbnailRenderWindow;
|
|
1682
|
+
/**
|
|
1683
|
+
* Hard set of zero-based pages exposed and eligible for rasterization.
|
|
1684
|
+
* Omit to preserve the existing all-pages behavior.
|
|
1685
|
+
*/
|
|
1686
|
+
pageIndexes?: readonly number[];
|
|
1687
|
+
/**
|
|
1688
|
+
* Default scheduling policy for thumbnail paint requests.
|
|
1689
|
+
*
|
|
1690
|
+
* @defaultValue `"idle"`
|
|
1691
|
+
*/
|
|
1692
|
+
scheduling?: DocxThumbnailScheduling;
|
|
1612
1693
|
/**
|
|
1613
1694
|
* Prevents thumbnail rendering while keeping stable item metadata.
|
|
1614
1695
|
*
|
|
@@ -1617,6 +1698,13 @@ interface UseDocxPageThumbnailsOptions {
|
|
|
1617
1698
|
disabled?: boolean;
|
|
1618
1699
|
}
|
|
1619
1700
|
type DocxPageThumbnailStatus = "idle" | "rendering" | "ready" | "unavailable" | "error";
|
|
1701
|
+
type DocxThumbnailScheduling = "idle" | "immediate";
|
|
1702
|
+
interface DocxRenderToCanvasOptions {
|
|
1703
|
+
/** Bypasses idle scheduling for a visible imperative request. */
|
|
1704
|
+
scheduling?: DocxThumbnailScheduling;
|
|
1705
|
+
/** Ignores unchanged-content and surface-cache fast paths. */
|
|
1706
|
+
force?: boolean;
|
|
1707
|
+
}
|
|
1620
1708
|
interface DocxPageThumbnailItem extends DocxPageThumbnailResolution {
|
|
1621
1709
|
/** Source page aspect ratio. */
|
|
1622
1710
|
aspectRatio: number;
|
|
@@ -1645,7 +1733,7 @@ interface DocxPageThumbnailItem extends DocxPageThumbnailResolution {
|
|
|
1645
1733
|
/** Ref callback that keeps an attached canvas rendered as the page changes. */
|
|
1646
1734
|
canvasRef: (canvas: HTMLCanvasElement | null) => void;
|
|
1647
1735
|
/** Asynchronously renders this thumbnail into a canvas. */
|
|
1648
|
-
renderToCanvas: (canvas: HTMLCanvasElement) => Promise<void>;
|
|
1736
|
+
renderToCanvas: (canvas: HTMLCanvasElement, options?: DocxRenderToCanvasOptions) => Promise<void>;
|
|
1649
1737
|
/** Alias for `widthPx`. */
|
|
1650
1738
|
width: number;
|
|
1651
1739
|
}
|
|
@@ -1679,7 +1767,7 @@ declare function useDocxTrackChanges(editor: Pick<DocxEditorController, "tracked
|
|
|
1679
1767
|
declare function useDocxComments(editor: Pick<DocxEditorController, "comments" | "showComments" | "setShowComments" | "toggleShowComments" | "createComment" | "setCommentResolved">): UseDocxCommentsResult;
|
|
1680
1768
|
declare function useDocxPageLayout(editor: Pick<DocxEditorController, "model">): UseDocxPageLayoutResult;
|
|
1681
1769
|
declare function useDocxPagination(editor: Pick<DocxEditorController, "currentPage" | "totalPages">): UseDocxPaginationResult;
|
|
1682
|
-
declare function DocxEditorViewer({ editor, className, style, pageBackgroundColor, pageGapBackgroundColor, deferInitialPaginationPaint, loadingState, pageVirtualization, visiblePageRange, onPageCountChange, onRequestPageReveal, headingStyles, showTrackedChanges, renderTrackedChangeCard, showComments, renderCommentCard, renderTableContextMenu, renderContextMenu, onFormFieldDoubleClick, mode, }: DocxEditorViewerProps): React.JSX.Element;
|
|
1770
|
+
declare function DocxEditorViewer({ editor, className, style, pageBackgroundColor, pageGapBackgroundColor, deferInitialPaginationPaint, loadingState, pageVirtualization, visiblePageRange, pageIndexes, onPageCountChange, onRequestPageReveal, headingStyles, showTrackedChanges, renderTrackedChangeCard, showComments, renderCommentCard, renderTableContextMenu, renderContextMenu, onFormFieldDoubleClick, mode, }: DocxEditorViewerProps): React.JSX.Element;
|
|
1683
1771
|
|
|
1684
1772
|
interface ResolvedModelSection {
|
|
1685
1773
|
startNodeIndex: number;
|
|
@@ -1896,9 +1984,6 @@ declare function modelToDocumentXml(model: DocModel, basePackage?: OoxmlPackage)
|
|
|
1896
1984
|
declare function serializeDocModel(model: DocModel, basePackage?: OoxmlPackage): Promise<OoxmlPackage>;
|
|
1897
1985
|
declare function serializeDocx(model: DocModel, basePackage?: OoxmlPackage): Promise<ArrayBuffer>;
|
|
1898
1986
|
|
|
1899
|
-
declare function setWasmSource(source: WasmSource): void;
|
|
1900
|
-
declare function initWasm(source?: WasmSource): ReturnType<typeof initWasm$1>;
|
|
1901
|
-
|
|
1902
1987
|
interface ReactDocxViewerProps {
|
|
1903
1988
|
/**
|
|
1904
1989
|
* Raw `.docx` file contents to parse and render.
|
|
@@ -1921,6 +2006,12 @@ interface ReactDocxViewerProps {
|
|
|
1921
2006
|
* pipeline.
|
|
1922
2007
|
*/
|
|
1923
2008
|
model?: DocModel;
|
|
2009
|
+
/** Parsed input returned by `parseDocxForViewer`. */
|
|
2010
|
+
document?: ParsedDocxDocument;
|
|
2011
|
+
/** Loads deferred embedded fonts when a parsed document is mounted. */
|
|
2012
|
+
loadEmbeddedFonts?: boolean;
|
|
2013
|
+
/** Hard set of zero-based pages to mount. */
|
|
2014
|
+
pageIndexes?: readonly number[];
|
|
1924
2015
|
/**
|
|
1925
2016
|
* CSS class applied to the outer viewer container.
|
|
1926
2017
|
*
|
|
@@ -1961,6 +2052,52 @@ interface UseDocxModelState {
|
|
|
1961
2052
|
error?: Error;
|
|
1962
2053
|
}
|
|
1963
2054
|
declare function useDocxModel(file?: ArrayBuffer): UseDocxModelState;
|
|
1964
|
-
declare function ReactDocxViewer({ file, model, className, layoutOptions, emptyState, }: ReactDocxViewerProps): React.JSX.Element;
|
|
2055
|
+
declare function ReactDocxViewer({ file, model, document, loadEmbeddedFonts, pageIndexes, className, layoutOptions, emptyState, }: ReactDocxViewerProps): React.JSX.Element;
|
|
2056
|
+
type DocxThumbnailOutput = "canvas" | "blob" | "imageBitmap";
|
|
2057
|
+
interface CreateDocxThumbnailRendererOptions {
|
|
2058
|
+
scheduling?: DocxThumbnailScheduling;
|
|
2059
|
+
pixelRatio?: number;
|
|
2060
|
+
resolution?: DocxPageThumbnailBounds;
|
|
2061
|
+
pageIndexes?: readonly number[];
|
|
2062
|
+
}
|
|
2063
|
+
interface RenderDocxThumbnailPageOptions {
|
|
2064
|
+
scheduling?: DocxThumbnailScheduling;
|
|
2065
|
+
pixelRatio?: number;
|
|
2066
|
+
resolution?: DocxPageThumbnailBounds;
|
|
2067
|
+
maxWidth?: number;
|
|
2068
|
+
maxHeight?: number;
|
|
2069
|
+
output?: DocxThumbnailOutput;
|
|
2070
|
+
canvas?: HTMLCanvasElement;
|
|
2071
|
+
mimeType?: string;
|
|
2072
|
+
quality?: number;
|
|
2073
|
+
}
|
|
2074
|
+
interface DocxThumbnailRenderTimings {
|
|
2075
|
+
paginationMs: number;
|
|
2076
|
+
pageMountMs: number;
|
|
2077
|
+
rasterizationMs: number;
|
|
2078
|
+
encodingMs: number;
|
|
2079
|
+
totalMs: number;
|
|
2080
|
+
}
|
|
2081
|
+
interface DocxThumbnailRenderResult {
|
|
2082
|
+
pageIndex: number;
|
|
2083
|
+
pageCount: number;
|
|
2084
|
+
width: number;
|
|
2085
|
+
height: number;
|
|
2086
|
+
pixelWidth: number;
|
|
2087
|
+
pixelHeight: number;
|
|
2088
|
+
output: DocxThumbnailOutput;
|
|
2089
|
+
canvas?: HTMLCanvasElement;
|
|
2090
|
+
blob?: Blob;
|
|
2091
|
+
imageBitmap?: ImageBitmap;
|
|
2092
|
+
timings: DocxThumbnailRenderTimings;
|
|
2093
|
+
}
|
|
2094
|
+
type DocxThumbnailDocument = ParsedDocxDocument | DocModel;
|
|
2095
|
+
interface DocxThumbnailRenderer {
|
|
2096
|
+
readonly document: DocxThumbnailDocument;
|
|
2097
|
+
readonly pageCount: number;
|
|
2098
|
+
renderPage(pageIndex: number, options?: RenderDocxThumbnailPageOptions): Promise<DocxThumbnailRenderResult>;
|
|
2099
|
+
dispose(): void;
|
|
2100
|
+
}
|
|
2101
|
+
declare function createDocxThumbnailRenderer(documentModel: DocxThumbnailDocument, options?: CreateDocxThumbnailRendererOptions): DocxThumbnailRenderer;
|
|
1965
2102
|
|
|
1966
|
-
export { type AnnotationMutationFailureReason, type AnnotationMutationResult, type CommentCreationResult, type CreateParagraphCommentInput, DEFAULT_MIN_PARAGRAPH_LINE_HEIGHT_PX, DEFAULT_PAGE_OVERFLOW_TOLERANCE_PX, type DocModel, type DocNode, type DocumentCommentDefinition, type DocumentCompatibilitySettings, type DocumentNoteDefinition, type DocumentPageNodeSegment, type DocumentPageRange, type DocumentPageSegmentationOptions, type DocumentSection, type DocxAnnotationCommandFailureReason, type DocxAnnotationCommandResult, type DocxBorderContext, type DocxBorderPreset, type DocxBorderPresetState, type DocxComment, type DocxCommentCardRenderProps, type DocxCommentCreationCommandResult, type DocxContextMenuAction, type DocxContextMenuActionId, type DocxContextMenuContext, type DocxContextMenuRenderProps, type DocxCreateCommentOptions, type DocxDocumentTheme, type DocxEditorController, type DocxEditorSelection, DocxEditorViewer, type DocxEditorViewerMode, type DocxEditorViewerProps, type DocxFormFieldLocation, type DocxHeadingStyleMap, type DocxImageDropTarget, type DocxImageLocation, type DocxImageWrapMenuOption, type DocxImageWrapMode, type DocxImageWrapState, type DocxLineSpacingInfo, type DocxListType, type DocxPageLayoutInfo, type DocxPageThumbnailBounds, type DocxPageThumbnailItem, type DocxPageThumbnailRenderWindow, type DocxPageThumbnailResolution, type DocxPageThumbnailResolutionOptions, type DocxPageThumbnailStatus, type DocxPageVirtualizationOptions, type DocxPaginationInfo, type DocxSectionColumnLayout, type DocxSelectedFormField, type DocxTableContextMenuAction, type DocxTableContextMenuActionId, type DocxTableContextMenuContext, type DocxTableContextMenuRenderProps, type DocxTextRange, type DocxTextRangeLocation, type DocxTrackedChange, type DocxTrackedChangeCardRenderProps, type DocxTrackedChangeKind, type DocxViewerThumbnails, type DocxVisiblePageRange, type FooterSection, type FormFieldCheckboxWidgetSettings, type FormFieldDropdownWidgetSettings, type FormFieldOption, type FormFieldRunNode, type FormFieldSourceKind, type FormFieldTextWidgetSettings, type FormFieldType, type FormFieldWidgetSettings, type HeaderSection, type HeadingLevel, type ImageRunNode, type InsertParagraphOptions, type LayoutBlock, type LayoutFragmentSource, type LayoutImageRun, type LayoutOptions, type LayoutPage, type LayoutParagraphBlock, type LayoutRun, type LayoutSnapshot, type LayoutSnapshotBlockFragment, type LayoutSnapshotImageRun, type LayoutSnapshotMargins, type LayoutSnapshotOptions, type LayoutSnapshotPage, type LayoutSnapshotPageSize, type LayoutSnapshotParagraphFragment, type LayoutSnapshotRect, type LayoutSnapshotRun, type LayoutSnapshotTableCellFragment, type LayoutSnapshotTableFragment, type LayoutSnapshotTableRowFragment, type LayoutSnapshotTextRun, type LayoutTableBlock, type LayoutTableCell, type LayoutTableRow, type LayoutTextRun, type LegacyWasmOoxmlPackage, type LetterheadColumnSegmentGroup, type NumberingAbstractDefinition, type NumberingDefinitionSet, type NumberingInstanceDefinition, type NumberingLevelDefinition, type NumberingPictureBulletDefinition, type OoxmlPackage, type OoxmlPart, type OverflowBreakCollectionOptions, type PageSegmentationCallbacks, type PaginationSectionMetrics, type ParagraphAlignment, type ParagraphBorderSet, type ParagraphBorderStyle, type ParagraphChildNode, type ParagraphIndent, type ParagraphLineRange, type ParagraphNode, type ParagraphNumbering, type ParagraphRevisionKind, type ParagraphRevisionTarget, type ParagraphSpacing, type ParagraphSplitControlOptions, type ParagraphStyle, type ParagraphStyleDefinition, type ParagraphTabStop, ReactDocxViewer, type ReactDocxViewerProps, type ResolvedDocument, type ResolvedDocumentSection, type ResolvedLayoutMetrics, type ResolvedModelSection, type TableBorderSet, type TableBorderStyle, type TableBoxSpacing, type TableCellContentNode, type TableCellNode, type TableCellStyle, type TableExplicitPageBreakInfo, type TableNode, type TableRowNode, type TableRowRange, type TableRowStyle, type TableStyle, type TextRunBorderStyle, type TextRunNode, type TextStyle, type UpdateTextOptions, type UseDocxBordersResult, type UseDocxCommentsResult, type UseDocxDocumentThemeResult, type UseDocxEditorOptions, type UseDocxFormFieldsResult, type UseDocxImageWrapMenuResult, type UseDocxLineSpacingResult, type UseDocxModelState, type UseDocxPageLayoutResult, type UseDocxPageThumbnailsOptions, type UseDocxPageThumbnailsResult, type UseDocxPaginationResult, type UseDocxParagraphStylesResult, type UseDocxTrackChangesResult, type UseDocxViewerThumbnailsOptions, type WasmOoxmlPackage, type WasmSource, acceptParagraphRevision, allocateBlockId, applyRunStyle, buildDocModel, buildDocModelFromBytes, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, cloneParagraphNode, cloneTableNode, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectDuplicateDocModelBlockIds, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createMinimalDocxPackage, createParagraphComment, deepFreezeDocModel, defaultStarterModel, duplicateParagraph, ensureDocModelBlockIds, getPart, initWasm, insertParagraph, layoutDocument, modelToDocumentXml, normalizeDocModel, packageToArrayBuffer, paragraphAfterSpacingPx, paragraphBeforeSpacingPx, paragraphHasExplicitPageBreak, paragraphHasLastRenderedPageBreak, paragraphHasPageBreakBefore, paragraphLetterheadColumnGroupAtSegmentOffset, paragraphLetterheadFloatSideAtNodeIndex, paragraphStartsWithLastRenderedPageBreak, parseDocx, parseParagraphsFromClipboard, parseSectionLayout, pasteParagraphs, rejectParagraphRevision, removeParagraph, replaceText, resolveDocumentForLayout, resolveDocumentLayout, resolveDocumentPageSegmentStartNodeIndex, resolveDocumentSectionsFromMetadata, resolveDocxPageThumbnailResolution, resolvePaginationSectionMetricsIndexForNodeIndex, resolveParagraphBeforeSpacingPx, resolveSectionIndexForNodeIndex, resolveSectionPropertiesXmlForNodeIndex, scalePaginationSectionMetricsHeights, scorePaginationAgainstStoredPageBreaks, sectionBreakAfterParagraphStartsNewPage, sectionBreakPropertiesStartNewPage, sectionTitlePageEnabled, selectSectionVariantForPage, serializeDocModel, serializeDocx, serializeParagraphsForClipboard, setCommentResolved, setParagraphAlignment, setParagraphHeading, setRunColor, setRunHighlight, setWasmSource, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxComments, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };
|
|
2103
|
+
export { type AnnotationMutationFailureReason, type AnnotationMutationResult, type CommentCreationResult, type CreateDocxThumbnailRendererOptions, type CreateParagraphCommentInput, DEFAULT_MIN_PARAGRAPH_LINE_HEIGHT_PX, DEFAULT_PAGE_OVERFLOW_TOLERANCE_PX, type DocModel, type DocNode, type DocumentCommentDefinition, type DocumentCompatibilitySettings, type DocumentNoteDefinition, type DocumentPageNodeSegment, type DocumentPageRange, type DocumentPageSegmentationOptions, type DocumentSection, type DocxAnnotationCommandFailureReason, type DocxAnnotationCommandResult, type DocxBorderContext, type DocxBorderPreset, type DocxBorderPresetState, type DocxComment, type DocxCommentCardRenderProps, type DocxCommentCreationCommandResult, type DocxContextMenuAction, type DocxContextMenuActionId, type DocxContextMenuContext, type DocxContextMenuRenderProps, type DocxCreateCommentOptions, type DocxDocumentTheme, type DocxEditorController, type DocxEditorSelection, DocxEditorViewer, type DocxEditorViewerMode, type DocxEditorViewerProps, type DocxFormFieldLocation, type DocxHeadingStyleMap, type DocxImageDropTarget, type DocxImageLocation, type DocxImageWrapMenuOption, type DocxImageWrapMode, type DocxImageWrapState, type DocxLineSpacingInfo, type DocxListType, type DocxPageLayoutInfo, type DocxPageThumbnailBounds, type DocxPageThumbnailItem, type DocxPageThumbnailRenderWindow, type DocxPageThumbnailResolution, type DocxPageThumbnailResolutionOptions, type DocxPageThumbnailStatus, type DocxPageVirtualizationOptions, type DocxPaginationInfo, type DocxRenderToCanvasOptions, type DocxSectionColumnLayout, type DocxSelectedFormField, type DocxTableContextMenuAction, type DocxTableContextMenuActionId, type DocxTableContextMenuContext, type DocxTableContextMenuRenderProps, type DocxTextRange, type DocxTextRangeLocation, type DocxThumbnailDocument, type DocxThumbnailOutput, type DocxThumbnailRenderResult, type DocxThumbnailRenderTimings, type DocxThumbnailRenderer, type DocxThumbnailScheduling, type DocxTrackedChange, type DocxTrackedChangeCardRenderProps, type DocxTrackedChangeKind, type DocxViewerSource, type DocxViewerThumbnails, type DocxVisiblePageRange, type FooterSection, type FormFieldCheckboxWidgetSettings, type FormFieldDropdownWidgetSettings, type FormFieldOption, type FormFieldRunNode, type FormFieldSourceKind, type FormFieldTextWidgetSettings, type FormFieldType, type FormFieldWidgetSettings, type HeaderSection, type HeadingLevel, type ImageRunNode, type InsertParagraphOptions, type LayoutBlock, type LayoutFragmentSource, type LayoutImageRun, type LayoutOptions, type LayoutPage, type LayoutParagraphBlock, type LayoutRun, type LayoutSnapshot, type LayoutSnapshotBlockFragment, type LayoutSnapshotImageRun, type LayoutSnapshotMargins, type LayoutSnapshotOptions, type LayoutSnapshotPage, type LayoutSnapshotPageSize, type LayoutSnapshotParagraphFragment, type LayoutSnapshotRect, type LayoutSnapshotRun, type LayoutSnapshotTableCellFragment, type LayoutSnapshotTableFragment, type LayoutSnapshotTableRowFragment, type LayoutSnapshotTextRun, type LayoutTableBlock, type LayoutTableCell, type LayoutTableRow, type LayoutTextRun, type LegacyWasmOoxmlPackage, type LetterheadColumnSegmentGroup, type NumberingAbstractDefinition, type NumberingDefinitionSet, type NumberingInstanceDefinition, type NumberingLevelDefinition, type NumberingPictureBulletDefinition, type OoxmlPackage, type OoxmlPart, type OverflowBreakCollectionOptions, type PageSegmentationCallbacks, type PaginationSectionMetrics, type ParagraphAlignment, type ParagraphBorderSet, type ParagraphBorderStyle, type ParagraphChildNode, type ParagraphIndent, type ParagraphLineRange, type ParagraphNode, type ParagraphNumbering, type ParagraphRevisionKind, type ParagraphRevisionTarget, type ParagraphSpacing, type ParagraphSplitControlOptions, type ParagraphStyle, type ParagraphStyleDefinition, type ParagraphTabStop, type ParseDocxForViewerOptions, type ParsedDocxDocument, type ParsedDocxPerformanceTimings, ReactDocxViewer, type ReactDocxViewerProps, type RenderDocxThumbnailPageOptions, type ResolvedDocument, type ResolvedDocumentSection, type ResolvedLayoutMetrics, type ResolvedModelSection, type TableBorderSet, type TableBorderStyle, type TableBoxSpacing, type TableCellContentNode, type TableCellNode, type TableCellStyle, type TableExplicitPageBreakInfo, type TableNode, type TableRowNode, type TableRowRange, type TableRowStyle, type TableStyle, type TextRunBorderStyle, type TextRunNode, type TextStyle, type UpdateTextOptions, type UseDocxBordersResult, type UseDocxCommentsResult, type UseDocxDocumentThemeResult, type UseDocxEditorOptions, type UseDocxFormFieldsResult, type UseDocxImageWrapMenuResult, type UseDocxLineSpacingResult, type UseDocxModelState, type UseDocxPageLayoutResult, type UseDocxPageThumbnailsOptions, type UseDocxPageThumbnailsResult, type UseDocxPaginationResult, type UseDocxParagraphStylesResult, type UseDocxTrackChangesResult, type UseDocxViewerThumbnailsOptions, type WasmOoxmlPackage, type WasmSource, acceptParagraphRevision, allocateBlockId, applyRunStyle, buildDocModel, buildDocModelFromBytes, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, cloneParagraphNode, cloneTableNode, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectDuplicateDocModelBlockIds, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createDocxThumbnailRenderer, createMinimalDocxPackage, createParagraphComment, deepFreezeDocModel, defaultStarterModel, duplicateParagraph, ensureDocModelBlockIds, getPart, initWasm, insertParagraph, layoutDocument, modelToDocumentXml, normalizeDocModel, packageToArrayBuffer, paragraphAfterSpacingPx, paragraphBeforeSpacingPx, paragraphHasExplicitPageBreak, paragraphHasLastRenderedPageBreak, paragraphHasPageBreakBefore, paragraphLetterheadColumnGroupAtSegmentOffset, paragraphLetterheadFloatSideAtNodeIndex, paragraphStartsWithLastRenderedPageBreak, parseDocx, parseDocxForViewer, parseParagraphsFromClipboard, parseSectionLayout, pasteParagraphs, rejectParagraphRevision, removeParagraph, replaceText, resolveDocumentForLayout, resolveDocumentLayout, resolveDocumentPageSegmentStartNodeIndex, resolveDocumentSectionsFromMetadata, resolveDocxPageThumbnailResolution, resolvePaginationSectionMetricsIndexForNodeIndex, resolveParagraphBeforeSpacingPx, resolveSectionIndexForNodeIndex, resolveSectionPropertiesXmlForNodeIndex, scalePaginationSectionMetricsHeights, scorePaginationAgainstStoredPageBreaks, sectionBreakAfterParagraphStartsNewPage, sectionBreakPropertiesStartNewPage, sectionTitlePageEnabled, selectSectionVariantForPage, serializeDocModel, serializeDocx, serializeParagraphsForClipboard, setCommentResolved, setParagraphAlignment, setParagraphHeading, setRunColor, setRunHighlight, setWasmSource, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxComments, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };
|
package/dist/index.d.ts
CHANGED
|
@@ -547,6 +547,11 @@ declare function buildDocModel(pkg: OoxmlPackage): Promise<DocModel>;
|
|
|
547
547
|
declare function buildDocModelFromBytes(bytes: ArrayBuffer | Uint8Array): Promise<{
|
|
548
548
|
package: OoxmlPackage;
|
|
549
549
|
model: DocModel;
|
|
550
|
+
timings: {
|
|
551
|
+
parseMs: number;
|
|
552
|
+
buildModelMs: number;
|
|
553
|
+
totalMs: number;
|
|
554
|
+
};
|
|
550
555
|
}>;
|
|
551
556
|
|
|
552
557
|
interface LayoutOptions {
|
|
@@ -614,6 +619,50 @@ interface LayoutPage {
|
|
|
614
619
|
}
|
|
615
620
|
declare function layoutDocument(model: DocModel, options?: LayoutOptions): LayoutPage[];
|
|
616
621
|
|
|
622
|
+
declare function setWasmSource(source: WasmSource): void;
|
|
623
|
+
declare function initWasm(source?: WasmSource): ReturnType<typeof initWasm$1>;
|
|
624
|
+
|
|
625
|
+
interface DocxImportResult {
|
|
626
|
+
package: OoxmlPackage;
|
|
627
|
+
model: DocModel;
|
|
628
|
+
source: "worker" | "main-thread";
|
|
629
|
+
timings?: DocxImportWorkerTimings;
|
|
630
|
+
}
|
|
631
|
+
interface DocxImportOptions {
|
|
632
|
+
signal?: AbortSignal;
|
|
633
|
+
transferBuffer?: boolean;
|
|
634
|
+
useWorker?: boolean | "required";
|
|
635
|
+
}
|
|
636
|
+
interface DocxImportWorkerTimings {
|
|
637
|
+
totalMs: number;
|
|
638
|
+
parseMs: number;
|
|
639
|
+
buildModelMs: number;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
type DocxViewerSource = ArrayBuffer | ArrayBufferView | Blob;
|
|
643
|
+
interface ParseDocxForViewerOptions extends DocxImportOptions {
|
|
644
|
+
loadEmbeddedFonts?: boolean | "defer";
|
|
645
|
+
fileName?: string;
|
|
646
|
+
}
|
|
647
|
+
interface ParsedDocxPerformanceTimings {
|
|
648
|
+
fileReadMs: number;
|
|
649
|
+
parseMs: number;
|
|
650
|
+
modelConstructionMs: number;
|
|
651
|
+
fontLoadingMs: number;
|
|
652
|
+
totalMs: number;
|
|
653
|
+
}
|
|
654
|
+
interface ParsedDocxDocument {
|
|
655
|
+
readonly model: DocModel;
|
|
656
|
+
readonly package: OoxmlPackage;
|
|
657
|
+
readonly source: DocxImportResult["source"];
|
|
658
|
+
readonly fileName?: string;
|
|
659
|
+
readonly timings: ParsedDocxPerformanceTimings;
|
|
660
|
+
readonly embeddedFontsLoaded: boolean;
|
|
661
|
+
loadEmbeddedFonts(): Promise<void>;
|
|
662
|
+
dispose(): void;
|
|
663
|
+
}
|
|
664
|
+
declare function parseDocxForViewer(source: DocxViewerSource, options?: ParseDocxForViewerOptions): Promise<ParsedDocxDocument>;
|
|
665
|
+
|
|
617
666
|
type AnnotationMutationFailureReason = "stale" | "unsupported" | "unsafe-xml";
|
|
618
667
|
type AnnotationMutationResult = {
|
|
619
668
|
ok: true;
|
|
@@ -767,6 +816,7 @@ interface DocxHistoryRestoreRequest {
|
|
|
767
816
|
nonce: number;
|
|
768
817
|
selection: DocxEditorSelection;
|
|
769
818
|
activeTextRange?: DocxTextRange;
|
|
819
|
+
textInput?: boolean;
|
|
770
820
|
}
|
|
771
821
|
type ParagraphLocation = DocxTextRangeLocation;
|
|
772
822
|
type DocxImageLocation = ParagraphLocation & {
|
|
@@ -793,6 +843,8 @@ interface DocxSelectedFormField {
|
|
|
793
843
|
}
|
|
794
844
|
type DocxImageDropTarget = ParagraphLocation & {
|
|
795
845
|
childIndex: number;
|
|
846
|
+
/** UTF-16 offset inside the target text run. */
|
|
847
|
+
textOffset?: number;
|
|
796
848
|
};
|
|
797
849
|
type DocxTrackedChangeKind = "insertion" | "deletion" | "move-from" | "move-to" | "format-change" | "paragraph-format-change";
|
|
798
850
|
interface DocxTrackedChange {
|
|
@@ -881,6 +933,17 @@ type DocxBorderPresetState = Record<DocxBorderPreset, boolean>;
|
|
|
881
933
|
* imports update the controller through `editor.importDocxFile`.
|
|
882
934
|
*/
|
|
883
935
|
interface UseDocxEditorOptions {
|
|
936
|
+
/**
|
|
937
|
+
* Parsed document to use as the initial editor state without reading or
|
|
938
|
+
* parsing the source again.
|
|
939
|
+
*/
|
|
940
|
+
document?: ParsedDocxDocument;
|
|
941
|
+
/**
|
|
942
|
+
* Loads embedded fonts when an initial parsed document deferred them.
|
|
943
|
+
*
|
|
944
|
+
* @defaultValue `true`
|
|
945
|
+
*/
|
|
946
|
+
loadEmbeddedFonts?: boolean;
|
|
884
947
|
/**
|
|
885
948
|
* Model used for `editor.newDocument()` and for the initial empty editor.
|
|
886
949
|
*
|
|
@@ -1028,6 +1091,7 @@ interface DocxEditorController {
|
|
|
1028
1091
|
setImageWrapMode: (location: DocxImageLocation, mode: DocxImageWrapMode, seedFloating?: Partial<NonNullable<ImageRunNode["floating"]>>) => void;
|
|
1029
1092
|
moveFloatingImage: (location: DocxImageLocation, patch: Partial<NonNullable<ImageRunNode["floating"]>>, options?: {
|
|
1030
1093
|
reparentToParagraphNodeIndex?: number;
|
|
1094
|
+
anchorTextOffset?: number;
|
|
1031
1095
|
}) => void;
|
|
1032
1096
|
moveSectionFloatingImage: (location: DocxSectionImageLocation, patch: Partial<NonNullable<ImageRunNode["floating"]>>) => void;
|
|
1033
1097
|
moveParagraphDropCap: (nodeIndex: number, patch: Partial<NonNullable<NonNullable<ParagraphNode["style"]>["dropCap"]>>) => void;
|
|
@@ -1049,6 +1113,7 @@ interface DocxEditorController {
|
|
|
1049
1113
|
moveTable: (tableIndex: number, targetNodeIndex: number) => void;
|
|
1050
1114
|
setTableFloating: (tableIndex: number, patch: Partial<NonNullable<NonNullable<TableNode["style"]>["floating"]>>, options?: {
|
|
1051
1115
|
moveToNodeIndex?: number;
|
|
1116
|
+
anchorTextOffset?: number;
|
|
1052
1117
|
}) => void;
|
|
1053
1118
|
moveEmbeddedTableToBody: (tableRuntimeKey: string, targetNodeIndex: number) => void;
|
|
1054
1119
|
replaceExpandedSelection: (text: string, range?: DocxTextRange) => DocxTextRange | undefined;
|
|
@@ -1309,6 +1374,11 @@ interface DocxEditorViewerProps {
|
|
|
1309
1374
|
* range is rendered.
|
|
1310
1375
|
*/
|
|
1311
1376
|
visiblePageRange?: DocxVisiblePageRange;
|
|
1377
|
+
/**
|
|
1378
|
+
* Hard set of zero-based pages to mount. Unlike `visiblePageRange`, omitted
|
|
1379
|
+
* pages remain metadata-only even when they fall between requested pages.
|
|
1380
|
+
*/
|
|
1381
|
+
pageIndexes?: readonly number[];
|
|
1312
1382
|
/**
|
|
1313
1383
|
* Called whenever the viewer's resolved page count changes.
|
|
1314
1384
|
*/
|
|
@@ -1609,6 +1679,17 @@ interface UseDocxPageThumbnailsOptions {
|
|
|
1609
1679
|
* Prioritizes thumbnails for consumer-owned virtualized thumbnail rails.
|
|
1610
1680
|
*/
|
|
1611
1681
|
renderWindow?: DocxPageThumbnailRenderWindow;
|
|
1682
|
+
/**
|
|
1683
|
+
* Hard set of zero-based pages exposed and eligible for rasterization.
|
|
1684
|
+
* Omit to preserve the existing all-pages behavior.
|
|
1685
|
+
*/
|
|
1686
|
+
pageIndexes?: readonly number[];
|
|
1687
|
+
/**
|
|
1688
|
+
* Default scheduling policy for thumbnail paint requests.
|
|
1689
|
+
*
|
|
1690
|
+
* @defaultValue `"idle"`
|
|
1691
|
+
*/
|
|
1692
|
+
scheduling?: DocxThumbnailScheduling;
|
|
1612
1693
|
/**
|
|
1613
1694
|
* Prevents thumbnail rendering while keeping stable item metadata.
|
|
1614
1695
|
*
|
|
@@ -1617,6 +1698,13 @@ interface UseDocxPageThumbnailsOptions {
|
|
|
1617
1698
|
disabled?: boolean;
|
|
1618
1699
|
}
|
|
1619
1700
|
type DocxPageThumbnailStatus = "idle" | "rendering" | "ready" | "unavailable" | "error";
|
|
1701
|
+
type DocxThumbnailScheduling = "idle" | "immediate";
|
|
1702
|
+
interface DocxRenderToCanvasOptions {
|
|
1703
|
+
/** Bypasses idle scheduling for a visible imperative request. */
|
|
1704
|
+
scheduling?: DocxThumbnailScheduling;
|
|
1705
|
+
/** Ignores unchanged-content and surface-cache fast paths. */
|
|
1706
|
+
force?: boolean;
|
|
1707
|
+
}
|
|
1620
1708
|
interface DocxPageThumbnailItem extends DocxPageThumbnailResolution {
|
|
1621
1709
|
/** Source page aspect ratio. */
|
|
1622
1710
|
aspectRatio: number;
|
|
@@ -1645,7 +1733,7 @@ interface DocxPageThumbnailItem extends DocxPageThumbnailResolution {
|
|
|
1645
1733
|
/** Ref callback that keeps an attached canvas rendered as the page changes. */
|
|
1646
1734
|
canvasRef: (canvas: HTMLCanvasElement | null) => void;
|
|
1647
1735
|
/** Asynchronously renders this thumbnail into a canvas. */
|
|
1648
|
-
renderToCanvas: (canvas: HTMLCanvasElement) => Promise<void>;
|
|
1736
|
+
renderToCanvas: (canvas: HTMLCanvasElement, options?: DocxRenderToCanvasOptions) => Promise<void>;
|
|
1649
1737
|
/** Alias for `widthPx`. */
|
|
1650
1738
|
width: number;
|
|
1651
1739
|
}
|
|
@@ -1679,7 +1767,7 @@ declare function useDocxTrackChanges(editor: Pick<DocxEditorController, "tracked
|
|
|
1679
1767
|
declare function useDocxComments(editor: Pick<DocxEditorController, "comments" | "showComments" | "setShowComments" | "toggleShowComments" | "createComment" | "setCommentResolved">): UseDocxCommentsResult;
|
|
1680
1768
|
declare function useDocxPageLayout(editor: Pick<DocxEditorController, "model">): UseDocxPageLayoutResult;
|
|
1681
1769
|
declare function useDocxPagination(editor: Pick<DocxEditorController, "currentPage" | "totalPages">): UseDocxPaginationResult;
|
|
1682
|
-
declare function DocxEditorViewer({ editor, className, style, pageBackgroundColor, pageGapBackgroundColor, deferInitialPaginationPaint, loadingState, pageVirtualization, visiblePageRange, onPageCountChange, onRequestPageReveal, headingStyles, showTrackedChanges, renderTrackedChangeCard, showComments, renderCommentCard, renderTableContextMenu, renderContextMenu, onFormFieldDoubleClick, mode, }: DocxEditorViewerProps): React.JSX.Element;
|
|
1770
|
+
declare function DocxEditorViewer({ editor, className, style, pageBackgroundColor, pageGapBackgroundColor, deferInitialPaginationPaint, loadingState, pageVirtualization, visiblePageRange, pageIndexes, onPageCountChange, onRequestPageReveal, headingStyles, showTrackedChanges, renderTrackedChangeCard, showComments, renderCommentCard, renderTableContextMenu, renderContextMenu, onFormFieldDoubleClick, mode, }: DocxEditorViewerProps): React.JSX.Element;
|
|
1683
1771
|
|
|
1684
1772
|
interface ResolvedModelSection {
|
|
1685
1773
|
startNodeIndex: number;
|
|
@@ -1896,9 +1984,6 @@ declare function modelToDocumentXml(model: DocModel, basePackage?: OoxmlPackage)
|
|
|
1896
1984
|
declare function serializeDocModel(model: DocModel, basePackage?: OoxmlPackage): Promise<OoxmlPackage>;
|
|
1897
1985
|
declare function serializeDocx(model: DocModel, basePackage?: OoxmlPackage): Promise<ArrayBuffer>;
|
|
1898
1986
|
|
|
1899
|
-
declare function setWasmSource(source: WasmSource): void;
|
|
1900
|
-
declare function initWasm(source?: WasmSource): ReturnType<typeof initWasm$1>;
|
|
1901
|
-
|
|
1902
1987
|
interface ReactDocxViewerProps {
|
|
1903
1988
|
/**
|
|
1904
1989
|
* Raw `.docx` file contents to parse and render.
|
|
@@ -1921,6 +2006,12 @@ interface ReactDocxViewerProps {
|
|
|
1921
2006
|
* pipeline.
|
|
1922
2007
|
*/
|
|
1923
2008
|
model?: DocModel;
|
|
2009
|
+
/** Parsed input returned by `parseDocxForViewer`. */
|
|
2010
|
+
document?: ParsedDocxDocument;
|
|
2011
|
+
/** Loads deferred embedded fonts when a parsed document is mounted. */
|
|
2012
|
+
loadEmbeddedFonts?: boolean;
|
|
2013
|
+
/** Hard set of zero-based pages to mount. */
|
|
2014
|
+
pageIndexes?: readonly number[];
|
|
1924
2015
|
/**
|
|
1925
2016
|
* CSS class applied to the outer viewer container.
|
|
1926
2017
|
*
|
|
@@ -1961,6 +2052,52 @@ interface UseDocxModelState {
|
|
|
1961
2052
|
error?: Error;
|
|
1962
2053
|
}
|
|
1963
2054
|
declare function useDocxModel(file?: ArrayBuffer): UseDocxModelState;
|
|
1964
|
-
declare function ReactDocxViewer({ file, model, className, layoutOptions, emptyState, }: ReactDocxViewerProps): React.JSX.Element;
|
|
2055
|
+
declare function ReactDocxViewer({ file, model, document, loadEmbeddedFonts, pageIndexes, className, layoutOptions, emptyState, }: ReactDocxViewerProps): React.JSX.Element;
|
|
2056
|
+
type DocxThumbnailOutput = "canvas" | "blob" | "imageBitmap";
|
|
2057
|
+
interface CreateDocxThumbnailRendererOptions {
|
|
2058
|
+
scheduling?: DocxThumbnailScheduling;
|
|
2059
|
+
pixelRatio?: number;
|
|
2060
|
+
resolution?: DocxPageThumbnailBounds;
|
|
2061
|
+
pageIndexes?: readonly number[];
|
|
2062
|
+
}
|
|
2063
|
+
interface RenderDocxThumbnailPageOptions {
|
|
2064
|
+
scheduling?: DocxThumbnailScheduling;
|
|
2065
|
+
pixelRatio?: number;
|
|
2066
|
+
resolution?: DocxPageThumbnailBounds;
|
|
2067
|
+
maxWidth?: number;
|
|
2068
|
+
maxHeight?: number;
|
|
2069
|
+
output?: DocxThumbnailOutput;
|
|
2070
|
+
canvas?: HTMLCanvasElement;
|
|
2071
|
+
mimeType?: string;
|
|
2072
|
+
quality?: number;
|
|
2073
|
+
}
|
|
2074
|
+
interface DocxThumbnailRenderTimings {
|
|
2075
|
+
paginationMs: number;
|
|
2076
|
+
pageMountMs: number;
|
|
2077
|
+
rasterizationMs: number;
|
|
2078
|
+
encodingMs: number;
|
|
2079
|
+
totalMs: number;
|
|
2080
|
+
}
|
|
2081
|
+
interface DocxThumbnailRenderResult {
|
|
2082
|
+
pageIndex: number;
|
|
2083
|
+
pageCount: number;
|
|
2084
|
+
width: number;
|
|
2085
|
+
height: number;
|
|
2086
|
+
pixelWidth: number;
|
|
2087
|
+
pixelHeight: number;
|
|
2088
|
+
output: DocxThumbnailOutput;
|
|
2089
|
+
canvas?: HTMLCanvasElement;
|
|
2090
|
+
blob?: Blob;
|
|
2091
|
+
imageBitmap?: ImageBitmap;
|
|
2092
|
+
timings: DocxThumbnailRenderTimings;
|
|
2093
|
+
}
|
|
2094
|
+
type DocxThumbnailDocument = ParsedDocxDocument | DocModel;
|
|
2095
|
+
interface DocxThumbnailRenderer {
|
|
2096
|
+
readonly document: DocxThumbnailDocument;
|
|
2097
|
+
readonly pageCount: number;
|
|
2098
|
+
renderPage(pageIndex: number, options?: RenderDocxThumbnailPageOptions): Promise<DocxThumbnailRenderResult>;
|
|
2099
|
+
dispose(): void;
|
|
2100
|
+
}
|
|
2101
|
+
declare function createDocxThumbnailRenderer(documentModel: DocxThumbnailDocument, options?: CreateDocxThumbnailRendererOptions): DocxThumbnailRenderer;
|
|
1965
2102
|
|
|
1966
|
-
export { type AnnotationMutationFailureReason, type AnnotationMutationResult, type CommentCreationResult, type CreateParagraphCommentInput, DEFAULT_MIN_PARAGRAPH_LINE_HEIGHT_PX, DEFAULT_PAGE_OVERFLOW_TOLERANCE_PX, type DocModel, type DocNode, type DocumentCommentDefinition, type DocumentCompatibilitySettings, type DocumentNoteDefinition, type DocumentPageNodeSegment, type DocumentPageRange, type DocumentPageSegmentationOptions, type DocumentSection, type DocxAnnotationCommandFailureReason, type DocxAnnotationCommandResult, type DocxBorderContext, type DocxBorderPreset, type DocxBorderPresetState, type DocxComment, type DocxCommentCardRenderProps, type DocxCommentCreationCommandResult, type DocxContextMenuAction, type DocxContextMenuActionId, type DocxContextMenuContext, type DocxContextMenuRenderProps, type DocxCreateCommentOptions, type DocxDocumentTheme, type DocxEditorController, type DocxEditorSelection, DocxEditorViewer, type DocxEditorViewerMode, type DocxEditorViewerProps, type DocxFormFieldLocation, type DocxHeadingStyleMap, type DocxImageDropTarget, type DocxImageLocation, type DocxImageWrapMenuOption, type DocxImageWrapMode, type DocxImageWrapState, type DocxLineSpacingInfo, type DocxListType, type DocxPageLayoutInfo, type DocxPageThumbnailBounds, type DocxPageThumbnailItem, type DocxPageThumbnailRenderWindow, type DocxPageThumbnailResolution, type DocxPageThumbnailResolutionOptions, type DocxPageThumbnailStatus, type DocxPageVirtualizationOptions, type DocxPaginationInfo, type DocxSectionColumnLayout, type DocxSelectedFormField, type DocxTableContextMenuAction, type DocxTableContextMenuActionId, type DocxTableContextMenuContext, type DocxTableContextMenuRenderProps, type DocxTextRange, type DocxTextRangeLocation, type DocxTrackedChange, type DocxTrackedChangeCardRenderProps, type DocxTrackedChangeKind, type DocxViewerThumbnails, type DocxVisiblePageRange, type FooterSection, type FormFieldCheckboxWidgetSettings, type FormFieldDropdownWidgetSettings, type FormFieldOption, type FormFieldRunNode, type FormFieldSourceKind, type FormFieldTextWidgetSettings, type FormFieldType, type FormFieldWidgetSettings, type HeaderSection, type HeadingLevel, type ImageRunNode, type InsertParagraphOptions, type LayoutBlock, type LayoutFragmentSource, type LayoutImageRun, type LayoutOptions, type LayoutPage, type LayoutParagraphBlock, type LayoutRun, type LayoutSnapshot, type LayoutSnapshotBlockFragment, type LayoutSnapshotImageRun, type LayoutSnapshotMargins, type LayoutSnapshotOptions, type LayoutSnapshotPage, type LayoutSnapshotPageSize, type LayoutSnapshotParagraphFragment, type LayoutSnapshotRect, type LayoutSnapshotRun, type LayoutSnapshotTableCellFragment, type LayoutSnapshotTableFragment, type LayoutSnapshotTableRowFragment, type LayoutSnapshotTextRun, type LayoutTableBlock, type LayoutTableCell, type LayoutTableRow, type LayoutTextRun, type LegacyWasmOoxmlPackage, type LetterheadColumnSegmentGroup, type NumberingAbstractDefinition, type NumberingDefinitionSet, type NumberingInstanceDefinition, type NumberingLevelDefinition, type NumberingPictureBulletDefinition, type OoxmlPackage, type OoxmlPart, type OverflowBreakCollectionOptions, type PageSegmentationCallbacks, type PaginationSectionMetrics, type ParagraphAlignment, type ParagraphBorderSet, type ParagraphBorderStyle, type ParagraphChildNode, type ParagraphIndent, type ParagraphLineRange, type ParagraphNode, type ParagraphNumbering, type ParagraphRevisionKind, type ParagraphRevisionTarget, type ParagraphSpacing, type ParagraphSplitControlOptions, type ParagraphStyle, type ParagraphStyleDefinition, type ParagraphTabStop, ReactDocxViewer, type ReactDocxViewerProps, type ResolvedDocument, type ResolvedDocumentSection, type ResolvedLayoutMetrics, type ResolvedModelSection, type TableBorderSet, type TableBorderStyle, type TableBoxSpacing, type TableCellContentNode, type TableCellNode, type TableCellStyle, type TableExplicitPageBreakInfo, type TableNode, type TableRowNode, type TableRowRange, type TableRowStyle, type TableStyle, type TextRunBorderStyle, type TextRunNode, type TextStyle, type UpdateTextOptions, type UseDocxBordersResult, type UseDocxCommentsResult, type UseDocxDocumentThemeResult, type UseDocxEditorOptions, type UseDocxFormFieldsResult, type UseDocxImageWrapMenuResult, type UseDocxLineSpacingResult, type UseDocxModelState, type UseDocxPageLayoutResult, type UseDocxPageThumbnailsOptions, type UseDocxPageThumbnailsResult, type UseDocxPaginationResult, type UseDocxParagraphStylesResult, type UseDocxTrackChangesResult, type UseDocxViewerThumbnailsOptions, type WasmOoxmlPackage, type WasmSource, acceptParagraphRevision, allocateBlockId, applyRunStyle, buildDocModel, buildDocModelFromBytes, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, cloneParagraphNode, cloneTableNode, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectDuplicateDocModelBlockIds, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createMinimalDocxPackage, createParagraphComment, deepFreezeDocModel, defaultStarterModel, duplicateParagraph, ensureDocModelBlockIds, getPart, initWasm, insertParagraph, layoutDocument, modelToDocumentXml, normalizeDocModel, packageToArrayBuffer, paragraphAfterSpacingPx, paragraphBeforeSpacingPx, paragraphHasExplicitPageBreak, paragraphHasLastRenderedPageBreak, paragraphHasPageBreakBefore, paragraphLetterheadColumnGroupAtSegmentOffset, paragraphLetterheadFloatSideAtNodeIndex, paragraphStartsWithLastRenderedPageBreak, parseDocx, parseParagraphsFromClipboard, parseSectionLayout, pasteParagraphs, rejectParagraphRevision, removeParagraph, replaceText, resolveDocumentForLayout, resolveDocumentLayout, resolveDocumentPageSegmentStartNodeIndex, resolveDocumentSectionsFromMetadata, resolveDocxPageThumbnailResolution, resolvePaginationSectionMetricsIndexForNodeIndex, resolveParagraphBeforeSpacingPx, resolveSectionIndexForNodeIndex, resolveSectionPropertiesXmlForNodeIndex, scalePaginationSectionMetricsHeights, scorePaginationAgainstStoredPageBreaks, sectionBreakAfterParagraphStartsNewPage, sectionBreakPropertiesStartNewPage, sectionTitlePageEnabled, selectSectionVariantForPage, serializeDocModel, serializeDocx, serializeParagraphsForClipboard, setCommentResolved, setParagraphAlignment, setParagraphHeading, setRunColor, setRunHighlight, setWasmSource, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxComments, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };
|
|
2103
|
+
export { type AnnotationMutationFailureReason, type AnnotationMutationResult, type CommentCreationResult, type CreateDocxThumbnailRendererOptions, type CreateParagraphCommentInput, DEFAULT_MIN_PARAGRAPH_LINE_HEIGHT_PX, DEFAULT_PAGE_OVERFLOW_TOLERANCE_PX, type DocModel, type DocNode, type DocumentCommentDefinition, type DocumentCompatibilitySettings, type DocumentNoteDefinition, type DocumentPageNodeSegment, type DocumentPageRange, type DocumentPageSegmentationOptions, type DocumentSection, type DocxAnnotationCommandFailureReason, type DocxAnnotationCommandResult, type DocxBorderContext, type DocxBorderPreset, type DocxBorderPresetState, type DocxComment, type DocxCommentCardRenderProps, type DocxCommentCreationCommandResult, type DocxContextMenuAction, type DocxContextMenuActionId, type DocxContextMenuContext, type DocxContextMenuRenderProps, type DocxCreateCommentOptions, type DocxDocumentTheme, type DocxEditorController, type DocxEditorSelection, DocxEditorViewer, type DocxEditorViewerMode, type DocxEditorViewerProps, type DocxFormFieldLocation, type DocxHeadingStyleMap, type DocxImageDropTarget, type DocxImageLocation, type DocxImageWrapMenuOption, type DocxImageWrapMode, type DocxImageWrapState, type DocxLineSpacingInfo, type DocxListType, type DocxPageLayoutInfo, type DocxPageThumbnailBounds, type DocxPageThumbnailItem, type DocxPageThumbnailRenderWindow, type DocxPageThumbnailResolution, type DocxPageThumbnailResolutionOptions, type DocxPageThumbnailStatus, type DocxPageVirtualizationOptions, type DocxPaginationInfo, type DocxRenderToCanvasOptions, type DocxSectionColumnLayout, type DocxSelectedFormField, type DocxTableContextMenuAction, type DocxTableContextMenuActionId, type DocxTableContextMenuContext, type DocxTableContextMenuRenderProps, type DocxTextRange, type DocxTextRangeLocation, type DocxThumbnailDocument, type DocxThumbnailOutput, type DocxThumbnailRenderResult, type DocxThumbnailRenderTimings, type DocxThumbnailRenderer, type DocxThumbnailScheduling, type DocxTrackedChange, type DocxTrackedChangeCardRenderProps, type DocxTrackedChangeKind, type DocxViewerSource, type DocxViewerThumbnails, type DocxVisiblePageRange, type FooterSection, type FormFieldCheckboxWidgetSettings, type FormFieldDropdownWidgetSettings, type FormFieldOption, type FormFieldRunNode, type FormFieldSourceKind, type FormFieldTextWidgetSettings, type FormFieldType, type FormFieldWidgetSettings, type HeaderSection, type HeadingLevel, type ImageRunNode, type InsertParagraphOptions, type LayoutBlock, type LayoutFragmentSource, type LayoutImageRun, type LayoutOptions, type LayoutPage, type LayoutParagraphBlock, type LayoutRun, type LayoutSnapshot, type LayoutSnapshotBlockFragment, type LayoutSnapshotImageRun, type LayoutSnapshotMargins, type LayoutSnapshotOptions, type LayoutSnapshotPage, type LayoutSnapshotPageSize, type LayoutSnapshotParagraphFragment, type LayoutSnapshotRect, type LayoutSnapshotRun, type LayoutSnapshotTableCellFragment, type LayoutSnapshotTableFragment, type LayoutSnapshotTableRowFragment, type LayoutSnapshotTextRun, type LayoutTableBlock, type LayoutTableCell, type LayoutTableRow, type LayoutTextRun, type LegacyWasmOoxmlPackage, type LetterheadColumnSegmentGroup, type NumberingAbstractDefinition, type NumberingDefinitionSet, type NumberingInstanceDefinition, type NumberingLevelDefinition, type NumberingPictureBulletDefinition, type OoxmlPackage, type OoxmlPart, type OverflowBreakCollectionOptions, type PageSegmentationCallbacks, type PaginationSectionMetrics, type ParagraphAlignment, type ParagraphBorderSet, type ParagraphBorderStyle, type ParagraphChildNode, type ParagraphIndent, type ParagraphLineRange, type ParagraphNode, type ParagraphNumbering, type ParagraphRevisionKind, type ParagraphRevisionTarget, type ParagraphSpacing, type ParagraphSplitControlOptions, type ParagraphStyle, type ParagraphStyleDefinition, type ParagraphTabStop, type ParseDocxForViewerOptions, type ParsedDocxDocument, type ParsedDocxPerformanceTimings, ReactDocxViewer, type ReactDocxViewerProps, type RenderDocxThumbnailPageOptions, type ResolvedDocument, type ResolvedDocumentSection, type ResolvedLayoutMetrics, type ResolvedModelSection, type TableBorderSet, type TableBorderStyle, type TableBoxSpacing, type TableCellContentNode, type TableCellNode, type TableCellStyle, type TableExplicitPageBreakInfo, type TableNode, type TableRowNode, type TableRowRange, type TableRowStyle, type TableStyle, type TextRunBorderStyle, type TextRunNode, type TextStyle, type UpdateTextOptions, type UseDocxBordersResult, type UseDocxCommentsResult, type UseDocxDocumentThemeResult, type UseDocxEditorOptions, type UseDocxFormFieldsResult, type UseDocxImageWrapMenuResult, type UseDocxLineSpacingResult, type UseDocxModelState, type UseDocxPageLayoutResult, type UseDocxPageThumbnailsOptions, type UseDocxPageThumbnailsResult, type UseDocxPaginationResult, type UseDocxParagraphStylesResult, type UseDocxTrackChangesResult, type UseDocxViewerThumbnailsOptions, type WasmOoxmlPackage, type WasmSource, acceptParagraphRevision, allocateBlockId, applyRunStyle, buildDocModel, buildDocModelFromBytes, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, cloneParagraphNode, cloneTableNode, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectDuplicateDocModelBlockIds, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createDocxThumbnailRenderer, createMinimalDocxPackage, createParagraphComment, deepFreezeDocModel, defaultStarterModel, duplicateParagraph, ensureDocModelBlockIds, getPart, initWasm, insertParagraph, layoutDocument, modelToDocumentXml, normalizeDocModel, packageToArrayBuffer, paragraphAfterSpacingPx, paragraphBeforeSpacingPx, paragraphHasExplicitPageBreak, paragraphHasLastRenderedPageBreak, paragraphHasPageBreakBefore, paragraphLetterheadColumnGroupAtSegmentOffset, paragraphLetterheadFloatSideAtNodeIndex, paragraphStartsWithLastRenderedPageBreak, parseDocx, parseDocxForViewer, parseParagraphsFromClipboard, parseSectionLayout, pasteParagraphs, rejectParagraphRevision, removeParagraph, replaceText, resolveDocumentForLayout, resolveDocumentLayout, resolveDocumentPageSegmentStartNodeIndex, resolveDocumentSectionsFromMetadata, resolveDocxPageThumbnailResolution, resolvePaginationSectionMetricsIndexForNodeIndex, resolveParagraphBeforeSpacingPx, resolveSectionIndexForNodeIndex, resolveSectionPropertiesXmlForNodeIndex, scalePaginationSectionMetricsHeights, scorePaginationAgainstStoredPageBreaks, sectionBreakAfterParagraphStartsNewPage, sectionBreakPropertiesStartNewPage, sectionTitlePageEnabled, selectSectionVariantForPage, serializeDocModel, serializeDocx, serializeParagraphsForClipboard, setCommentResolved, setParagraphAlignment, setParagraphHeading, setRunColor, setRunHighlight, setWasmSource, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxComments, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };
|