2017-03-10 16:51:19 +01:00
|
|
|
import { XmlAttributeComponent, XmlComponent } from "../xml-components";
|
2017-03-07 19:22:10 +01:00
|
|
|
|
2017-03-10 16:51:19 +01:00
|
|
|
type widthTypes = "dxa" | "pct" | "nil" | "auto";
|
2017-03-07 19:22:10 +01:00
|
|
|
|
2017-03-10 16:51:19 +01:00
|
|
|
export class TableProperties extends XmlComponent {
|
2017-03-07 19:22:10 +01:00
|
|
|
constructor() {
|
2017-03-10 16:51:19 +01:00
|
|
|
super("w:tblPr");
|
2017-03-07 19:22:10 +01:00
|
|
|
}
|
|
|
|
|
2017-03-10 16:51:19 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-10 16:51:19 +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 {
|
2017-03-10 16:51:19 +01:00
|
|
|
constructor(type: widthTypes, w: number | string) {
|
|
|
|
super("w:tblW");
|
|
|
|
this.root.push(new TableWidthAttributes({type, w}));
|
2017-03-07 19:22:10 +01:00
|
|
|
}
|
|
|
|
}
|