Add table borders

This commit is contained in:
Dolan
2019-11-18 01:04:31 +00:00
parent e9d3853d93
commit da9e6d6664
5 changed files with 138 additions and 12 deletions

View File

@ -2,7 +2,7 @@
import { XmlComponent } from "file/xml-components";
import { TableGrid } from "./grid";
import { TableCell, VerticalMergeType, WidthType } from "./table-cell";
import { ITableFloatOptions, TableProperties } from "./table-properties";
import { ITableBordersOptions, ITableFloatOptions, TableProperties } from "./table-properties";
import { TableLayoutType } from "./table-properties/table-layout";
import { TableRow } from "./table-row";
@ -32,6 +32,7 @@ export interface ITableOptions {
};
readonly float?: ITableFloatOptions;
readonly layout?: TableLayoutType;
readonly borders?: ITableBordersOptions;
}
export class Table extends XmlComponent {
@ -44,11 +45,17 @@ export class Table extends XmlComponent {
margins: { marginUnitType, top, bottom, right, left } = { marginUnitType: WidthType.AUTO, top: 0, bottom: 0, right: 0, left: 0 },
float,
layout,
borders,
}: ITableOptions) {
super("w:tbl");
this.properties = new TableProperties();
this.root.push(this.properties);
this.properties.setBorder();
if (borders) {
this.properties.setBorder(borders);
} else {
this.properties.setBorder({});
}
if (width) {
this.properties.setWidth(width.size, width.type);