table of contents with all the options

This commit is contained in:
Sergio Mendonça
2018-09-25 01:18:47 -03:00
parent 4de6b51e76
commit 808c5b00a0
6 changed files with 300 additions and 56 deletions

View File

@ -6,18 +6,19 @@ import { XmlComponent } from "file/xml-components";
import { SdtContent } from "./sdt-content";
import { SdtProperties } from "./sdt-properties";
import { TableOfContentsInstruction } from "./table-of-contents-instruction";
import { TableOfContentsProperties } from "./table-of-contents-properties";
export class TableOfContents extends XmlComponent {
constructor() {
constructor(alias: string = "Table of Contents", properties?: TableOfContentsProperties) {
super("w:sdt");
this.root.push(new SdtProperties("Table of Contents"));
this.root.push(new SdtProperties(alias));
const content = new SdtContent();
const beginParagraph = new Paragraph();
const beginRun = new Run();
beginRun.addChildElement(new Begin(true));
beginRun.addChildElement(new TableOfContentsInstruction());
beginRun.addChildElement(new TableOfContentsInstruction(properties));
beginRun.addChildElement(new Separate());
beginParagraph.addRun(beginRun);
content.addChildElement(beginParagraph);