Skip to content

Commit

Permalink
Merge pull request #106 from ydfzgyj/shading
Browse files Browse the repository at this point in the history
Add table cell shading
  • Loading branch information
dolanmiu committed Aug 2, 2018
2 parents 5232c05 + 60f3124 commit 8fbaec3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/file/table/table-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,27 @@ export class TableCellWidth extends XmlComponent {
);
}
}

interface ITableCellShadingAttributesProperties {
fill?: string;
color?: string;
val?: string;
}

class TableCellShadingAttributes extends XmlAttributeComponent<ITableCellShadingAttributesProperties> {
protected xmlKeys = {
fill: "w:fill",
color: "w:color",
val: "w:val",
};
}

/**
* Table cell shading element.
*/
export class TableCellShading extends XmlComponent {
constructor(attrs: object) {
super("w:shd");
this.root.push(new TableCellShadingAttributes(attrs));
}
}
18 changes: 17 additions & 1 deletion src/file/table/table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { GridSpan, TableCellBorders, TableCellWidth, VAlign, VerticalAlign, VMerge, VMergeType, WidthType } from "file/table/table-cell";
import {
GridSpan,
TableCellBorders,
TableCellShading,
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";
Expand Down Expand Up @@ -159,4 +169,10 @@ export class TableCellProperties extends XmlComponent {

return this;
}

public setShading(attrs: object): TableCellProperties {
this.root.push(new TableCellShading(attrs));

return this;
}
}

0 comments on commit 8fbaec3

Please sign in to comment.