// add a table of contents applying legend styles

import {
    CreateDocx,
    OptionsParagraph,
    OptionsTableOfContents,
    OptionsText,
} from "../../../build";
import * as fs from "fs";

const docx = new CreateDocx();

const toc: OptionsTableOfContents = {
    legend: {
        text: "Click here to update the TOC",
        bold: true,
        color: "FF0000",
    },
};
docx.addTableOfContents(toc);

const optionsParagraphA: OptionsParagraph = {
    pStyle: "Heading1",
};
docx.addText("Heading 1 content.", optionsParagraphA);

const optionsParagraphB: OptionsParagraph = {
    pStyle: "Heading2",
};
docx.addText("Heading 2 content.", optionsParagraphB);

const text: OptionsText = {
    text: "Text content with an outline level.",
    bold: true,
    italic: true,
};
const optionsParagraphC: OptionsParagraph = {
    outlineLvl: 2,
};
docx.addText([text], optionsParagraphC);

docx.addText("Text content without an outline level.");

docx.save().then(contents => {
    fs.writeFileSync("addTableOfContents_2.docx", Buffer.from(contents));
});
