@extend-ai/react-docx 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +45 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +44 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -931,10 +931,15 @@ interface UseDocxPaginationResult {
|
|
|
931
931
|
interface DocxPageThumbnailResolutionOptions {
|
|
932
932
|
sourceWidthPx: number;
|
|
933
933
|
sourceHeightPx: number;
|
|
934
|
+
resolution?: DocxPageThumbnailBounds;
|
|
934
935
|
maxWidthPx?: number;
|
|
935
936
|
maxHeightPx?: number;
|
|
936
937
|
pixelRatio?: number;
|
|
937
938
|
}
|
|
939
|
+
type DocxPageThumbnailBounds = number | {
|
|
940
|
+
maxHeight?: number;
|
|
941
|
+
maxWidth?: number;
|
|
942
|
+
};
|
|
938
943
|
interface DocxPageThumbnailResolution {
|
|
939
944
|
widthPx: number;
|
|
940
945
|
heightPx: number;
|
|
@@ -943,6 +948,7 @@ interface DocxPageThumbnailResolution {
|
|
|
943
948
|
scale: number;
|
|
944
949
|
}
|
|
945
950
|
interface UseDocxPageThumbnailsOptions {
|
|
951
|
+
resolution?: DocxPageThumbnailBounds;
|
|
946
952
|
maxWidthPx?: number;
|
|
947
953
|
maxHeightPx?: number;
|
|
948
954
|
pixelRatio?: number;
|
|
@@ -950,6 +956,10 @@ interface UseDocxPageThumbnailsOptions {
|
|
|
950
956
|
}
|
|
951
957
|
type DocxPageThumbnailStatus = "idle" | "rendering" | "ready" | "unavailable" | "error";
|
|
952
958
|
interface DocxPageThumbnailItem extends DocxPageThumbnailResolution {
|
|
959
|
+
aspectRatio: number;
|
|
960
|
+
contentHeight: number;
|
|
961
|
+
contentWidth: number;
|
|
962
|
+
height: number;
|
|
953
963
|
pageIndex: number;
|
|
954
964
|
pageNumber: number;
|
|
955
965
|
sourceWidthPx: number;
|
|
@@ -957,17 +967,23 @@ interface DocxPageThumbnailItem extends DocxPageThumbnailResolution {
|
|
|
957
967
|
isMounted: boolean;
|
|
958
968
|
status: DocxPageThumbnailStatus;
|
|
959
969
|
error?: Error;
|
|
970
|
+
paint: (canvas: HTMLCanvasElement | null) => boolean;
|
|
960
971
|
canvasRef: (canvas: HTMLCanvasElement | null) => void;
|
|
961
972
|
renderToCanvas: (canvas: HTMLCanvasElement) => Promise<void>;
|
|
973
|
+
width: number;
|
|
962
974
|
}
|
|
963
975
|
interface UseDocxPageThumbnailsResult {
|
|
976
|
+
paintThumbnail: (pageIndex: number, canvas: HTMLCanvasElement | null) => boolean;
|
|
964
977
|
thumbnails: DocxPageThumbnailItem[];
|
|
965
978
|
rerenderAttachedThumbnails: () => Promise<void>;
|
|
966
979
|
}
|
|
980
|
+
type UseDocxViewerThumbnailsOptions = UseDocxPageThumbnailsOptions;
|
|
981
|
+
type DocxViewerThumbnails = UseDocxPageThumbnailsResult;
|
|
967
982
|
declare const defaultStarterModel: DocModel;
|
|
968
983
|
declare function useDocxEditor(options?: UseDocxEditorOptions): DocxEditorController;
|
|
969
984
|
declare function resolveDocxPageThumbnailResolution(options: DocxPageThumbnailResolutionOptions): DocxPageThumbnailResolution;
|
|
970
985
|
declare function useDocxPageThumbnails(editor: DocxEditorController, options?: UseDocxPageThumbnailsOptions): UseDocxPageThumbnailsResult;
|
|
986
|
+
declare const useDocxViewerThumbnails: typeof useDocxPageThumbnails;
|
|
971
987
|
declare function useDocxDocumentTheme(editor: Pick<DocxEditorController, "documentTheme" | "setDocumentTheme">): UseDocxDocumentThemeResult;
|
|
972
988
|
declare function useDocxParagraphStyles(editor: Pick<DocxEditorController, "availableParagraphStyles" | "selectedParagraphStyleId" | "setParagraphStyle">): UseDocxParagraphStylesResult;
|
|
973
989
|
declare function useDocxImageWrapMenu(menu: Pick<DocxContextMenuRenderProps, "context" | "runAction">): UseDocxImageWrapMenuResult | undefined;
|
|
@@ -1242,4 +1258,4 @@ interface UseDocxModelState {
|
|
|
1242
1258
|
declare function useDocxModel(file?: ArrayBuffer): UseDocxModelState;
|
|
1243
1259
|
declare function ReactDocxViewer({ file, model, className, layoutOptions, emptyState }: ReactDocxViewerProps): React.JSX.Element;
|
|
1244
1260
|
|
|
1245
|
-
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 DocxPageThumbnailItem, type DocxPageThumbnailResolution, type DocxPageThumbnailResolutionOptions, type DocxPageThumbnailStatus, 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 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, 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, withPart };
|
|
1261
|
+
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 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 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -931,10 +931,15 @@ interface UseDocxPaginationResult {
|
|
|
931
931
|
interface DocxPageThumbnailResolutionOptions {
|
|
932
932
|
sourceWidthPx: number;
|
|
933
933
|
sourceHeightPx: number;
|
|
934
|
+
resolution?: DocxPageThumbnailBounds;
|
|
934
935
|
maxWidthPx?: number;
|
|
935
936
|
maxHeightPx?: number;
|
|
936
937
|
pixelRatio?: number;
|
|
937
938
|
}
|
|
939
|
+
type DocxPageThumbnailBounds = number | {
|
|
940
|
+
maxHeight?: number;
|
|
941
|
+
maxWidth?: number;
|
|
942
|
+
};
|
|
938
943
|
interface DocxPageThumbnailResolution {
|
|
939
944
|
widthPx: number;
|
|
940
945
|
heightPx: number;
|
|
@@ -943,6 +948,7 @@ interface DocxPageThumbnailResolution {
|
|
|
943
948
|
scale: number;
|
|
944
949
|
}
|
|
945
950
|
interface UseDocxPageThumbnailsOptions {
|
|
951
|
+
resolution?: DocxPageThumbnailBounds;
|
|
946
952
|
maxWidthPx?: number;
|
|
947
953
|
maxHeightPx?: number;
|
|
948
954
|
pixelRatio?: number;
|
|
@@ -950,6 +956,10 @@ interface UseDocxPageThumbnailsOptions {
|
|
|
950
956
|
}
|
|
951
957
|
type DocxPageThumbnailStatus = "idle" | "rendering" | "ready" | "unavailable" | "error";
|
|
952
958
|
interface DocxPageThumbnailItem extends DocxPageThumbnailResolution {
|
|
959
|
+
aspectRatio: number;
|
|
960
|
+
contentHeight: number;
|
|
961
|
+
contentWidth: number;
|
|
962
|
+
height: number;
|
|
953
963
|
pageIndex: number;
|
|
954
964
|
pageNumber: number;
|
|
955
965
|
sourceWidthPx: number;
|
|
@@ -957,17 +967,23 @@ interface DocxPageThumbnailItem extends DocxPageThumbnailResolution {
|
|
|
957
967
|
isMounted: boolean;
|
|
958
968
|
status: DocxPageThumbnailStatus;
|
|
959
969
|
error?: Error;
|
|
970
|
+
paint: (canvas: HTMLCanvasElement | null) => boolean;
|
|
960
971
|
canvasRef: (canvas: HTMLCanvasElement | null) => void;
|
|
961
972
|
renderToCanvas: (canvas: HTMLCanvasElement) => Promise<void>;
|
|
973
|
+
width: number;
|
|
962
974
|
}
|
|
963
975
|
interface UseDocxPageThumbnailsResult {
|
|
976
|
+
paintThumbnail: (pageIndex: number, canvas: HTMLCanvasElement | null) => boolean;
|
|
964
977
|
thumbnails: DocxPageThumbnailItem[];
|
|
965
978
|
rerenderAttachedThumbnails: () => Promise<void>;
|
|
966
979
|
}
|
|
980
|
+
type UseDocxViewerThumbnailsOptions = UseDocxPageThumbnailsOptions;
|
|
981
|
+
type DocxViewerThumbnails = UseDocxPageThumbnailsResult;
|
|
967
982
|
declare const defaultStarterModel: DocModel;
|
|
968
983
|
declare function useDocxEditor(options?: UseDocxEditorOptions): DocxEditorController;
|
|
969
984
|
declare function resolveDocxPageThumbnailResolution(options: DocxPageThumbnailResolutionOptions): DocxPageThumbnailResolution;
|
|
970
985
|
declare function useDocxPageThumbnails(editor: DocxEditorController, options?: UseDocxPageThumbnailsOptions): UseDocxPageThumbnailsResult;
|
|
986
|
+
declare const useDocxViewerThumbnails: typeof useDocxPageThumbnails;
|
|
971
987
|
declare function useDocxDocumentTheme(editor: Pick<DocxEditorController, "documentTheme" | "setDocumentTheme">): UseDocxDocumentThemeResult;
|
|
972
988
|
declare function useDocxParagraphStyles(editor: Pick<DocxEditorController, "availableParagraphStyles" | "selectedParagraphStyleId" | "setParagraphStyle">): UseDocxParagraphStylesResult;
|
|
973
989
|
declare function useDocxImageWrapMenu(menu: Pick<DocxContextMenuRenderProps, "context" | "runAction">): UseDocxImageWrapMenuResult | undefined;
|
|
@@ -1242,4 +1258,4 @@ interface UseDocxModelState {
|
|
|
1242
1258
|
declare function useDocxModel(file?: ArrayBuffer): UseDocxModelState;
|
|
1243
1259
|
declare function ReactDocxViewer({ file, model, className, layoutOptions, emptyState }: ReactDocxViewerProps): React.JSX.Element;
|
|
1244
1260
|
|
|
1245
|
-
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 DocxPageThumbnailItem, type DocxPageThumbnailResolution, type DocxPageThumbnailResolutionOptions, type DocxPageThumbnailStatus, 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 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, 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, withPart };
|
|
1261
|
+
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 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 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 };
|
package/dist/index.js
CHANGED
|
@@ -26896,8 +26896,15 @@ async function rasterizeDocxViewerPageSurfaceToCanvas(params) {
|
|
|
26896
26896
|
function resolveDocxPageThumbnailResolution(options) {
|
|
26897
26897
|
const safeSourceWidthPx = Math.max(1, Math.round(options.sourceWidthPx));
|
|
26898
26898
|
const safeSourceHeightPx = Math.max(1, Math.round(options.sourceHeightPx));
|
|
26899
|
-
const
|
|
26900
|
-
|
|
26899
|
+
const resolutionBounds = typeof options.resolution === "number" && Number.isFinite(options.resolution) && options.resolution > 0 ? {
|
|
26900
|
+
maxWidthPx: Number(options.resolution),
|
|
26901
|
+
maxHeightPx: Number(options.resolution)
|
|
26902
|
+
} : typeof options.resolution === "object" && options.resolution ? {
|
|
26903
|
+
maxWidthPx: Number.isFinite(options.resolution.maxWidth) && Number(options.resolution.maxWidth) > 0 ? Number(options.resolution.maxWidth) : void 0,
|
|
26904
|
+
maxHeightPx: Number.isFinite(options.resolution.maxHeight) && Number(options.resolution.maxHeight) > 0 ? Number(options.resolution.maxHeight) : void 0
|
|
26905
|
+
} : void 0;
|
|
26906
|
+
const widthBoundPx = Number.isFinite(options.maxWidthPx) ? Math.max(1, Math.round(options.maxWidthPx)) : Number.isFinite(resolutionBounds?.maxWidthPx) ? Math.max(1, Math.round(resolutionBounds?.maxWidthPx)) : 180;
|
|
26907
|
+
const heightBoundPx = Number.isFinite(options.maxHeightPx) ? Math.max(1, Math.round(options.maxHeightPx)) : Number.isFinite(resolutionBounds?.maxHeightPx) ? Math.max(1, Math.round(resolutionBounds?.maxHeightPx)) : Number.POSITIVE_INFINITY;
|
|
26901
26908
|
const scale = Math.min(
|
|
26902
26909
|
1,
|
|
26903
26910
|
widthBoundPx / safeSourceWidthPx,
|
|
@@ -26984,6 +26991,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
26984
26991
|
const resolution = resolveDocxPageThumbnailResolution({
|
|
26985
26992
|
sourceWidthPx: sourceSize.widthPx,
|
|
26986
26993
|
sourceHeightPx: sourceSize.heightPx,
|
|
26994
|
+
resolution: options.resolution,
|
|
26987
26995
|
maxWidthPx: options.maxWidthPx,
|
|
26988
26996
|
maxHeightPx: options.maxHeightPx,
|
|
26989
26997
|
pixelRatio: options.pixelRatio
|
|
@@ -27014,6 +27022,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27014
27022
|
fallbackLayout.pageWidthPx,
|
|
27015
27023
|
mountedPageElements,
|
|
27016
27024
|
options.disabled,
|
|
27025
|
+
options.resolution,
|
|
27017
27026
|
options.maxHeightPx,
|
|
27018
27027
|
options.maxWidthPx,
|
|
27019
27028
|
options.pixelRatio,
|
|
@@ -27042,6 +27051,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27042
27051
|
editor.model,
|
|
27043
27052
|
mountedPageElements,
|
|
27044
27053
|
options.disabled,
|
|
27054
|
+
options.resolution,
|
|
27045
27055
|
options.maxHeightPx,
|
|
27046
27056
|
options.maxWidthPx,
|
|
27047
27057
|
options.pixelRatio,
|
|
@@ -27059,6 +27069,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27059
27069
|
const resolution = resolveDocxPageThumbnailResolution({
|
|
27060
27070
|
sourceWidthPx: sourceSize.widthPx,
|
|
27061
27071
|
sourceHeightPx: sourceSize.heightPx,
|
|
27072
|
+
resolution: options.resolution,
|
|
27062
27073
|
maxWidthPx: options.maxWidthPx,
|
|
27063
27074
|
maxHeightPx: options.maxHeightPx,
|
|
27064
27075
|
pixelRatio: options.pixelRatio
|
|
@@ -27072,6 +27083,13 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27072
27083
|
isMounted: Boolean(pageElement && pageElement.isConnected),
|
|
27073
27084
|
status: state?.status ?? (pageElement ? "idle" : "unavailable"),
|
|
27074
27085
|
error: state?.error,
|
|
27086
|
+
paint: (canvas) => {
|
|
27087
|
+
if (!canvas || options.disabled) {
|
|
27088
|
+
return false;
|
|
27089
|
+
}
|
|
27090
|
+
void renderPageThumbnailToCanvasRef.current(pageIndex, canvas);
|
|
27091
|
+
return true;
|
|
27092
|
+
},
|
|
27075
27093
|
canvasRef: canvasRefCallbacksRef.current.get(pageIndex) ?? (() => {
|
|
27076
27094
|
const nextCanvasRef = (canvas) => {
|
|
27077
27095
|
if (canvas) {
|
|
@@ -27094,6 +27112,11 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27094
27112
|
);
|
|
27095
27113
|
return nextRenderToCanvas;
|
|
27096
27114
|
})(),
|
|
27115
|
+
aspectRatio: sourceSize.widthPx / Math.max(1, sourceSize.heightPx),
|
|
27116
|
+
contentWidth: sourceSize.widthPx,
|
|
27117
|
+
contentHeight: sourceSize.heightPx,
|
|
27118
|
+
width: resolution.widthPx,
|
|
27119
|
+
height: resolution.heightPx,
|
|
27097
27120
|
...resolution
|
|
27098
27121
|
};
|
|
27099
27122
|
});
|
|
@@ -27102,19 +27125,36 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27102
27125
|
fallbackLayout.pageHeightPx,
|
|
27103
27126
|
fallbackLayout.pageWidthPx,
|
|
27104
27127
|
mountedPageElements,
|
|
27128
|
+
options.disabled,
|
|
27129
|
+
options.resolution,
|
|
27105
27130
|
options.maxHeightPx,
|
|
27106
27131
|
options.maxWidthPx,
|
|
27107
27132
|
options.pixelRatio,
|
|
27108
27133
|
pageThumbnailStates
|
|
27109
27134
|
]);
|
|
27135
|
+
const paintThumbnail = React.useCallback(
|
|
27136
|
+
(pageIndex, canvas) => {
|
|
27137
|
+
if (!canvas || options.disabled) {
|
|
27138
|
+
return false;
|
|
27139
|
+
}
|
|
27140
|
+
const thumbnail = thumbnails[pageIndex];
|
|
27141
|
+
if (!thumbnail) {
|
|
27142
|
+
return false;
|
|
27143
|
+
}
|
|
27144
|
+
return thumbnail.paint(canvas);
|
|
27145
|
+
},
|
|
27146
|
+
[options.disabled, thumbnails]
|
|
27147
|
+
);
|
|
27110
27148
|
return React.useMemo(
|
|
27111
27149
|
() => ({
|
|
27150
|
+
paintThumbnail,
|
|
27112
27151
|
thumbnails,
|
|
27113
27152
|
rerenderAttachedThumbnails
|
|
27114
27153
|
}),
|
|
27115
|
-
[rerenderAttachedThumbnails, thumbnails]
|
|
27154
|
+
[paintThumbnail, rerenderAttachedThumbnails, thumbnails]
|
|
27116
27155
|
);
|
|
27117
27156
|
}
|
|
27157
|
+
var useDocxViewerThumbnails = useDocxPageThumbnails;
|
|
27118
27158
|
function useDocxDocumentTheme(editor) {
|
|
27119
27159
|
const setDocumentTheme = React.useCallback(
|
|
27120
27160
|
(theme) => {
|
|
@@ -46021,6 +46061,7 @@ export {
|
|
|
46021
46061
|
useDocxPagination,
|
|
46022
46062
|
useDocxParagraphStyles,
|
|
46023
46063
|
useDocxTrackChanges,
|
|
46064
|
+
useDocxViewerThumbnails,
|
|
46024
46065
|
withPart
|
|
46025
46066
|
};
|
|
46026
46067
|
//# sourceMappingURL=index.js.map
|