/
table-layout.ts
28 lines (25 loc) · 948 Bytes
/
table-layout.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
// <xsd:simpleType name="ST_TblLayoutType">
// <xsd:restriction base="xsd:string">
// <xsd:enumeration value="fixed"/>
// <xsd:enumeration value="autofit"/>
// </xsd:restriction>
// </xsd:simpleType>
export const TableLayoutType = {
AUTOFIT: "autofit",
FIXED: "fixed",
} as const;
class TableLayoutAttributes extends XmlAttributeComponent<{
readonly type: (typeof TableLayoutType)[keyof typeof TableLayoutType];
}> {
protected readonly xmlKeys = { type: "w:type" };
}
// <xsd:complexType name="CT_TblLayoutType">
// <xsd:attribute name="type" type="ST_TblLayoutType"/>
// </xsd:complexType>
export class TableLayout extends XmlComponent {
public constructor(type: (typeof TableLayoutType)[keyof typeof TableLayoutType]) {
super("w:tblLayout");
this.root.push(new TableLayoutAttributes({ type }));
}
}