diff --git a/src/file/document/body/section-properties/index.ts b/src/file/document/body/section-properties/index.ts index ee0820c640..337bb3b461 100644 --- a/src/file/document/body/section-properties/index.ts +++ b/src/file/document/body/section-properties/index.ts @@ -5,5 +5,4 @@ export * from "./page-size"; export * from "./page-number"; export * from "./page-border"; export * from "./line-number"; -export * from "./vertical-align"; export * from "./type"; diff --git a/src/file/document/body/section-properties/section-properties.spec.ts b/src/file/document/body/section-properties/section-properties.spec.ts index 9483a4d47e..e118d7c457 100644 --- a/src/file/document/body/section-properties/section-properties.spec.ts +++ b/src/file/document/body/section-properties/section-properties.spec.ts @@ -5,13 +5,13 @@ import { Formatter } from "export/formatter"; import { FooterWrapper } from "file/footer-wrapper"; import { HeaderWrapper } from "file/header-wrapper"; import { Media } from "file/media"; +import { VerticalAlign } from "file/vertical-align"; import { LineNumberRestartFormat } from "./line-number"; import { PageBorderOffsetFrom } from "./page-border"; import { PageNumberFormat } from "./page-number"; import { SectionProperties } from "./section-properties"; import { SectionType } from "./type/section-type-attributes"; -import { SectionVerticalAlignValue } from "./vertical-align"; describe("SectionProperties", () => { describe("#constructor()", () => { @@ -53,7 +53,7 @@ describe("SectionProperties", () => { even: new FooterWrapper(media, 200), }, titlePage: true, - verticalAlign: SectionVerticalAlignValue.TOP, + verticalAlign: VerticalAlign.TOP, }); const tree = new Formatter().format(properties); diff --git a/src/file/document/body/section-properties/section-properties.ts b/src/file/document/body/section-properties/section-properties.ts index 82b9204394..96dcad467f 100644 --- a/src/file/document/body/section-properties/section-properties.ts +++ b/src/file/document/body/section-properties/section-properties.ts @@ -4,6 +4,7 @@ import { convertInchesToTwip } from "convenience-functions"; import { FooterWrapper } from "file/footer-wrapper"; import { HeaderWrapper } from "file/header-wrapper"; +import { VerticalAlign, VerticalAlignElement } from "file/vertical-align"; import { XmlComponent } from "file/xml-components"; import { Columns } from "./columns/columns"; @@ -23,7 +24,6 @@ import { IPageSizeAttributes, PageOrientation } from "./page-size/page-size-attr import { TitlePage } from "./title-page/title-page"; import { Type } from "./type/section-type"; import { SectionType } from "./type/section-type-attributes"; -import { SectionVerticalAlign, SectionVerticalAlignValue } from "./vertical-align"; export interface IHeaderFooterGroup { readonly default?: T; @@ -43,7 +43,7 @@ export interface ISectionPropertiesOptions { readonly footerWrapperGroup?: IHeaderFooterGroup; readonly lineNumbers?: ILineNumberAttributes; readonly titlePage?: boolean; - readonly verticalAlign?: SectionVerticalAlignValue; + readonly verticalAlign?: VerticalAlign; readonly column?: { readonly space?: number; readonly count?: number; @@ -51,6 +51,39 @@ export interface ISectionPropertiesOptions { }; readonly type?: SectionType; } + +// +// +// +// +// +// +// +// + +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// export class SectionProperties extends XmlComponent { constructor({ page: { @@ -101,7 +134,7 @@ export class SectionProperties extends XmlComponent { this.root.push(new Columns(space, count, separate)); if (verticalAlign) { - this.root.push(new SectionVerticalAlign(verticalAlign)); + this.root.push(new VerticalAlignElement(verticalAlign)); } if (titlePage) { diff --git a/src/file/document/body/section-properties/vertical-align/index.ts b/src/file/document/body/section-properties/vertical-align/index.ts deleted file mode 100644 index 1f3fb76bb2..0000000000 --- a/src/file/document/body/section-properties/vertical-align/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./vertical-align"; -export * from "./vertical-align-attributes"; diff --git a/src/file/document/body/section-properties/vertical-align/vertical-align-attributes.ts b/src/file/document/body/section-properties/vertical-align/vertical-align-attributes.ts deleted file mode 100644 index 477bb448b4..0000000000 --- a/src/file/document/body/section-properties/vertical-align/vertical-align-attributes.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { XmlAttributeComponent } from "file/xml-components"; -import { SectionVerticalAlignValue } from "./vertical-align"; - -export class SectionVerticalAlignAttributes extends XmlAttributeComponent<{ - readonly verticalAlign?: SectionVerticalAlignValue; -}> { - protected readonly xmlKeys = { - verticalAlign: "w:val", - }; -} diff --git a/src/file/document/body/section-properties/vertical-align/vertical-align.ts b/src/file/document/body/section-properties/vertical-align/vertical-align.ts deleted file mode 100644 index b025059d16..0000000000 --- a/src/file/document/body/section-properties/vertical-align/vertical-align.ts +++ /dev/null @@ -1,18 +0,0 @@ -// http://officeopenxml.com/WPsection.php - -import { XmlComponent } from "file/xml-components"; -import { SectionVerticalAlignAttributes } from "./vertical-align-attributes"; - -export enum SectionVerticalAlignValue { - BOTH = "both", - BOTTOM = "bottom", - CENTER = "center", - TOP = "top", -} - -export class SectionVerticalAlign extends XmlComponent { - constructor(value: SectionVerticalAlignValue) { - super("w:vAlign"); - this.root.push(new SectionVerticalAlignAttributes({ verticalAlign: value })); - } -} diff --git a/src/file/table/table-cell/table-cell-components.ts b/src/file/table/table-cell/table-cell-components.ts index e676adab79..e57785a19f 100644 --- a/src/file/table/table-cell/table-cell-components.ts +++ b/src/file/table/table-cell/table-cell-components.ts @@ -110,31 +110,6 @@ export class VerticalMerge extends XmlComponent { } } -export enum VerticalAlign { - BOTTOM = "bottom", - CENTER = "center", - TOP = "top", -} - -class VAlignAttributes extends XmlAttributeComponent<{ readonly val: VerticalAlign }> { - protected readonly xmlKeys = { val: "w:val" }; -} - -/** - * Vertical align element. - */ -export class VAlign extends XmlComponent { - constructor(value: VerticalAlign) { - super("w:vAlign"); - - this.root.push( - new VAlignAttributes({ - val: value, - }), - ); - } -} - export enum TextDirection { BOTTOM_TO_TOP_LEFT_TO_RIGHT = "btLr", LEFT_TO_RIGHT_TOP_TO_BOTTOM = "lrTb", diff --git a/src/file/table/table-cell/table-cell-properties.spec.ts b/src/file/table/table-cell/table-cell-properties.spec.ts index c2a17d05d4..03bd2adc3b 100644 --- a/src/file/table/table-cell/table-cell-properties.spec.ts +++ b/src/file/table/table-cell/table-cell-properties.spec.ts @@ -2,9 +2,11 @@ import { expect } from "chai"; import { Formatter } from "export/formatter"; import { BorderStyle } from "file/border"; +import { VerticalAlign } from "file/vertical-align"; + import { WidthType } from "../table-width"; -import { VerticalAlign, VerticalMergeType } from "./table-cell-components"; +import { VerticalMergeType } from "./table-cell-components"; import { TableCellProperties } from "./table-cell-properties"; describe("TableCellProperties", () => { diff --git a/src/file/table/table-cell/table-cell-properties.ts b/src/file/table/table-cell/table-cell-properties.ts index ebbf44bd55..a10808ef7c 100644 --- a/src/file/table/table-cell/table-cell-properties.ts +++ b/src/file/table/table-cell/table-cell-properties.ts @@ -1,3 +1,4 @@ +import { VerticalAlign, VerticalAlignElement } from "file/vertical-align"; import { IgnoreIfEmptyXmlComponent } from "file/xml-components"; import { IShadingAttributesProperties, Shading } from "../../shading"; @@ -9,8 +10,6 @@ import { TableCellBorders, TDirection, TextDirection, - VAlign, - VerticalAlign, VerticalMerge, VerticalMergeType, } from "./table-cell-components"; @@ -63,7 +62,7 @@ export class TableCellProperties extends IgnoreIfEmptyXmlComponent { } if (options.verticalAlign) { - this.root.push(new VAlign(options.verticalAlign)); + this.root.push(new VerticalAlignElement(options.verticalAlign)); } } } diff --git a/src/file/table/table-cell/table-cell.spec.ts b/src/file/table/table-cell/table-cell.spec.ts index 8f0c6ee766..25e6e26672 100644 --- a/src/file/table/table-cell/table-cell.spec.ts +++ b/src/file/table/table-cell/table-cell.spec.ts @@ -2,11 +2,12 @@ import { expect } from "chai"; import { Formatter } from "export/formatter"; import { BorderStyle } from "file/border"; - import { ShadingType } from "file/shading"; +import { VerticalAlign } from "file/vertical-align"; + import { WidthType } from "../table-width"; import { TableCell } from "./table-cell"; -import { TableCellBorders, TextDirection, VerticalAlign, VerticalMergeType } from "./table-cell-components"; +import { TableCellBorders, TextDirection, VerticalMergeType } from "./table-cell-components"; describe("TableCellBorders", () => { describe("#prepForXml", () => { diff --git a/src/file/vertical-align/index.ts b/src/file/vertical-align/index.ts new file mode 100644 index 0000000000..29714c88b6 --- /dev/null +++ b/src/file/vertical-align/index.ts @@ -0,0 +1 @@ +export * from "./vertical-align"; diff --git a/src/file/vertical-align/vertical-align.ts b/src/file/vertical-align/vertical-align.ts new file mode 100644 index 0000000000..a031eb674d --- /dev/null +++ b/src/file/vertical-align/vertical-align.ts @@ -0,0 +1,34 @@ +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; + +// +// +// + +// +// +// +// +// +// +// +// +export enum VerticalAlign { + BOTH = "both", + BOTTOM = "bottom", + CENTER = "center", + TOP = "top", +} +export class VerticalAlignAttributes extends XmlAttributeComponent<{ + readonly verticalAlign?: VerticalAlign; +}> { + protected readonly xmlKeys = { + verticalAlign: "w:val", + }; +} + +export class VerticalAlignElement extends XmlComponent { + constructor(value: VerticalAlign) { + super("w:vAlign"); + this.root.push(new VerticalAlignAttributes({ verticalAlign: value })); + } +}