Files
docx-js/src/file/table/table-row/table-row-properties.ts

54 lines
1.5 KiB
TypeScript
Raw Normal View History

2020-10-24 21:38:20 +01:00
// http://officeopenxml.com/WPtableRowProperties.php
import { IgnoreIfEmptyXmlComponent, XmlAttributeComponent, XmlComponent } from "file/xml-components";
2018-10-23 23:44:50 +01:00
2020-10-24 21:38:20 +01:00
import { HeightRule, TableRowHeight } from "./table-row-height";
export interface ITableRowPropertiesOptions {
readonly cantSplit?: boolean;
readonly tableHeader?: boolean;
readonly height?: {
readonly value: number;
readonly rule: HeightRule;
};
}
export class TableRowProperties extends IgnoreIfEmptyXmlComponent {
constructor(options: ITableRowPropertiesOptions) {
2018-10-23 23:44:50 +01:00
super("w:trPr");
if (options.cantSplit) {
this.root.push(new CantSplit());
}
2019-06-25 12:02:53 +02:00
if (options.tableHeader) {
this.root.push(new TableHeader());
}
2019-06-25 12:02:53 +02:00
if (options.height) {
this.root.push(new TableRowHeight(options.height.value, options.height.rule));
}
2019-06-25 12:02:53 +02:00
}
}
class CantSplitAttributes extends XmlAttributeComponent<{ readonly val: boolean }> {
protected readonly xmlKeys = { val: "w:val" };
}
export class CantSplit extends XmlComponent {
constructor() {
super("w:cantSplit");
this.root.push(new CantSplitAttributes({ val: true }));
}
}
class TableHeaderAttributes extends XmlAttributeComponent<{ readonly val: boolean }> {
protected readonly xmlKeys = { val: "w:val" };
}
export class TableHeader extends XmlComponent {
constructor() {
super("w:tblHeader");
this.root.push(new TableHeaderAttributes({ val: true }));
}
2018-10-23 23:44:50 +01:00
}