Merge pull request #43 from jacwright/default-run-styles
Making it easier to work with default styles
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user