// add a list with text contents and WordFragments

import {
    CreateDocx,
    ListNested,
    OptionsLink,
    OptionsList,
    OptionsText,
    WordFragment,
} from "../../../build";
import * as fs from "fs";

const docx = new CreateDocx();

docx.addText("Bullets list:");

// create a link WordFragment
const wordFragmentLink = new WordFragment();
const optionsLink: OptionsLink = {
    link: "https://www.phpdocx.com",
    text: "phpdocx",
};
wordFragmentLink.addLink(optionsLink);

// create a text WordFragment
const wordFragmentText = new WordFragment();
const textA: OptionsText = {
    bold: false,
    italic: true,
    fontSize: 14,
    text: "A content with styles ",
};
const textB: OptionsText = {
    color: "0000FF",
    font: "Times New Roman",
    text: "in the same list item.",
};
wordFragmentText.addText([textA, textB]);

const items: ListNested = [
    "Item 1",
    wordFragmentLink,
    ["Item A", "Item B", "Item C", ["Item C.1", "Item C.2"]],
    wordFragmentText,
    "Item 4",
    ["Item 4.1", "Item 4.2"],
    "Item 5",
];
const optionsListBullets: OptionsList = {
    type: "bullets",
};
docx.addList(items, optionsListBullets);

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