@extend-ai/react-docx 0.7.0-alpha.0 → 0.7.0-alpha.2
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 +28 -0
- package/dist/chunk-BGCGPO6Q.js +575 -0
- package/dist/chunk-BGCGPO6Q.js.map +1 -0
- package/dist/docx_wasm_bg.wasm +0 -0
- package/dist/index.cjs +318 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +145 -36
- package/dist/index.js.map +1 -1
- package/dist/{src-QLGK7AGO.js → src-XA2NEWYM.js} +2 -2
- package/package.json +4 -2
- package/dist/chunk-ULEO2IBU.js +0 -505
- package/dist/chunk-ULEO2IBU.js.map +0 -1
- /package/dist/{src-QLGK7AGO.js.map → src-XA2NEWYM.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
+
type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
4
|
+
|
|
5
|
+
interface InitOutput {
|
|
6
|
+
readonly memory: WebAssembly.Memory;
|
|
7
|
+
readonly build_doc_model_from_bytes: (a: number, b: number, c: number) => void;
|
|
8
|
+
readonly build_doc_model_from_package: (a: number, b: number) => void;
|
|
9
|
+
readonly model_to_document_xml_from_json_wasm: (a: number, b: number, c: number, d: number) => void;
|
|
10
|
+
readonly model_to_document_xml_wasm: (a: number, b: number, c: number) => void;
|
|
11
|
+
readonly package_to_array_buffer_wasm: (a: number, b: number) => void;
|
|
12
|
+
readonly parse_docx_wasm: (a: number, b: number, c: number) => void;
|
|
13
|
+
readonly serialize_docx_from_json_wasm: (a: number, b: number, c: number, d: number) => void;
|
|
14
|
+
readonly serialize_docx_wasm: (a: number, b: number, c: number) => void;
|
|
15
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
16
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
17
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
18
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
19
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type WasmSource = InitInput;
|
|
23
|
+
/**
|
|
24
|
+
* Override where the `docx_wasm_bg.wasm` binary is loaded from (URL, Response,
|
|
25
|
+
* bytes, or a compiled module). Must be called before the first operation that
|
|
26
|
+
* touches WASM; by default the binary shipped alongside this package is used.
|
|
27
|
+
*/
|
|
28
|
+
declare function setWasmSource(source: WasmSource): void;
|
|
29
|
+
declare function initWasm(source?: WasmSource): Promise<InitOutput>;
|
|
3
30
|
interface WasmOoxmlPart {
|
|
4
31
|
name: string;
|
|
5
32
|
content: string;
|
|
@@ -1591,4 +1618,4 @@ interface UseDocxModelState {
|
|
|
1591
1618
|
declare function useDocxModel(file?: ArrayBuffer): UseDocxModelState;
|
|
1592
1619
|
declare function ReactDocxViewer({ file, model, className, layoutOptions, emptyState }: ReactDocxViewerProps): React.JSX.Element;
|
|
1593
1620
|
|
|
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 };
|
|
1621
|
+
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, type WasmSource, applyRunStyle, buildDocModel, buildDocModelFromBytes, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createMinimalDocxPackage, defaultStarterModel, duplicateParagraph, getPart, initWasm, 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, setWasmSource, 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,32 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
+
type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
4
|
+
|
|
5
|
+
interface InitOutput {
|
|
6
|
+
readonly memory: WebAssembly.Memory;
|
|
7
|
+
readonly build_doc_model_from_bytes: (a: number, b: number, c: number) => void;
|
|
8
|
+
readonly build_doc_model_from_package: (a: number, b: number) => void;
|
|
9
|
+
readonly model_to_document_xml_from_json_wasm: (a: number, b: number, c: number, d: number) => void;
|
|
10
|
+
readonly model_to_document_xml_wasm: (a: number, b: number, c: number) => void;
|
|
11
|
+
readonly package_to_array_buffer_wasm: (a: number, b: number) => void;
|
|
12
|
+
readonly parse_docx_wasm: (a: number, b: number, c: number) => void;
|
|
13
|
+
readonly serialize_docx_from_json_wasm: (a: number, b: number, c: number, d: number) => void;
|
|
14
|
+
readonly serialize_docx_wasm: (a: number, b: number, c: number) => void;
|
|
15
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
16
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
17
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
18
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
19
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type WasmSource = InitInput;
|
|
23
|
+
/**
|
|
24
|
+
* Override where the `docx_wasm_bg.wasm` binary is loaded from (URL, Response,
|
|
25
|
+
* bytes, or a compiled module). Must be called before the first operation that
|
|
26
|
+
* touches WASM; by default the binary shipped alongside this package is used.
|
|
27
|
+
*/
|
|
28
|
+
declare function setWasmSource(source: WasmSource): void;
|
|
29
|
+
declare function initWasm(source?: WasmSource): Promise<InitOutput>;
|
|
3
30
|
interface WasmOoxmlPart {
|
|
4
31
|
name: string;
|
|
5
32
|
content: string;
|
|
@@ -1591,4 +1618,4 @@ interface UseDocxModelState {
|
|
|
1591
1618
|
declare function useDocxModel(file?: ArrayBuffer): UseDocxModelState;
|
|
1592
1619
|
declare function ReactDocxViewer({ file, model, className, layoutOptions, emptyState }: ReactDocxViewerProps): React.JSX.Element;
|
|
1593
1620
|
|
|
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 };
|
|
1621
|
+
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, type WasmSource, applyRunStyle, buildDocModel, buildDocModelFromBytes, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createMinimalDocxPackage, defaultStarterModel, duplicateParagraph, getPart, initWasm, 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, setWasmSource, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMinimalDocxPackage,
|
|
3
3
|
getPart,
|
|
4
|
+
initWasm,
|
|
4
5
|
mapsToWasmPackage,
|
|
5
6
|
packageToArrayBuffer,
|
|
6
7
|
parseDocx,
|
|
8
|
+
setWasmSource,
|
|
7
9
|
wasmBuildDocModelFromPackage,
|
|
8
10
|
wasmModelToDocumentXml,
|
|
9
11
|
wasmSerializeDocx,
|
|
10
12
|
withPart
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BGCGPO6Q.js";
|
|
12
14
|
|
|
13
15
|
// src/index.tsx
|
|
14
16
|
import * as React2 from "react";
|
|
@@ -636,7 +638,7 @@ async function buildDocModel(pkg) {
|
|
|
636
638
|
return normalizeDocModel(model);
|
|
637
639
|
}
|
|
638
640
|
async function buildDocModelFromBytes(bytes) {
|
|
639
|
-
const { parseDocx: parseDocx2 } = await import("./src-
|
|
641
|
+
const { parseDocx: parseDocx2 } = await import("./src-XA2NEWYM.js");
|
|
640
642
|
const payload = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
641
643
|
const buffer = payload.buffer.slice(payload.byteOffset, payload.byteOffset + payload.byteLength);
|
|
642
644
|
const pkg = await parseDocx2(buffer);
|
|
@@ -2007,7 +2009,7 @@ async function serializeDocModel(model, basePackage) {
|
|
|
2007
2009
|
model,
|
|
2008
2010
|
basePackage ? mapsToWasmPackage(basePackage) : void 0
|
|
2009
2011
|
);
|
|
2010
|
-
const { parseDocx: parseDocx2 } = await import("./src-
|
|
2012
|
+
const { parseDocx: parseDocx2 } = await import("./src-XA2NEWYM.js");
|
|
2011
2013
|
return parseDocx2(bytes);
|
|
2012
2014
|
}
|
|
2013
2015
|
async function serializeDocx(model, basePackage) {
|
|
@@ -4302,22 +4304,46 @@ function parseSectionColumns(sectionPropertiesXml) {
|
|
|
4302
4304
|
if (!columnsTag) {
|
|
4303
4305
|
return void 0;
|
|
4304
4306
|
}
|
|
4305
|
-
const numberOfColumnsRaw = columnsTag.match(/w:num="(\d+)"/i)?.[1];
|
|
4306
|
-
const numberOfColumns = numberOfColumnsRaw ? Number(numberOfColumnsRaw) : 1;
|
|
4307
|
+
const numberOfColumnsRaw = columnsTag.match(/w:num="([\d.]+)"/i)?.[1];
|
|
4308
|
+
const numberOfColumns = numberOfColumnsRaw ? Math.round(Number(numberOfColumnsRaw)) : 1;
|
|
4307
4309
|
if (!Number.isFinite(numberOfColumns) || numberOfColumns <= 1) {
|
|
4308
4310
|
return void 0;
|
|
4309
4311
|
}
|
|
4310
|
-
const
|
|
4311
|
-
const
|
|
4312
|
+
const columnCount = Math.max(2, numberOfColumns);
|
|
4313
|
+
const columnTags = [...sectionPropertiesXml.matchAll(/<w:col\b[^>]*\/>/gi)];
|
|
4314
|
+
const widthsTwips = columnTags.map((match) => Number(match[0].match(/w:w="([\d.]+)"/i)?.[1])).filter((value) => Number.isFinite(value) && value > 0);
|
|
4315
|
+
const widthsPx = widthsTwips.map(
|
|
4316
|
+
(value) => Math.max(1, Math.round(twipsToPixels(value) ?? 0))
|
|
4317
|
+
);
|
|
4318
|
+
const colsTagSpaceRaw = columnsTag.match(/w:space="([\d.]+)"/i)?.[1];
|
|
4319
|
+
const firstColSpaceRaw = columnTags.map((match) => match[0].match(/w:space="([\d.]+)"/i)?.[1]).find((value) => value !== void 0);
|
|
4320
|
+
let columnGapTwips = colsTagSpaceRaw !== void 0 ? Number(colsTagSpaceRaw) : firstColSpaceRaw !== void 0 ? Number(firstColSpaceRaw) : void 0;
|
|
4321
|
+
if (columnGapTwips === void 0 && widthsTwips.length === columnCount) {
|
|
4322
|
+
const pageWidthTwips = Number(
|
|
4323
|
+
sectionPropertiesXml.match(/<w:pgSz\b[^>]*w:w="([\d.]+)"/i)?.[1]
|
|
4324
|
+
);
|
|
4325
|
+
const marginTag = sectionPropertiesXml.match(/<w:pgMar\b[^>]*\/?>/i)?.[0];
|
|
4326
|
+
const marginLeftTwips = Number(marginTag?.match(/w:left="([\d.-]+)"/i)?.[1]);
|
|
4327
|
+
const marginRightTwips = Number(
|
|
4328
|
+
marginTag?.match(/w:right="([\d.-]+)"/i)?.[1]
|
|
4329
|
+
);
|
|
4330
|
+
if (Number.isFinite(pageWidthTwips) && Number.isFinite(marginLeftTwips) && Number.isFinite(marginRightTwips)) {
|
|
4331
|
+
const bodyTwips = pageWidthTwips - marginLeftTwips - marginRightTwips;
|
|
4332
|
+
const totalWidthTwips = widthsTwips.reduce((sum, value) => sum + value, 0);
|
|
4333
|
+
columnGapTwips = Math.max(
|
|
4334
|
+
0,
|
|
4335
|
+
(bodyTwips - totalWidthTwips) / Math.max(1, columnCount - 1)
|
|
4336
|
+
);
|
|
4337
|
+
}
|
|
4338
|
+
}
|
|
4339
|
+
if (columnGapTwips === void 0 || !Number.isFinite(columnGapTwips)) {
|
|
4340
|
+
columnGapTwips = 720;
|
|
4341
|
+
}
|
|
4312
4342
|
const columnGapPx = twipsToPixels(columnGapTwips) ?? 24;
|
|
4313
|
-
const columnWidthTags = [
|
|
4314
|
-
...sectionPropertiesXml.matchAll(/<w:col\b[^>]*w:w="(\d+)"[^>]*\/>/gi)
|
|
4315
|
-
];
|
|
4316
|
-
const widthsPx = columnWidthTags.map((match) => Number(match[1])).filter((value) => Number.isFinite(value) && value > 0).map((value) => Math.max(1, Math.round(twipsToPixels(value) ?? 0)));
|
|
4317
4343
|
return {
|
|
4318
|
-
count:
|
|
4344
|
+
count: columnCount,
|
|
4319
4345
|
gapPx: Math.max(0, columnGapPx),
|
|
4320
|
-
...widthsPx.length ===
|
|
4346
|
+
...widthsPx.length === columnCount ? { widthsPx } : void 0
|
|
4321
4347
|
};
|
|
4322
4348
|
}
|
|
4323
4349
|
function resolveSectionPaginationContentWidthPx(layout, sectionPropertiesXml) {
|
|
@@ -10257,7 +10283,7 @@ function splitParagraphSegmentForColumnRender(params) {
|
|
|
10257
10283
|
}
|
|
10258
10284
|
};
|
|
10259
10285
|
}
|
|
10260
|
-
function buildRenderColumnSegmentsForPageSection(model, flowSegments, columnWidthsPx, columnHeightPx, numberingDefinitions, docGridLinePitchPxByNodeIndex, measuredParagraphOuterHeightsPxByNodeIndex, balanceColumns = false) {
|
|
10286
|
+
function buildRenderColumnSegmentsForPageSection(model, flowSegments, columnWidthsPx, columnHeightPx, numberingDefinitions, docGridLinePitchPxByNodeIndex, measuredParagraphOuterHeightsPxByNodeIndex, balanceColumns = false, forceColumnBreakNodeIndexes) {
|
|
10261
10287
|
const columnCount = Math.max(1, columnWidthsPx.length);
|
|
10262
10288
|
const columns = Array.from(
|
|
10263
10289
|
{ length: columnCount },
|
|
@@ -10312,6 +10338,10 @@ function buildRenderColumnSegmentsForPageSection(model, flowSegments, columnWidt
|
|
|
10312
10338
|
consumedHeightPx += Math.max(1, Math.round(heightPx));
|
|
10313
10339
|
};
|
|
10314
10340
|
for (const flowSegment of flowSegments) {
|
|
10341
|
+
const isNodeStartSegment = (flowSegment.paragraphLineRange?.startLineIndex ?? 0) === 0 && (flowSegment.tableRowRange?.startRowIndex ?? 0) === 0 && !flowSegment.tableRowSlice;
|
|
10342
|
+
if (isNodeStartSegment && forceColumnBreakNodeIndexes?.has(flowSegment.nodeIndex) && consumedHeightPx > 0) {
|
|
10343
|
+
moveToNextColumn();
|
|
10344
|
+
}
|
|
10315
10345
|
let pendingSegment = flowSegment;
|
|
10316
10346
|
let splitGuard = 0;
|
|
10317
10347
|
while (pendingSegment && splitGuard < 256) {
|
|
@@ -10682,16 +10712,19 @@ function buildDocumentPageNodeSegments(model, pageContentHeightPx, pageContentWi
|
|
|
10682
10712
|
const nodeNumberingLabel = paginationNumberingLabels.get(
|
|
10683
10713
|
`p:${nodeIndex}`
|
|
10684
10714
|
);
|
|
10715
|
+
const sectionUsesColumnFlow = (nodeMetrics.pageContentHeightMultiplier ?? 1) > 1;
|
|
10716
|
+
const measuredOuterHeightPx = sectionUsesColumnFlow ? options?.measuredParagraphOuterHeightsPxByNodeIndex?.get(nodeIndex) : void 0;
|
|
10717
|
+
const estimatedOrMeasuredHeightPx = Number.isFinite(measuredOuterHeightPx) && measuredOuterHeightPx > 0 ? measuredOuterHeightPx : estimateParagraphHeightPx(
|
|
10718
|
+
node,
|
|
10719
|
+
nodeMetrics.pageContentWidthPx,
|
|
10720
|
+
numberingDefinitions,
|
|
10721
|
+
nodeMetrics.docGridLinePitchPx,
|
|
10722
|
+
false,
|
|
10723
|
+
nodeNumberingLabel
|
|
10724
|
+
);
|
|
10685
10725
|
let rawNodeHeightPx = Math.max(
|
|
10686
10726
|
1,
|
|
10687
|
-
|
|
10688
|
-
node,
|
|
10689
|
-
nodeMetrics.pageContentWidthPx,
|
|
10690
|
-
numberingDefinitions,
|
|
10691
|
-
nodeMetrics.docGridLinePitchPx,
|
|
10692
|
-
false,
|
|
10693
|
-
nodeNumberingLabel
|
|
10694
|
-
) - directBeforeSpacingPx - directAfterSpacingPx + beforeSpacingPx + afterSpacingPx
|
|
10727
|
+
estimatedOrMeasuredHeightPx - directBeforeSpacingPx - directAfterSpacingPx + beforeSpacingPx + afterSpacingPx
|
|
10695
10728
|
);
|
|
10696
10729
|
const coverFootprintPx = paragraphLikelyFullPageCoverFootprintPx(
|
|
10697
10730
|
model,
|
|
@@ -15741,6 +15774,10 @@ function columnWidthsFromTableDefinition(table, columnCount) {
|
|
|
15741
15774
|
const gridWidths = table.style?.columnWidthsTwips;
|
|
15742
15775
|
const rowDerivedWidths = deriveColumnWidthsFromTableRows(table, columnCount);
|
|
15743
15776
|
if (gridWidths && gridWidths.length === columnCount) {
|
|
15777
|
+
console.log("[colw]", columnCount, gridWidths.length, !!rowDerivedWidths, gridConflictsWithRowWidths(table, gridWidths));
|
|
15778
|
+
if (rowDerivedWidths && rowDerivedWidths.length > 0 && gridConflictsWithRowWidths(table, gridWidths)) {
|
|
15779
|
+
return rowDerivedWidths;
|
|
15780
|
+
}
|
|
15744
15781
|
return normalizeColumnWidthsTwips(gridWidths, columnCount);
|
|
15745
15782
|
}
|
|
15746
15783
|
if (rowDerivedWidths && rowDerivedWidths.length > 0) {
|
|
@@ -15751,6 +15788,35 @@ function columnWidthsFromTableDefinition(table, columnCount) {
|
|
|
15751
15788
|
}
|
|
15752
15789
|
return void 0;
|
|
15753
15790
|
}
|
|
15791
|
+
function gridConflictsWithRowWidths(table, gridWidths) {
|
|
15792
|
+
let conflictRows = 0;
|
|
15793
|
+
let measuredRows = 0;
|
|
15794
|
+
for (const row of table.rows) {
|
|
15795
|
+
let columnCursor = 0;
|
|
15796
|
+
let measuredCells = 0;
|
|
15797
|
+
let conflictCells = 0;
|
|
15798
|
+
for (const cell of row.cells) {
|
|
15799
|
+
const span = cell.style?.gridSpan && cell.style.gridSpan > 1 ? cell.style.gridSpan : 1;
|
|
15800
|
+
const expected = gridWidths.slice(columnCursor, columnCursor + span).reduce((sum, value) => sum + Math.max(0, value), 0);
|
|
15801
|
+
columnCursor += span;
|
|
15802
|
+
const actual = cell.style?.widthTwips;
|
|
15803
|
+
if (!actual || actual <= 0 || expected <= 0) {
|
|
15804
|
+
continue;
|
|
15805
|
+
}
|
|
15806
|
+
measuredCells += 1;
|
|
15807
|
+
if (Math.abs(actual - expected) / expected > 0.2) {
|
|
15808
|
+
conflictCells += 1;
|
|
15809
|
+
}
|
|
15810
|
+
}
|
|
15811
|
+
if (measuredCells > 0) {
|
|
15812
|
+
measuredRows += 1;
|
|
15813
|
+
if (conflictCells * 2 > measuredCells) {
|
|
15814
|
+
conflictRows += 1;
|
|
15815
|
+
}
|
|
15816
|
+
}
|
|
15817
|
+
}
|
|
15818
|
+
return measuredRows > 0 && conflictRows * 2 > measuredRows;
|
|
15819
|
+
}
|
|
15754
15820
|
function deriveColumnWidthsFromTableRows(table, columnCount) {
|
|
15755
15821
|
let bestCandidate;
|
|
15756
15822
|
let bestPositiveCount = -1;
|
|
@@ -18970,10 +19036,10 @@ function useDocxEditor(options = {}) {
|
|
|
18970
19036
|
);
|
|
18971
19037
|
const importDocxFile = React.useCallback(
|
|
18972
19038
|
async (file) => {
|
|
18973
|
-
if (!/\.docx
|
|
19039
|
+
if (!/\.docx?$/i.test(file.name)) {
|
|
18974
19040
|
replaceDocumentWithImportError(
|
|
18975
19041
|
file.name,
|
|
18976
|
-
new Error("Only .docx files are supported")
|
|
19042
|
+
new Error("Only .docx and .doc files are supported")
|
|
18977
19043
|
);
|
|
18978
19044
|
return;
|
|
18979
19045
|
}
|
|
@@ -19034,7 +19100,7 @@ function useDocxEditor(options = {}) {
|
|
|
19034
19100
|
const url = URL.createObjectURL(blob);
|
|
19035
19101
|
const anchor = document.createElement("a");
|
|
19036
19102
|
anchor.href = url;
|
|
19037
|
-
anchor.download =
|
|
19103
|
+
anchor.download = /\.docx?$/i.test(fileName) ? fileName.replace(/\.docx?$/i, "") + "-edited.docx" : "edited.docx";
|
|
19038
19104
|
anchor.style.display = "none";
|
|
19039
19105
|
document.body.append(anchor);
|
|
19040
19106
|
anchor.click();
|
|
@@ -24188,7 +24254,8 @@ function DocxEditorViewer({
|
|
|
24188
24254
|
preferLastRenderedParagraphStartBreaks,
|
|
24189
24255
|
strictLastRenderedParagraphStartBreaks: paginationOptions?.strictLastRenderedParagraphStartBreaks ?? false,
|
|
24190
24256
|
measuredTableRowHeightsByNodeIndex,
|
|
24191
|
-
measuredPageContentHeightsPxByPageIndex: resolvedPageContentHeights
|
|
24257
|
+
measuredPageContentHeightsPxByPageIndex: resolvedPageContentHeights,
|
|
24258
|
+
measuredParagraphOuterHeightsPxByNodeIndex
|
|
24192
24259
|
}
|
|
24193
24260
|
);
|
|
24194
24261
|
const basePages = buildPagesWithHeights(baseMeasuredHeights);
|
|
@@ -24228,7 +24295,10 @@ function DocxEditorViewer({
|
|
|
24228
24295
|
}
|
|
24229
24296
|
);
|
|
24230
24297
|
const minimumPageCount = Math.max(1, hardBreakCount + 1);
|
|
24231
|
-
const
|
|
24298
|
+
const hasColumnFlowSections = paginationSectionMetrics.some(
|
|
24299
|
+
(metrics) => (metrics.pageContentHeightMultiplier ?? 1) > 1
|
|
24300
|
+
);
|
|
24301
|
+
const targetPageCount = !hasColumnFlowSections && Number.isFinite(storedDocumentPageCount2) && storedDocumentPageCount2 > 0 ? Math.max(
|
|
24232
24302
|
minimumPageCount,
|
|
24233
24303
|
Math.round(storedDocumentPageCount2)
|
|
24234
24304
|
) : void 0;
|
|
@@ -24461,7 +24531,8 @@ function DocxEditorViewer({
|
|
|
24461
24531
|
measuredPageContentHeightsPxByPageIndex: measuredPageContentHeightsOverride === null ? void 0 : scaleMeasuredPageContentHeights(
|
|
24462
24532
|
measuredPageContentHeightsOverride ?? measuredPageContentHeightByIndex,
|
|
24463
24533
|
heightScale
|
|
24464
|
-
)
|
|
24534
|
+
),
|
|
24535
|
+
measuredParagraphOuterHeightsPxByNodeIndex
|
|
24465
24536
|
}
|
|
24466
24537
|
)
|
|
24467
24538
|
});
|
|
@@ -24534,6 +24605,7 @@ function DocxEditorViewer({
|
|
|
24534
24605
|
hasMeasuredBodyFooterOverlap,
|
|
24535
24606
|
initialPaginationBackgroundRefinementUnlocked,
|
|
24536
24607
|
measuredPageContentHeightByIndex,
|
|
24608
|
+
measuredParagraphOuterHeightsPxByNodeIndex,
|
|
24537
24609
|
tableMeasuredRowHeightsForPagination
|
|
24538
24610
|
]);
|
|
24539
24611
|
const pageNodeSegmentsByPage = pageSegmentationPlan.pages;
|
|
@@ -25260,6 +25332,8 @@ function DocxEditorViewer({
|
|
|
25260
25332
|
setMeasuredParagraphOuterHeightsPxByNodeIndex((current) => {
|
|
25261
25333
|
const next = new Map(current);
|
|
25262
25334
|
let changed = false;
|
|
25335
|
+
const rootElement = viewerRootRef.current;
|
|
25336
|
+
const zoomScale = rootElement ? resolveEffectiveZoomScale(rootElement) : 1;
|
|
25263
25337
|
paragraphElementsRef.current.forEach((element, nodeIndex) => {
|
|
25264
25338
|
if (!element.isConnected || element.dataset.docxParagraphPartialLineRange === "true" || element.closest('[data-docx-header-footer-region="footer"]') || element.closest('[data-docx-header-footer-region="header"]')) {
|
|
25265
25339
|
return;
|
|
@@ -25274,10 +25348,11 @@ function DocxEditorViewer({
|
|
|
25274
25348
|
const outerHeightPx = Math.max(
|
|
25275
25349
|
1,
|
|
25276
25350
|
Math.round(
|
|
25277
|
-
rect.height + (Number.isFinite(marginTop) ? marginTop : 0) + (Number.isFinite(marginBottom) ? marginBottom : 0)
|
|
25351
|
+
rect.height / zoomScale + (Number.isFinite(marginTop) ? marginTop : 0) + (Number.isFinite(marginBottom) ? marginBottom : 0)
|
|
25278
25352
|
)
|
|
25279
25353
|
);
|
|
25280
|
-
|
|
25354
|
+
const previousHeightPx = next.get(nodeIndex);
|
|
25355
|
+
if (previousHeightPx === void 0 || Math.abs(previousHeightPx - outerHeightPx) > 1) {
|
|
25281
25356
|
next.set(nodeIndex, outerHeightPx);
|
|
25282
25357
|
changed = true;
|
|
25283
25358
|
}
|
|
@@ -34830,7 +34905,7 @@ function DocxEditorViewer({
|
|
|
34830
34905
|
const extractDroppedDocxFile = React.useCallback(
|
|
34831
34906
|
(dataTransfer) => {
|
|
34832
34907
|
return Array.from(dataTransfer?.files ?? []).find(
|
|
34833
|
-
(candidate) => /\.docx
|
|
34908
|
+
(candidate) => /\.docx?$/i.test(candidate.name)
|
|
34834
34909
|
);
|
|
34835
34910
|
},
|
|
34836
34911
|
[]
|
|
@@ -37853,7 +37928,24 @@ ${currentText.slice(end)}`;
|
|
|
37853
37928
|
}
|
|
37854
37929
|
)
|
|
37855
37930
|
}
|
|
37856
|
-
) : /* @__PURE__ */ jsx(
|
|
37931
|
+
) : /* @__PURE__ */ jsx(
|
|
37932
|
+
"div",
|
|
37933
|
+
{
|
|
37934
|
+
style: {
|
|
37935
|
+
display: "grid",
|
|
37936
|
+
gap: 0,
|
|
37937
|
+
// Word clips content of hRule="exact" rows
|
|
37938
|
+
// at the declared height; without this the
|
|
37939
|
+
// row balloons to fit content (height on a
|
|
37940
|
+
// <tr>/<td> is only ever a minimum).
|
|
37941
|
+
...row.style?.heightRule === "exact" && !isSlicedRow && resolvedRowHeightStyle?.height ? {
|
|
37942
|
+
maxHeight: resolvedRowHeightStyle.height,
|
|
37943
|
+
overflow: "hidden"
|
|
37944
|
+
} : void 0
|
|
37945
|
+
},
|
|
37946
|
+
children: renderStaticCellContent()
|
|
37947
|
+
}
|
|
37948
|
+
)
|
|
37857
37949
|
},
|
|
37858
37950
|
`cell-${nodeIndex}-${rowIndex}-${cellIndex}`
|
|
37859
37951
|
);
|
|
@@ -39641,6 +39733,7 @@ ${currentText.slice(end)}`;
|
|
|
39641
39733
|
});
|
|
39642
39734
|
return sectionGroups.map((group, groupIndex) => {
|
|
39643
39735
|
const sectionColumns = sectionColumnsBySectionIndex[group.sectionIndex];
|
|
39736
|
+
const isLastGroupOnPage = groupIndex === sectionGroups.length - 1;
|
|
39644
39737
|
const overlaySegments = group.segments.filter(
|
|
39645
39738
|
(segment) => {
|
|
39646
39739
|
const segmentNode = editor.model.nodes[segment.nodeIndex];
|
|
@@ -39801,7 +39894,19 @@ ${currentText.slice(end)}`;
|
|
|
39801
39894
|
editor.model.metadata.numberingDefinitions,
|
|
39802
39895
|
docGridLinePitchPxByNodeIndex,
|
|
39803
39896
|
measuredParagraphOuterHeightsPxByNodeIndex,
|
|
39804
|
-
isLastPage
|
|
39897
|
+
isLastPage || !isLastGroupOnPage,
|
|
39898
|
+
new Set(
|
|
39899
|
+
(editor.model.metadata.sections ?? []).filter(
|
|
39900
|
+
(candidate) => parseSectionStartType(
|
|
39901
|
+
candidate.sectionPropertiesXml
|
|
39902
|
+
) === "nextColumn"
|
|
39903
|
+
).map(
|
|
39904
|
+
(candidate) => Math.max(
|
|
39905
|
+
0,
|
|
39906
|
+
Math.round(candidate.startNodeIndex)
|
|
39907
|
+
)
|
|
39908
|
+
)
|
|
39909
|
+
)
|
|
39805
39910
|
);
|
|
39806
39911
|
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
39807
39912
|
overlaySegments.map((overlaySegment) => {
|
|
@@ -39837,7 +39942,9 @@ ${currentText.slice(end)}`;
|
|
|
39837
39942
|
gridTemplateColumns: columnWidthsPx.map((widthPx) => `${widthPx}px`).join(" "),
|
|
39838
39943
|
columnGap: sectionColumns.gapPx,
|
|
39839
39944
|
alignItems: "start",
|
|
39840
|
-
|
|
39945
|
+
...isLastGroupOnPage ? {
|
|
39946
|
+
minHeight: pageBodyAvailableHeightPx
|
|
39947
|
+
} : void 0,
|
|
39841
39948
|
position: "relative",
|
|
39842
39949
|
zIndex: 1
|
|
39843
39950
|
},
|
|
@@ -39845,9 +39952,9 @@ ${currentText.slice(end)}`;
|
|
|
39845
39952
|
(segmentsForColumn, columnIndex) => /* @__PURE__ */ jsx(
|
|
39846
39953
|
"div",
|
|
39847
39954
|
{
|
|
39848
|
-
style: {
|
|
39955
|
+
style: isLastGroupOnPage ? {
|
|
39849
39956
|
minHeight: pageBodyAvailableHeightPx
|
|
39850
|
-
},
|
|
39957
|
+
} : void 0,
|
|
39851
39958
|
children: segmentsForColumn.map(
|
|
39852
39959
|
(segment) => renderSegmentInColumn(
|
|
39853
39960
|
segment,
|
|
@@ -42868,6 +42975,7 @@ export {
|
|
|
42868
42975
|
defaultStarterModel,
|
|
42869
42976
|
duplicateParagraph,
|
|
42870
42977
|
getPart,
|
|
42978
|
+
initWasm,
|
|
42871
42979
|
insertParagraph,
|
|
42872
42980
|
layoutDocument,
|
|
42873
42981
|
modelToDocumentXml,
|
|
@@ -42909,6 +43017,7 @@ export {
|
|
|
42909
43017
|
setParagraphHeading,
|
|
42910
43018
|
setRunColor,
|
|
42911
43019
|
setRunHighlight,
|
|
43020
|
+
setWasmSource,
|
|
42912
43021
|
splitParagraphChildrenAtTextOffsets,
|
|
42913
43022
|
toggleRunStyleFlag,
|
|
42914
43023
|
updateParagraphText,
|