added #style method to runs

This commit is contained in:
felipe
2017-03-12 17:35:15 +01:00
parent 3dbd917667
commit 90049a31ee
3 changed files with 31 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import { RunProperties } from "./properties";
import { RunFonts } from "./run-fonts";
import { SubScript, SuperScript } from "./script";
import { DoubleStrike, Strike } from "./strike";
import { Style } from "./style";
import { Tab } from "./tab";
import { Underline } from "./underline";
@ -88,4 +89,9 @@ export class Run extends XmlComponent {
this.properties.push(new RunFonts(fontName));
return this;
}
public style(styleId: string): Run {
this.properties.push(new Style(styleId));
return this;
}
}

13
ts/docx/run/style.ts Normal file
View File

@ -0,0 +1,13 @@
import { XmlAttributeComponent, XmlComponent } from "../xml-components";
class StyleAttributes extends XmlAttributeComponent<{val: string}> {
protected xmlKeys = {val: "w:val"};
}
export class Style extends XmlComponent {
constructor(styleId: string) {
super("w:rStyle");
this.root.push(new StyleAttributes({val: styleId}));
}
}