From 371398bc2c9dd6101dac876b9105ff49f294d017 Mon Sep 17 00:00:00 2001 From: felipe Date: Sun, 12 Mar 2017 17:44:42 +0100 Subject: [PATCH] added #strike and #doubleStrike methods to paragraphStyle --- ts/styles/style/index.ts | 10 ++++++++++ ts/tests/stylesTest.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/ts/styles/style/index.ts b/ts/styles/style/index.ts index 6b9b64fdd9..af37157bd9 100644 --- a/ts/styles/style/index.ts +++ b/ts/styles/style/index.ts @@ -101,6 +101,16 @@ export class ParagraphStyle extends Style { return this; } + public strike(): ParagraphStyle { + this.addRunProperty(new formatting.Strike()); + return this; + } + + public doubleStrike(): ParagraphStyle { + this.addRunProperty(new formatting.DoubleStrike()); + 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 03214ec701..c7a87f6b40 100644 --- a/ts/tests/stylesTest.ts +++ b/ts/tests/stylesTest.ts @@ -260,6 +260,36 @@ describe("ParagraphStyle", () => { }); }); + it("#strike", () => { + const style = new ParagraphStyle("myStyleId") + .strike(); + 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:strike": [{_attr: {"w:val": true}}]}, + ]}, + ], + }); + }); + + it("#doubleStrike", () => { + const style = new ParagraphStyle("myStyleId") + .doubleStrike(); + 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:dstrike": [{_attr: {"w:val": true}}]}, + ]}, + ], + }); + }); + it("#bold", () => { const style = new ParagraphStyle("myStyleId") .bold();