elements need to be inside runs
This commit is contained in:
@ -8,6 +8,11 @@ const DEFAULT_TOC = {
|
||||
{
|
||||
"w:pPr": [],
|
||||
},
|
||||
{
|
||||
"w:r": [
|
||||
{
|
||||
"w:rPr": [],
|
||||
},
|
||||
{
|
||||
"w:fldChar": [
|
||||
{
|
||||
@ -17,15 +22,6 @@ const DEFAULT_TOC = {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:fldChar": [
|
||||
{
|
||||
_attr: {
|
||||
"w:fldCharType": "separate",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:instrText": [
|
||||
{
|
||||
@ -36,6 +32,22 @@ const DEFAULT_TOC = {
|
||||
'TOC \\n "1-6"',
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:fldChar": [
|
||||
{
|
||||
_attr: {
|
||||
"w:fldCharType": "separate",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:r": [
|
||||
{
|
||||
"w:rPr": [],
|
||||
},
|
||||
{
|
||||
"w:fldChar": [
|
||||
{
|
||||
@ -46,6 +58,8 @@ const DEFAULT_TOC = {
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("Table of Contents", () => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
// import { TableOfContentsProperties } from "./properties";
|
||||
import { Paragraph } from "file/paragraph";
|
||||
import { Run } from "file/paragraph/run";
|
||||
import { Begin, End, Separate } from "file/paragraph/run/field";
|
||||
import { TableOfContentsInstruction } from "./instruction";
|
||||
|
||||
@ -9,9 +10,14 @@ export class TableOfContents extends Paragraph {
|
||||
constructor(/*tocProperties?: TableOfContentsProperties*/) {
|
||||
super();
|
||||
// this.tocProperties = tocProperties || new TableOfContentsProperties();
|
||||
this.root.push(new Begin());
|
||||
this.root.push(new Separate());
|
||||
this.root.push(new TableOfContentsInstruction());
|
||||
this.root.push(new End());
|
||||
const firstRun = new Run();
|
||||
firstRun.addChildElement(new Begin());
|
||||
firstRun.addChildElement(new TableOfContentsInstruction());
|
||||
firstRun.addChildElement(new Separate());
|
||||
this.root.push(firstRun);
|
||||
|
||||
const secondRun = new Run();
|
||||
secondRun.addChildElement(new End());
|
||||
this.root.push(secondRun);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user