Merge pull request #448 from Sraleik/master

fix hyperlink id
This commit is contained in:
Dolan
2019-11-12 00:48:21 +00:00
committed by GitHub
5 changed files with 11 additions and 9 deletions

View File

@ -8,7 +8,7 @@ describe("Hyperlink", () => {
let hyperlink: Hyperlink;
beforeEach(() => {
hyperlink = new Hyperlink("https://example.com", 0);
hyperlink = new Hyperlink("https://example.com", "superid");
});
describe("#constructor()", () => {
@ -19,7 +19,7 @@ describe("Hyperlink", () => {
{
_attr: {
"w:history": 1,
"r:id": "rId1",
"r:id": "rIdsuperid",
},
},
{
@ -34,7 +34,7 @@ describe("Hyperlink", () => {
describe("with optional anchor parameter", () => {
beforeEach(() => {
hyperlink = new Hyperlink("Anchor Text", 0, "anchor");
hyperlink = new Hyperlink("Anchor Text", "superid2", "anchor");
});
it("should create an internal link with anchor tag", () => {

View File

@ -4,13 +4,13 @@ import { TextRun } from "../run";
import { HyperlinkAttributes, IHyperlinkAttributesProperties } from "./hyperlink-attributes";
export class Hyperlink extends XmlComponent {
public readonly linkId: number;
public readonly linkId: string;
private readonly textRun: TextRun;
constructor(text: string, relationshipsCount: number, anchor?: string) {
constructor(text: string, relationshipId: string, anchor?: string) {
super("w:hyperlink");
this.linkId = relationshipsCount + 1;
this.linkId = relationshipId;
const props: IHyperlinkAttributesProperties = {
history: 1,