Files
docx-js/src/file/paragraph/links/hyperlink.ts
2018-05-06 23:18:00 -05:00

22 lines
637 B
TypeScript

// http://officeopenxml.com/WPhyperlink.php
import { XmlComponent } from "file/xml-components";
import { TextRun } from "../run";
import { HyperlinkAttributes } from "./hyperlink-attributes";
export class Hyperlink extends XmlComponent {
public linkId: number;
constructor(text: string, relationshipsCount: number) {
super("w:hyperlink");
this.linkId = relationshipsCount + 1;
const attributes = new HyperlinkAttributes({
id: `rId${this.linkId}`,
history: 1,
});
this.root.push(attributes);
this.root.push(new TextRun(text).style("Hyperlink"));
}
}