add hyperlink to paragraph and doc

This commit is contained in:
Ivan Lopez
2018-05-06 22:24:16 -05:00
parent 195c62f80b
commit 9d7fd55e4c
3 changed files with 20 additions and 1 deletions

View File

@ -7,7 +7,7 @@ import { FooterWrapper } from "./footer-wrapper";
import { HeaderWrapper } from "./header-wrapper";
import { Media } from "./media";
import { Numbering } from "./numbering";
import { Paragraph, PictureRun } from "./paragraph";
import { Hyperlink, Paragraph, PictureRun } from "./paragraph";
import { Relationships } from "./relationships";
import { Styles } from "./styles";
import { DefaultStylesFactory } from "./styles/factory";
@ -111,6 +111,18 @@ export class File {
return this.document.createDrawing(mediaData);
}
public createHyperlink(link: string, text?: string): Hyperlink {
text = text === undefined ? link : text;
const hyperlink = new Hyperlink(text, this.docRelationships.RelationshipCount);
this.docRelationships.createRelationship(
hyperlink.linkId,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
link,
"External",
);
return hyperlink;
}
public get Document(): Document {
return this.document;
}