import { IgnoreIfEmptyXmlComponent } from "file/xml-components"; import { TableWidthElement, WidthType } from "../table-width"; export interface ITableCellMarginOptions { readonly marginUnitType?: WidthType; readonly top?: number; readonly bottom?: number; readonly left?: number; readonly right?: number; } // Technically two different types, but they're identical // // // // // // // // // // // // // // // // // // // // // export enum TableCellMarginElementType { TABLE = "w:tblCellMar", TABLE_CELL = "w:tcMar", } export class TableCellMargin extends IgnoreIfEmptyXmlComponent { constructor(type: TableCellMarginElementType, { marginUnitType = WidthType.DXA, top, left, bottom, right }: ITableCellMarginOptions) { super(type); if (top !== undefined) { this.root.push(new TableWidthElement("w:top", { type: marginUnitType, size: top })); } if (left !== undefined) { this.root.push(new TableWidthElement("w:left", { type: marginUnitType, size: left })); } if (bottom !== undefined) { this.root.push(new TableWidthElement("w:bottom", { type: marginUnitType, size: bottom })); } if (right !== undefined) { this.root.push(new TableWidthElement("w:right", { type: marginUnitType, size: right })); } } }