2022-06-26 23:26:42 +01:00
|
|
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
2021-05-24 21:06:34 +03:00
|
|
|
|
|
|
|
// <xsd:complexType name="CT_VerticalJc">
|
|
|
|
// <xsd:attribute name="val" type="ST_VerticalJc" use="required"/>
|
|
|
|
// </xsd:complexType>
|
|
|
|
|
|
|
|
// <xsd:simpleType name="ST_VerticalJc">
|
|
|
|
// <xsd:restriction base="xsd:string">
|
2025-05-02 13:58:10 -05:00
|
|
|
// <xsd:enumeration value="both"/>
|
2021-05-24 21:06:34 +03:00
|
|
|
// <xsd:enumeration value="top"/>
|
|
|
|
// <xsd:enumeration value="center"/>
|
|
|
|
// <xsd:enumeration value="bottom"/>
|
|
|
|
// </xsd:restriction>
|
|
|
|
// </xsd:simpleType>
|
2025-05-02 13:58:10 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enumeration for table-cell vertical alignment. Only `top`, `center`, `bottom`
|
|
|
|
* are valid according to ECMA-376 (§17.18.87 ST_VerticalJc within <w:tcPr>).
|
|
|
|
*/
|
|
|
|
export const VerticalAlignTable = {
|
2023-12-22 10:25:00 +09:00
|
|
|
TOP: "top",
|
2025-05-02 13:58:10 -05:00
|
|
|
CENTER: "center",
|
|
|
|
BOTTOM: "bottom",
|
2023-12-22 10:25:00 +09:00
|
|
|
} as const;
|
|
|
|
|
2025-05-02 13:58:10 -05:00
|
|
|
/**
|
|
|
|
* Enumeration for section (<w:sectPr>) vertical alignment. Adds `both` on top of
|
|
|
|
* the table-cell set (§17.18.87 ST_VerticalJc within <w:sectPr>).
|
|
|
|
*/
|
|
|
|
export const VerticalAlignSection = {
|
|
|
|
...VerticalAlignTable,
|
|
|
|
BOTH: "both",
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated Use {@link VerticalAlignTable} for table cells or
|
|
|
|
* {@link VerticalAlignSection} for section properties. This alias remains for
|
|
|
|
* backward-compatibility and will be removed in the next major release.
|
|
|
|
*/
|
|
|
|
export const VerticalAlign = VerticalAlignSection;
|
|
|
|
|
|
|
|
export type TableVerticalAlign = (typeof VerticalAlignTable)[keyof typeof VerticalAlignTable];
|
|
|
|
|
|
|
|
export type SectionVerticalAlign = (typeof VerticalAlignSection)[keyof typeof VerticalAlignSection];
|
|
|
|
|
2021-05-24 21:06:34 +03:00
|
|
|
export class VerticalAlignAttributes extends XmlAttributeComponent<{
|
2023-12-22 10:25:00 +09:00
|
|
|
readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign];
|
2021-05-24 21:06:34 +03:00
|
|
|
}> {
|
|
|
|
protected readonly xmlKeys = {
|
|
|
|
verticalAlign: "w:val",
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export class VerticalAlignElement extends XmlComponent {
|
2023-12-22 10:25:00 +09:00
|
|
|
public constructor(value: (typeof VerticalAlign)[keyof typeof VerticalAlign]) {
|
2021-05-24 21:06:34 +03:00
|
|
|
super("w:vAlign");
|
|
|
|
this.root.push(new VerticalAlignAttributes({ verticalAlign: value }));
|
|
|
|
}
|
|
|
|
}
|