2018-09-26 02:17:39 +01:00
|
|
|
// http://officeopenxml.com/WPtableOfContents.php
|
|
|
|
// http://www.datypic.com/sc/ooxml/e-w_sdt-1.html
|
2022-06-26 23:26:42 +01:00
|
|
|
import { Paragraph } from "@file/paragraph";
|
|
|
|
import { Run } from "@file/paragraph/run";
|
|
|
|
import { Begin, End, Separate } from "@file/paragraph/run/field";
|
2023-01-23 14:14:05 +00:00
|
|
|
import { FileChild } from "@file/file-child";
|
2018-09-26 02:17:39 +01:00
|
|
|
import { FieldInstruction } from "./field-instruction";
|
|
|
|
import { StructuredDocumentTagContent } from "./sdt-content";
|
|
|
|
import { StructuredDocumentTagProperties } from "./sdt-properties";
|
2018-09-25 21:09:30 +01:00
|
|
|
import { ITableOfContentsOptions } from "./table-of-contents-properties";
|
2018-08-21 07:19:46 -03:00
|
|
|
|
2023-01-23 14:14:05 +00:00
|
|
|
export class TableOfContents extends FileChild {
|
2022-08-31 07:52:27 +01:00
|
|
|
public constructor(alias: string = "Table of Contents", properties?: ITableOfContentsOptions) {
|
2018-09-21 11:16:14 -03:00
|
|
|
super("w:sdt");
|
2018-09-26 02:17:39 +01:00
|
|
|
this.root.push(new StructuredDocumentTagProperties(alias));
|
2018-08-29 12:06:01 -03:00
|
|
|
|
2018-09-26 02:17:39 +01:00
|
|
|
const content = new StructuredDocumentTagContent();
|
2018-09-18 05:24:19 -03:00
|
|
|
|
2019-09-30 22:56:21 +01:00
|
|
|
const beginParagraph = new Paragraph({
|
|
|
|
children: [
|
|
|
|
new Run({
|
|
|
|
children: [new Begin(true), new FieldInstruction(properties), new Separate()],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2018-09-21 11:16:14 -03:00
|
|
|
content.addChildElement(beginParagraph);
|
2018-09-18 05:24:19 -03:00
|
|
|
|
2019-09-30 22:56:21 +01:00
|
|
|
const endParagraph = new Paragraph({
|
|
|
|
children: [
|
|
|
|
new Run({
|
|
|
|
children: [new End()],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2018-09-21 11:16:14 -03:00
|
|
|
content.addChildElement(endParagraph);
|
2018-09-04 18:22:08 -03:00
|
|
|
|
2018-09-21 11:16:14 -03:00
|
|
|
this.root.push(content);
|
2018-08-29 12:06:01 -03:00
|
|
|
}
|
|
|
|
}
|