added #SubScript and #SuperScript methods to ParagraphStyle

This commit is contained in:
felipe
2017-03-12 17:52:03 +01:00
parent 8c6cd012e7
commit 7f4d1bf3e7
3 changed files with 41 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import { Attributes, XmlComponent } from "../xml-components";
export { Underline } from "./underline";
export { SubScript, SuperScript } from "./script";
export class Bold extends XmlComponent {

View File

@ -111,6 +111,16 @@ export class ParagraphStyle extends Style {
return this;
}
public subScript(): ParagraphStyle {
this.addRunProperty(new formatting.SubScript());
return this;
}
public superScript(): ParagraphStyle {
this.addRunProperty(new formatting.SuperScript());
return this;
}
public underline(underlineType?: string, color?: string): ParagraphStyle {
this.addRunProperty(new formatting.Underline(underlineType, color));
return this;

View File

@ -290,6 +290,36 @@ describe("ParagraphStyle", () => {
});
});
it("#subScript", () => {
const style = new ParagraphStyle("myStyleId")
.subScript();
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
{"w:pPr": []},
{"w:rPr": [
{"w:vertAlign": [{_attr: {"w:val": "subscript"}}]},
]},
],
});
});
it("#superScript", () => {
const style = new ParagraphStyle("myStyleId")
.superScript();
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
{"w:pPr": []},
{"w:rPr": [
{"w:vertAlign": [{_attr: {"w:val": "superscript"}}]},
]},
],
});
});
it("#bold", () => {
const style = new ParagraphStyle("myStyleId")
.bold();