Update demo 35 with new API

This commit is contained in:
Rowan Cockett
2021-08-31 18:55:38 -06:00
parent c1cc211c7f
commit 243d73542f

View File

@ -11,10 +11,12 @@ const doc = new Document({
children: [ children: [
new TextRun("Click here for the "), new TextRun("Click here for the "),
new ExternalHyperlink({ new ExternalHyperlink({
child: new TextRun({ children: [
text: "Footnotes external hyperlink", new TextRun({
style: "Hyperlink", text: "Footnotes external hyperlink",
}), style: "Hyperlink",
}),
],
link: "http://www.example.com", link: "http://www.example.com",
}), }),
], ],
@ -31,10 +33,12 @@ const doc = new Document({
children: [ children: [
new TextRun("Click here for the "), new TextRun("Click here for the "),
new ExternalHyperlink({ new ExternalHyperlink({
child: new TextRun({ children: [
text: "Footer external hyperlink", new TextRun({
style: "Hyperlink", text: "Footer external hyperlink",
}), style: "Hyperlink",
}),
],
link: "http://www.example.com", link: "http://www.example.com",
}), }),
], ],
@ -49,10 +53,12 @@ const doc = new Document({
children: [ children: [
new TextRun("Click here for the "), new TextRun("Click here for the "),
new ExternalHyperlink({ new ExternalHyperlink({
child: new TextRun({ children: [
text: "Header external hyperlink", new TextRun({
style: "Hyperlink", text: "Header external hyperlink",
}), style: "Hyperlink",
}),
],
link: "http://www.google.com", link: "http://www.google.com",
}), }),
], ],
@ -64,10 +70,12 @@ const doc = new Document({
new Paragraph({ new Paragraph({
children: [ children: [
new ExternalHyperlink({ new ExternalHyperlink({
child: new TextRun({ children: [
text: "Anchor Text", new TextRun({
style: "Hyperlink", text: "Anchor Text",
}), style: "Hyperlink",
}),
],
link: "http://www.example.com", link: "http://www.example.com",
}), }),
new FootnoteReferenceRun(1), new FootnoteReferenceRun(1),
@ -76,24 +84,63 @@ const doc = new Document({
new Paragraph({ new Paragraph({
children: [ children: [
new ExternalHyperlink({ new ExternalHyperlink({
child: new ImageRun({ children: [
data: fs.readFileSync("./demo/images/image1.jpeg"), new ImageRun({
transformation: { data: fs.readFileSync("./demo/images/image1.jpeg"),
width: 100, transformation: {
height: 100, width: 100,
}, height: 100,
}), },
}),
],
link: "http://www.google.com", link: "http://www.google.com",
}), }),
new ExternalHyperlink({ new ExternalHyperlink({
child: new TextRun({ children: [
text: "BBC News Link", new TextRun({
style: "Hyperlink", text: "BBC News Link",
}), style: "Hyperlink",
}),
],
link: "https://www.bbc.co.uk/news", link: "https://www.bbc.co.uk/news",
}), }),
], ],
}), }),
new Paragraph({
children: [
new TextRun({
text: "This is a hyperlink with formatting: ",
}),
new ExternalHyperlink({
children: [
new TextRun({
text: "A ",
style: "Hyperlink",
}),
new TextRun({
text: "single ",
bold: true,
style: "Hyperlink",
}),
new TextRun({
text: "link",
doubleStrike: true,
style: "Hyperlink",
}),
new TextRun({
text: "1",
superScript: true,
style: "Hyperlink",
}),
new TextRun({
text: "!",
style: "Hyperlink",
}),
],
link: "http://www.example.com",
}),
],
}),
], ],
}, },
], ],