diff --git a/ts/styles/defaults/run-properties.ts b/ts/styles/defaults/run-properties.ts index 388d7a2e88..edea19a079 100644 --- a/ts/styles/defaults/run-properties.ts +++ b/ts/styles/defaults/run-properties.ts @@ -1,10 +1,24 @@ import { RunProperties } from "../../docx/run/properties"; import { XmlComponent } from "../../docx/xml-components"; +import { RunFonts } from "../../docx/run/run-fonts"; +import { Size } from "../../docx/run/formatting"; export class RunPropertiesDefaults extends XmlComponent { + private properties: RunProperties; constructor() { super("w:rPrDefault"); - this.root.push(new RunProperties()); + this.properties = new RunProperties(); + this.root.push(this.properties); + } + + public size(size: number): RunPropertiesDefaults { + this.properties.push(new Size(size)); + return this; + } + + public font(fontName: string): RunPropertiesDefaults { + this.properties.push(new RunFonts(fontName)); + return this; } } diff --git a/ts/styles/factory.ts b/ts/styles/factory.ts index 5cfa36a441..f17fa1e1d4 100644 --- a/ts/styles/factory.ts +++ b/ts/styles/factory.ts @@ -11,7 +11,7 @@ export class DefaultStylesFactory { public newInstance(): Styles { const styles = new Styles(); - styles.push(new DocumentDefaults()); + styles.createDocumentDefaults(); const titleStyle = new TitleStyle(); titleStyle.addRunProperty(new Size(56)); diff --git a/ts/styles/index.ts b/ts/styles/index.ts index e24f32d986..b96a245a08 100644 --- a/ts/styles/index.ts +++ b/ts/styles/index.ts @@ -1,6 +1,7 @@ import { DocumentAttributes } from "../docx/document/document-attributes"; import { XmlComponent } from "../docx/xml-components"; import { ParagraphStyle } from "./style"; +import { DocumentDefaults } from "./defaults"; export class Styles extends XmlComponent { @@ -14,11 +15,7 @@ export class Styles extends XmlComponent { w15: "http://schemas.microsoft.com/office/word/2012/wordml", Ignorable: "w14 w15", })); - // let latentStyles = new LatentStyles(); - // latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({ - // name: "Normal" - // }))); - // this.root.push(latentStyles); + } public push(style: XmlComponent): Styles { @@ -26,6 +23,12 @@ export class Styles extends XmlComponent { return this; } + public createDocumentDefaults(): DocumentDefaults { + const defaults = new DocumentDefaults(); + this.push(defaults); + return defaults; + } + public createParagraphStyle(styleId: string, name?: string): ParagraphStyle { const para = new ParagraphStyle(styleId, name); this.push(para);