elements need to be inside runs
This commit is contained in:
@ -9,39 +9,53 @@ const DEFAULT_TOC = {
|
|||||||
"w:pPr": [],
|
"w:pPr": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"w:fldChar": [
|
"w:r": [
|
||||||
{
|
{
|
||||||
_attr: {
|
"w:rPr": [],
|
||||||
"w:fldCharType": "begin",
|
},
|
||||||
},
|
{
|
||||||
|
"w:fldChar": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:fldCharType": "begin",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:instrText": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"xml:space": "preserve",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'TOC \\n "1-6"',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:fldChar": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:fldCharType": "separate",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"w:fldChar": [
|
"w:r": [
|
||||||
{
|
{
|
||||||
_attr: {
|
"w:rPr": [],
|
||||||
"w:fldCharType": "separate",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"w:instrText": [
|
|
||||||
{
|
{
|
||||||
_attr: {
|
"w:fldChar": [
|
||||||
"xml:space": "preserve",
|
{
|
||||||
},
|
_attr: {
|
||||||
},
|
"w:fldCharType": "end",
|
||||||
'TOC \\n "1-6"',
|
},
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
{
|
|
||||||
"w:fldChar": [
|
|
||||||
{
|
|
||||||
_attr: {
|
|
||||||
"w:fldCharType": "end",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// import { TableOfContentsProperties } from "./properties";
|
// import { TableOfContentsProperties } from "./properties";
|
||||||
import { Paragraph } from "file/paragraph";
|
import { Paragraph } from "file/paragraph";
|
||||||
|
import { Run } from "file/paragraph/run";
|
||||||
import { Begin, End, Separate } from "file/paragraph/run/field";
|
import { Begin, End, Separate } from "file/paragraph/run/field";
|
||||||
import { TableOfContentsInstruction } from "./instruction";
|
import { TableOfContentsInstruction } from "./instruction";
|
||||||
|
|
||||||
@ -9,9 +10,14 @@ export class TableOfContents extends Paragraph {
|
|||||||
constructor(/*tocProperties?: TableOfContentsProperties*/) {
|
constructor(/*tocProperties?: TableOfContentsProperties*/) {
|
||||||
super();
|
super();
|
||||||
// this.tocProperties = tocProperties || new TableOfContentsProperties();
|
// this.tocProperties = tocProperties || new TableOfContentsProperties();
|
||||||
this.root.push(new Begin());
|
const firstRun = new Run();
|
||||||
this.root.push(new Separate());
|
firstRun.addChildElement(new Begin());
|
||||||
this.root.push(new TableOfContentsInstruction());
|
firstRun.addChildElement(new TableOfContentsInstruction());
|
||||||
this.root.push(new End());
|
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