/
table-row-height.ts
43 lines (38 loc) · 1.45 KB
/
table-row-height.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
import { PositiveUniversalMeasure, twipsMeasureValue } from "@util/values";
// <xsd:complexType name="CT_Height">
// <xsd:attribute name="val" type="s:ST_TwipsMeasure"/>
// <xsd:attribute name="hRule" type="ST_HeightRule"/>
// </xsd:complexType>
// <xsd:simpleType name="ST_HeightRule">
// <xsd:restriction base="xsd:string">
// <xsd:enumeration value="auto"/>
// <xsd:enumeration value="exact"/>
// <xsd:enumeration value="atLeast"/>
// </xsd:restriction>
// </xsd:simpleType>
export const HeightRule = {
/** Height is determined based on the content, so value is ignored. */
AUTO: "auto",
/** At least the value specified */
ATLEAST: "atLeast",
/** Exactly the value specified */
EXACT: "exact",
} as const;
export class TableRowHeightAttributes extends XmlAttributeComponent<{
readonly value: number | string;
readonly rule: (typeof HeightRule)[keyof typeof HeightRule];
}> {
protected readonly xmlKeys = { value: "w:val", rule: "w:hRule" };
}
export class TableRowHeight extends XmlComponent {
public constructor(value: number | PositiveUniversalMeasure, rule: (typeof HeightRule)[keyof typeof HeightRule]) {
super("w:trHeight");
this.root.push(
new TableRowHeightAttributes({
value: twipsMeasureValue(value),
rule: rule,
}),
);
}
}