Add shading to paragraph

This commit is contained in:
Dolan
2020-10-28 01:05:31 +00:00
parent ed52ef358b
commit 60eb686d05
8 changed files with 124 additions and 22 deletions

View File

@ -9,6 +9,7 @@ import { File } from "../file";
import { AlignmentType, HeadingLevel, LeaderType, PageBreak, TabStopPosition, TabStopType } from "./formatting";
import { Bookmark, HyperlinkRef } from "./links";
import { Paragraph } from "./paragraph";
import { ShadingType } from "../table/shading";
describe("Paragraph", () => {
describe("#constructor()", () => {
@ -761,6 +762,36 @@ describe("Paragraph", () => {
});
});
describe("#shading", () => {
it("should set paragraph outline level to the given value", () => {
const paragraph = new Paragraph({
shading: {
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "00FFFF",
fill: "FF0000",
},
});
const tree = new Formatter().format(paragraph);
expect(tree).to.deep.equal({
"w:p": [
{
"w:pPr": [
{
"w:shd": {
_attr: {
"w:color": "00FFFF",
"w:fill": "FF0000",
"w:val": "reverseDiagStripe",
},
},
},
],
},
],
});
});
});
describe("#prepForXml", () => {
it("should set paragraph outline level to the given value", () => {
const paragraph = new Paragraph({