Add shading

This commit is contained in:
Dolan
2019-03-21 01:06:07 +00:00
parent 48c17d51bb
commit c6ab47e838
9 changed files with 164 additions and 50 deletions

View File

@ -194,27 +194,3 @@ export class TableCellWidth extends XmlComponent {
);
}
}
export interface ITableCellShadingAttributesProperties {
readonly fill?: string;
readonly color?: string;
readonly val?: string;
}
class TableCellShadingAttributes extends XmlAttributeComponent<ITableCellShadingAttributesProperties> {
protected readonly xmlKeys = {
fill: "w:fill",
color: "w:color",
val: "w:val",
};
}
/**
* Table cell shading element.
*/
export class TableCellShading extends XmlComponent {
constructor(attrs: ITableCellShadingAttributesProperties) {
super("w:shd");
this.root.push(new TableCellShadingAttributes(attrs));
}
}

View File

@ -1,18 +1,8 @@
import { XmlComponent } from "file/xml-components";
import { ITableShadingAttributesProperties, TableShading } from "../shading";
import { ITableCellMargainOptions, TableCellMargain } from "./cell-margain/table-cell-margains";
import {
GridSpan,
ITableCellShadingAttributesProperties,
TableCellBorders,
TableCellShading,
TableCellWidth,
VAlign,
VerticalAlign,
VMerge,
VMergeType,
WidthType,
} from "./table-cell-components";
import { GridSpan, TableCellBorders, TableCellWidth, VAlign, VerticalAlign, VMerge, VMergeType, WidthType } from "./table-cell-components";
export class TableCellProperties extends XmlComponent {
private readonly cellBorder: TableCellBorders;
@ -51,8 +41,8 @@ export class TableCellProperties extends XmlComponent {
return this;
}
public setShading(attrs: ITableCellShadingAttributesProperties): TableCellProperties {
this.root.push(new TableCellShading(attrs));
public setShading(attrs: ITableShadingAttributesProperties): TableCellProperties {
this.root.push(new TableShading(attrs));
return this;
}

View File

@ -2,6 +2,7 @@
import { Paragraph } from "file/paragraph";
import { IXmlableObject, XmlComponent } from "file/xml-components";
import { ITableShadingAttributesProperties } from "../shading";
import { Table } from "../table";
import { ITableCellMargainOptions } from "./cell-margain/table-cell-margains";
import { TableCellBorders, VerticalAlign, VMergeType } from "./table-cell-components";
@ -72,6 +73,12 @@ export class TableCell extends XmlComponent {
return this;
}
public setShading(attrs: ITableShadingAttributesProperties): TableCell {
this.properties.setShading(attrs);
return this;
}
public get Borders(): TableCellBorders {
return this.properties.Borders;
}