Make fixed layout declaritive

This commit is contained in:
Dolan
2019-06-25 20:57:46 +01:00
parent b566b0f765
commit 3ef8f5311d
7 changed files with 34 additions and 31 deletions

View File

@ -5,6 +5,7 @@ import { TableGrid } from "./grid";
import { TableCell, WidthType } from "./table-cell";
import { TableColumn } from "./table-column";
import { ITableFloatOptions, TableProperties } from "./table-properties";
import { TableLayoutType } from "./table-properties/table-layout";
import { TableRow } from "./table-row";
/*
0-width columns don't get rendered correctly, so we need
@ -30,6 +31,7 @@ export interface ITableOptions {
readonly left?: number;
};
readonly float?: ITableFloatOptions;
readonly layout?: TableLayoutType;
}
export class Table extends XmlComponent {
@ -44,6 +46,7 @@ export class Table extends XmlComponent {
columnWidths = Array<number>(columns).fill(100),
margins: { marginUnitType, top, bottom, right, left } = { marginUnitType: WidthType.AUTO, top: 0, bottom: 0, right: 0, left: 0 },
float,
layout,
}: ITableOptions) {
super("w:tbl");
this.properties = new TableProperties();
@ -73,6 +76,10 @@ export class Table extends XmlComponent {
if (float) {
this.properties.setTableFloatProperties(float);
}
if (layout) {
this.properties.setLayout(layout);
}
}
public getRow(index: number): TableRow {
@ -94,9 +101,4 @@ export class Table extends XmlComponent {
public getCell(row: number, col: number): TableCell {
return this.getRow(row).getCell(col);
}
public setFixedWidthLayout(): Table {
this.properties.setFixedWidthLayout();
return this;
}
}