#750 Add widow control
This commit is contained in:
19
src/file/paragraph/formatting/alignment.spec.ts
Normal file
19
src/file/paragraph/formatting/alignment.spec.ts
Normal 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",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
20
src/file/paragraph/formatting/widow-control.spec.ts
Normal file
20
src/file/paragraph/formatting/widow-control.spec.ts
Normal 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,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
13
src/file/paragraph/formatting/widow-control.ts
Normal file
13
src/file/paragraph/formatting/widow-control.ts
Normal 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 }));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user