Turn Run into a declaritive API

This commit is contained in:
Dolan
2019-06-17 01:51:57 +01:00
parent a1cd5e9573
commit fb65bb4207
27 changed files with 411 additions and 183 deletions

View File

@ -92,7 +92,16 @@ doc.addParagraph(
}),
);
doc.addParagraph(new Paragraph({}).addRun(new TextRun("Some monospaced content").font("Monospace")));
doc.addParagraph(
new Paragraph({}).addRun(
new TextRun({
text: "Some monospaced content",
font: {
name: "Monospace",
},
}),
),
);
doc.addParagraph(
new Paragraph({
@ -108,10 +117,25 @@ doc.addParagraph(
);
const para = new Paragraph({});
doc.addParagraph(para);
para.addRun(new TextRun("This is a bold run,").bold());
// Showing the different ways to create a TextRun
para.addRun(
new TextRun({
text: "This is a bold run,",
bold: true,
}),
);
para.addRun(new TextRun(" switching to normal "));
para.addRun(new TextRun("and then underlined ").underline());
para.addRun(new TextRun("and back to normal."));
para.addRun(
new TextRun({
text: "and then underlined ",
underline: {},
}),
);
para.addRun(
new TextRun({
text: "and back to normal.",
}),
);
const packer = new Packer();