Fix styling and linting
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
export * from "./table";
|
||||
export * from './table-cell';
|
||||
export * from "./table-cell";
|
||||
|
@ -169,13 +169,13 @@ describe("TableCellWidth", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:tcW": [
|
||||
{
|
||||
"_attr": {
|
||||
_attr: {
|
||||
"w:type": "dxa",
|
||||
"w:w": 100
|
||||
}
|
||||
}
|
||||
]
|
||||
"w:w": 100,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { XmlComponent, XmlAttributeComponent, IXmlableObject } from "file/xml-components";
|
||||
import { IXmlableObject, XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||
|
||||
export enum BorderStyle {
|
||||
SINGLE = "single",
|
||||
@ -41,13 +41,15 @@ class CellBorderAttributes extends XmlAttributeComponent<ICellBorder> {
|
||||
}
|
||||
|
||||
class BaseTableCellBorder extends XmlComponent {
|
||||
setProperties(style: BorderStyle, size: number, color: string) {
|
||||
let attrs = new CellBorderAttributes({
|
||||
public setProperties(style: BorderStyle, size: number, color: string): BaseTableCellBorder {
|
||||
const attrs = new CellBorderAttributes({
|
||||
style: style,
|
||||
size: size,
|
||||
color: color,
|
||||
});
|
||||
this.root.push(attrs);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,28 +62,36 @@ export class TableCellBorders extends XmlComponent {
|
||||
return this.root.length > 0 ? super.prepForXml() : "";
|
||||
}
|
||||
|
||||
addTopBorder(style: BorderStyle, size: number, color: string) {
|
||||
public addTopBorder(style: BorderStyle, size: number, color: string): TableCellBorders {
|
||||
const top = new BaseTableCellBorder("w:top");
|
||||
top.setProperties(style, size, color);
|
||||
this.root.push(top);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
addStartBorder(style: BorderStyle, size: number, color: string) {
|
||||
public addStartBorder(style: BorderStyle, size: number, color: string): TableCellBorders {
|
||||
const start = new BaseTableCellBorder("w:start");
|
||||
start.setProperties(style, size, color);
|
||||
this.root.push(start);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
addBottomBorder(style: BorderStyle, size: number, color: string) {
|
||||
public addBottomBorder(style: BorderStyle, size: number, color: string): TableCellBorders {
|
||||
const bottom = new BaseTableCellBorder("w:bottom");
|
||||
bottom.setProperties(style, size, color);
|
||||
this.root.push(bottom);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
addEndBorder(style: BorderStyle, size: number, color: string) {
|
||||
public addEndBorder(style: BorderStyle, size: number, color: string): TableCellBorders {
|
||||
const end = new BaseTableCellBorder("w:end");
|
||||
end.setProperties(style, size, color);
|
||||
this.root.push(end);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { GridSpan, TableCellBorders, TableCellWidth, VAlign, VerticalAlign, VMerge, VMergeType, WidthType } from "file/table/table-cell";
|
||||
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;
|
||||
@ -119,7 +119,7 @@ export class TableCell extends XmlComponent {
|
||||
return para;
|
||||
}
|
||||
|
||||
get cellProperties() {
|
||||
get cellProperties(): TableCellProperties {
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
@ -132,22 +132,31 @@ export class TableCellProperties extends XmlComponent {
|
||||
this.root.push(this.cellBorder);
|
||||
}
|
||||
|
||||
get borders() {
|
||||
get borders(): TableCellBorders {
|
||||
return this.cellBorder;
|
||||
}
|
||||
addGridSpan(cellSpan: number) {
|
||||
|
||||
public addGridSpan(cellSpan: number): TableCellProperties {
|
||||
this.root.push(new GridSpan(cellSpan));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
addVerticalMerge(type: VMergeType) {
|
||||
public addVerticalMerge(type: VMergeType): TableCellProperties {
|
||||
this.root.push(new VMerge(type));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
setVerticalAlign(vAlignType: VerticalAlign) {
|
||||
public setVerticalAlign(vAlignType: VerticalAlign): TableCellProperties {
|
||||
this.root.push(new VAlign(vAlignType));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
setWidth(width: string | number, type: WidthType) {
|
||||
public setWidth(width: string | number, type: WidthType): TableCellProperties {
|
||||
this.root.push(new TableCellWidth(width, type));
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user