// add a WordFragment that contains text and link contents

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

const docx = new CreateDocx();

// add text and link fragments in the same WordFragment
const wordFragmentContents = new WordFragment();
wordFragmentContents.addText("New paragraph.");
wordFragmentContents.addText("Other paragraph.");

const link: OptionsLink = {
    link: "https://www.phpdocx.com",
    text: "Link to phpdocx.",
};
wordFragmentContents.addLink(link);

// add WordFragments to the document
docx.addWordFragment(wordFragmentContents);

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