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

@ -1,2 +1,3 @@
export * from "./table-properties";
export * from "./table-float-properties";
export * from "./table-layout";

View File

@ -3,6 +3,7 @@ import { expect } from "chai";
import { Formatter } from "export/formatter";
import { WidthType } from "../table-cell";
import { TableLayoutType } from "./table-layout";
import { TableProperties } from "./table-properties";
describe("TableProperties", () => {
@ -35,9 +36,10 @@ describe("TableProperties", () => {
});
});
describe("#setFixedWidthLayout", () => {
describe("#setLayout", () => {
it("sets the table to fixed width layout", () => {
const tp = new TableProperties().setFixedWidthLayout();
const tp = new TableProperties();
tp.setLayout(TableLayoutType.FIXED);
const tree = new Formatter().format(tp);
expect(tree).to.deep.equal({
"w:tblPr": [{ "w:tblLayout": { _attr: { "w:type": "fixed" } } }],

View File

@ -23,9 +23,8 @@ export class TableProperties extends IgnoreIfEmptyXmlComponent {
return this;
}
public setFixedWidthLayout(): TableProperties {
this.root.push(new TableLayout(TableLayoutType.FIXED));
return this;
public setLayout(type: TableLayoutType): void {
this.root.push(new TableLayout(type));
}
public setBorder(): TableProperties {