clean up imports into paragraph and paragraph style
(this prep for importing it from styles)
This commit is contained in:
15
ts/docx/paragraph/alignment.ts
Normal file
15
ts/docx/paragraph/alignment.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { XmlAttributeComponent, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
|
type alignmentOptions = "left" | "center" | "right" | "both";
|
||||||
|
|
||||||
|
class AlignmentAttributes extends XmlAttributeComponent<{val: alignmentOptions}> {
|
||||||
|
protected xmlKeys = {val: "w:val"};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Alignment extends XmlComponent {
|
||||||
|
|
||||||
|
constructor(type: alignmentOptions) {
|
||||||
|
super("w:jc");
|
||||||
|
this.root.push(new AlignmentAttributes({val: type}));
|
||||||
|
}
|
||||||
|
}
|
9
ts/docx/paragraph/formatting.ts
Normal file
9
ts/docx/paragraph/formatting.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export { Alignment } from "./alignment";
|
||||||
|
export { ThematicBreak } from "./border";
|
||||||
|
export { Indent } from "./indent";
|
||||||
|
export { PageBreak } from "./page-break";
|
||||||
|
export { ParagraphProperties } from "./properties";
|
||||||
|
export { ISpacingProperties, Spacing } from "./spacing";
|
||||||
|
export { Style } from "./style";
|
||||||
|
export { LeftTabStop, MaxRightTabStop } from "./tab-stop";
|
||||||
|
export { NumberProperties } from "./unordered-list";
|
@ -1,7 +1,8 @@
|
|||||||
import { Num } from "../../numbering/num";
|
import { Num } from "../../numbering/num";
|
||||||
import { TextRun } from "../run/text-run";
|
import { TextRun } from "../run/text-run";
|
||||||
import { Attributes, XmlComponent } from "../xml-components";
|
import { XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
|
import { Alignment } from "./alignment";
|
||||||
import { ThematicBreak } from "./border";
|
import { ThematicBreak } from "./border";
|
||||||
import { Indent } from "./indent";
|
import { Indent } from "./indent";
|
||||||
import { PageBreak } from "./page-break";
|
import { PageBreak } from "./page-break";
|
||||||
@ -11,16 +12,6 @@ import { Style } from "./style";
|
|||||||
import { LeftTabStop, MaxRightTabStop } from "./tab-stop";
|
import { LeftTabStop, MaxRightTabStop } from "./tab-stop";
|
||||||
import { NumberProperties } from "./unordered-list";
|
import { NumberProperties } from "./unordered-list";
|
||||||
|
|
||||||
class Alignment extends XmlComponent {
|
|
||||||
|
|
||||||
constructor(type: string) {
|
|
||||||
super("w:jc");
|
|
||||||
this.root.push(new Attributes({
|
|
||||||
val: type,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Paragraph extends XmlComponent {
|
export class Paragraph extends XmlComponent {
|
||||||
private properties: ParagraphProperties;
|
private properties: ParagraphProperties;
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { Indent } from "../../docx/paragraph/indent";
|
import * as paragraph from "../../docx/paragraph/formatting";
|
||||||
import { ParagraphProperties } from "../../docx/paragraph/properties";
|
|
||||||
import { ISpacingProperties, Spacing } from "../../docx/paragraph/spacing";
|
|
||||||
import * as formatting from "../../docx/run/formatting";
|
import * as formatting from "../../docx/run/formatting";
|
||||||
import { RunProperties } from "../../docx/run/properties";
|
import { RunProperties } from "../../docx/run/properties";
|
||||||
import { XmlAttributeComponent, XmlComponent } from "../../docx/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "../../docx/xml-components";
|
||||||
@ -40,12 +38,12 @@ export class Style extends XmlComponent {
|
|||||||
|
|
||||||
export class ParagraphStyle extends Style {
|
export class ParagraphStyle extends Style {
|
||||||
|
|
||||||
private paragraphProperties: ParagraphProperties;
|
private paragraphProperties: paragraph.ParagraphProperties;
|
||||||
private runProperties: RunProperties;
|
private runProperties: RunProperties;
|
||||||
|
|
||||||
constructor(styleId: string, name?: string) {
|
constructor(styleId: string, name?: string) {
|
||||||
super({type: "paragraph", styleId: styleId}, name);
|
super({type: "paragraph", styleId: styleId}, name);
|
||||||
this.paragraphProperties = new ParagraphProperties();
|
this.paragraphProperties = new paragraph.ParagraphProperties();
|
||||||
this.runProperties = new RunProperties();
|
this.runProperties = new RunProperties();
|
||||||
this.root.push(this.paragraphProperties);
|
this.root.push(this.paragraphProperties);
|
||||||
this.root.push(this.runProperties);
|
this.root.push(this.runProperties);
|
||||||
@ -139,12 +137,12 @@ export class ParagraphStyle extends Style {
|
|||||||
// --------------------- Paragraph formatting ------------------------ //
|
// --------------------- Paragraph formatting ------------------------ //
|
||||||
|
|
||||||
public indent(left: number, hanging?: number): ParagraphStyle {
|
public indent(left: number, hanging?: number): ParagraphStyle {
|
||||||
this.addParagraphProperty(new Indent(left, hanging));
|
this.addParagraphProperty(new paragraph.Indent(left, hanging));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public spacing(params: ISpacingProperties): ParagraphStyle {
|
public spacing(params: paragraph.ISpacingProperties): ParagraphStyle {
|
||||||
this.addParagraphProperty(new Spacing(params));
|
this.addParagraphProperty(new paragraph.Spacing(params));
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user