// http://officeopenxml.com/WPtableCellSpacing.php import { NextAttributeComponent, XmlComponent } from "@file/xml-components"; import { Percentage, UniversalMeasure, measurementOrPercentValue } from "@util/values"; // // // // // // export const CellSpacingType = { /** Value is in twentieths of a point */ DXA: "dxa", /** No (empty) value. */ NIL: "nil", } as const; // // // // export type ITableCellSpacingProperties = { readonly value: number | Percentage | UniversalMeasure; readonly type?: (typeof CellSpacingType)[keyof typeof CellSpacingType]; }; export class TableCellSpacingElement extends XmlComponent { public constructor({ type = CellSpacingType.DXA, value }: ITableCellSpacingProperties) { super("w:tblCellSpacing"); this.root.push( new NextAttributeComponent({ type: { key: "w:type", value: type }, value: { key: "w:w", value: measurementOrPercentValue(value) }, }), ); } }