added #smallCaps and #allCaps methods to ParagraphStyle

This commit is contained in:
felipe
2017-03-12 17:43:00 +01:00
parent 90049a31ee
commit 9a90818729
2 changed files with 42 additions and 0 deletions

View File

@ -74,6 +74,8 @@ export class ParagraphStyle extends Style {
return this;
}
// ---------- Run formatting ---------------------- //
public size(twips: number): ParagraphStyle {
this.addRunProperty(new formatting.Size(twips));
return this;
@ -89,6 +91,16 @@ export class ParagraphStyle extends Style {
return this;
}
public smallCaps(): ParagraphStyle {
this.addRunProperty(new formatting.SmallCaps());
return this;
}
public allCaps(): ParagraphStyle {
this.addRunProperty(new formatting.Caps());
return this;
}
public underline(underlineType?: string, color?: string): ParagraphStyle {
this.addRunProperty(new formatting.Underline(underlineType, color));
return this;

View File

@ -230,6 +230,36 @@ describe("ParagraphStyle", () => {
});
});
it("#smallCaps", () => {
const style = new ParagraphStyle("myStyleId")
.smallCaps();
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:smallCaps": [{_attr: {"w:val": true}}]},
]},
],
});
});
it("#allCaps", () => {
const style = new ParagraphStyle("myStyleId")
.allCaps();
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:caps": [{_attr: {"w:val": true}}]},
]},
],
});
});
it("#bold", () => {
const style = new ParagraphStyle("myStyleId")
.bold();