add schema comments and update file/document; unify VerticalAlign type
This commit is contained in:
@ -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";
|
||||
|
@ -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);
|
||||
|
@ -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<T> {
|
||||
readonly default?: T;
|
||||
@ -43,7 +43,7 @@ export interface ISectionPropertiesOptions {
|
||||
readonly footerWrapperGroup?: IHeaderFooterGroup<FooterWrapper>;
|
||||
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;
|
||||
}
|
||||
|
||||
// <xsd:complexType name="CT_SectPr">
|
||||
// <xsd:sequence>
|
||||
// <xsd:group ref="EG_HdrFtrReferences" minOccurs="0" maxOccurs="6"/>
|
||||
// <xsd:group ref="EG_SectPrContents" minOccurs="0"/>
|
||||
// <xsd:element name="sectPrChange" type="CT_SectPrChange" minOccurs="0"/>
|
||||
// </xsd:sequence>
|
||||
// <xsd:attributeGroup ref="AG_SectPrAttributes"/>
|
||||
// </xsd:complexType>
|
||||
|
||||
// <xsd:group name="EG_SectPrContents">
|
||||
// <xsd:sequence>
|
||||
// <xsd:element name="footnotePr" type="CT_FtnProps" minOccurs="0"/>
|
||||
// <xsd:element name="endnotePr" type="CT_EdnProps" minOccurs="0"/>
|
||||
// <xsd:element name="type" type="CT_SectType" minOccurs="0"/>
|
||||
// <xsd:element name="pgSz" type="CT_PageSz" minOccurs="0"/>
|
||||
// <xsd:element name="pgMar" type="CT_PageMar" minOccurs="0"/>
|
||||
// <xsd:element name="paperSrc" type="CT_PaperSource" minOccurs="0"/>
|
||||
// <xsd:element name="pgBorders" type="CT_PageBorders" minOccurs="0"/>
|
||||
// <xsd:element name="lnNumType" type="CT_LineNumber" minOccurs="0"/>
|
||||
// <xsd:element name="pgNumType" type="CT_PageNumber" minOccurs="0"/>
|
||||
// <xsd:element name="cols" type="CT_Columns" minOccurs="0"/>
|
||||
// <xsd:element name="formProt" type="CT_OnOff" minOccurs="0"/>
|
||||
// <xsd:element name="vAlign" type="CT_VerticalJc" minOccurs="0"/>
|
||||
// <xsd:element name="noEndnote" type="CT_OnOff" minOccurs="0"/>
|
||||
// <xsd:element name="titlePg" type="CT_OnOff" minOccurs="0"/>
|
||||
// <xsd:element name="textDirection" type="CT_TextDirection" minOccurs="0"/>
|
||||
// <xsd:element name="bidi" type="CT_OnOff" minOccurs="0"/>
|
||||
// <xsd:element name="rtlGutter" type="CT_OnOff" minOccurs="0"/>
|
||||
// <xsd:element name="docGrid" type="CT_DocGrid" minOccurs="0"/>
|
||||
// <xsd:element name="printerSettings" type="CT_Rel" minOccurs="0"/>
|
||||
// </xsd:sequence>
|
||||
// </xsd:group>
|
||||
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) {
|
||||
|
@ -1,2 +0,0 @@
|
||||
export * from "./vertical-align";
|
||||
export * from "./vertical-align-attributes";
|
@ -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",
|
||||
};
|
||||
}
|
@ -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 }));
|
||||
}
|
||||
}
|
@ -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",
|
||||
|
@ -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", () => {
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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", () => {
|
||||
|
1
src/file/vertical-align/index.ts
Normal file
1
src/file/vertical-align/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from "./vertical-align";
|
34
src/file/vertical-align/vertical-align.ts
Normal file
34
src/file/vertical-align/vertical-align.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||
|
||||
// <xsd:complexType name="CT_VerticalJc">
|
||||
// <xsd:attribute name="val" type="ST_VerticalJc" use="required"/>
|
||||
// </xsd:complexType>
|
||||
|
||||
// <xsd:simpleType name="ST_VerticalJc">
|
||||
// <xsd:restriction base="xsd:string">
|
||||
// <xsd:enumeration value="top"/>
|
||||
// <xsd:enumeration value="center"/>
|
||||
// <xsd:enumeration value="both"/>
|
||||
// <xsd:enumeration value="bottom"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
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 }));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user