refactor code

This commit is contained in:
alexbogomolov
2019-10-31 13:54:53 +02:00
parent 2276572902
commit afd468277e
4 changed files with 11 additions and 11 deletions

View File

@ -7,7 +7,7 @@ const doc = new Document();
doc.addSection({
properties: {
valign: SectionVerticalAlignValue.Center,
verticalAlign: SectionVerticalAlignValue.CENTER,
},
children: [
new Paragraph({

View File

@ -89,7 +89,7 @@ export class SectionProperties extends XmlComponent {
pageBorderBottom,
pageBorderLeft,
titlePage = false,
valign,
verticalAlign,
} = options;
this.options = options;
@ -125,8 +125,8 @@ export class SectionProperties extends XmlComponent {
this.root.push(new TitlePage());
}
if (valign) {
this.root.push(new SectionVerticalAlign(valign));
if (verticalAlign) {
this.root.push(new SectionVerticalAlign(verticalAlign));
}
}

View File

@ -2,11 +2,11 @@ import { XmlAttributeComponent } from "file/xml-components";
import { SectionVerticalAlignValue } from "./vertical-align";
export interface ISectionVerticalAlignAttributes {
readonly valign?: SectionVerticalAlignValue;
readonly verticalAlign?: SectionVerticalAlignValue;
}
export class SectionVerticalAlignAttributes extends XmlAttributeComponent<ISectionVerticalAlignAttributes> {
protected readonly xmlKeys = {
valign: "w:val",
verticalAlign: "w:val",
};
}

View File

@ -4,15 +4,15 @@ import { XmlComponent } from "file/xml-components";
import { SectionVerticalAlignAttributes } from "./vertical-align-attributes";
export enum SectionVerticalAlignValue {
Both = "both",
Bottom = "bottom",
Center = "center",
Top = "top",
BOTH = "both",
BOTTOM = "bottom",
CENTER = "center",
TOP = "top",
}
export class SectionVerticalAlign extends XmlComponent {
constructor(value: SectionVerticalAlignValue) {
super("w:vAlign");
this.root.push(new SectionVerticalAlignAttributes({ valign: value }));
this.root.push(new SectionVerticalAlignAttributes({ verticalAlign: value }));
}
}