// add a bookmark at the beginning of a text

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

const docx = new CreateDocx();

// create a bookmark WordFragment
const wordFragmentBookmark = new WordFragment();
wordFragmentBookmark.addBookmark("bookmark_name");

// create a text WordFragment
const wordFragmentText = new WordFragment();
wordFragmentText.addText("New paragraph.");

// add the WordFragments as inline contents in the same paragraph
docx.addText([wordFragmentBookmark, wordFragmentText]);

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