2018-07-24 15:56:13 -04:00
|
|
|
// http://officeopenxml.com/WPbookmark.php
|
|
|
|
import { XmlComponent } from "file/xml-components";
|
|
|
|
import { TextRun } from "../run";
|
|
|
|
import { BookmarkEndAttributes, BookmarkStartAttributes } from "./bookmark-attributes";
|
|
|
|
|
|
|
|
export class Bookmark {
|
2018-11-02 02:51:57 +00:00
|
|
|
public readonly linkId: number;
|
2018-07-24 15:56:13 -04:00
|
|
|
public readonly start: BookmarkStart;
|
|
|
|
public readonly text: TextRun;
|
|
|
|
public readonly end: BookmarkEnd;
|
|
|
|
|
|
|
|
constructor(name: string, text: string, relationshipsCount: number) {
|
|
|
|
this.linkId = relationshipsCount + 1;
|
|
|
|
|
2018-07-24 16:56:27 -04:00
|
|
|
this.start = new BookmarkStart(name, this.linkId);
|
2018-07-24 15:56:13 -04:00
|
|
|
this.text = new TextRun(text);
|
|
|
|
this.end = new BookmarkEnd(this.linkId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class BookmarkStart extends XmlComponent {
|
2018-11-02 02:51:57 +00:00
|
|
|
public readonly linkId: number;
|
2018-07-24 15:56:13 -04:00
|
|
|
|
2018-07-24 16:56:27 -04:00
|
|
|
constructor(name: string, relationshipsCount: number) {
|
2018-07-24 15:56:13 -04:00
|
|
|
super("w:bookmarkStart");
|
|
|
|
|
|
|
|
this.linkId = relationshipsCount;
|
|
|
|
const id = `${this.linkId}`;
|
|
|
|
const attributes = new BookmarkStartAttributes({
|
|
|
|
name,
|
|
|
|
id,
|
|
|
|
});
|
|
|
|
this.root.push(attributes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class BookmarkEnd extends XmlComponent {
|
2018-11-02 02:51:57 +00:00
|
|
|
public readonly linkId: number;
|
2018-07-24 15:56:13 -04:00
|
|
|
|
|
|
|
constructor(relationshipsCount: number) {
|
|
|
|
super("w:bookmarkEnd");
|
|
|
|
|
|
|
|
this.linkId = relationshipsCount;
|
|
|
|
const id = `${this.linkId}`;
|
|
|
|
const attributes = new BookmarkEndAttributes({
|
|
|
|
id,
|
|
|
|
});
|
|
|
|
this.root.push(attributes);
|
|
|
|
}
|
|
|
|
}
|