UNPKG

@m2d/table

Version:

Plugin to convert Markdown tables (MDAST) to DOCX with support for rich formatting and seamless integration into mdast2docx.

61 lines (60 loc) 2.13 kB
import { AlignmentType, type ITableCellOptions, type ITableOptions, type ITableRowOptions, VerticalAlignTable } from "docx"; import { IPlugin, Optional } from "@m2d/core"; import { MutableParaOptions, MutableRunOptions } from "@m2d/core/utils"; export type RowProps = Omit<ITableRowOptions, "children">; export type TableProps = Omit<ITableOptions, "rows">; export type CellProps = Omit<ITableCellOptions, "children">; export interface ITableAlignments { defaultVerticalAlign?: (typeof VerticalAlignTable)[keyof typeof VerticalAlignTable]; defaultHorizontalAlign?: (typeof AlignmentType)[keyof typeof AlignmentType]; /** * Use MDAST data for horizontal aligning columns * @default true */ preferMdData?: boolean; } /** * Props for the first row cell component. */ export interface IFirstRowCellProps extends CellProps { /** * Text alignment for the cell. * * @deprecated Use the `data.alignment` property instead. */ alignment?: (typeof AlignmentType)[keyof typeof AlignmentType]; /** * Content and styling options for the cell. * * Combines mutable paragraph and run options, * and optionally supports alignment. */ data?: MutableParaOptions & MutableRunOptions; } export interface ICellProps extends CellProps { /** * Content and styling options for the cell. * * Combines mutable paragraph and run options, * and optionally supports alignment. */ data?: MutableParaOptions & MutableRunOptions; } interface IDefaultTablePluginProps { tableProps: TableProps; rowProps: RowProps; cellProps: ICellProps; firstRowProps: RowProps; firstRowCellProps: IFirstRowCellProps; alignments: ITableAlignments; } type ITablePluginProps = Optional<IDefaultTablePluginProps>; /** * default table options */ export declare const defaultTableOptions: IDefaultTablePluginProps; /** * Plugin to convert Markdown tables (MDAST) to DOCX with support for rich formatting and seamless integration into mdast2docx. */ export declare const tablePlugin: (options?: ITablePluginProps) => IPlugin; export {};