diff --git a/ts/styles/style/index.ts b/ts/styles/style/index.ts index e5e3561eef..6b9b64fdd9 100644 --- a/ts/styles/style/index.ts +++ b/ts/styles/style/index.ts @@ -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; diff --git a/ts/tests/stylesTest.ts b/ts/tests/stylesTest.ts index dfbd1ca2d3..03214ec701 100644 --- a/ts/tests/stylesTest.ts +++ b/ts/tests/stylesTest.ts @@ -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();