diff --git a/src/file/table-of-contents/std-content.ts b/src/file/table-of-contents/sdt-content.ts similarity index 76% rename from src/file/table-of-contents/std-content.ts rename to src/file/table-of-contents/sdt-content.ts index cbab4c8440..a059886b42 100644 --- a/src/file/table-of-contents/std-content.ts +++ b/src/file/table-of-contents/sdt-content.ts @@ -1,9 +1,9 @@ import { Paragraph } from "file/paragraph"; import { XmlComponent } from "file/xml-components"; -export class StdContent extends XmlComponent { +export class SdtContent extends XmlComponent { constructor() { - super("w:stdContent"); + super("w:sdtContent"); } public addGeneratedContent(paragraph: Paragraph): void { diff --git a/src/file/table-of-contents/std-properties.ts b/src/file/table-of-contents/sdt-properties.ts similarity index 68% rename from src/file/table-of-contents/std-properties.ts rename to src/file/table-of-contents/sdt-properties.ts index 628e92840c..bb8ef77a6b 100644 --- a/src/file/table-of-contents/std-properties.ts +++ b/src/file/table-of-contents/sdt-properties.ts @@ -1,9 +1,9 @@ import { XmlComponent } from "file/xml-components"; import { Alias } from "./alias"; -export class StdProperties extends XmlComponent { +export class SdtProperties extends XmlComponent { constructor(alias: string) { - super("w:stdPr"); + super("w:sdtPr"); this.root.push(new Alias(alias)); } } diff --git a/src/file/table-of-contents/table-of-contents.spec.ts b/src/file/table-of-contents/table-of-contents.spec.ts index 98c6a36936..d29b3ffc75 100644 --- a/src/file/table-of-contents/table-of-contents.spec.ts +++ b/src/file/table-of-contents/table-of-contents.spec.ts @@ -4,39 +4,14 @@ import { Formatter } from "../../export/formatter"; import { TableOfContents } from "./"; const DEFAULT_TOC = { - "w:p": [ + "w:sdt": [ { - "w:pPr": [], - }, - { - "w:r": [ + "w:sdtPr": [ { - "w:rPr": [], - }, - { - "w:fldChar": [ + "w:alias": [ { _attr: { - "w:fldCharType": "begin", - }, - }, - ], - }, - { - "w:instrText": [ - { - _attr: { - "xml:space": "preserve", - }, - }, - 'TOC \\o "1-6"', - ], - }, - { - "w:fldChar": [ - { - _attr: { - "w:fldCharType": "separate", + "w:val": "Table of Contents", }, }, ], @@ -44,16 +19,69 @@ const DEFAULT_TOC = { ], }, { - "w:r": [ + "w:sdtContent": [ { - "w:rPr": [], + "w:p": [ + { + "w:pPr": [], + }, + { + "w:r": [ + { + "w:rPr": [], + }, + { + "w:fldChar": [ + { + _attr: { + "w:fldCharType": "begin", + }, + }, + ], + }, + { + "w:instrText": [ + { + _attr: { + "xml:space": "preserve", + }, + }, + 'TOC \\o "1-6"', + ], + }, + { + "w:fldChar": [ + { + _attr: { + "w:fldCharType": "separate", + }, + }, + ], + }, + ], + }, + ], }, { - "w:fldChar": [ + "w:p": [ { - _attr: { - "w:fldCharType": "end", - }, + "w:pPr": [], + }, + { + "w:r": [ + { + "w:rPr": [], + }, + { + "w:fldChar": [ + { + _attr: { + "w:fldCharType": "end", + }, + }, + ], + }, + ], }, ], }, diff --git a/src/file/table-of-contents/table-of-contents.ts b/src/file/table-of-contents/table-of-contents.ts index 7a31373143..f6f70558f9 100644 --- a/src/file/table-of-contents/table-of-contents.ts +++ b/src/file/table-of-contents/table-of-contents.ts @@ -3,22 +3,22 @@ import { Paragraph } from "file/paragraph"; import { Run } from "file/paragraph/run"; import { Begin, End, Separate } from "file/paragraph/run/field"; import { XmlComponent } from "file/xml-components"; -import { StdContent } from "./std-content"; -import { StdProperties } from "./std-properties"; +import { SdtContent } from "./sdt-content"; +import { SdtProperties } from "./sdt-properties"; import { TableOfContentsInstruction } from "./table-of-contents-instruction"; export class TableOfContents extends XmlComponent { // private readonly tocProperties: TableOfContentsProperties; - private readonly properties: StdProperties; + private readonly properties: SdtProperties; - private readonly content: StdContent; + private readonly content: SdtContent; private readonly instruction: TableOfContentsInstruction; constructor(/*tocProperties?: TableOfContentsProperties*/) { super("w:sdt"); - this.properties = new StdProperties("Table of Contents"); - this.content = new StdContent(); + this.properties = new SdtProperties("Table of Contents"); + this.content = new SdtContent(); this.instruction = new TableOfContentsInstruction(); this.root.push(this.properties); this.root.push(this.content);