From 0b78e33444909888cc6870c06b49e744f9d92aad Mon Sep 17 00:00:00 2001 From: felipe Date: Sun, 12 Mar 2017 22:04:57 +0100 Subject: [PATCH] added #leftTabStop and #maxRightTabStop methods to paragraph styles --- ts/styles/style/index.ts | 10 ++++++++++ ts/tests/stylesTest.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/ts/styles/style/index.ts b/ts/styles/style/index.ts index 35e456d937..e70936655b 100644 --- a/ts/styles/style/index.ts +++ b/ts/styles/style/index.ts @@ -161,6 +161,16 @@ export class ParagraphStyle extends Style { return this; } + public maxRightTabStop(): ParagraphStyle { + this.addParagraphProperty(new paragraph.MaxRightTabStop()); + return this; + } + + public leftTabStop(position: number): ParagraphStyle { + this.addParagraphProperty(new paragraph.LeftTabStop(position)); + return this; + } + public indent(left: number, hanging?: number): ParagraphStyle { this.addParagraphProperty(new paragraph.Indent(left, hanging)); return this; diff --git a/ts/tests/stylesTest.ts b/ts/tests/stylesTest.ts index 821ff2a9f3..d00fb4cc0d 100644 --- a/ts/tests/stylesTest.ts +++ b/ts/tests/stylesTest.ts @@ -292,6 +292,40 @@ describe("ParagraphStyle", () => { ], }); }); + + it("#leftTabStop", () => { + const style = new ParagraphStyle("myStyleId") + .leftTabStop(1200); + const tree = new Formatter().format(style); + expect(tree).to.deep.equal({ + "w:style": [ + {_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}}, + {"w:pPr": [ + {"w:tabs": [ + {"w:tab": [{_attr: {"w:val": "left", "w:pos": 1200}}]}, + ]}, + ]}, + {"w:rPr": []}, + ], + }); + }); + + it("#maxRightTabStop", () => { + const style = new ParagraphStyle("myStyleId") + .maxRightTabStop(); + const tree = new Formatter().format(style); + expect(tree).to.deep.equal({ + "w:style": [ + {_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}}, + {"w:pPr": [ + {"w:tabs": [ + {"w:tab": [{_attr: {"w:val": "right", "w:pos": 9026}}]}, + ]}, + ]}, + {"w:rPr": []}, + ], + }); + }); }); describe("formatting methods: run properties", () => {