#750 Add widow control

This commit is contained in:
Dolan
2021-03-13 04:07:44 +00:00
parent 2391375ac0
commit 8724fbe7a7
6 changed files with 93 additions and 5 deletions

View File

@ -0,0 +1,19 @@
import { expect } from "chai";
import { Formatter } from "export/formatter";
import { Alignment, AlignmentType } from "./alignment";
describe("Alignment", () => {
it("should create", () => {
const alignment = new Alignment(AlignmentType.BOTH);
const tree = new Formatter().format(alignment);
expect(tree).to.deep.equal({
"w:jc": {
_attr: {
"w:val": "both",
},
},
});
});
});

View File

@ -0,0 +1,20 @@
import { expect } from "chai";
import { Formatter } from "export/formatter";
import { WidowControl } from "./widow-control";
describe("WidowControl", () => {
it("should create", () => {
const widowControl = new WidowControl(true);
const tree = new Formatter().format(widowControl);
expect(tree).to.deep.equal({
"w:widowControl": {
_attr: {
"w:val": true,
},
},
});
});
});

View File

@ -0,0 +1,13 @@
// http://www.datypic.com/sc/ooxml/e-w_widowControl-1.html
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
export class WidowControlAttributes extends XmlAttributeComponent<{ readonly val: boolean }> {
protected readonly xmlKeys = { val: "w:val" };
}
export class WidowControl extends XmlComponent {
constructor(value: boolean) {
super("w:widowControl");
this.root.push(new WidowControlAttributes({ val: value }));
}
}