diff --git a/demo/21-bookmarks.ts b/demo/21-bookmarks.ts index 6c673f1520..56343c94cd 100644 --- a/demo/21-bookmarks.ts +++ b/demo/21-bookmarks.ts @@ -18,10 +18,12 @@ const doc = new Document({ new Paragraph({ children: [ new InternalHyperlink({ - child: new TextRun({ - text: "Click here!", - style: "Hyperlink", - }), + children: [ + new TextRun({ + text: "Click here!", + style: "Hyperlink", + }), + ], anchor: "myAnchorId", }), ], @@ -47,19 +49,23 @@ const doc = new Document({ new Paragraph({ children: [ new InternalHyperlink({ - child: new TextRun({ - text: "Anchor Text", - style: "Hyperlink", - }), + children: [ + new TextRun({ + text: "Styled", + bold: true, + style: "Hyperlink", + }), + new TextRun({ + text: " Anchor Text", + style: "Hyperlink", + }), + ], anchor: "myAnchorId", }), ], }), new Paragraph({ - children: [ - new TextRun("The bookmark can be seen on page "), - new PageRef("myAnchorId"), - ] + children: [new TextRun("The bookmark can be seen on page "), new PageRef("myAnchorId")], }), ], }, diff --git a/src/file/paragraph/links/hyperlink.spec.ts b/src/file/paragraph/links/hyperlink.spec.ts index 8b6fefb691..9f79a19ff1 100644 --- a/src/file/paragraph/links/hyperlink.spec.ts +++ b/src/file/paragraph/links/hyperlink.spec.ts @@ -95,7 +95,7 @@ describe("InternalHyperlink", () => { describe("#constructor()", () => { it("should create", () => { const internalHyperlink = new InternalHyperlink({ - child: new TextRun("test"), + children: [new TextRun("test")], anchor: "test-id", }); diff --git a/src/file/paragraph/links/hyperlink.ts b/src/file/paragraph/links/hyperlink.ts index 7ee4409298..2c39997908 100644 --- a/src/file/paragraph/links/hyperlink.ts +++ b/src/file/paragraph/links/hyperlink.ts @@ -33,8 +33,8 @@ export class ConcreteHyperlink extends XmlComponent { } export class InternalHyperlink extends ConcreteHyperlink { - constructor(options: { readonly child: ParagraphChild; readonly anchor: string }) { - super([options.child], uniqueId(), options.anchor); + constructor(options: { readonly children: ParagraphChild[]; readonly anchor: string }) { + super(options.children, uniqueId(), options.anchor); } }