Add API for specifying columns with different widths

This commit is contained in:
askoufis
2021-09-18 22:58:19 +10:00
parent a2566e92d2
commit 23fd3b483f
4 changed files with 71 additions and 1 deletions

View File

@ -0,0 +1,26 @@
import { twipsMeasureValue } from "file/values";
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
export interface IColumnAttributes {
readonly width: number | string;
readonly space?: number | string;
}
export class ColumnAttributes extends XmlAttributeComponent<IColumnAttributes> {
protected readonly xmlKeys = {
width: 'w:w',
space: 'w:space',
}
}
export class Column extends XmlComponent {
constructor({width, space}: IColumnAttributes) {
super("w:col");
this.root.push(
new ColumnAttributes({
width: twipsMeasureValue(width),
space: space === undefined ? undefined : twipsMeasureValue(space),
})
)
}
}