extend table and table cell support for cell merge, span, borders ... (#6)

* extend table and table cell support for cell merge, span, borders ...

* added tests for table cell borders and table cell width, renamed some variables, added jsdoc
This commit is contained in:
h4buli
2018-05-04 15:56:28 +02:00
committed by GitHub
parent 21bb8f9016
commit 753287d9d1
4 changed files with 402 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import { IXmlableObject, XmlComponent } from "file/xml-components";
import { Paragraph } from "../paragraph";
import { TableGrid } from "./grid";
import { TableProperties, WidthTypes } from "./properties";
import { TableCellBorders, GridSpan, VMerge, VMergeType, VerticalAlign, VAlign, TableCellWidth, WidthType } from "file/table/table-cell";
export class Table extends XmlComponent {
private readonly properties: TableProperties;
@ -123,7 +124,29 @@ export class TableCell extends XmlComponent {
}
export class TableCellProperties extends XmlComponent {
private cellBorder: TableCellBorders;
constructor() {
super("w:tcPr");
this.cellBorder = new TableCellBorders();
this.root.push(this.cellBorder);
}
get borders() {
return this.cellBorder;
}
addGridSpan(cellSpan: number) {
this.root.push(new GridSpan(cellSpan));
}
addVerticalMerge(type: VMergeType) {
this.root.push(new VMerge(type));
}
setVerticalAlign(vAlignType: VerticalAlign) {
this.root.push(new VAlign(vAlignType));
}
setWidth(width: string | number, type: WidthType) {
this.root.push(new TableCellWidth(width, type));
}
}