@extend-ai/react-docx 0.3.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 +50 -81
- 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 +49 -81
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
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
|
@@ -6498,7 +6498,6 @@ function resolveDocumentLayout(model) {
|
|
|
6498
6498
|
}
|
|
6499
6499
|
|
|
6500
6500
|
// src/image-render.ts
|
|
6501
|
-
import { convertEmfToDataUrl, convertWmfToDataUrl } from "emf-converter";
|
|
6502
6501
|
import { encode as encodePng } from "fast-png";
|
|
6503
6502
|
import UTIFModule from "utif";
|
|
6504
6503
|
var TIFF_CONTENT_TYPES = /* @__PURE__ */ new Set(["image/tiff", "image/tif"]);
|
|
@@ -6513,9 +6512,6 @@ var EMF_DATA_URI_PREFIXES = ["data:image/emf", "data:image/x-emf"];
|
|
|
6513
6512
|
var WMF_DATA_URI_PREFIXES = ["data:image/wmf", "data:image/x-wmf"];
|
|
6514
6513
|
var UTIF = UTIFModule;
|
|
6515
6514
|
var convertedTiffSrcCache = /* @__PURE__ */ new Map();
|
|
6516
|
-
var convertedMetafileSrcCache = /* @__PURE__ */ new Map();
|
|
6517
|
-
var pendingMetafileConversions = /* @__PURE__ */ new Map();
|
|
6518
|
-
var renderableImageSourceListeners = /* @__PURE__ */ new Set();
|
|
6519
6515
|
function normalizeImageContentType(image) {
|
|
6520
6516
|
return image.contentType?.trim().toLowerCase();
|
|
6521
6517
|
}
|
|
@@ -6556,45 +6552,15 @@ function imageUsesWmfContent(image) {
|
|
|
6556
6552
|
const src = normalizeImageSrc(image)?.toLowerCase();
|
|
6557
6553
|
return Boolean(src && WMF_DATA_URI_PREFIXES.some((prefix) => src.startsWith(prefix)));
|
|
6558
6554
|
}
|
|
6559
|
-
function metafileCacheKey(image) {
|
|
6560
|
-
const src = normalizeImageSrc(image);
|
|
6561
|
-
if (src) {
|
|
6562
|
-
return src;
|
|
6563
|
-
}
|
|
6564
|
-
const bytes = image.data;
|
|
6565
|
-
if (!bytes?.byteLength) {
|
|
6566
|
-
return void 0;
|
|
6567
|
-
}
|
|
6568
|
-
const base64 = bytesToBase642(bytes);
|
|
6569
|
-
const contentType = normalizeImageContentType(image) ?? "application/octet-stream";
|
|
6570
|
-
return base64 ? `data:${contentType};base64,${base64}` : void 0;
|
|
6571
|
-
}
|
|
6572
|
-
function notifyRenderableImageSourceListeners() {
|
|
6573
|
-
renderableImageSourceListeners.forEach((listener) => {
|
|
6574
|
-
try {
|
|
6575
|
-
listener();
|
|
6576
|
-
} catch {
|
|
6577
|
-
}
|
|
6578
|
-
});
|
|
6579
|
-
}
|
|
6580
6555
|
function imageUsesPlaceholderFallback(image) {
|
|
6581
|
-
|
|
6582
|
-
if (!contentType || !PLACEHOLDER_FALLBACK_CONTENT_TYPES.has(contentType)) {
|
|
6583
|
-
return false;
|
|
6584
|
-
}
|
|
6585
|
-
const cacheKey = metafileCacheKey(image);
|
|
6586
|
-
if (!cacheKey) {
|
|
6587
|
-
return true;
|
|
6588
|
-
}
|
|
6589
|
-
return convertedMetafileSrcCache.get(cacheKey) == null;
|
|
6556
|
+
return imageHasMetafileContent(image);
|
|
6590
6557
|
}
|
|
6591
6558
|
function unsupportedImageFallbackLabel(image, widthPx, heightPx) {
|
|
6592
6559
|
const isSmallIcon = (widthPx ?? 0) <= 56 && (heightPx ?? 0) <= 56;
|
|
6593
|
-
|
|
6594
|
-
if (contentType === "image/x-emf" || contentType === "image/emf") {
|
|
6560
|
+
if (imageUsesEmfContent(image)) {
|
|
6595
6561
|
return isSmallIcon ? "e" : "EMF";
|
|
6596
6562
|
}
|
|
6597
|
-
if (
|
|
6563
|
+
if (imageUsesWmfContent(image)) {
|
|
6598
6564
|
return isSmallIcon ? "w" : "WMF";
|
|
6599
6565
|
}
|
|
6600
6566
|
return isSmallIcon ? "e" : "TIFF";
|
|
@@ -6640,13 +6606,6 @@ function toArrayBuffer(bytes) {
|
|
|
6640
6606
|
}
|
|
6641
6607
|
return buffer.slice(byteOffset, byteOffset + byteLength);
|
|
6642
6608
|
}
|
|
6643
|
-
function toStrictArrayBuffer(bytes) {
|
|
6644
|
-
const arrayBuffer = toArrayBuffer(bytes);
|
|
6645
|
-
if (arrayBuffer instanceof ArrayBuffer) {
|
|
6646
|
-
return arrayBuffer;
|
|
6647
|
-
}
|
|
6648
|
-
return Uint8Array.from(bytes).buffer;
|
|
6649
|
-
}
|
|
6650
6609
|
function resolveTiffBytes(image) {
|
|
6651
6610
|
if (image.data?.byteLength) {
|
|
6652
6611
|
return image.data;
|
|
@@ -6708,37 +6667,6 @@ function resolveRenderableImageSource(image) {
|
|
|
6708
6667
|
return void 0;
|
|
6709
6668
|
}
|
|
6710
6669
|
if (imageHasMetafileContent(image)) {
|
|
6711
|
-
const cacheKey = metafileCacheKey(image);
|
|
6712
|
-
if (!cacheKey) {
|
|
6713
|
-
return void 0;
|
|
6714
|
-
}
|
|
6715
|
-
if (convertedMetafileSrcCache.has(cacheKey)) {
|
|
6716
|
-
return convertedMetafileSrcCache.get(cacheKey) ?? void 0;
|
|
6717
|
-
}
|
|
6718
|
-
if (!pendingMetafileConversions.has(cacheKey)) {
|
|
6719
|
-
const bytes = resolveTiffBytes(image);
|
|
6720
|
-
if (bytes) {
|
|
6721
|
-
const conversionPromise = (async () => {
|
|
6722
|
-
try {
|
|
6723
|
-
const arrayBuffer = toStrictArrayBuffer(bytes);
|
|
6724
|
-
const converted2 = imageUsesEmfContent(image) ? await convertEmfToDataUrl(arrayBuffer, void 0, void 0, { dpiScale: 1 }) : imageUsesWmfContent(image) ? await convertWmfToDataUrl(arrayBuffer, void 0, void 0, { dpiScale: 1 }) : null;
|
|
6725
|
-
const normalized = converted2 ?? void 0;
|
|
6726
|
-
convertedMetafileSrcCache.set(cacheKey, normalized ?? null);
|
|
6727
|
-
notifyRenderableImageSourceListeners();
|
|
6728
|
-
return normalized;
|
|
6729
|
-
} catch {
|
|
6730
|
-
convertedMetafileSrcCache.set(cacheKey, null);
|
|
6731
|
-
notifyRenderableImageSourceListeners();
|
|
6732
|
-
return void 0;
|
|
6733
|
-
} finally {
|
|
6734
|
-
pendingMetafileConversions.delete(cacheKey);
|
|
6735
|
-
}
|
|
6736
|
-
})();
|
|
6737
|
-
pendingMetafileConversions.set(cacheKey, conversionPromise);
|
|
6738
|
-
} else {
|
|
6739
|
-
convertedMetafileSrcCache.set(cacheKey, null);
|
|
6740
|
-
}
|
|
6741
|
-
}
|
|
6742
6670
|
return void 0;
|
|
6743
6671
|
}
|
|
6744
6672
|
if (!imageHasTiffContent(image)) {
|
|
@@ -6761,9 +6689,8 @@ function resolveRenderableImageSource(image) {
|
|
|
6761
6689
|
return converted;
|
|
6762
6690
|
}
|
|
6763
6691
|
function subscribeRenderableImageSourceUpdates(listener) {
|
|
6764
|
-
|
|
6692
|
+
void listener;
|
|
6765
6693
|
return () => {
|
|
6766
|
-
renderableImageSourceListeners.delete(listener);
|
|
6767
6694
|
};
|
|
6768
6695
|
}
|
|
6769
6696
|
|
|
@@ -10544,7 +10471,7 @@ var DOC_SURFACE_STYLE_BY_THEME = {
|
|
|
10544
10471
|
boxShadow: "0 2px 10px rgba(2, 6, 23, 0.55), 0 1px 2px rgba(2, 6, 23, 0.45)"
|
|
10545
10472
|
}
|
|
10546
10473
|
};
|
|
10547
|
-
var NIGHT_READER_INVERSION_FILTER = "invert(
|
|
10474
|
+
var NIGHT_READER_INVERSION_FILTER = "invert(0.95) hue-rotate(180deg) saturate(0.9) brightness(0.9) contrast(0.94)";
|
|
10548
10475
|
function appendCssFilters(...filters) {
|
|
10549
10476
|
const resolvedFilters = filters.map((filter) => filter?.trim()).filter((filter) => Boolean(filter));
|
|
10550
10477
|
return resolvedFilters.length > 0 ? resolvedFilters.join(" ") : void 0;
|
|
@@ -26969,8 +26896,15 @@ async function rasterizeDocxViewerPageSurfaceToCanvas(params) {
|
|
|
26969
26896
|
function resolveDocxPageThumbnailResolution(options) {
|
|
26970
26897
|
const safeSourceWidthPx = Math.max(1, Math.round(options.sourceWidthPx));
|
|
26971
26898
|
const safeSourceHeightPx = Math.max(1, Math.round(options.sourceHeightPx));
|
|
26972
|
-
const
|
|
26973
|
-
|
|
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;
|
|
26974
26908
|
const scale = Math.min(
|
|
26975
26909
|
1,
|
|
26976
26910
|
widthBoundPx / safeSourceWidthPx,
|
|
@@ -27057,6 +26991,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27057
26991
|
const resolution = resolveDocxPageThumbnailResolution({
|
|
27058
26992
|
sourceWidthPx: sourceSize.widthPx,
|
|
27059
26993
|
sourceHeightPx: sourceSize.heightPx,
|
|
26994
|
+
resolution: options.resolution,
|
|
27060
26995
|
maxWidthPx: options.maxWidthPx,
|
|
27061
26996
|
maxHeightPx: options.maxHeightPx,
|
|
27062
26997
|
pixelRatio: options.pixelRatio
|
|
@@ -27087,6 +27022,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27087
27022
|
fallbackLayout.pageWidthPx,
|
|
27088
27023
|
mountedPageElements,
|
|
27089
27024
|
options.disabled,
|
|
27025
|
+
options.resolution,
|
|
27090
27026
|
options.maxHeightPx,
|
|
27091
27027
|
options.maxWidthPx,
|
|
27092
27028
|
options.pixelRatio,
|
|
@@ -27115,6 +27051,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27115
27051
|
editor.model,
|
|
27116
27052
|
mountedPageElements,
|
|
27117
27053
|
options.disabled,
|
|
27054
|
+
options.resolution,
|
|
27118
27055
|
options.maxHeightPx,
|
|
27119
27056
|
options.maxWidthPx,
|
|
27120
27057
|
options.pixelRatio,
|
|
@@ -27132,6 +27069,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27132
27069
|
const resolution = resolveDocxPageThumbnailResolution({
|
|
27133
27070
|
sourceWidthPx: sourceSize.widthPx,
|
|
27134
27071
|
sourceHeightPx: sourceSize.heightPx,
|
|
27072
|
+
resolution: options.resolution,
|
|
27135
27073
|
maxWidthPx: options.maxWidthPx,
|
|
27136
27074
|
maxHeightPx: options.maxHeightPx,
|
|
27137
27075
|
pixelRatio: options.pixelRatio
|
|
@@ -27145,6 +27083,13 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27145
27083
|
isMounted: Boolean(pageElement && pageElement.isConnected),
|
|
27146
27084
|
status: state?.status ?? (pageElement ? "idle" : "unavailable"),
|
|
27147
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
|
+
},
|
|
27148
27093
|
canvasRef: canvasRefCallbacksRef.current.get(pageIndex) ?? (() => {
|
|
27149
27094
|
const nextCanvasRef = (canvas) => {
|
|
27150
27095
|
if (canvas) {
|
|
@@ -27167,6 +27112,11 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27167
27112
|
);
|
|
27168
27113
|
return nextRenderToCanvas;
|
|
27169
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,
|
|
27170
27120
|
...resolution
|
|
27171
27121
|
};
|
|
27172
27122
|
});
|
|
@@ -27175,19 +27125,36 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27175
27125
|
fallbackLayout.pageHeightPx,
|
|
27176
27126
|
fallbackLayout.pageWidthPx,
|
|
27177
27127
|
mountedPageElements,
|
|
27128
|
+
options.disabled,
|
|
27129
|
+
options.resolution,
|
|
27178
27130
|
options.maxHeightPx,
|
|
27179
27131
|
options.maxWidthPx,
|
|
27180
27132
|
options.pixelRatio,
|
|
27181
27133
|
pageThumbnailStates
|
|
27182
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
|
+
);
|
|
27183
27148
|
return React.useMemo(
|
|
27184
27149
|
() => ({
|
|
27150
|
+
paintThumbnail,
|
|
27185
27151
|
thumbnails,
|
|
27186
27152
|
rerenderAttachedThumbnails
|
|
27187
27153
|
}),
|
|
27188
|
-
[rerenderAttachedThumbnails, thumbnails]
|
|
27154
|
+
[paintThumbnail, rerenderAttachedThumbnails, thumbnails]
|
|
27189
27155
|
);
|
|
27190
27156
|
}
|
|
27157
|
+
var useDocxViewerThumbnails = useDocxPageThumbnails;
|
|
27191
27158
|
function useDocxDocumentTheme(editor) {
|
|
27192
27159
|
const setDocumentTheme = React.useCallback(
|
|
27193
27160
|
(theme) => {
|
|
@@ -46094,6 +46061,7 @@ export {
|
|
|
46094
46061
|
useDocxPagination,
|
|
46095
46062
|
useDocxParagraphStyles,
|
|
46096
46063
|
useDocxTrackChanges,
|
|
46064
|
+
useDocxViewerThumbnails,
|
|
46097
46065
|
withPart
|
|
46098
46066
|
};
|
|
46099
46067
|
//# sourceMappingURL=index.js.map
|