Merge pull request #277 from filippomuscolino/feat/style-outline

Select styles that will go into TOC
This commit is contained in:
Dolan
2019-03-05 13:22:22 +00:00
committed by GitHub
2 changed files with 18 additions and 0 deletions

View File

@ -258,6 +258,18 @@ describe("ParagraphStyle", () => {
], ],
}); });
}); });
it("#outlineLevel", () => {
const style = new ParagraphStyle("myStyleId").outlineLevel("1");
const tree = new Formatter().format(style);
expect(tree).to.deep.equal({
"w:style": [
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
{ "w:pPr": [{ "w:outlineLvl": [{ _attr: { "w:val": "1" } }] }] },
{ "w:rPr": [] },
],
});
});
}); });
describe("formatting methods: run properties", () => { describe("formatting methods: run properties", () => {

View File

@ -7,6 +7,7 @@ import {
KeepNext, KeepNext,
LeftTabStop, LeftTabStop,
MaxRightTabStop, MaxRightTabStop,
OutlineLevel,
ParagraphProperties, ParagraphProperties,
Spacing, Spacing,
ThematicBreak, ThematicBreak,
@ -34,6 +35,11 @@ export class ParagraphStyle extends Style {
return this; return this;
} }
public outlineLevel(level: string): ParagraphStyle {
this.paragraphProperties.push(new OutlineLevel(level));
return this;
}
public addRunProperty(property: XmlComponent): ParagraphStyle { public addRunProperty(property: XmlComponent): ParagraphStyle {
this.runProperties.push(property); this.runProperties.push(property);
return this; return this;