Files
docx-js/ts/docx/table/properties.ts

31 lines
794 B
TypeScript
Raw Normal View History

import { XmlAttributeComponent, XmlComponent } from "../xml-components";
2017-03-07 19:22:10 +01:00
type widthTypes = "dxa" | "pct" | "nil" | "auto";
2017-03-07 19:22:10 +01:00
export class TableProperties extends XmlComponent {
2017-03-07 19:22:10 +01:00
constructor() {
super("w:tblPr");
2017-03-07 19:22:10 +01:00
}
public setWidth(type: widthTypes, w: number | string): TableProperties {
this.root.push(new PreferredTableWidth(type, w));
return this;
2017-03-07 19:22:10 +01:00
}
}
interface ITableWidth {
type: widthTypes;
w: number | string;
}
class TableWidthAttributes extends XmlAttributeComponent<ITableWidth> {
protected xmlKeys = {type: "w:type", w: "w:w"};
}
2017-03-07 19:22:10 +01:00
class PreferredTableWidth extends XmlComponent {
constructor(type: widthTypes, w: number | string) {
super("w:tblW");
this.root.push(new TableWidthAttributes({type, w}));
2017-03-07 19:22:10 +01:00
}
}