Make the internal hyperlink consistent
This commit is contained in:
@ -18,10 +18,12 @@ const doc = new Document({
|
|||||||
new Paragraph({
|
new Paragraph({
|
||||||
children: [
|
children: [
|
||||||
new InternalHyperlink({
|
new InternalHyperlink({
|
||||||
child: new TextRun({
|
children: [
|
||||||
text: "Click here!",
|
new TextRun({
|
||||||
style: "Hyperlink",
|
text: "Click here!",
|
||||||
}),
|
style: "Hyperlink",
|
||||||
|
}),
|
||||||
|
],
|
||||||
anchor: "myAnchorId",
|
anchor: "myAnchorId",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@ -47,19 +49,23 @@ const doc = new Document({
|
|||||||
new Paragraph({
|
new Paragraph({
|
||||||
children: [
|
children: [
|
||||||
new InternalHyperlink({
|
new InternalHyperlink({
|
||||||
child: new TextRun({
|
children: [
|
||||||
text: "Anchor Text",
|
new TextRun({
|
||||||
style: "Hyperlink",
|
text: "Styled",
|
||||||
}),
|
bold: true,
|
||||||
|
style: "Hyperlink",
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: " Anchor Text",
|
||||||
|
style: "Hyperlink",
|
||||||
|
}),
|
||||||
|
],
|
||||||
anchor: "myAnchorId",
|
anchor: "myAnchorId",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
children: [
|
children: [new TextRun("The bookmark can be seen on page "), new PageRef("myAnchorId")],
|
||||||
new TextRun("The bookmark can be seen on page "),
|
|
||||||
new PageRef("myAnchorId"),
|
|
||||||
]
|
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -95,7 +95,7 @@ describe("InternalHyperlink", () => {
|
|||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
it("should create", () => {
|
it("should create", () => {
|
||||||
const internalHyperlink = new InternalHyperlink({
|
const internalHyperlink = new InternalHyperlink({
|
||||||
child: new TextRun("test"),
|
children: [new TextRun("test")],
|
||||||
anchor: "test-id",
|
anchor: "test-id",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ export class ConcreteHyperlink extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class InternalHyperlink extends ConcreteHyperlink {
|
export class InternalHyperlink extends ConcreteHyperlink {
|
||||||
constructor(options: { readonly child: ParagraphChild; readonly anchor: string }) {
|
constructor(options: { readonly children: ParagraphChild[]; readonly anchor: string }) {
|
||||||
super([options.child], uniqueId(), options.anchor);
|
super(options.children, uniqueId(), options.anchor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user