Merge pull request #156 from bre7/master

Added mirror margins option
This commit is contained in:
Dolan
2018-09-19 12:40:31 +01:00
committed by GitHub
5 changed files with 16 additions and 1 deletions

4
.gitignore vendored
View File

@ -48,8 +48,12 @@ docs/.nojekyll
!.vscode/extensions.json !.vscode/extensions.json
.history .history
# IntelliJ
.idea
# Lock files # Lock files
package-lock.json package-lock.json
yarn.lock
# Documents # Documents
My Document.docx My Document.docx

View File

@ -8,6 +8,7 @@ export interface IPageMarginAttributes {
header?: number; header?: number;
footer?: number; footer?: number;
gutter?: number; gutter?: number;
mirror?: boolean;
} }
export class PageMarginAttributes extends XmlAttributeComponent<IPageMarginAttributes> { export class PageMarginAttributes extends XmlAttributeComponent<IPageMarginAttributes> {
@ -19,5 +20,6 @@ export class PageMarginAttributes extends XmlAttributeComponent<IPageMarginAttri
header: "w:header", header: "w:header",
footer: "w:footer", footer: "w:footer",
gutter: "w:gutter", gutter: "w:gutter",
mirror: "w:mirrorMargins",
}; };
} }

View File

@ -2,7 +2,7 @@ import { XmlComponent } from "file/xml-components";
import { PageMarginAttributes } from "./page-margin-attributes"; import { PageMarginAttributes } from "./page-margin-attributes";
export class PageMargin extends XmlComponent { export class PageMargin extends XmlComponent {
constructor(top: number, right: number, bottom: number, left: number, header: number, footer: number, gutter: number) { constructor(top: number, right: number, bottom: number, left: number, header: number, footer: number, gutter: number, mirror: boolean) {
super("w:pgMar"); super("w:pgMar");
this.root.push( this.root.push(
new PageMarginAttributes({ new PageMarginAttributes({
@ -13,6 +13,7 @@ export class PageMargin extends XmlComponent {
header: header, header: header,
footer: footer, footer: footer,
gutter: gutter, gutter: gutter,
mirror: mirror,
}), }),
); );
} }

View File

@ -17,6 +17,7 @@ describe("SectionProperties", () => {
header: 708, header: 708,
footer: 708, footer: 708,
gutter: 0, gutter: 0,
mirror: false,
space: 708, space: 708,
linePitch: 360, linePitch: 360,
headerId: 100, headerId: 100,
@ -40,6 +41,7 @@ describe("SectionProperties", () => {
"w:left": 1440, "w:left": 1440,
"w:header": 708, "w:header": 708,
"w:gutter": 0, "w:gutter": 0,
"w:mirrorMargins": false,
}, },
}, },
], ],
@ -69,6 +71,7 @@ describe("SectionProperties", () => {
"w:left": 1440, "w:left": 1440,
"w:header": 708, "w:header": 708,
"w:gutter": 0, "w:gutter": 0,
"w:mirrorMargins": false,
}, },
}, },
], ],
@ -99,6 +102,7 @@ describe("SectionProperties", () => {
"w:left": 1440, "w:left": 1440,
"w:header": 708, "w:header": 708,
"w:gutter": 0, "w:gutter": 0,
"w:mirrorMargins": false,
}, },
}, },
], ],
@ -124,6 +128,7 @@ describe("SectionProperties", () => {
"w:left": 1440, "w:left": 1440,
"w:header": 708, "w:header": 708,
"w:gutter": 0, "w:gutter": 0,
"w:mirrorMargins": false,
}, },
}, },
], ],
@ -150,6 +155,7 @@ describe("SectionProperties", () => {
"w:left": 1440, "w:left": 1440,
"w:header": 708, "w:header": 708,
"w:gutter": 0, "w:gutter": 0,
"w:mirrorMargins": false,
}, },
}, },
], ],

View File

@ -38,6 +38,7 @@ export class SectionProperties extends XmlComponent {
header: 708, header: 708,
footer: 708, footer: 708,
gutter: 0, gutter: 0,
mirror: false,
space: 708, space: 708,
linePitch: 360, linePitch: 360,
orientation: PageOrientation.PORTRAIT, orientation: PageOrientation.PORTRAIT,
@ -69,6 +70,7 @@ export class SectionProperties extends XmlComponent {
mergedOptions.header, mergedOptions.header,
mergedOptions.footer, mergedOptions.footer,
mergedOptions.gutter, mergedOptions.gutter,
mergedOptions.mirror,
), ),
); );
this.root.push(new Columns(mergedOptions.space)); this.root.push(new Columns(mergedOptions.space));