@extend-ai/react-docx 0.6.7 → 0.7.0-alpha.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.cts CHANGED
@@ -1,5 +1,14 @@
1
1
  import * as React from 'react';
2
2
 
3
+ interface WasmOoxmlPart {
4
+ name: string;
5
+ content: string;
6
+ }
7
+ interface WasmOoxmlPackage {
8
+ parts: Record<string, WasmOoxmlPart>;
9
+ binaryAssets: Record<string, number[]>;
10
+ }
11
+
3
12
  interface OoxmlPart {
4
13
  name: string;
5
14
  content: string;
@@ -9,7 +18,7 @@ interface OoxmlPackage {
9
18
  binaryAssets: Map<string, Uint8Array>;
10
19
  }
11
20
  declare function parseDocx(input: ArrayBuffer): Promise<OoxmlPackage>;
12
- declare function packageToArrayBuffer(pkg: OoxmlPackage): ArrayBuffer;
21
+ declare function packageToArrayBuffer(pkg: OoxmlPackage): Promise<ArrayBuffer>;
13
22
  declare function createMinimalDocxPackage(documentXml?: string): OoxmlPackage;
14
23
  declare function getPart(pkg: OoxmlPackage, partName: string): OoxmlPart | undefined;
15
24
  declare function withPart(pkg: OoxmlPackage, part: OoxmlPart): OoxmlPackage;
@@ -164,6 +173,11 @@ interface ParagraphBorderSet {
164
173
  between?: ParagraphBorderStyle;
165
174
  bar?: ParagraphBorderStyle;
166
175
  }
176
+ interface ParagraphTabStop {
177
+ alignment?: "left" | "center" | "right" | "decimal" | "bar";
178
+ leader?: "none" | "dot" | "hyphen" | "underscore" | "middleDot";
179
+ positionTwips?: number;
180
+ }
167
181
  interface ParagraphStyle {
168
182
  align?: ParagraphAlignment;
169
183
  headingLevel?: HeadingLevel;
@@ -383,86 +397,17 @@ interface DocModel {
383
397
  endnotes?: DocumentNoteDefinition[];
384
398
  };
385
399
  }
386
- interface ContentTypeLookup {
387
- defaultByExtension: Map<string, string>;
388
- overrideByPartName: Map<string, string>;
389
- }
390
- interface ParseContext {
391
- relationships: Map<string, string>;
392
- contentTypes: ContentTypeLookup;
393
- parts: OoxmlPackage["parts"];
394
- binaryAssets: Map<string, Uint8Array>;
395
- styleSheet: ParsedStyleSheet;
396
- warnings: string[];
397
- }
398
- interface ThemeFontMap {
399
- majorLatin?: string;
400
- minorLatin?: string;
401
- majorEastAsia?: string;
402
- minorEastAsia?: string;
403
- majorComplexScript?: string;
404
- minorComplexScript?: string;
405
- }
406
- interface ThemeColorMap {
407
- [token: ThemeColorToken]: string;
408
- }
409
- interface ParagraphTabStop {
410
- alignment?: "left" | "center" | "right" | "decimal" | "bar";
411
- leader?: "none" | "dot" | "hyphen" | "underscore" | "middleDot";
412
- positionTwips?: number;
413
- }
414
- interface ParsedStyleSheet {
415
- paragraphStyles: ParagraphStyleDefinition[];
416
- paragraphStyleById: Map<string, ParagraphStyleDefinition>;
417
- runStyleById: Map<string, TextStyle>;
418
- tableStyleById: Map<string, ParsedTableStyleDefinition>;
419
- defaultParagraphStyle?: ParagraphStyle;
420
- defaultParagraphStyleId?: string;
421
- defaultRunStyle?: TextStyle;
422
- themeFonts: ThemeFontMap;
423
- themeColors: ThemeColorMap;
424
- }
425
- type TableConditionalStyleType = "wholeTable" | "firstRow" | "lastRow" | "firstCol" | "lastCol" | "band1Horz" | "band2Horz" | "band1Vert" | "band2Vert" | "nwCell" | "neCell" | "swCell" | "seCell";
426
- interface ParsedTableStyleCondition {
427
- rowBackgroundColor?: string;
428
- cellBackgroundColor?: string;
429
- paragraphAlign?: ParagraphAlignment;
430
- runStyle?: TextStyle;
431
- tableBorders?: TableBorderSet;
432
- cellBorders?: TableBorderSet;
433
- tableProperties?: ParsedTableProperties;
434
- tableLook?: ParsedTableLook;
435
- }
436
- interface ParsedTableStyleDefinition {
437
- id: string;
438
- basedOnId?: string;
439
- name: string;
440
- conditions: Partial<Record<TableConditionalStyleType, ParsedTableStyleCondition>>;
441
- floating?: NonNullable<TableStyle["floating"]>;
442
- properties?: ParsedTableProperties;
443
- }
444
- interface ParsedTableProperties {
445
- widthTwips?: number;
446
- indentTwips?: number;
447
- layout?: "fixed" | "autofit";
448
- cellSpacingTwips?: number;
449
- cellMarginTwips?: TableBoxSpacing;
450
- floating?: NonNullable<TableStyle["floating"]>;
451
- }
452
- interface ParsedTableLook {
453
- firstRow: boolean;
454
- lastRow: boolean;
455
- firstCol: boolean;
456
- lastCol: boolean;
457
- noHBand: boolean;
458
- noVBand: boolean;
459
- rowBandSize: number;
460
- colBandSize: number;
461
- }
462
- declare function parseDocumentXml(documentXml: string, context?: ParseContext): DocNode[];
463
- declare function buildDocModel(pkg: OoxmlPackage): DocModel;
400
+
464
401
  declare function cloneDocModel(model: DocModel): DocModel;
465
402
 
403
+ declare function normalizeDocModel(model: DocModel): DocModel;
404
+
405
+ declare function buildDocModel(pkg: OoxmlPackage): Promise<DocModel>;
406
+ declare function buildDocModelFromBytes(bytes: ArrayBuffer | Uint8Array): Promise<{
407
+ package: OoxmlPackage;
408
+ model: DocModel;
409
+ }>;
410
+
466
411
  interface LayoutOptions {
467
412
  pageWidth?: number;
468
413
  pageHeight?: number;
@@ -1578,9 +1523,9 @@ interface LayoutSnapshot {
1578
1523
  declare function resolveDocumentForLayout(model: DocModel, options?: LayoutSnapshotOptions): ResolvedDocument;
1579
1524
  declare function buildLayoutSnapshot(model: DocModel, options?: LayoutSnapshotOptions): LayoutSnapshot;
1580
1525
 
1581
- declare function modelToDocumentXml(model: DocModel, basePackage?: OoxmlPackage): string;
1582
- declare function serializeDocModel(model: DocModel, basePackage?: OoxmlPackage): OoxmlPackage;
1583
- declare function serializeDocx(model: DocModel, basePackage?: OoxmlPackage): ArrayBuffer;
1526
+ declare function modelToDocumentXml(model: DocModel, basePackage?: OoxmlPackage): Promise<string>;
1527
+ declare function serializeDocModel(model: DocModel, basePackage?: OoxmlPackage): Promise<OoxmlPackage>;
1528
+ declare function serializeDocx(model: DocModel, basePackage?: OoxmlPackage): Promise<ArrayBuffer>;
1584
1529
 
1585
1530
  interface ReactDocxViewerProps {
1586
1531
  /**
@@ -1646,4 +1591,4 @@ interface UseDocxModelState {
1646
1591
  declare function useDocxModel(file?: ArrayBuffer): UseDocxModelState;
1647
1592
  declare function ReactDocxViewer({ file, model, className, layoutOptions, emptyState }: ReactDocxViewerProps): React.JSX.Element;
1648
1593
 
1649
- export { DEFAULT_MIN_PARAGRAPH_LINE_HEIGHT_PX, DEFAULT_PAGE_OVERFLOW_TOLERANCE_PX, type DocModel, type DocNode, type DocumentCompatibilitySettings, type DocumentNoteDefinition, type DocumentPageNodeSegment, type DocumentPageRange, type DocumentPageSegmentationOptions, type DocumentSection, type DocxBorderContext, type DocxBorderPreset, type DocxBorderPresetState, type DocxContextMenuAction, type DocxContextMenuActionId, type DocxContextMenuContext, type DocxContextMenuRenderProps, 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 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 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 ParagraphSpacing, type ParagraphSplitControlOptions, type ParagraphStyle, type ParagraphStyleDefinition, 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 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, applyRunStyle, buildDocModel, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createMinimalDocxPackage, defaultStarterModel, duplicateParagraph, getPart, insertParagraph, layoutDocument, modelToDocumentXml, packageToArrayBuffer, paragraphAfterSpacingPx, paragraphBeforeSpacingPx, paragraphHasExplicitPageBreak, paragraphHasLastRenderedPageBreak, paragraphHasPageBreakBefore, paragraphLetterheadColumnGroupAtSegmentOffset, paragraphLetterheadFloatSideAtNodeIndex, paragraphStartsWithLastRenderedPageBreak, parseDocumentXml, parseDocx, parseParagraphsFromClipboard, parseSectionLayout, pasteParagraphs, removeParagraph, replaceText, resolveDocumentForLayout, resolveDocumentLayout, resolveDocumentPageSegmentStartNodeIndex, resolveDocumentSectionsFromMetadata, resolveDocxPageThumbnailResolution, resolvePaginationSectionMetricsIndexForNodeIndex, resolveParagraphBeforeSpacingPx, resolveSectionIndexForNodeIndex, resolveSectionPropertiesXmlForNodeIndex, scalePaginationSectionMetricsHeights, scorePaginationAgainstStoredPageBreaks, sectionBreakAfterParagraphStartsNewPage, sectionBreakPropertiesStartNewPage, sectionTitlePageEnabled, selectSectionVariantForPage, serializeDocModel, serializeDocx, serializeParagraphsForClipboard, setParagraphAlignment, setParagraphHeading, setRunColor, setRunHighlight, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };
1594
+ export { DEFAULT_MIN_PARAGRAPH_LINE_HEIGHT_PX, DEFAULT_PAGE_OVERFLOW_TOLERANCE_PX, type DocModel, type DocNode, type DocumentCompatibilitySettings, type DocumentNoteDefinition, type DocumentPageNodeSegment, type DocumentPageRange, type DocumentPageSegmentationOptions, type DocumentSection, type DocxBorderContext, type DocxBorderPreset, type DocxBorderPresetState, type DocxContextMenuAction, type DocxContextMenuActionId, type DocxContextMenuContext, type DocxContextMenuRenderProps, 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 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 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 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 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, applyRunStyle, buildDocModel, buildDocModelFromBytes, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createMinimalDocxPackage, defaultStarterModel, duplicateParagraph, getPart, insertParagraph, layoutDocument, modelToDocumentXml, normalizeDocModel, packageToArrayBuffer, paragraphAfterSpacingPx, paragraphBeforeSpacingPx, paragraphHasExplicitPageBreak, paragraphHasLastRenderedPageBreak, paragraphHasPageBreakBefore, paragraphLetterheadColumnGroupAtSegmentOffset, paragraphLetterheadFloatSideAtNodeIndex, paragraphStartsWithLastRenderedPageBreak, parseDocx, parseParagraphsFromClipboard, parseSectionLayout, pasteParagraphs, removeParagraph, replaceText, resolveDocumentForLayout, resolveDocumentLayout, resolveDocumentPageSegmentStartNodeIndex, resolveDocumentSectionsFromMetadata, resolveDocxPageThumbnailResolution, resolvePaginationSectionMetricsIndexForNodeIndex, resolveParagraphBeforeSpacingPx, resolveSectionIndexForNodeIndex, resolveSectionPropertiesXmlForNodeIndex, scalePaginationSectionMetricsHeights, scorePaginationAgainstStoredPageBreaks, sectionBreakAfterParagraphStartsNewPage, sectionBreakPropertiesStartNewPage, sectionTitlePageEnabled, selectSectionVariantForPage, serializeDocModel, serializeDocx, serializeParagraphsForClipboard, setParagraphAlignment, setParagraphHeading, setRunColor, setRunHighlight, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  import * as React from 'react';
2
2
 
3
+ interface WasmOoxmlPart {
4
+ name: string;
5
+ content: string;
6
+ }
7
+ interface WasmOoxmlPackage {
8
+ parts: Record<string, WasmOoxmlPart>;
9
+ binaryAssets: Record<string, number[]>;
10
+ }
11
+
3
12
  interface OoxmlPart {
4
13
  name: string;
5
14
  content: string;
@@ -9,7 +18,7 @@ interface OoxmlPackage {
9
18
  binaryAssets: Map<string, Uint8Array>;
10
19
  }
11
20
  declare function parseDocx(input: ArrayBuffer): Promise<OoxmlPackage>;
12
- declare function packageToArrayBuffer(pkg: OoxmlPackage): ArrayBuffer;
21
+ declare function packageToArrayBuffer(pkg: OoxmlPackage): Promise<ArrayBuffer>;
13
22
  declare function createMinimalDocxPackage(documentXml?: string): OoxmlPackage;
14
23
  declare function getPart(pkg: OoxmlPackage, partName: string): OoxmlPart | undefined;
15
24
  declare function withPart(pkg: OoxmlPackage, part: OoxmlPart): OoxmlPackage;
@@ -164,6 +173,11 @@ interface ParagraphBorderSet {
164
173
  between?: ParagraphBorderStyle;
165
174
  bar?: ParagraphBorderStyle;
166
175
  }
176
+ interface ParagraphTabStop {
177
+ alignment?: "left" | "center" | "right" | "decimal" | "bar";
178
+ leader?: "none" | "dot" | "hyphen" | "underscore" | "middleDot";
179
+ positionTwips?: number;
180
+ }
167
181
  interface ParagraphStyle {
168
182
  align?: ParagraphAlignment;
169
183
  headingLevel?: HeadingLevel;
@@ -383,86 +397,17 @@ interface DocModel {
383
397
  endnotes?: DocumentNoteDefinition[];
384
398
  };
385
399
  }
386
- interface ContentTypeLookup {
387
- defaultByExtension: Map<string, string>;
388
- overrideByPartName: Map<string, string>;
389
- }
390
- interface ParseContext {
391
- relationships: Map<string, string>;
392
- contentTypes: ContentTypeLookup;
393
- parts: OoxmlPackage["parts"];
394
- binaryAssets: Map<string, Uint8Array>;
395
- styleSheet: ParsedStyleSheet;
396
- warnings: string[];
397
- }
398
- interface ThemeFontMap {
399
- majorLatin?: string;
400
- minorLatin?: string;
401
- majorEastAsia?: string;
402
- minorEastAsia?: string;
403
- majorComplexScript?: string;
404
- minorComplexScript?: string;
405
- }
406
- interface ThemeColorMap {
407
- [token: ThemeColorToken]: string;
408
- }
409
- interface ParagraphTabStop {
410
- alignment?: "left" | "center" | "right" | "decimal" | "bar";
411
- leader?: "none" | "dot" | "hyphen" | "underscore" | "middleDot";
412
- positionTwips?: number;
413
- }
414
- interface ParsedStyleSheet {
415
- paragraphStyles: ParagraphStyleDefinition[];
416
- paragraphStyleById: Map<string, ParagraphStyleDefinition>;
417
- runStyleById: Map<string, TextStyle>;
418
- tableStyleById: Map<string, ParsedTableStyleDefinition>;
419
- defaultParagraphStyle?: ParagraphStyle;
420
- defaultParagraphStyleId?: string;
421
- defaultRunStyle?: TextStyle;
422
- themeFonts: ThemeFontMap;
423
- themeColors: ThemeColorMap;
424
- }
425
- type TableConditionalStyleType = "wholeTable" | "firstRow" | "lastRow" | "firstCol" | "lastCol" | "band1Horz" | "band2Horz" | "band1Vert" | "band2Vert" | "nwCell" | "neCell" | "swCell" | "seCell";
426
- interface ParsedTableStyleCondition {
427
- rowBackgroundColor?: string;
428
- cellBackgroundColor?: string;
429
- paragraphAlign?: ParagraphAlignment;
430
- runStyle?: TextStyle;
431
- tableBorders?: TableBorderSet;
432
- cellBorders?: TableBorderSet;
433
- tableProperties?: ParsedTableProperties;
434
- tableLook?: ParsedTableLook;
435
- }
436
- interface ParsedTableStyleDefinition {
437
- id: string;
438
- basedOnId?: string;
439
- name: string;
440
- conditions: Partial<Record<TableConditionalStyleType, ParsedTableStyleCondition>>;
441
- floating?: NonNullable<TableStyle["floating"]>;
442
- properties?: ParsedTableProperties;
443
- }
444
- interface ParsedTableProperties {
445
- widthTwips?: number;
446
- indentTwips?: number;
447
- layout?: "fixed" | "autofit";
448
- cellSpacingTwips?: number;
449
- cellMarginTwips?: TableBoxSpacing;
450
- floating?: NonNullable<TableStyle["floating"]>;
451
- }
452
- interface ParsedTableLook {
453
- firstRow: boolean;
454
- lastRow: boolean;
455
- firstCol: boolean;
456
- lastCol: boolean;
457
- noHBand: boolean;
458
- noVBand: boolean;
459
- rowBandSize: number;
460
- colBandSize: number;
461
- }
462
- declare function parseDocumentXml(documentXml: string, context?: ParseContext): DocNode[];
463
- declare function buildDocModel(pkg: OoxmlPackage): DocModel;
400
+
464
401
  declare function cloneDocModel(model: DocModel): DocModel;
465
402
 
403
+ declare function normalizeDocModel(model: DocModel): DocModel;
404
+
405
+ declare function buildDocModel(pkg: OoxmlPackage): Promise<DocModel>;
406
+ declare function buildDocModelFromBytes(bytes: ArrayBuffer | Uint8Array): Promise<{
407
+ package: OoxmlPackage;
408
+ model: DocModel;
409
+ }>;
410
+
466
411
  interface LayoutOptions {
467
412
  pageWidth?: number;
468
413
  pageHeight?: number;
@@ -1578,9 +1523,9 @@ interface LayoutSnapshot {
1578
1523
  declare function resolveDocumentForLayout(model: DocModel, options?: LayoutSnapshotOptions): ResolvedDocument;
1579
1524
  declare function buildLayoutSnapshot(model: DocModel, options?: LayoutSnapshotOptions): LayoutSnapshot;
1580
1525
 
1581
- declare function modelToDocumentXml(model: DocModel, basePackage?: OoxmlPackage): string;
1582
- declare function serializeDocModel(model: DocModel, basePackage?: OoxmlPackage): OoxmlPackage;
1583
- declare function serializeDocx(model: DocModel, basePackage?: OoxmlPackage): ArrayBuffer;
1526
+ declare function modelToDocumentXml(model: DocModel, basePackage?: OoxmlPackage): Promise<string>;
1527
+ declare function serializeDocModel(model: DocModel, basePackage?: OoxmlPackage): Promise<OoxmlPackage>;
1528
+ declare function serializeDocx(model: DocModel, basePackage?: OoxmlPackage): Promise<ArrayBuffer>;
1584
1529
 
1585
1530
  interface ReactDocxViewerProps {
1586
1531
  /**
@@ -1646,4 +1591,4 @@ interface UseDocxModelState {
1646
1591
  declare function useDocxModel(file?: ArrayBuffer): UseDocxModelState;
1647
1592
  declare function ReactDocxViewer({ file, model, className, layoutOptions, emptyState }: ReactDocxViewerProps): React.JSX.Element;
1648
1593
 
1649
- export { DEFAULT_MIN_PARAGRAPH_LINE_HEIGHT_PX, DEFAULT_PAGE_OVERFLOW_TOLERANCE_PX, type DocModel, type DocNode, type DocumentCompatibilitySettings, type DocumentNoteDefinition, type DocumentPageNodeSegment, type DocumentPageRange, type DocumentPageSegmentationOptions, type DocumentSection, type DocxBorderContext, type DocxBorderPreset, type DocxBorderPresetState, type DocxContextMenuAction, type DocxContextMenuActionId, type DocxContextMenuContext, type DocxContextMenuRenderProps, 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 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 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 ParagraphSpacing, type ParagraphSplitControlOptions, type ParagraphStyle, type ParagraphStyleDefinition, 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 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, applyRunStyle, buildDocModel, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createMinimalDocxPackage, defaultStarterModel, duplicateParagraph, getPart, insertParagraph, layoutDocument, modelToDocumentXml, packageToArrayBuffer, paragraphAfterSpacingPx, paragraphBeforeSpacingPx, paragraphHasExplicitPageBreak, paragraphHasLastRenderedPageBreak, paragraphHasPageBreakBefore, paragraphLetterheadColumnGroupAtSegmentOffset, paragraphLetterheadFloatSideAtNodeIndex, paragraphStartsWithLastRenderedPageBreak, parseDocumentXml, parseDocx, parseParagraphsFromClipboard, parseSectionLayout, pasteParagraphs, removeParagraph, replaceText, resolveDocumentForLayout, resolveDocumentLayout, resolveDocumentPageSegmentStartNodeIndex, resolveDocumentSectionsFromMetadata, resolveDocxPageThumbnailResolution, resolvePaginationSectionMetricsIndexForNodeIndex, resolveParagraphBeforeSpacingPx, resolveSectionIndexForNodeIndex, resolveSectionPropertiesXmlForNodeIndex, scalePaginationSectionMetricsHeights, scorePaginationAgainstStoredPageBreaks, sectionBreakAfterParagraphStartsNewPage, sectionBreakPropertiesStartNewPage, sectionTitlePageEnabled, selectSectionVariantForPage, serializeDocModel, serializeDocx, serializeParagraphsForClipboard, setParagraphAlignment, setParagraphHeading, setRunColor, setRunHighlight, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };
1594
+ export { DEFAULT_MIN_PARAGRAPH_LINE_HEIGHT_PX, DEFAULT_PAGE_OVERFLOW_TOLERANCE_PX, type DocModel, type DocNode, type DocumentCompatibilitySettings, type DocumentNoteDefinition, type DocumentPageNodeSegment, type DocumentPageRange, type DocumentPageSegmentationOptions, type DocumentSection, type DocxBorderContext, type DocxBorderPreset, type DocxBorderPresetState, type DocxContextMenuAction, type DocxContextMenuActionId, type DocxContextMenuContext, type DocxContextMenuRenderProps, 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 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 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 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 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, applyRunStyle, buildDocModel, buildDocModelFromBytes, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createMinimalDocxPackage, defaultStarterModel, duplicateParagraph, getPart, insertParagraph, layoutDocument, modelToDocumentXml, normalizeDocModel, packageToArrayBuffer, paragraphAfterSpacingPx, paragraphBeforeSpacingPx, paragraphHasExplicitPageBreak, paragraphHasLastRenderedPageBreak, paragraphHasPageBreakBefore, paragraphLetterheadColumnGroupAtSegmentOffset, paragraphLetterheadFloatSideAtNodeIndex, paragraphStartsWithLastRenderedPageBreak, parseDocx, parseParagraphsFromClipboard, parseSectionLayout, pasteParagraphs, removeParagraph, replaceText, resolveDocumentForLayout, resolveDocumentLayout, resolveDocumentPageSegmentStartNodeIndex, resolveDocumentSectionsFromMetadata, resolveDocxPageThumbnailResolution, resolvePaginationSectionMetricsIndexForNodeIndex, resolveParagraphBeforeSpacingPx, resolveSectionIndexForNodeIndex, resolveSectionPropertiesXmlForNodeIndex, scalePaginationSectionMetricsHeights, scorePaginationAgainstStoredPageBreaks, sectionBreakAfterParagraphStartsNewPage, sectionBreakPropertiesStartNewPage, sectionTitlePageEnabled, selectSectionVariantForPage, serializeDocModel, serializeDocx, serializeParagraphsForClipboard, setParagraphAlignment, setParagraphHeading, setRunColor, setRunHighlight, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };