feat: Added TableCellSpacing (#3052)
* feat: Added TableCellSpacingElement * feat: Added cellSpacing (Table-constructor, TableProperties-constructor and ITableOptions) * feat: Added cellSpacing (ITablePropertiesOptions and constructor implementation) * feat: Added cellSpacing (ITableRowPropertiesOptions and constructor implementation) * feat: Added cellSpacing (Implementation Test) --------- Co-authored-by: Philip <1760073-philip.asx@users.noreply.gitlab.com>
This commit is contained in:
39
src/file/table/table-cell-spacing.ts
Normal file
39
src/file/table/table-cell-spacing.ts
Normal file
@ -0,0 +1,39 @@
|
||||
// http://officeopenxml.com/WPtableCellSpacing.php
|
||||
import { NextAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
import { Percentage, UniversalMeasure, measurementOrPercentValue } from "@util/values";
|
||||
|
||||
// <xsd:simpleType name="ST_TblCellSpacing">
|
||||
// <xsd:restriction base="xsd:string">
|
||||
// <xsd:enumeration value="nil"/>
|
||||
// <xsd:enumeration value="dxa"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
|
||||
export const CellSpacingType = {
|
||||
/** Value is in twentieths of a point */
|
||||
DXA: "dxa",
|
||||
/** No (empty) value. */
|
||||
NIL: "nil",
|
||||
} as const;
|
||||
|
||||
// <xsd:complexType name="CT_TblCellSpacing">
|
||||
// <xsd:attribute name="w" type="ST_MeasurementOrPercent"/>
|
||||
// <xsd:attribute name="type" type="ST_TblCellSpacing"/>
|
||||
// </xsd:complexType>
|
||||
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<ITableCellSpacingProperties>({
|
||||
type: { key: "w:type", value: type },
|
||||
value: { key: "w:w", value: measurementOrPercentValue(value) },
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user