diff --git a/ts/docx/paragraph/indent.ts b/ts/docx/paragraph/indent.ts index 24a73cb3e8..c98b3570a1 100644 --- a/ts/docx/paragraph/indent.ts +++ b/ts/docx/paragraph/indent.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../docx/xml-components"; +import { XmlAttributeComponent, XmlComponent } from "../xml-components"; interface IndentAttributesProperties { left: number; diff --git a/ts/docx/paragraph/index.ts b/ts/docx/paragraph/index.ts index e22badcba5..7b82b63434 100644 --- a/ts/docx/paragraph/index.ts +++ b/ts/docx/paragraph/index.ts @@ -119,6 +119,11 @@ export class Paragraph extends XmlComponent { return this; } + public style(styleId: string): Paragraph { + this.properties.push(new Style(styleId)); + return this; + } + public indent(start: number, hanging?: number): Paragraph { this.properties.push(new Indent(start, hanging)); return this; diff --git a/ts/tests/docx/paragraph/paragraphTests.ts b/ts/tests/docx/paragraph/paragraphTests.ts index e581bf11f9..96b23ac8bd 100644 --- a/ts/tests/docx/paragraph/paragraphTests.ts +++ b/ts/tests/docx/paragraph/paragraphTests.ts @@ -155,6 +155,23 @@ describe("Paragraph", () => { }); }); + describe("#style", () => { + it("should set the paragraph style to the given styleId", () => { + paragraph.style('myFancyStyle'); + const tree = new Formatter().format(paragraph); + expect(tree).to.deep.equal({ + "w:p": [ + { + "w:pPr": [ + {"_attr": {}}, + {"w:pStyle": [{"_attr": {"w:val": "myFancyStyle"}}]}, + ], + }, + ] + }) + }); + }); + describe("#indent", () => { it("should set the paragraph indent to the given values", () => { paragraph.indent(720);