docxml
Version:
TypeScript (component) library for building and parsing a DOCX file
46 lines (45 loc) • 1.92 kB
TypeScript
import { type ComponentAncestor, Component, ComponentContext } from '../classes/Component.js';
import { type TableCellProperties } from '../properties/table-cell-properties.js';
import { BookmarkRangeEnd } from './BookmarkRangeEnd.js';
import { BookmarkRangeStart } from './BookmarkRangeStart.js';
import { Paragraph } from './Paragraph.js';
import { Table } from './Table.js';
/**
* A type describing the components accepted as children of {@link Cell}.
*/
export declare type CellChild = Paragraph | Table | BookmarkRangeStart | BookmarkRangeEnd;
/**
* A type describing the props accepted by {@link Cell}.
*/
export declare type CellProps = Omit<TableCellProperties, 'width'>;
/**
* A component that represents a table cell.
*
* For MS Word to be happy any cell needs to have a paragraph as the last child. This component will
* quietly fix that for you if you don't have a paragraph there already.
*/
export declare class Cell extends Component<CellProps, CellChild> {
static readonly children: string[];
static readonly mixed: boolean;
constructor(cellProps: CellProps, ...cellChild: CellChild[]);
/**
* Creates an XML DOM node for this component instance.
*/
toNode(ancestry: ComponentAncestor[]): Promise<Node>;
toRepeatingNode(ancestry: ComponentAncestor[], column: number, _row: number): Node | null;
/**
* Returns `true` when this cell has no visual representation because a column-spanning or row-
* spanning neighbour overlaps it.
*/
isMergedAway(ancestry: ComponentAncestor[]): boolean;
getColSpan(): number;
getRowSpan(): number;
/**
* Asserts whether or not a given XML node correlates with this component.
*/
static matchesNode(node: Node): boolean;
/**
* Instantiate this component from the XML in an existing DOCX file.
*/
static fromNode(node: Node, context: ComponentContext): null | Cell;
}