Multiple columns in a section
This commit is contained in:
@ -2,10 +2,12 @@ import { XmlAttributeComponent } from "file/xml-components";
|
||||
|
||||
export interface IColumnsAttributes {
|
||||
readonly space?: number;
|
||||
readonly num?: number;
|
||||
}
|
||||
|
||||
export class ColumnsAttributes extends XmlAttributeComponent<IColumnsAttributes> {
|
||||
protected readonly xmlKeys = {
|
||||
space: "w:space",
|
||||
num: "w:num",
|
||||
};
|
||||
}
|
||||
|
@ -2,11 +2,12 @@ import { XmlComponent } from "file/xml-components";
|
||||
import { ColumnsAttributes } from "./columns-attributes";
|
||||
|
||||
export class Columns extends XmlComponent {
|
||||
constructor(space: number) {
|
||||
constructor(space: number, num: number) {
|
||||
super("w:cols");
|
||||
this.root.push(
|
||||
new ColumnsAttributes({
|
||||
space: space,
|
||||
num: num,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ describe("SectionProperties", () => {
|
||||
gutter: 0,
|
||||
mirror: false,
|
||||
space: 708,
|
||||
num: 1,
|
||||
linePitch: 360,
|
||||
headers: {
|
||||
default: new HeaderWrapper(media, 100),
|
||||
@ -55,7 +56,7 @@ describe("SectionProperties", () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(tree["w:sectPr"][2]).to.deep.equal({ "w:cols": { _attr: { "w:space": 708 } } });
|
||||
expect(tree["w:sectPr"][2]).to.deep.equal({ "w:cols": { _attr: { "w:space": 708, "w:num": 1 } } });
|
||||
expect(tree["w:sectPr"][3]).to.deep.equal({ "w:docGrid": { _attr: { "w:linePitch": 360 } } });
|
||||
expect(tree["w:sectPr"][4]).to.deep.equal({ "w:headerReference": { _attr: { "r:id": "rId100", "w:type": "default" } } });
|
||||
expect(tree["w:sectPr"][5]).to.deep.equal({ "w:footerReference": { _attr: { "r:id": "rId200", "w:type": "even" } } });
|
||||
@ -82,7 +83,7 @@ describe("SectionProperties", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(tree["w:sectPr"][2]).to.deep.equal({ "w:cols": { _attr: { "w:space": 708 } } });
|
||||
expect(tree["w:sectPr"][2]).to.deep.equal({ "w:cols": { _attr: { "w:space": 708, "w:num": 1 } } });
|
||||
expect(tree["w:sectPr"][3]).to.deep.equal({ "w:docGrid": { _attr: { "w:linePitch": 360 } } });
|
||||
});
|
||||
|
||||
|
@ -67,6 +67,7 @@ export class SectionProperties extends XmlComponent {
|
||||
gutter = 0,
|
||||
mirror = false,
|
||||
space = 708,
|
||||
num = 1,
|
||||
linePitch = 360,
|
||||
orientation = PageOrientation.PORTRAIT,
|
||||
headers,
|
||||
@ -88,7 +89,7 @@ export class SectionProperties extends XmlComponent {
|
||||
this.options = options;
|
||||
this.root.push(new PageSize(width, height, orientation));
|
||||
this.root.push(new PageMargin(top, right, bottom, left, header, footer, gutter, mirror));
|
||||
this.root.push(new Columns(space));
|
||||
this.root.push(new Columns(space, num));
|
||||
this.root.push(new DocumentGrid(linePitch));
|
||||
|
||||
this.addHeaders(headers);
|
||||
|
Reference in New Issue
Block a user