@docen/export-docx 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { OutputType, ISectionOptions, IPropertiesOptions, ITableOfContentsOptions, IParagraphStyleOptions, IImageOptions as IImageOptions$1, ITableOptions, IParagraphOptions, ITableRowOptions, ITableCellOptions, OutputByType, FileChild, TextRun, ExternalHyperlink, PositiveUniversalMeasure as PositiveUniversalMeasure$1, Paragraph, ImageRun, Table, TableRow, TableCell } from 'docx';
2
+ import { PositiveUniversalMeasure as PositiveUniversalMeasure$1, OutputType, ISectionOptions, IPropertiesOptions, ITableOfContentsOptions, IParagraphStyleOptions, IImageOptions as IImageOptions$1, ITableOptions, IParagraphOptions, ITableRowOptions, ITableCellOptions, FileChild, OutputByType, TextRun, ExternalHyperlink, ImageRun, Table, TableRow, TableCell } from 'docx';
3
3
  import { ImageMeta } from 'image-meta';
4
4
 
5
5
  declare class OrderedMap$1<T = any> {
@@ -2029,6 +2029,16 @@ declare class Transform$1 {
2029
2029
  */
2030
2030
  get docChanged(): boolean;
2031
2031
  /**
2032
+ Return a single range, in post-transform document positions,
2033
+ that covers all content changed by this transform. Returns null
2034
+ if no replacements are made. Note that this will ignore changes
2035
+ that add/remove marks without replacing the underlying content.
2036
+ */
2037
+ changedRange(): {
2038
+ from: number;
2039
+ to: number;
2040
+ } | null;
2041
+ /**
2032
2042
  Replace the part of the document between `from` and `to` with the
2033
2043
  given `slice`.
2034
2044
  */
@@ -6567,6 +6577,62 @@ interface Commands$1<ReturnType = any> {
6567
6577
  interface Storage$1 {
6568
6578
  }
6569
6579
 
6580
+ type DocxImageExportHandler = (src: string) => Promise<Uint8Array>;
6581
+ /**
6582
+ * Convert image MIME type to DOCX type
6583
+ */
6584
+ declare function convertToDocxImageType(mimeType?: string): "jpg" | "png" | "gif" | "bmp";
6585
+ /**
6586
+ * Extract image type from URL or base64 data
6587
+ */
6588
+ declare function getImageTypeFromSrc(src: string): "png" | "jpeg" | "gif" | "bmp" | "tiff";
6589
+ /**
6590
+ * Create floating options for full-width images
6591
+ */
6592
+ declare function createFloatingOptions(): {
6593
+ horizontalPosition: {
6594
+ relative: string;
6595
+ align: string;
6596
+ };
6597
+ verticalPosition: {
6598
+ relative: string;
6599
+ align: string;
6600
+ };
6601
+ lockAnchor: boolean;
6602
+ behindDocument: boolean;
6603
+ inFrontOfText: boolean;
6604
+ };
6605
+ /**
6606
+ * Get image width with priority: node attrs > image meta > calculated > default
6607
+ */
6608
+ declare function getImageWidth(node: {
6609
+ attrs?: {
6610
+ width?: number | null;
6611
+ };
6612
+ }, imageMeta?: {
6613
+ width?: number;
6614
+ height?: number;
6615
+ }, maxWidth?: number | PositiveUniversalMeasure$1): number;
6616
+ /**
6617
+ * Get image height with priority: node attrs > image meta > calculated > default
6618
+ */
6619
+ declare function getImageHeight(node: {
6620
+ attrs?: {
6621
+ height?: number | null;
6622
+ };
6623
+ }, width: number, imageMeta?: {
6624
+ width?: number;
6625
+ height?: number;
6626
+ }, maxWidth?: number | PositiveUniversalMeasure$1): number;
6627
+ /**
6628
+ * Fetch image data and metadata from HTTP/HTTPS URL
6629
+ * (Only for use without custom handler)
6630
+ */
6631
+ declare function getImageDataAndMeta(url: string): Promise<{
6632
+ data: Uint8Array;
6633
+ meta: ImageMeta;
6634
+ }>;
6635
+
6570
6636
  /**
6571
6637
  * Options for exporting TipTap content to DOCX
6572
6638
  */
@@ -6598,6 +6664,7 @@ interface DocxExportOptions<T extends OutputType = OutputType> {
6598
6664
  run?: Partial<ITableOfContentsOptions>;
6599
6665
  };
6600
6666
  image?: {
6667
+ handler?: DocxImageExportHandler;
6601
6668
  style?: IParagraphStyleOptions;
6602
6669
  run?: Partial<IImageOptions$1>;
6603
6670
  };
@@ -6617,6 +6684,9 @@ interface DocxExportOptions<T extends OutputType = OutputType> {
6617
6684
  run?: Partial<ITableCellOptions>;
6618
6685
  };
6619
6686
  };
6687
+ code?: {
6688
+ style?: IParagraphStyleOptions;
6689
+ };
6620
6690
  details?: {
6621
6691
  summary?: {
6622
6692
  paragraph?: Partial<IParagraphOptions>;
@@ -6647,6 +6717,11 @@ declare function convertDocument(node: JSONContent$1, params: {
6647
6717
  }): Promise<FileChild[]>;
6648
6718
  /**
6649
6719
  * Convert a single node to DOCX element(s)
6720
+ *
6721
+ * This function implements a three-layer architecture:
6722
+ * 1. Data Transformation: Convert node.attrs → IParagraphOptions (pure data)
6723
+ * 2. Style Application: Apply styleId references (if configured)
6724
+ * 3. Object Creation: Create actual DOCX instances (Paragraph, Table, etc.)
6650
6725
  */
6651
6726
  declare function convertNode(node: JSONContent$1, options: DocxExportOptions, effectiveContentWidth: number): Promise<FileChild | FileChild[] | null>;
6652
6727
 
@@ -8677,6 +8752,16 @@ declare class Transform {
8677
8752
  */
8678
8753
  get docChanged(): boolean;
8679
8754
  /**
8755
+ Return a single range, in post-transform document positions,
8756
+ that covers all content changed by this transform. Returns null
8757
+ if no replacements are made. Note that this will ignore changes
8758
+ that add/remove marks without replacing the underlying content.
8759
+ */
8760
+ changedRange(): {
8761
+ from: number;
8762
+ to: number;
8763
+ } | null;
8764
+ /**
8680
8765
  Replace the part of the document between `from` and `to` with the
8681
8766
  given `slice`.
8682
8767
  */
@@ -13613,11 +13698,14 @@ declare function convertHardBreak(marks?: Array<{
13613
13698
  declare function convertTextNodes(nodes?: JSONContent$1[]): Array<TextRun | ExternalHyperlink | undefined>;
13614
13699
 
13615
13700
  /**
13616
- * Convert TipTap paragraph node to DOCX Paragraph
13701
+ * Convert TipTap paragraph node to DOCX paragraph options
13702
+ *
13703
+ * This converter only handles data transformation from node.attrs to DOCX format properties.
13704
+ * It returns pure data objects (IParagraphOptions), not DOCX instances.
13617
13705
  *
13618
13706
  * @param node - TipTap paragraph node
13619
13707
  * @param params - Conversion parameters
13620
- * @returns Promise<DOCX Paragraph object>
13708
+ * @returns Promise<DOCX paragraph options (pure data object)>
13621
13709
  */
13622
13710
  declare function convertParagraph(node: ParagraphNode, params?: {
13623
13711
  options?: IParagraphOptions;
@@ -13625,163 +13713,34 @@ declare function convertParagraph(node: ParagraphNode, params?: {
13625
13713
  image?: {
13626
13714
  /** Maximum available width for inline images (number = pixels, or string like "6in", "152.4mm") */
13627
13715
  maxWidth?: number | PositiveUniversalMeasure$1;
13716
+ /** Additional image options to apply */
13717
+ options?: Partial<IImageOptions$1>;
13718
+ /** Custom image handler for fetching image data */
13719
+ handler?: DocxImageExportHandler;
13628
13720
  };
13629
- }): Promise<Paragraph>;
13721
+ }): Promise<IParagraphOptions>;
13630
13722
 
13631
13723
  /**
13632
- * Convert TipTap heading node to DOCX paragraph
13724
+ * Convert TipTap heading node to DOCX paragraph options
13633
13725
  *
13634
- * @param node - TipTap heading node
13635
- * @returns DOCX Paragraph object
13636
- */
13637
- declare function convertHeading(node: HeadingNode): Paragraph;
13638
-
13639
- /**
13640
- * Convert TipTap blockquote node to array of DOCX Paragraphs
13641
- * Each paragraph in blockquote is indented and styled
13726
+ * This converter only handles data transformation from node.attrs to DOCX format properties.
13727
+ * It returns pure data objects (IParagraphOptions), not DOCX instances.
13642
13728
  *
13643
- * @param node - TipTap blockquote node
13644
- * @returns Array of DOCX Paragraph objects
13645
- */
13646
- declare function convertBlockquote(node: BlockquoteNode): Paragraph[];
13647
-
13648
- /**
13649
- * Convert TipTap image node to DOCX ImageRun
13650
- *
13651
- * @param node - TipTap image node
13652
- * @param params - Conversion parameters
13653
- * @returns Promise<DOCX ImageRun>
13654
- */
13655
- declare function convertImage(node: ImageNode, params?: {
13656
- /** Maximum available width (number = pixels, or string like "6in", "152.4mm") */
13657
- maxWidth?: number | PositiveUniversalMeasure$1;
13658
- /** Additional image options to apply */
13659
- options?: Partial<IImageOptions$1>;
13660
- }): Promise<ImageRun>;
13661
-
13662
- /**
13663
- * Convert TipTap table node to DOCX Table
13664
- *
13665
- * @param node - TipTap table node
13666
- * @param params - Conversion parameters
13667
- * @returns Promise<Table>
13668
- */
13669
- declare function convertTable(node: TableNode, params: {
13670
- options: DocxExportOptions["table"];
13671
- }): Promise<Table>;
13672
-
13673
- /**
13674
- * Convert TipTap table row node to DOCX TableRow
13675
- *
13676
- * @param node - TipTap table row node
13677
- * @param params - Conversion parameters
13678
- * @returns Promise<DOCX TableRow object>
13679
- */
13680
- declare function convertTableRow(node: TableRowNode, params: {
13681
- options: DocxExportOptions["table"];
13682
- }): Promise<TableRow>;
13683
-
13684
- /**
13685
- * Convert TipTap table cell node to DOCX TableCell
13686
- *
13687
- * @param node - TipTap table cell node
13688
- * @param params - Conversion parameters
13689
- * @returns Promise<DOCX TableCell object>
13690
- */
13691
- declare function convertTableCell(node: TableCellNode, params: {
13692
- options: DocxExportOptions["table"];
13693
- }): Promise<TableCell>;
13694
-
13695
- /**
13696
- * Convert TipTap table header node to DOCX TableCell
13697
- *
13698
- * @param node - TipTap table header node
13699
- * @param params - Conversion parameters
13700
- * @returns Promise<DOCX TableCell object for header>
13701
- */
13702
- declare function convertTableHeader(node: TableHeaderNode, params: {
13703
- options: DocxExportOptions["table"];
13704
- }): Promise<TableCell>;
13705
-
13706
- /**
13707
- * Convert TipTap codeBlock node to DOCX Paragraph
13708
- *
13709
- * @param node - TipTap codeBlock node
13710
- * @returns DOCX Paragraph object with code styling
13711
- */
13712
- declare function convertCodeBlock(node: CodeBlockNode): Paragraph;
13713
-
13714
- interface ListOptions {
13715
- numbering: {
13716
- reference: string;
13717
- level: number;
13718
- };
13719
- start?: number;
13720
- }
13721
- declare function convertBulletList(): ListOptions;
13722
- declare function convertOrderedList(node: OrderedListNode): ListOptions;
13723
- /**
13724
- * Convert list nodes (bullet or ordered) with proper numbering
13725
- */
13726
- declare function convertList(node: BulletListNode | OrderedListNode, params: {
13727
- listType: "bullet" | "ordered";
13728
- }): Promise<Paragraph[]>;
13729
-
13730
- /**
13731
- * Convert TipTap list item node to DOCX Paragraph
13732
- *
13733
- * Note: The numbering reference (including start value) is typically
13734
- * handled by the parent list converter. This function focuses on
13735
- * converting the paragraph content of the list item.
13736
- *
13737
- * @param node - TipTap list item node
13738
- * @param params - Conversion parameters
13739
- * @returns Promise<DOCX Paragraph object>
13740
- */
13741
- declare function convertListItem(node: ListItemNode, params: {
13742
- options?: IParagraphOptions;
13743
- }): Promise<Paragraph>;
13744
-
13745
- /**
13746
- * Convert TipTap task list node to DOCX paragraphs
13747
- *
13748
- * @param node - TipTap task list node
13749
- * @returns Array of Paragraph objects with checkboxes
13729
+ * @param node - TipTap heading node
13730
+ * @returns DOCX paragraph options (pure data object)
13750
13731
  */
13751
- declare function convertTaskList(node: TaskListNode): Paragraph[];
13732
+ declare function convertHeading(node: HeadingNode): IParagraphOptions;
13752
13733
 
13753
13734
  /**
13754
- * Convert TipTap task item node to DOCX Paragraph with checkbox
13735
+ * Convert TipTap blockquote node to array of paragraph options
13755
13736
  *
13756
- * @param node - TipTap task item node
13757
- * @returns DOCX Paragraph object with checkbox
13758
- */
13759
- declare function convertTaskItem(node: TaskItemNode): Paragraph;
13760
-
13761
- /**
13762
- * Convert TipTap horizontalRule node to DOCX Paragraph
13763
- * Uses page break by default (consistent with import-docx behavior)
13737
+ * This converter only handles data transformation from node content to DOCX format properties.
13738
+ * It returns pure data objects (IParagraphOptions[]), not DOCX instances.
13764
13739
  *
13765
- * @param node - TipTap horizontalRule node
13766
- * @param params - Conversion parameters
13767
- * @returns DOCX Paragraph object with page break or custom styling
13768
- */
13769
- declare function convertHorizontalRule(node: HorizontalRuleNode, params: {
13770
- /** Export options for horizontal rule styling */
13771
- options?: DocxExportOptions["horizontalRule"];
13772
- }): Paragraph;
13773
-
13774
- /**
13775
- * Convert TipTap detailsSummary node to DOCX Paragraph
13776
- *
13777
- * @param node - TipTap detailsSummary node
13778
- * @param params - Conversion parameters
13779
- * @returns DOCX Paragraph with summary styling
13740
+ * @param node - TipTap blockquote node
13741
+ * @returns Array of paragraph options (pure data objects)
13780
13742
  */
13781
- declare function convertDetailsSummary(node: DetailsSummaryNode, params: {
13782
- /** Export options for details styling */
13783
- options?: DocxExportOptions["details"];
13784
- }): Paragraph;
13743
+ declare function convertBlockquote(node: BlockquoteNode): IParagraphOptions[];
13785
13744
 
13786
13745
  // ## Interfaces
13787
13746
 
@@ -14176,11 +14135,6 @@ interface TextData extends Data {}
14176
14135
  * Unit conversion utilities for DOCX processing
14177
14136
  * Handles conversions between TWIPs, EMUs, pixels, and other units
14178
14137
  */
14179
- /**
14180
- * DOCX DPI (dots per inch) for pixel conversions
14181
- * Word uses 96 DPI internally
14182
- */
14183
- declare const DOCX_DPI = 96;
14184
14138
  /**
14185
14139
  * Convert TWIPs to CSS pixels (returns number)
14186
14140
  * @param twip - Value in TWIPs (1 inch = 1440 TWIPs)
@@ -14247,6 +14201,7 @@ declare function convertEmuStringToPixels(emuStr: string): number | undefined;
14247
14201
  * convertCssLengthToPixels("20px") // returns 20
14248
14202
  * convertCssLengthToPixels("1.5em") // returns 24
14249
14203
  * convertCssLengthToPixels("100%") // returns 16
14204
+ * convertCssLengthToPixels("20") // returns 20 (unitless treated as px)
14250
14205
  */
14251
14206
  declare function convertCssLengthToPixels(value: string): number;
14252
14207
  /**
@@ -14361,68 +14316,284 @@ declare function parseTwipAttr(attributes: Record<string, any> | {
14361
14316
  }, name: string): string | undefined;
14362
14317
 
14363
14318
  /**
14364
- * Calculate effective content width from document options
14319
+ * Shared constants for DOCX processing
14320
+ * Used across @docen/export-docx and @docen/import-docx packages
14365
14321
  */
14366
- declare function calculateEffectiveContentWidth(options?: DocxExportOptions): number;
14367
-
14368
14322
  /**
14369
- * Convert image MIME type to DOCX type
14323
+ * DOCX DPI (dots per inch) for pixel conversions
14324
+ * Word uses 96 DPI internally
14370
14325
  */
14371
- declare function convertToDocxImageType(mimeType?: string): "jpg" | "png" | "gif" | "bmp";
14326
+ declare const DOCX_DPI = 96;
14372
14327
  /**
14373
- * Extract image type from URL or base64 data
14328
+ * TWIP (Twentieth of a Point) conversion constants
14329
+ * 1 inch = 1440 TWIPs
14374
14330
  */
14375
- declare function getImageTypeFromSrc(src: string): "png" | "jpeg" | "gif" | "bmp" | "tiff";
14331
+ declare const TWIPS_PER_INCH = 1440;
14376
14332
  /**
14377
- * Create floating options for full-width images
14333
+ * EMU (English Metric Unit) conversion constants
14334
+ * 1 inch = 914400 EMUs
14378
14335
  */
14379
- declare function createFloatingOptions(): {
14380
- horizontalPosition: {
14381
- relative: string;
14382
- align: string;
14336
+ declare const EMUS_PER_INCH = 914400;
14337
+ /**
14338
+ * Font size conversion factors
14339
+ * DOCX uses half-points, TipTap uses pixels
14340
+ * 1px ≈ 0.75pt, 1pt = 2 half-points
14341
+ * So: px * 0.75 * 2 = px * 1.5
14342
+ */
14343
+ declare const HALF_POINTS_PER_PIXEL = 1.5;
14344
+ declare const PIXELS_PER_HALF_POINT: number;
14345
+ /**
14346
+ * Default code font family
14347
+ */
14348
+ declare const DEFAULT_CODE_FONT = "Consolas";
14349
+ /**
14350
+ * Checkbox symbols for task lists
14351
+ */
14352
+ declare const CHECKBOX_SYMBOLS: {
14353
+ readonly checked: "☑";
14354
+ readonly unchecked: "☐";
14355
+ };
14356
+ /**
14357
+ * DOCX style names
14358
+ */
14359
+ declare const DOCX_STYLE_NAMES: {
14360
+ readonly CODE_BLOCK: "CodeBlock";
14361
+ readonly CODE_PREFIX: "Code";
14362
+ };
14363
+ /**
14364
+ * Text alignment mappings
14365
+ */
14366
+ declare const TEXT_ALIGN_MAP: {
14367
+ /** TipTap to DOCX alignment mapping */
14368
+ readonly tiptapToDocx: {
14369
+ readonly left: "left";
14370
+ readonly right: "right";
14371
+ readonly center: "center";
14372
+ readonly justify: "both";
14383
14373
  };
14384
- verticalPosition: {
14385
- relative: string;
14386
- align: string;
14374
+ /** DOCX to TipTap alignment mapping */
14375
+ readonly docxToTipTap: {
14376
+ readonly left: "left";
14377
+ readonly right: "right";
14378
+ readonly center: "center";
14379
+ readonly both: "justify";
14387
14380
  };
14388
- lockAnchor: boolean;
14389
- behindDocument: boolean;
14390
- inFrontOfText: boolean;
14391
14381
  };
14392
14382
  /**
14393
- * Get image width with priority: node attrs > image meta > calculated > default
14383
+ * Common page dimensions in TWIPs
14394
14384
  */
14395
- declare function getImageWidth(node: {
14396
- attrs?: {
14397
- width?: number | null;
14398
- };
14399
- }, imageMeta?: {
14400
- width?: number;
14401
- height?: number;
14402
- }, maxWidth?: number | PositiveUniversalMeasure$1): number;
14385
+ declare const PAGE_DIMENSIONS: {
14386
+ /** A4 width in TWIPs (8.27 inches = 11906 TWIPs) */
14387
+ readonly A4_WIDTH_TWIP: 11906;
14388
+ /** Default 1 inch margin in TWIPs */
14389
+ readonly DEFAULT_MARGIN_TWIP: 1440;
14390
+ };
14391
+
14403
14392
  /**
14404
- * Get image height with priority: node attrs > image meta > calculated > default
14393
+ * Type guard utilities for DOCX processing
14405
14394
  */
14406
- declare function getImageHeight(node: {
14407
- attrs?: {
14408
- height?: number | null;
14409
- };
14410
- }, width: number, imageMeta?: {
14411
- width?: number;
14412
- height?: number;
14413
- }, maxWidth?: number | PositiveUniversalMeasure$1): number;
14414
14395
  /**
14415
- * Fetch image data and metadata from URL
14396
+ * Type guard factory function
14397
+ * Creates a type guard function that checks if a value is one of the valid values
14398
+ *
14399
+ * @param validValues - Readonly array of valid string values
14400
+ * @returns Type guard function
14401
+ *
14402
+ * @example
14403
+ * const isValidAlign = createStringValidator(["left", "right", "center"] as const);
14404
+ * if (isValidAlign(value)) {
14405
+ * // value is typed as "left" | "right" | "center"
14406
+ * }
14416
14407
  */
14417
- declare function getImageDataAndMeta(url: string): Promise<{
14418
- data: Uint8Array;
14419
- meta: ImageMeta;
14420
- }>;
14408
+ declare function createStringValidator<T extends string>(validValues: readonly T[]): (value: string) => value is T;
14409
+
14410
+ /**
14411
+ * Calculate effective content width from document options
14412
+ */
14413
+ declare function calculateEffectiveContentWidth(options?: DocxExportOptions): number;
14421
14414
 
14422
14415
  /**
14423
14416
  * Apply paragraph style attributes to options
14424
14417
  */
14425
14418
  declare const applyParagraphStyleAttributes: <T extends Record<string, unknown>>(options: T, attrs?: ParagraphNode["attrs"]) => T;
14426
14419
 
14427
- export { COLOR_NAME_TO_HEX, DOCX_DPI, applyParagraphStyleAttributes, calculateEffectiveContentWidth, convertBlockquote, convertBulletList, convertCodeBlock, convertColorToHex, convertCssLengthToPixels, convertDetailsSummary, convertDocument, convertEmuStringToPixels, convertEmuToPixels, convertHardBreak, convertHeading, convertHorizontalRule, convertImage, convertList, convertListItem, convertMeasureToInches, convertMeasureToPixels, convertNode, convertOrderedList, convertParagraph, convertPixelsToEmu, convertPixelsToTwip, convertTable, convertTableCell, convertTableHeader, convertTableRow, convertTaskItem, convertTaskList, convertText, convertTextNodes, convertToDocxImageType, convertTwipToCssString, convertTwipToPixels, createFloatingOptions, findChild, findDeepChild, findDeepChildren, generateDOCX, getImageDataAndMeta, getImageHeight, getImageTypeFromSrc, getImageWidth, normalizeHexColor, parseTwipAttr };
14428
- export type { BlockNode, BlockquoteNode, BulletListNode, CodeBlockNode, DetailsContentNode, DetailsNode, DetailsSummaryNode, DocumentNode, DocxExportOptions, HardBreakNode, HeadingNode, HorizontalRuleNode, ImageFloatingOptions, ImageNode, ImageOutlineOptions, JSONContent, ListItemNode, ListOptions, Mark, OrderedListNode, ParagraphNode, PositiveUniversalMeasure, TableCellBorder, TableCellNode, TableHeaderNode, TableNode, TableRowNode, TaskItemNode, TaskListNode, TextContent, TextNode };
14420
+ /**
14421
+ * Convert TipTap border to DOCX border format
14422
+ *
14423
+ * @param border - TipTap table cell border definition
14424
+ * @returns DOCX border options or undefined if no border
14425
+ */
14426
+ declare function convertBorder(border: TableCellBorder | null | undefined): {
14427
+ color?: string;
14428
+ size?: number;
14429
+ style: "single" | "dashed" | "dotted" | "double" | "none";
14430
+ } | undefined;
14431
+
14432
+ /**
14433
+ * Convert TipTap image node to DOCX ImageRun
14434
+ *
14435
+ * @param node - TipTap image node
14436
+ * @param params - Conversion parameters
14437
+ * @returns Promise<DOCX ImageRun>
14438
+ */
14439
+ declare function convertImage(node: ImageNode, params?: {
14440
+ /** Maximum available width (number = pixels, or string like "6in", "152.4mm") */
14441
+ maxWidth?: number | PositiveUniversalMeasure$1;
14442
+ /** Additional image options to apply */
14443
+ options?: Partial<IImageOptions$1>;
14444
+ /** Custom image handler for fetching image data */
14445
+ handler?: DocxImageExportHandler;
14446
+ }): Promise<ImageRun>;
14447
+
14448
+ /**
14449
+ * Apply table margins to table options
14450
+ */
14451
+ declare const applyTableMargins: <T extends ITableOptions>(options: T, node: TableNode) => T;
14452
+ /**
14453
+ * Convert TipTap table node to DOCX Table
14454
+ *
14455
+ * @param node - TipTap table node
14456
+ * @param params - Conversion parameters
14457
+ * @returns Promise<Table>
14458
+ */
14459
+ declare function convertTable(node: TableNode, params: {
14460
+ options: DocxExportOptions["table"];
14461
+ }): Promise<Table>;
14462
+
14463
+ /**
14464
+ * Convert TipTap table row node to DOCX TableRow
14465
+ *
14466
+ * @param node - TipTap table row node
14467
+ * @param params - Conversion parameters
14468
+ * @returns Promise<DOCX TableRow object>
14469
+ */
14470
+ declare function convertTableRow(node: TableRowNode, params: {
14471
+ options: DocxExportOptions["table"];
14472
+ }): Promise<TableRow>;
14473
+
14474
+ /**
14475
+ * Convert TipTap table cell node to DOCX TableCell
14476
+ *
14477
+ * @param node - TipTap table cell node
14478
+ * @param params - Conversion parameters
14479
+ * @returns Promise<DOCX TableCell object>
14480
+ */
14481
+ declare function convertTableCell(node: TableCellNode, params: {
14482
+ options: DocxExportOptions["table"];
14483
+ }): Promise<TableCell>;
14484
+
14485
+ /**
14486
+ * Convert TipTap table header node to DOCX TableCell
14487
+ *
14488
+ * @param node - TipTap table header node
14489
+ * @param params - Conversion parameters
14490
+ * @returns Promise<DOCX TableCell object for header>
14491
+ */
14492
+ declare function convertTableHeader(node: TableHeaderNode, params: {
14493
+ options: DocxExportOptions["table"];
14494
+ }): Promise<TableCell>;
14495
+
14496
+ /**
14497
+ * Convert TipTap codeBlock node to DOCX paragraph options
14498
+ *
14499
+ * This converter only handles data transformation from node.attrs to DOCX format properties.
14500
+ * It returns pure data objects (IParagraphOptions), not DOCX instances.
14501
+ *
14502
+ * @param node - TipTap codeBlock node
14503
+ * @returns DOCX paragraph options (pure data object)
14504
+ */
14505
+ declare function convertCodeBlock(node: CodeBlockNode): IParagraphOptions;
14506
+
14507
+ interface ListOptions {
14508
+ numbering: {
14509
+ reference: string;
14510
+ level: number;
14511
+ };
14512
+ start?: number;
14513
+ }
14514
+ declare function convertBulletList(): ListOptions;
14515
+ declare function convertOrderedList(node: OrderedListNode): ListOptions;
14516
+ /**
14517
+ * Convert list nodes (bullet or ordered) with proper numbering
14518
+ *
14519
+ * This converter only handles data transformation from node content to DOCX format properties.
14520
+ * It returns pure data objects (IParagraphOptions[]), not DOCX instances.
14521
+ */
14522
+ declare function convertList(node: BulletListNode | OrderedListNode, params: {
14523
+ listType: "bullet" | "ordered";
14524
+ }): Promise<IParagraphOptions[]>;
14525
+
14526
+ /**
14527
+ * Convert TipTap list item node to paragraph options
14528
+ *
14529
+ * This converter only handles data transformation from node content to DOCX format properties.
14530
+ * It returns pure data objects (IParagraphOptions), not DOCX instances.
14531
+ *
14532
+ * Note: The numbering reference (including start value) is typically
14533
+ * handled by the parent list converter. This function focuses on
14534
+ * converting the paragraph content of the list item.
14535
+ *
14536
+ * @param node - TipTap list item node
14537
+ * @param params - Conversion parameters
14538
+ * @returns Promise<Paragraph options (pure data object)>
14539
+ */
14540
+ declare function convertListItem(node: ListItemNode, params: {
14541
+ options?: IParagraphOptions;
14542
+ }): Promise<IParagraphOptions>;
14543
+
14544
+ /**
14545
+ * Convert TipTap task list node to array of paragraph options
14546
+ *
14547
+ * This converter only handles data transformation from node content to DOCX format properties.
14548
+ * It returns pure data objects (IParagraphOptions[]), not DOCX instances.
14549
+ *
14550
+ * @param node - TipTap task list node
14551
+ * @returns Array of paragraph options (pure data objects) with checkboxes
14552
+ */
14553
+ declare function convertTaskList(node: TaskListNode): IParagraphOptions[];
14554
+
14555
+ /**
14556
+ * Convert TipTap task item node to paragraph options with checkbox
14557
+ *
14558
+ * This converter only handles data transformation from node content to DOCX format properties.
14559
+ * It returns pure data objects (IParagraphOptions), not DOCX instances.
14560
+ *
14561
+ * @param node - TipTap task item node
14562
+ * @returns Paragraph options (pure data object) with checkbox
14563
+ */
14564
+ declare function convertTaskItem(node: TaskItemNode): IParagraphOptions;
14565
+
14566
+ /**
14567
+ * Convert TipTap horizontalRule node to paragraph options
14568
+ *
14569
+ * This converter only handles data transformation from node to DOCX format properties.
14570
+ * It returns pure data objects (IParagraphOptions), not DOCX instances.
14571
+ *
14572
+ * Uses page break by default (consistent with import-docx behavior)
14573
+ *
14574
+ * @param node - TipTap horizontalRule node
14575
+ * @param params - Conversion parameters
14576
+ * @returns Paragraph options (pure data object) with page break or custom styling
14577
+ */
14578
+ declare function convertHorizontalRule(node: HorizontalRuleNode, params: {
14579
+ /** Export options for horizontal rule styling */
14580
+ options?: DocxExportOptions["horizontalRule"];
14581
+ }): IParagraphOptions;
14582
+
14583
+ /**
14584
+ * Convert TipTap detailsSummary node to paragraph options
14585
+ *
14586
+ * This converter only handles data transformation from node content to DOCX format properties.
14587
+ * It returns pure data objects (IParagraphOptions), not DOCX instances.
14588
+ *
14589
+ * @param node - TipTap detailsSummary node
14590
+ * @param params - Conversion parameters
14591
+ * @returns Paragraph options (pure data object) with summary styling
14592
+ */
14593
+ declare function convertDetailsSummary(node: DetailsSummaryNode, params: {
14594
+ /** Export options for details styling */
14595
+ options?: DocxExportOptions["details"];
14596
+ }): IParagraphOptions;
14597
+
14598
+ export { CHECKBOX_SYMBOLS, COLOR_NAME_TO_HEX, DEFAULT_CODE_FONT, DOCX_DPI, DOCX_STYLE_NAMES, EMUS_PER_INCH, HALF_POINTS_PER_PIXEL, PAGE_DIMENSIONS, PIXELS_PER_HALF_POINT, TEXT_ALIGN_MAP, TWIPS_PER_INCH, applyParagraphStyleAttributes, applyTableMargins, calculateEffectiveContentWidth, convertBlockquote, convertBorder, convertBulletList, convertCodeBlock, convertColorToHex, convertCssLengthToPixels, convertDetailsSummary, convertDocument, convertEmuStringToPixels, convertEmuToPixels, convertHardBreak, convertHeading, convertHorizontalRule, convertImage, convertList, convertListItem, convertMeasureToInches, convertMeasureToPixels, convertNode, convertOrderedList, convertParagraph, convertPixelsToEmu, convertPixelsToTwip, convertTable, convertTableCell, convertTableHeader, convertTableRow, convertTaskItem, convertTaskList, convertText, convertTextNodes, convertToDocxImageType, convertTwipToCssString, convertTwipToPixels, createFloatingOptions, createStringValidator, findChild, findDeepChild, findDeepChildren, generateDOCX, getImageDataAndMeta, getImageHeight, getImageTypeFromSrc, getImageWidth, normalizeHexColor, parseTwipAttr };
14599
+ export type { BlockNode, BlockquoteNode, BulletListNode, CodeBlockNode, DetailsContentNode, DetailsNode, DetailsSummaryNode, DocumentNode, DocxExportOptions, DocxImageExportHandler, HardBreakNode, HeadingNode, HorizontalRuleNode, ImageFloatingOptions, ImageNode, ImageOutlineOptions, JSONContent, ListItemNode, ListOptions, Mark, OrderedListNode, ParagraphNode, PositiveUniversalMeasure, TableCellBorder, TableCellNode, TableHeaderNode, TableNode, TableRowNode, TaskItemNode, TaskListNode, TextContent, TextNode };