Background color for document
This commit is contained in:
17
src/file/settings/display-background-shape.spec.ts
Normal file
17
src/file/settings/display-background-shape.spec.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { DisplayBackgroundShape } from "./display-background-shape";
|
||||
|
||||
describe("DisplayBackgroundShape", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should create", () => {
|
||||
const displayBackgroundShape = new DisplayBackgroundShape();
|
||||
const tree = new Formatter().format(displayBackgroundShape);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:displayBackgroundShape": {},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
9
src/file/settings/display-background-shape.ts
Normal file
9
src/file/settings/display-background-shape.ts
Normal file
@ -0,0 +1,9 @@
|
||||
// http://officeopenxml.com/WPdocument.php
|
||||
// http://www.datypic.com/sc/ooxml/e-w_background-1.html
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
|
||||
export class DisplayBackgroundShape extends XmlComponent {
|
||||
constructor() {
|
||||
super("w:displayBackgroundShape");
|
||||
}
|
||||
}
|
@ -15,8 +15,7 @@ describe("Settings", () => {
|
||||
expect(keys[0]).to.be.equal("w:settings");
|
||||
keys = Object.keys(tree["w:settings"]);
|
||||
expect(keys).is.an.instanceof(Array);
|
||||
expect(keys).has.length(1);
|
||||
expect(keys[0]).to.be.equal("_attr");
|
||||
expect(keys).has.length(2);
|
||||
});
|
||||
});
|
||||
describe("#addUpdateFields", () => {
|
||||
@ -28,16 +27,16 @@ describe("Settings", () => {
|
||||
expect(keys[0]).to.be.equal("w:settings");
|
||||
const rootArray = tree["w:settings"];
|
||||
expect(rootArray).is.an.instanceof(Array);
|
||||
expect(rootArray).has.length(2);
|
||||
expect(rootArray).has.length(3);
|
||||
keys = Object.keys(rootArray[0]);
|
||||
expect(keys).is.an.instanceof(Array);
|
||||
expect(keys).has.length(1);
|
||||
expect(keys[0]).to.be.equal("_attr");
|
||||
keys = Object.keys(rootArray[1]);
|
||||
keys = Object.keys(rootArray[2]);
|
||||
expect(keys).is.an.instanceof(Array);
|
||||
expect(keys).has.length(1);
|
||||
expect(keys[0]).to.be.equal("w:updateFields");
|
||||
const updateFields = rootArray[1]["w:updateFields"];
|
||||
const updateFields = rootArray[2]["w:updateFields"];
|
||||
keys = Object.keys(updateFields);
|
||||
expect(keys).is.an.instanceof(Array);
|
||||
expect(keys).has.length(1);
|
||||
@ -68,12 +67,12 @@ describe("Settings", () => {
|
||||
expect(keys[0]).to.be.equal("w:settings");
|
||||
const rootArray = tree["w:settings"];
|
||||
expect(rootArray).is.an.instanceof(Array);
|
||||
expect(rootArray).has.length(2);
|
||||
expect(rootArray).has.length(3);
|
||||
keys = Object.keys(rootArray[0]);
|
||||
expect(keys).is.an.instanceof(Array);
|
||||
expect(keys).has.length(1);
|
||||
expect(keys[0]).to.be.equal("_attr");
|
||||
keys = Object.keys(rootArray[1]);
|
||||
keys = Object.keys(rootArray[2]);
|
||||
expect(keys).is.an.instanceof(Array);
|
||||
expect(keys).has.length(1);
|
||||
expect(keys[0]).to.be.equal("w:compat");
|
||||
@ -89,12 +88,12 @@ describe("Settings", () => {
|
||||
expect(keys[0]).to.be.equal("w:settings");
|
||||
const rootArray = tree["w:settings"];
|
||||
expect(rootArray).is.an.instanceof(Array);
|
||||
expect(rootArray).has.length(2);
|
||||
expect(rootArray).has.length(3);
|
||||
keys = Object.keys(rootArray[0]);
|
||||
expect(keys).is.an.instanceof(Array);
|
||||
expect(keys).has.length(1);
|
||||
expect(keys[0]).to.be.equal("_attr");
|
||||
keys = Object.keys(rootArray[1]);
|
||||
keys = Object.keys(rootArray[2]);
|
||||
expect(keys).is.an.instanceof(Array);
|
||||
expect(keys).has.length(1);
|
||||
expect(keys[0]).to.be.equal("w:trackRevisions");
|
||||
@ -111,12 +110,12 @@ describe("Settings", () => {
|
||||
expect(keys[0]).to.be.equal("w:settings");
|
||||
const rootArray = tree["w:settings"];
|
||||
expect(rootArray).is.an.instanceof(Array);
|
||||
expect(rootArray).has.length(2);
|
||||
expect(rootArray).has.length(3);
|
||||
keys = Object.keys(rootArray[0]);
|
||||
expect(keys).is.an.instanceof(Array);
|
||||
expect(keys).has.length(1);
|
||||
expect(keys[0]).to.be.equal("_attr");
|
||||
keys = Object.keys(rootArray[1]);
|
||||
keys = Object.keys(rootArray[2]);
|
||||
expect(keys).is.an.instanceof(Array);
|
||||
expect(keys).has.length(1);
|
||||
expect(keys[0]).to.be.equal("w:trackRevisions");
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||
import { Compatibility } from "./compatibility";
|
||||
import { DisplayBackgroundShape } from "./display-background-shape";
|
||||
import { TrackRevisions } from "./track-revisions";
|
||||
import { UpdateFields } from "./update-fields";
|
||||
|
||||
@ -72,8 +73,11 @@ export class Settings extends XmlComponent {
|
||||
Ignorable: "w14 w15 wp14",
|
||||
}),
|
||||
);
|
||||
|
||||
this.compatibility = new Compatibility();
|
||||
this.trackRevisions = new TrackRevisions();
|
||||
|
||||
this.root.push(new DisplayBackgroundShape());
|
||||
}
|
||||
|
||||
public addUpdateFields(): void {
|
||||
|
Reference in New Issue
Block a user