// http://officeopenxml.com/WPbookmark.php import { XmlComponent } from "@file/xml-components"; import { uniqueNumericId } from "@util/convenience-functions"; import { ParagraphChild } from "../paragraph"; import { BookmarkEndAttributes, BookmarkStartAttributes } from "./bookmark-attributes"; export class Bookmark { public readonly start: BookmarkStart; public readonly children: ParagraphChild[]; public readonly end: BookmarkEnd; public constructor(options: { readonly id: string; readonly children: ParagraphChild[] }) { const linkId = uniqueNumericId(); this.start = new BookmarkStart(options.id, linkId); this.children = options.children; this.end = new BookmarkEnd(linkId); } } // // // // // // // // // // // // // // // // // // // // // // // // // // // export class BookmarkStart extends XmlComponent { public constructor(id: string, linkId: number) { super("w:bookmarkStart"); const attributes = new BookmarkStartAttributes({ name: id, id: linkId, }); this.root.push(attributes); } } export class BookmarkEnd extends XmlComponent { public constructor(linkId: number) { super("w:bookmarkEnd"); const attributes = new BookmarkEndAttributes({ id: linkId, }); this.root.push(attributes); } }